Refine search
@Test public void testUserByIdAndType() throws Exception { User u = mgr.getAuthorizable(user.getID(), User.class); assertTrue(u instanceof UserImpl); Authorizable auth = mgr.getAuthorizable(user.getID(), user.getClass()); assertTrue(auth instanceof UserImpl); auth = mgr.getAuthorizable(user.getID(), Authorizable.class); assertTrue(auth instanceof AuthorizableImpl); }
@Test public void testGetAuthorizable() throws RepositoryException { Authorizable a = mgr.getAuthorizable(UserConstants.DEFAULT_ANONYMOUS_ID); assertNotNull(a); assertTrue(a instanceof AuthorizableImpl); assertTrue(a instanceof UserImpl); a = mgr.getAuthorizableByPath(a.getPath()); assertNotNull(a); assertTrue(a instanceof AuthorizableImpl); assertTrue(a instanceof UserImpl); a = mgr.getAuthorizable(a.getPrincipal()); assertNotNull(a); assertTrue(a instanceof AuthorizableImpl); assertTrue(a instanceof UserImpl); assertNull(mgr.getAuthorizable("unknown")); }
@Test(expected = AuthorizableTypeException.class) public void testUserByIdAndWrongType() throws Exception { mgr.getAuthorizable(user.getID(), Group.class); fail("Wrong Authorizable type is not detected."); }
private static void assertSyncedMembership(@NotNull UserManager userManager, @NotNull Authorizable a, @NotNull ExternalIdentity externalIdentity) throws Exception { for (ExternalIdentityRef ref : externalIdentity.getDeclaredGroups()) { Group gr = userManager.getAuthorizable(ref.getId(), Group.class); assertNotNull(gr); assertTrue(gr.isMember(a)); } }
@Test(expected = AuthorizableTypeException.class) public void testGroupByIdAndWrongType() throws Exception { mgr.getAuthorizable(group.getID(), User.class); fail("Wrong Authorizable type is not detected."); } }
@Test public void testGroupByIdAndType() throws Exception { Group g = mgr.getAuthorizable(group.getID(), Group.class); assertTrue(g instanceof GroupImpl); Authorizable auth = mgr.getAuthorizable(group.getID(), group.getClass()); assertTrue(auth instanceof GroupImpl); auth = mgr.getAuthorizable(group.getID(), Authorizable.class); assertTrue(auth instanceof AuthorizableImpl); }
private void assertRepExternalId(@NotNull SyncResult result) throws Exception { assertSame(SyncResult.Status.ADD, result.getStatus()); SyncedIdentity si = result.getIdentity(); assertNotNull(si); Authorizable authorizable = userManager.getAuthorizable(si.getId()); assertNotNull(authorizable); Tree userTree = r.getTree(authorizable.getPath()); assertTrue(userTree.hasProperty(DefaultSyncContext.REP_EXTERNAL_ID)); PropertyState ps = userTree.getProperty(DefaultSyncContext.REP_EXTERNAL_ID); assertNotNull(ps); assertFalse(ps.isArray()); assertSame(Type.STRING, ps.getType()); assertEquals(si.getExternalIdRef(), ExternalIdentityRef.fromString(ps.getValue(Type.STRING))); }
@Test public void testIsUser() throws RepositoryException { Authorizable authorizable = userMgr.getAuthorizable(user.getID()); assertTrue(authorizable instanceof User); }
@Test public void testGetPrincipalsNonExistingUser() throws Exception { assertNull(getUserManager(root).getAuthorizable("nonExistingUser")); Set<? extends Principal> principals = principalProvider.getPrincipals("nonExistingUser"); assertTrue(principals.isEmpty()); }
@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())); }
@Test public void testGetPrincipalsExternalGroup() throws Exception { Authorizable authorizable = getUserManager(root).getAuthorizable("secondGroup"); assertNotNull(authorizable); Set<? extends Principal> principals = principalProvider.getPrincipals(authorizable.getID()); assertTrue(principals.isEmpty()); }
@Test public void testBuildInUserExist() throws Exception { assertNotNull(userMgr.getAuthorizable(UserUtil.getAdminId(config))); assertNotNull(userMgr.getAuthorizable(UserUtil.getAnonymousId(config))); }
@Test public void testIsSameIDPSyncedGroup() throws Exception { ExternalIdentity externalGroup = idp.listGroups().next(); sync(externalGroup); assertTrue(syncCtx.isSameIDP(userManager.getAuthorizable(externalGroup.getId()))); }
@Test public void testSyncExternalUser() throws Exception { ExternalUser externalUser = idp.getUser(USER_ID); sync(externalUser, SyncResult.Status.ADD); assertNotNull(userManager.getAuthorizable(USER_ID)); }
@Test public void testGetGroupMembershipDefaultSync() throws Exception { // synchronized by default sync-context => no 'dynamic' group principals Authorizable user = getUserManager(root).getAuthorizable(TestIdentityProvider.ID_SECOND_USER); assertNotNull(user); Set<? extends Principal> principals = principalProvider.getMembershipPrincipals(user.getPrincipal()); assertTrue(principals.isEmpty()); }
@Test public void testRemoveExternalUser() throws Exception { getUserManager(root).getAuthorizable(USER_ID).remove(); root.commit(); }
@Test public void testIsSameIDPSyncedUser() throws Exception { ExternalIdentity externalUser = idp.listUsers().next(); sync(externalUser); assertTrue(syncCtx.isSameIDP(userManager.getAuthorizable(externalUser.getId()))); }
@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 testGetGroupMembershipDefaultSync2() throws Exception { // synchronized by default sync-context => no 'dynamic' group principals Authorizable user = getUserManager(root).getAuthorizable(TestIdentityProvider.ID_SECOND_USER); assertNotNull(user); // same as in test before even if the principal is not a tree-based-principal Set<? extends Principal> principals = principalProvider.getMembershipPrincipals(new PrincipalImpl(user.getPrincipal().getName())); assertTrue(principals.isEmpty()); }
@Test public void testUnknownGroupId() throws Exception { String id = "unknownGroupId"; assertNull(userManager.getAuthorizable(id)); Predicate<Authorizable> predicate = getDeclaredMembershipPredicate(id); assertFalse(predicate.apply(testUser)); assertFalse(predicate.apply(testGroup)); assertFalse(predicate.apply(inheritedMember)); assertFalse(predicate.apply(null)); }