public void testAdministratorCanImpersonate() throws RepositoryException, NotExecutableException { User admin = getTestUser(superuser); Subject subject = createSubject(admin); assertTrue(impersonation.allows(subject)); }
/** * @see <a href="https://issues.apache.org/jira/browse/JCR-2931">JCR-2931</a> */ public void testAdminImpersonatingOneself() throws RepositoryException, NotExecutableException { User admin = getTestUser(superuser); Subject subject = createSubject(admin); assertTrue(admin.getImpersonation().allows(subject)); }
public void testGrantImpersonation() throws RepositoryException, NotExecutableException { User u = null; Principal test = getTestPrincipal(); try { u = userMgr.createUser(test.getName(), buildPassword(test)); save(superuser); assertTrue("Admin should be allowed to edit impersonation and grant to another test-user.", impersonation.grantImpersonation(test)); } finally { impersonation.revokeImpersonation(test); if (u != null) { u.remove(); } save(superuser); } }
public void testRevokeImpersonation() throws RepositoryException, NotExecutableException { User u = null; Principal test = getTestPrincipal(); try { u = userMgr.createUser(test.getName(), buildPassword(test)); save(superuser); impersonation.grantImpersonation(test); save(superuser); assertTrue(impersonation.revokeImpersonation(test)); } finally { if (u != null) { u.remove(); } } }