Refine search
protected void afterSuite() throws Exception { Node root = admin.getRootNode(); if (root.hasNode(ROOT_NODE_NAME)) { root.getNode(ROOT_NODE_NAME).remove(); } if (userManager != null) { userManager.getAuthorizable(TEST_USER_ID).remove(); } admin.save(); } }
public void testCreateUserWithoutPassword() throws RepositoryException { testUser = userManager.createUser(testId, null); superuser.save(); // EXERCISE: look at the user node. does it have a password property set? // EXERCISE: add the correct assertion Node userNode = superuser.getNode(testUser.getPath()); }
@Override protected void createDeepTree() throws Exception { super.createDeepTree(); UserManager userManager = ((JackrabbitSession) adminSession).getUserManager(); User user = userManager.createUser(userId, userId); for (int i = 0; i < membershipSize; i++) { Group g = userManager.createGroup("group" + i); g.addMember(user); setupACEs(g.getPrincipal()); } adminSession.save(); }
@Override protected void createDeepTree() throws Exception { UserManager uMgr = ((JackrabbitSession) adminSession).getUserManager(); for (int i = 0; i < 100; i++) { Authorizable a = uMgr.getAuthorizable("group" + i); if (a == null) { a = uMgr.createGroup("group" + i); principals.add(a.getPrincipal()); } } super.createDeepTree(); }
@Test public void testGetGroupMembershipExternalGroup() throws Exception { Authorizable group = getUserManager(root).getAuthorizable("secondGroup"); assertNotNull(group); Set<? extends Principal> principals = principalProvider.getMembershipPrincipals(group.getPrincipal()); assertTrue(principals.isEmpty()); // same if the principal is not marked as 'GroupPrincipal' and not tree-based-principal principals = principalProvider.getMembershipPrincipals(new PrincipalImpl(group.getPrincipal().getName())); assertTrue(principals.isEmpty()); }
@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()); }
public void testCreateUser() throws NotExecutableException { try { Principal p = getTestPrincipal(); User u = uMgr.createUser(p.getName(), buildPassword(p)); save(uSession); fail("A non-UserAdmin should not be allowed to create a new User."); // clean-up: let superuser remove the user created by fault. userMgr.getAuthorizable(u.getID()).remove(); } catch (AuthorizableExistsException e) { // should never get here. fail(e.getMessage()); } catch (RepositoryException e) { // success } }
@Test public void testGetByID() throws RepositoryException { // EXERCISE fix the test-case UserManager uMgr = getUserManager(root); Group g = uMgr.getAuthorizable(testUser.getID(), Group.class); assertEquals(g, uMgr.getAuthorizable(testGroup.getID())); assertEquals(g, uMgr.getAuthorizable(testGroup.getPrincipal().getName())); }
private String getYetAnotherID() throws RepositoryException, NotExecutableException { if (otherUID2 == null) { // create a third user Principal p = getTestPrincipal(); otherUID2 = userMgr.createUser(p.getName(), buildPassword(p)).getID(); save(superuser); } return otherUID2; }
@Test public void testAccessDisabledUser() throws Exception { user.disable("readonly user is disabled!"); superuser.save(); // user must still be retrievable from user manager assertNotNull(getUserManager(superuser).getAuthorizable(user.getID())); // ... and from principal manager as well assertTrue(((JackrabbitSession) superuser).getPrincipalManager().hasPrincipal(user.getPrincipal().getName())); }
@Test public void testAdminImpersonation() throws Exception { final String adminPrincipalName = userMgr.getAuthorizable(superuser.getUserID()).getPrincipal().getName(); Iterator<Authorizable> result = userMgr.findAuthorizables(new Query() { public <T> void build(QueryBuilder<T> builder) { builder.setCondition(builder.impersonates(adminPrincipalName)); } }); Iterator<Authorizable> expected = userMgr.findAuthorizables(UserConstants.REP_PRINCIPAL_NAME, null, UserManager.SEARCH_TYPE_USER); assertTrue(result.hasNext()); assertSameElements(expected, result); }
@Test public void testGetPrincipalsForAdminUser() throws Exception { Authorizable adminUser = getUserManager(root).getAuthorizable(adminSession.getAuthInfo().getUserID()); if (adminUser != null && adminUser.getPrincipal() instanceof AdminPrincipal) { Set<? extends Principal> principals = principalProvider.getPrincipals(adminUser.getID()); for (Principal p : principals) { String name = p.getName(); if (name.equals(adminUser.getPrincipal().getName())) { assertTrue(p instanceof AdminPrincipalImpl); } else if (!EveryonePrincipal.NAME.equals(name)) { assertTrue(p instanceof AbstractGroupPrincipal); } } } }
@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 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())); }
@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(); }
@Override public void afterSuite() throws Exception { Session s = loginAdministrative(); try { Authorizable authorizable = ((JackrabbitSession) s).getUserManager().getAuthorizable(GROUP); if (authorizable != null) { Node n = s.getNode(Text.getRelativeParent(authorizable.getPath(), 1)); n.remove(); } s.save(); } finally { s.logout(); } }
public void testAddCustomNodeToGroupAdminNode() throws RepositoryException, NotExecutableException { UserManager umgr = getUserManager(uSession); Node groupAdminNode = ((AuthorizableImpl) umgr.getAuthorizable(grID)).getNode(); Session s = groupAdminNode.getSession(); Node n = groupAdminNode.addNode(nodeName1, ntUnstructured); save(uSession); n.setProperty(propertyName1, s.getValueFactory().createValue("anyValue")); save(uSession); n.remove(); save(uSession); } }
@Override protected void tearDown() throws Exception { try { userSession.logout(); superuser.getNode(testPath).remove(); UserManager uMgr = ((JackrabbitSession) superuser).getUserManager(); Authorizable a = uMgr.getAuthorizable("u"); if (a != null) { a.remove(); } a = uMgr.getAuthorizable("g"); if (a != null) { a.remove(); } superuser.save(); } finally { super.tearDown(); } }
@Test public void testFindAuthorizable() throws Exception { user.setProperty("prop", superuser.getValueFactory().createValue(true)); superuser.save(); session.refresh(false); Map<String, String> m = ImmutableMap.of("prop", "true", "my:property", "value", "my:node/my:property2", "value"); for (String relPath : m.keySet()) { String value = m.get(relPath); Iterator<Authorizable> result = getUserManager(session).findAuthorizables(relPath, value); assertTrue(result.hasNext()); assertEquals(user.getID(), result.next().getID()); } }
@Override public void afterSuite() throws Exception { UserManager userMgr = ((JackrabbitSession) session).getUserManager(); Authorizable authorizable = userMgr.getAuthorizable(USER); if (authorizable != null) { authorizable.remove(); } authorizable = userMgr.getAuthorizable(GROUP); if (authorizable != null) { Node n = session.getNode(Text.getRelativeParent(authorizable.getPath(), 1)); n.remove(); } session.save(); }