Refine search
@Test public void testWriteOnParentWithNoReadePriv() throws Exception { Node a = superuser.getNode(path).addNode("a"); allow(path, testUser.getPrincipal(), readWritePrivileges); deny(a.getPath(), testUser.getPrincipal(), readPrivileges); superuser.save(); testSession.getNode(path).addNode("a"); }
@Test public void testGetPrincipal() throws Exception { User user = createUser(null); assertTrue(user.getPrincipal() instanceof SystemUserPrincipal); }
@Test public void testGetGroupMembershipLocalPrincipal() throws Exception { Set<? extends Principal> principals = principalProvider.getMembershipPrincipals(getTestUser().getPrincipal()); assertTrue(principals.isEmpty()); }
@Test public void testTreeBasedUserPrincipal() throws Exception { User user = getTestUser(); Principal principal = principalProvider.getPrincipal(user.getPrincipal().getName()); assertTrue(principal instanceof TreeBasedPrincipal); }
@Test public void testCreateUser() throws RepositoryException, NotExecutableException { Principal p = getTestPrincipal(); String uid = p.getName(); User user = createUser(uid, "pw"); createdUsers.add(user); assertNotNull(user.getID()); assertEquals(p.getName(), user.getPrincipal().getName()); }
@Test public void testGetPrincipalExternalUser() throws Exception { UserManager userManager = getUserManager(root); // synced by principal-sync-ctx User syncedUser = userManager.getAuthorizable(USER_ID, User.class); assertNull(principalProvider.getPrincipal(syncedUser.getPrincipal().getName())); // synced by default-sync-ctx syncedUser = userManager.getAuthorizable(TestIdentityProvider.ID_SECOND_USER, User.class); assertNull(principalProvider.getPrincipal(syncedUser.getPrincipal().getName())); }
@Test public void testMixedImpersonators() throws Exception { assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, "impersonator1", testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); assertEquals(ImmutableSet.of("impersonator1", testUser.getPrincipal().getName()), ImmutableSet.copyOf(impersonators.getValue(Type.STRINGS))); } }
@Test public void testKnownImpersonators() throws Exception { assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); assertEquals(ImmutableList.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); }
@Test public void testReplaceExistingProperty() throws Exception { userTree.setProperty(REP_IMPERSONATORS, ImmutableList.of("impersonator1"), Type.STRINGS); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); PropertyState impersonators = userTree.getProperty(REP_IMPERSONATORS); assertNotNull(impersonators); assertEquals(ImmutableList.of(testUser.getPrincipal().getName()), impersonators.getValue(Type.STRINGS)); }
@Test public void testAdminUser() throws Exception { Authorizable a = userMgr.getAuthorizable(UserUtil.getAdminId(config)); assertFalse(a.isGroup()); User admin = (User) a; assertTrue(admin.isAdmin()); assertTrue(admin.getPrincipal() instanceof AdminPrincipal); assertTrue(admin.getPrincipal() instanceof TreeBasedPrincipal); assertEquals(admin.getID(), admin.getPrincipal().getName()); }
@Test public void testAnonymous() throws Exception { Authorizable a = userMgr.getAuthorizable(UserUtil.getAnonymousId(config)); assertFalse(a.isGroup()); User anonymous = (User) a; assertFalse(anonymous.isAdmin()); assertFalse(anonymous.getPrincipal() instanceof AdminPrincipal); assertTrue(anonymous.getPrincipal() instanceof TreeBasedPrincipal); assertEquals(anonymous.getID(), anonymous.getPrincipal().getName()); }
@Test(expected = ConstraintViolationException.class) public void testMixedImpersonators() throws Exception { assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, "impersonator1", testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); importer.processReferences(); } }
@Test public void testContentRepresentation() throws Exception { Tree tree = root.getTree(user.getPath()); PropertyState property = tree.getProperty(UserConstants.REP_IMPERSONATORS); assertNotNull(property); assertEquals(ImmutableList.of(impersonator.getPrincipal().getName()), property.getValue(Type.STRINGS)); }
@Test(expected = AccessDeniedException.class) public void testSetPolicyMissingAcPermission() throws Exception { setupPermission(PathUtils.ROOT_PATH, getTestUser().getPrincipal(), true, JCR_READ); setupPermission(null, getTestUser().getPrincipal(), true, JCR_READ_ACCESS_CONTROL); setupPermission(getTestRoot(), null, EveryonePrincipal.getInstance(), false, JCR_NAMESPACE_MANAGEMENT); }
@Test(expected = AccessDeniedException.class) public void testSetPolicyMissingAcPermission2() throws Exception { setupPermission(PathUtils.ROOT_PATH, getTestUser().getPrincipal(), true, JCR_READ, JCR_READ_ACCESS_CONTROL, JCR_MODIFY_ACCESS_CONTROL); setupPermission(null, getTestUser().getPrincipal(), true, JCR_READ_ACCESS_CONTROL); setupPermission(getTestRoot(), null, EveryonePrincipal.getInstance(), false, JCR_NAMESPACE_MANAGEMENT); }
@Test public void testSetPolicy2() throws Exception { // see above: ac-related permissions should not be required on ROOT_PATH (workaround for OAK-5947) setupPermission(PathUtils.ROOT_PATH, getTestUser().getPrincipal(), true, JCR_READ, JCR_READ_ACCESS_CONTROL, JCR_MODIFY_ACCESS_CONTROL); setupPermission(null, getTestUser().getPrincipal(), true, JCR_READ_ACCESS_CONTROL, JCR_MODIFY_ACCESS_CONTROL); setupPermission(getTestRoot(), null, EveryonePrincipal.getInstance(), false, JCR_NAMESPACE_MANAGEMENT); }
@Test public void testFindAuthorizable() throws Exception { user = createUser(uid); Iterator<Authorizable> iterator = userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, user.getPrincipal().getName()); assertTrue(iterator.hasNext()); Authorizable authorizable = iterator.next(); assertNotNull(authorizable); assertFalse(authorizable.isGroup()); assertTrue(((User) authorizable).isSystemUser()); assertFalse(iterator.hasNext()); }
@Test public void testGetPrivileges() throws Exception { setupPermission(null, getTestUser().getPrincipal(), true, JCR_READ_ACCESS_CONTROL, JCR_NAMESPACE_MANAGEMENT); Set<Privilege> expected = ImmutableSet.copyOf(privilegesFromNames(JCR_READ_ACCESS_CONTROL, JCR_NAMESPACE_MANAGEMENT)); AccessControlManager testAcMgr = getAccessControlManager(getTestRoot()); assertEquals(expected, ImmutableSet.copyOf(testAcMgr.getPrivileges(null))); } }
@Test(expected = RepositoryException.class) public void testUserConvertedGroupBeforeProcessing() throws Exception { assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); userTree.setProperty(JcrConstants.JCR_PRIMARYTYPE, NT_REP_GROUP); importer.processReferences(); }
@Test(expected = RepositoryException.class) public void testUserRemovedBeforeProcessing() throws Exception { assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_IMPERSONATORS, testUser.getPrincipal().getName()), mockPropertyDefinition(NT_REP_USER, true))); userTree.remove(); importer.processReferences(); }