@Test public void testRoleAndUserAccount() throws InterruptedException { setUpForReadConfigurationTest(); executeTest(new Runnable() { public void run() { assertTrue("role not found when it was expected", realm.roleExists("role1")); assertTrue("user not found when it was expected", realm.accountExists("user1")); } }); }
@Test public void testIsPermitted() throws InterruptedException { setUpForReadConfigurationTest(); executeTest(new Runnable() { public void run() { PrincipalCollection principalCollection = new SimplePrincipalCollection("user1", "realm1"); assertTrue("permission not permitted when it should be", realm.isPermitted(principalCollection, "role1_permission1")); assertTrue("permission not permitted when it should be", realm.isPermittedAll(principalCollection, new String[]{"role1_permission1", "role2_permission2"})); } }); }
@Test public void testHasRole() throws InterruptedException { setUpForReadConfigurationTest(); executeTest(new Runnable() { public void run() { PrincipalCollection principalCollection = new SimplePrincipalCollection("user1", "realm1"); assertTrue("principal doesn't have role when it should", realm.hasRole(principalCollection, "role2")); assertTrue("principal doesn't have all roles when it should", realm.hasAllRoles(principalCollection, Arrays.asList(new String[]{"role1", "role2"}))); } }); }
@Test public void testCheckRole() throws InterruptedException { setUpForReadConfigurationTest(); executeTest(new Runnable() { public void run() { PrincipalCollection principalCollection = new SimplePrincipalCollection("user1", "realm1"); try { realm.checkRoles(principalCollection, new String[]{"role1", "role2"}); } catch (AuthorizationException ae) { fail("principal doesn't have all roles when it should"); } } }); }
@Test public void testCheckPermission() throws InterruptedException { setUpForReadConfigurationTest(); executeTest(new Runnable() { public void run() { PrincipalCollection principalCollection = new SimplePrincipalCollection("user1", "realm1"); try { realm.checkPermission(principalCollection, "role1_permission1"); realm.checkPermissions(principalCollection, new String[]{"role1_permission1", "role2_permission2"}); } catch (AuthorizationException ae) { fail("principal doesn't have permission when it should"); } } }); }