TestPermissionspublic class TestPermissions extends TestCase Unit tests for the Permissions class. |
Methods Summary |
---|
public void | runTests()Runs all tests.
setUp();
declare("testSetPermissionGroupRuntime");
testSetPermissionGroupRuntime();
declare("testSetPermissionGroupAppSettings");
testSetPermissionGroupAppSettings();
declare("testCheckPushInterruptLevel");
testCheckPushInterruptLevel();
tearDown();
| void | setUp()
| void | tearDown()
| void | testCheckPushInterruptLevel()Test the checkPushInterruptLevel method.
boolean securityExceptionThrown;
byte [][] temp =
Permissions.forDomain(Permissions.IDENTIFIED_DOMAIN_BINDING);
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS],
(byte)0,
Permissions.NET_ACCESS_GROUP,
Permissions.BLANKET_GRANTED);
try {
securityExceptionThrown = false;
Permissions.checkPushInterruptLevel(temp[Permissions.CUR_LEVELS],
Permissions.BLANKET_GRANTED);
} catch (SecurityException se) {
securityExceptionThrown = true;
}
assertTrue(securityExceptionThrown);
| void | testSetPermissionGroupAppSettings()Tests the method setPermissionGroup used by app settings to ensure
that mutally exclusive permission combinations using the Third Party
Indentified domain do not occur.
boolean securityExceptionThrown;
byte [][] temp =
Permissions.forDomain(Permissions.IDENTIFIED_DOMAIN_BINDING);
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS], (byte)0,
Permissions.NET_ACCESS_GROUP,
Permissions.BLANKET_GRANTED);
try {
securityExceptionThrown = false;
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS],
(byte)0,
Permissions.MULTIMEDIA_GROUP,
Permissions.BLANKET_GRANTED);
} catch (SecurityException se) {
securityExceptionThrown = true;
}
assertTrue(securityExceptionThrown);
try {
securityExceptionThrown = false;
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS],
(byte)0,
Permissions.READ_USER_DATA_GROUP,
Permissions.BLANKET_GRANTED);
} catch (SecurityException se) {
securityExceptionThrown = true;
}
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS], (byte)0,
Permissions.NET_ACCESS_GROUP,
Permissions.SESSION);
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS],
(byte)0,
Permissions.MULTIMEDIA_GROUP,
Permissions.BLANKET_GRANTED);
try {
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS],
(byte)0,
Permissions.NET_ACCESS_GROUP,
Permissions.BLANKET_GRANTED);
} catch (SecurityException se) {
securityExceptionThrown = true;
}
assertTrue(securityExceptionThrown);
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS],
(byte)0,
Permissions.MULTIMEDIA_GROUP,
Permissions.SESSION);
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS],
(byte)0,
Permissions.READ_USER_DATA_GROUP,
Permissions.BLANKET_GRANTED);
try {
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS],
(byte)0,
Permissions.NET_ACCESS_GROUP,
Permissions.BLANKET_GRANTED);
} catch (SecurityException se) {
securityExceptionThrown = true;
}
assertTrue(securityExceptionThrown);
try {
securityExceptionThrown = false;
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS],
Permissions.BLANKET_GRANTED,
Permissions.NET_ACCESS_GROUP,
Permissions.BLANKET_GRANTED);
} catch (SecurityException se) {
securityExceptionThrown = true;
}
assertTrue(securityExceptionThrown);
| void | testSetPermissionGroupRuntime()Tests the method setPermissionGroup for the correct grouping for
the runtime dialog.
byte [][] temp =
Permissions.forDomain(Permissions.UNIDENTIFIED_DOMAIN_BINDING);
int push = temp[Permissions.CUR_LEVELS][Permissions.PUSH];
assertFalse("default permission level for HTTPS is ONESHOT",
Permissions.ONESHOT !=
temp[Permissions.CUR_LEVELS][Permissions.HTTPS]);
Permissions.setPermissionGroup(temp[Permissions.CUR_LEVELS],
Permissions.HTTP,
Permissions.SESSION);
assertEquals("changed HTTP permissions, HTTPS permissions must also change",
Permissions.SESSION,
temp[Permissions.CUR_LEVELS][Permissions.HTTPS]);
assertEquals("but PUSH permissions must not change",
push,
temp[Permissions.CUR_LEVELS][Permissions.PUSH]);
|
|