private Subject createSubject(Principal p) throws RepositoryException { Set<Credentials> creds = Collections.singleton(buildCredentials(p.getName(), buildPassword(p))); return new Subject(true, Collections.singleton(p), creds, creds); } }
@Override protected void setUp() throws Exception { super.setUp(); Principal test = getTestPrincipal(); String pw = buildPassword(test); newUser = userMgr.createUser(test.getName(), pw); save(superuser); impersonation = newUser.getImpersonation(); }
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(); } } }
public void testRevokeImpersonationTwice() throws RepositoryException, NotExecutableException { User u = null; Principal test = getTestPrincipal(); try { u = userMgr.createUser(test.getName(), buildPassword(test)); save(superuser); impersonation.grantImpersonation(test); save(superuser); impersonation.revokeImpersonation(test); save(superuser); // try again assertFalse("Revoking impersonation twice should not succeed.", impersonation.revokeImpersonation(test)); } finally { if (u != null) { u.remove(); } } }
public void testGrantImpersonationTwice() throws RepositoryException, NotExecutableException { Principal test = getTestPrincipal(); User u = null; try { u = userMgr.createUser(test.getName(), buildPassword(test)); save(superuser); impersonation.grantImpersonation(test); save(superuser); // try again assertFalse("Granting impersonation twice should not succeed.", impersonation.grantImpersonation(test)); } finally { impersonation.revokeImpersonation(test); if (u != null) { u.remove(); } save(superuser); } }