@NotNull @Override public String perform() throws RepositoryException { return delegate.getPath(); } });
public String getUserPath(ResourceResolver resolver, String userId) throws UnsupportedRepositoryOperationException, RepositoryException { if (!userPaths.containsKey(userId)) { final UserManager userManager = resolver.adaptTo(UserManager.class); final Authorizable usr = userManager.getAuthorizable(userId); if (usr != null) { userPaths.put(userId, usr.getPath()); } } return userPaths.get(userId); }
@Test public void testUserRootPath() throws Exception { Authorizable authorizable = createAuthorizable(false, UserConstants.DEFAULT_USER_PATH); assertFalse(UserConstants.DEFAULT_USER_PATH.equals(PathUtils.getAncestorPath(authorizable.getPath(), 1))); assertTrue(authorizable.getPath().startsWith(UserConstants.DEFAULT_USER_PATH)); }
@Test public void testGroupEmptyPath() throws Exception { Authorizable authorizable = createAuthorizable(true, ""); assertFalse(UserConstants.DEFAULT_GROUP_PATH.equals(PathUtils.getAncestorPath(authorizable.getPath(), 1))); assertTrue(authorizable.getPath().startsWith(UserConstants.DEFAULT_GROUP_PATH)); }
@Test public void testGroupRootPath() throws Exception { Authorizable authorizable = createAuthorizable(true, UserConstants.DEFAULT_GROUP_PATH); assertFalse(UserConstants.DEFAULT_GROUP_PATH.equals(PathUtils.getAncestorPath(authorizable.getPath(), 1))); assertTrue(authorizable.getPath().startsWith(UserConstants.DEFAULT_GROUP_PATH)); }
protected static void assertNotDeclaredMember(Group gr, String potentialID, Session session) throws RepositoryException { // declared members must not list the invalid entry. Iterator<Authorizable> it = gr.getDeclaredMembers(); while (it.hasNext()) { Authorizable member = it.next(); assertFalse(potentialID.equals(session.getNode(member.getPath()).getIdentifier())); } } }
@Test public void testUserRelativePath() throws Exception { Authorizable authorizable = createAuthorizable(false, "a/b/c"); assertTrue(authorizable.getPath().startsWith(UserConstants.DEFAULT_USER_PATH + "/a/b/c")); }
@Test public void testAbsolutePathsWithParentElements() throws Exception { Authorizable authorizable = createAuthorizable(true, UserConstants.DEFAULT_GROUP_PATH + "/a/../b"); assertTrue(authorizable.getPath().startsWith(UserConstants.DEFAULT_GROUP_PATH + "/b")); }
@Test public void testGroupRelativePath() throws Exception { Authorizable authorizable = createAuthorizable(true, "a/b/c"); assertTrue(authorizable.getPath().startsWith(UserConstants.DEFAULT_GROUP_PATH + "/a/b/c")); }
@Test(expected = RepositoryException.class) public void testRemovePropertyOtherUser() throws Exception { emptyProperties.removeProperty("../" + PathUtils.getName(user2.getPath()) + "/prop"); } }
@Test public void testCurrentRelativePath() throws Exception { Authorizable authorizable = createAuthorizable(false, "."); assertEquals(UserConstants.DEFAULT_USER_PATH, PathUtils.getAncestorPath(authorizable.getPath(), 1)); } }
@Test public void testRemoveTokenRemovesNode() throws Exception { TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap()); Tree userTree = root.getTree(getUserManager(root).getAuthorizable(userId).getPath()); Tree tokens = userTree.getChild(TOKENS_NODE_NAME); String tokenNodePath = tokens.getChildren().iterator().next().getPath(); info.remove(); assertFalse(root.getTree(tokenNodePath).exists()); }
@Test public void testGetPath() throws RepositoryException, NotExecutableException { assertNotNull(group.getPath()); assertNotNull(userMgr.getAuthorizable(group.getID()).getPath()); try { assertEquals(getNode(group, superuser).getPath(), group.getPath()); } catch (UnsupportedRepositoryOperationException e) { // ok. } }
@Test public void testManuallyCreateTokenParentWithNtUnstructured() throws Exception { Tree userTree = root.getTree(getUserManager(root).getAuthorizable(userId).getPath()); NodeUtil node = new NodeUtil(userTree); node.addChild(TOKENS_NODE_NAME, JcrConstants.NT_UNSTRUCTURED); root.commit(); }
@Test public void testManuallyCreateTokenParent() throws Exception { Tree userTree = root.getTree(getUserManager(root).getAuthorizable(userId).getPath()); NodeUtil node = new NodeUtil(userTree); node.addChild(TOKENS_NODE_NAME, TOKENS_NT_NAME); root.commit(); }
@Test public void testChangeTokenParentPrimaryTypeToRepUnstructured() throws Exception { Tree userTree = root.getTree(getUserManager(root).getAuthorizable(userId).getPath()); NodeUtil node = new NodeUtil(userTree); node = node.addChild(TOKENS_NODE_NAME, JcrConstants.NT_UNSTRUCTURED); root.commit(); node.setName(JcrConstants.JCR_PRIMARYTYPE, TOKENS_NT_NAME); root.commit(); }
@Test public void testSyncExternalUserDepth0() throws Exception { syncConfig.user().setMembershipNestingDepth(0); ExternalUser externalUser = idp.getUser(USER_ID); sync(externalUser, SyncResult.Status.ADD); Tree tree = r.getTree(userManager.getAuthorizable(USER_ID).getPath()); PropertyState extPrincipalNames = tree.getProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES); assertNotNull(extPrincipalNames); assertEquals(0, extPrincipalNames.count()); }
@Test public void testSyncUserByIdUpdate() throws Exception { ExternalIdentity externalId = idp.listUsers().next(); Authorizable a = userManager.createUser(externalId.getId(), null); a.setProperty(DefaultSyncContext.REP_EXTERNAL_ID, valueFactory.createValue(externalId.getExternalId().getString())); syncContext.setForceUserSync(true); SyncResult result = syncContext.sync(externalId.getId()); assertEquals(SyncResult.Status.UPDATE, result.getStatus()); Tree t = r.getTree(a.getPath()); assertTrue(t.hasProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES)); }
@Override public void before() throws Exception { super.before(); testUserPath = getTestUser().getPath(); // force an external user to be synchronized into the repo login(new SimpleCredentials(USER_ID, new char[0])).close(); root.refresh(); Authorizable a = getUserManager(root).getAuthorizable(USER_ID); assertNotNull(a); assertEquals(isDynamic(), a.hasProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES)); externalUserPath = a.getPath(); }
@Test public void testHandleAuthorizableId() throws Exception { init(); Tree userTree = createUserTree(); assertTrue(importer.handlePropInfo(userTree, createPropInfo(REP_AUTHORIZABLE_ID, TEST_USER_ID), mockPropertyDefinition(NT_REP_AUTHORIZABLE, false))); assertEquals(TEST_USER_ID, userTree.getProperty(REP_AUTHORIZABLE_ID).getValue(Type.STRING)); assertEquals(userTree.getPath(), getUserManager(root).getAuthorizable(TEST_USER_ID).getPath()); }