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 testGetDeclaredMembersWithMemberRemoved() throws RepositoryException { String uid = user.getID(); user.remove(); superuser.save(); user = null; Iterator<Authorizable> it = group.getDeclaredMembers(); while (it.hasNext()) { Authorizable a = it.next(); assertFalse(uid.equals(a.getID())); } }
@Test public void testUserId() throws Exception { Predicate<Authorizable> predicate = getDeclaredMembershipPredicate(testUser.getID()); assertFalse(predicate.apply(testUser)); assertFalse(predicate.apply(testGroup)); assertFalse(predicate.apply(inheritedMember)); assertFalse(predicate.apply(null)); }
@Test public void testRemoveMembers() throws Exception { Group gr = createGroup(); User member = createUser(); Group member2 = createGroup(); gr.addMembers(member.getID(), member2.getID()); Map m = Maps.newHashMap(); m.put(getContentID(member.getID()), member.getID()); m.put(getContentID(member2.getID()), member2.getID()); Set<String> failed = mp.removeMembers(getTree(gr), m); assertTrue(failed.isEmpty()); }
@Test public void testCreateUserWithRelativePath() throws RepositoryException, NotExecutableException { Principal p = getTestPrincipal(); String uid = p.getName(); User user = createUser(uid, "pw", p, "any/path"); createdUsers.add(user); assertNotNull(user.getID()); assertTrue(user.getPath().contains("any/path")); }
@Test public void testIdConflict() throws RepositoryException, CommitFailedException { // EXERCISE: fix this test without changing the ID-parameter of the 2 create-calls. User conflictUser = getUserManager(root).createUser(testUser.getID(), null); root.refresh(); Group conflictGroup = getUserManager(root).createGroup(testUser.getID()); root.refresh(); }
@Test public void testQuery() throws Exception { Iterator<Authorizable> result = getUserManager(session).findAuthorizables(new Query() { public <T> void build(QueryBuilder<T> builder) { builder.setCondition(builder. eq("@my:property", vf.createValue("value"))); } }); assertTrue(result.hasNext()); assertEquals(user.getID(), result.next().getID()); }
@Test public void testLoginWithOldPassword() throws RepositoryException, NotExecutableException { try { user.changePassword("changed"); superuser.save(); Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), testPw.toCharArray())); s.logout(); fail("user pw has changed. login must fail."); } catch (LoginException e) { // success } }
@Test public void testValidAndEmptyIdModifiesRoot() throws Exception { try { testGroup.addMembers(getTestUser().getID(), ""); } catch (ConstraintViolationException e) { // expected } // no modifications expected as testing for empty id is done before changes are made assertFalse(root.hasPendingChanges()); }
@Test public void testValidAndNullIdModifiesRoot() throws Exception { try { testGroup.addMembers(getTestUser().getID(), null); } catch (ConstraintViolationException e) { // expected } // no modifications expected as testing for null id is done before changes are made assertFalse(root.hasPendingChanges()); }