public void testRemoveNotExistingProperty() throws RepositoryException, NotExecutableException { Authorizable auth = getTestUser(superuser); String hint = "Fullname"; String propName = hint; int i = 0; while (auth.hasProperty(propName)) { propName = hint + i; i++; } assertFalse(auth.removeProperty(propName)); save(superuser); }
public void testGroupGetPrincipalNotNull() throws RepositoryException, NotExecutableException { Group gr = getTestGroup(superuser); assertNotNull(gr.getPrincipal()); }
public void testGetNotExistingProperty() throws RepositoryException, NotExecutableException { Authorizable auth = getTestUser(superuser); String hint = "Fullname"; String propName = hint; int i = 0; while (auth.hasProperty(propName)) { propName = hint + i; i++; } assertNull(auth.getProperty(propName)); assertFalse(auth.hasProperty(propName)); }
public void testGetId() throws NotExecutableException, RepositoryException { User user = getTestUser(superuser); assertNotNull(user.getID()); }
public void testSetPropertyByRelPath() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); Value[] v = new Value[] {superuser.getValueFactory().createValue("Super User")}; List<String> relPaths = new ArrayList<String>(); relPaths.add("testing/Fullname"); relPaths.add("testing/Email"); relPaths.add("testing/testing/testing/Fullname"); relPaths.add("testing/testing/testing/Email"); for (String relPath : relPaths) { try { auth.setProperty(relPath, v); save(superuser); assertTrue(auth.hasProperty(relPath)); String propName = Text.getName(relPath); assertFalse(auth.hasProperty(propName)); } finally { // try to remove the property even if previous calls failed. auth.removeProperty(relPath); save(superuser); } } }
public void testGetPropertyNamesByRelPath() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); try { auth.setProperty(relPath, v); save(superuser); } catch (RepositoryException e) { throw new NotExecutableException("Cannot test 'Authorizable.setProperty'."); for (Iterator<String> it = auth.getPropertyNames(); it.hasNext();) { String name = it.next(); assertFalse("Fullname".equals(name)); String rp = "testing/" + name; assertFalse(auth.hasProperty(name)); assertNull(auth.getProperty(name)); assertTrue(auth.hasProperty(rp)); assertNotNull(auth.getProperty(rp)); assertFalse(auth.hasProperty(name)); assertNull(auth.getProperty(name)); assertTrue(auth.hasProperty(rp)); assertNotNull(auth.getProperty(rp)); save(superuser);
save(superuser); assertNull(userMgr.getAuthorizable(id)); Session s2 = getHelper().getSuperuserSession(); User u2 = null; try { UserManager umgr = ((JackrabbitSession) s2).getUserManager(); assertNull(umgr.getAuthorizable(id)); assertNotNull(umgr.getAuthorizable(id)); assertNotNull(userMgr.getAuthorizable(id)); save(s2);
public void testGetPropertyNames() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); // TODO: retrieve propname and value from config String propName = "Fullname"; Value v = superuser.getValueFactory().createValue("Super User"); try { auth.setProperty(propName, v); save(superuser); } catch (RepositoryException e) { throw new NotExecutableException("Cannot test 'Authorizable.setProperty'."); } try { for (Iterator<String> it = auth.getPropertyNames(); it.hasNext();) { String name = it.next(); assertTrue(auth.hasProperty(name)); assertNotNull(auth.getProperty(name)); } } finally { // try to remove the property again even if previous calls failed. auth.removeProperty(propName); save(superuser); } }
public void testDeclaredMemberOf() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); Iterator<Group> it = auth.declaredMemberOf(); while (it.hasNext()) { Object group = it.next(); assertTrue(group instanceof Group); } }
public void testGetPropertyNamesByInvalidRelPath() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); List<String> invalidPaths = new ArrayList<String>(); invalidPaths.add("../"); invalidPaths.add("../../"); invalidPaths.add("../testing"); invalidPaths.add("/testing"); invalidPaths.add(null); for (String invalidRelPath : invalidPaths) { try { auth.getPropertyNames(invalidRelPath); fail("Calling Authorizable#getPropertyNames with " + invalidRelPath + " must fail."); } catch (Exception e) { // success } } }
public void testHasPropertyByInvalidRelativePath() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); List<String> wrongPaths = new ArrayList<String>(); wrongPaths.add("../jcr:primaryType"); wrongPaths.add("../../jcr:primaryType"); wrongPaths.add("../testing/jcr:primaryType"); for (String path : wrongPaths) { assertFalse(auth.hasProperty(path)); } List<String> invalidPaths = new ArrayList<String>(); invalidPaths.add(".."); invalidPaths.add("."); invalidPaths.add(null); for (String invalidPath : invalidPaths) { try { assertFalse(auth.hasProperty(invalidPath)); } catch (Exception e) { // success } } }
public void testGetPropertyByInvalidRelativePath() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); List<String> wrongPaths = new ArrayList<String>(); wrongPaths.add("../jcr:primaryType"); wrongPaths.add("../../jcr:primaryType"); wrongPaths.add("../testing/jcr:primaryType"); for (String path : wrongPaths) { assertNull(auth.getProperty(path)); } List<String> invalidPaths = new ArrayList<String>(); invalidPaths.add("/testing/jcr:primaryType"); invalidPaths.add(".."); invalidPaths.add("."); invalidPaths.add(null); for (String invalidPath : invalidPaths) { try { assertNull(auth.getProperty(invalidPath)); } catch (Exception e) { // success } } }
Principal uP = getTestPrincipal(); User newUser = userMgr.createUser(uP.getName(), uP.getName()); save(superuser); newUserId = newUser.getID(); newGroup = userMgr.createGroup(getTestPrincipal()); newGroup.addMember(newUser); save(superuser); save(superuser); } finally { if (newUserId != null) { newGroup.remove(); save(superuser);
public void testSetProperty() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); try { auth.setProperty(propName, v); save(superuser); } catch (RepositoryException e) { throw new NotExecutableException("Cannot test 'Authorizable.setProperty'."); assertTrue(found); assertTrue(found); assertTrue(auth.hasProperty(propName)); assertTrue(auth.hasProperty("./" + propName)); assertTrue(auth.getProperty(propName).length == 1); assertEquals(v, auth.getProperty(propName)[0]); assertEquals(v, auth.getProperty("./" + propName)[0]); assertTrue(auth.removeProperty(propName)); assertFalse(auth.hasProperty(propName)); save(superuser); } finally { save(superuser);
public void testMemberOf() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); Iterator<Group> it = auth.memberOf(); while (it.hasNext()) { Object group = it.next(); assertTrue(group instanceof Group); } }
public void testGetPrincipalNotNull() throws RepositoryException, NotExecutableException { User user = getTestUser(superuser); assertNotNull(user.getPrincipal()); }
public void testSetPropertyInvalidRelativePath() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); Value[] v = new Value[] {superuser.getValueFactory().createValue("Super User")}; List<String> invalidPaths = new ArrayList<String>(); // try setting outside of tree defined by the user. invalidPaths.add("../testing/Fullname"); invalidPaths.add("../../testing/Fullname"); invalidPaths.add("testing/testing/../../../Fullname"); // try absolute path -> must fail invalidPaths.add("/testing/Fullname"); for (String invalidRelPath : invalidPaths) { try { auth.setProperty(invalidRelPath, v); fail("Modifications outside of the scope of the authorizable must fail."); } catch (Exception e) { // success. } } }
public void testSetMultiValueProperty() throws NotExecutableException, RepositoryException { Authorizable auth = getTestUser(superuser); try { auth.setProperty(propName, v); save(superuser); } catch (RepositoryException e) { throw new NotExecutableException("Cannot test 'Authorizable.setProperty'."); found = propName.equals(it.next()); assertTrue(found); assertTrue(found); assertTrue(auth.hasProperty(propName)); assertTrue(auth.hasProperty("./" + propName)); assertEquals(Arrays.asList(v), Arrays.asList(auth.getProperty(propName))); assertEquals(Arrays.asList(v), Arrays.asList(auth.getProperty("./" + propName))); assertTrue(auth.removeProperty(propName)); assertFalse(auth.hasProperty(propName)); save(superuser); } finally { save(superuser);
public void testGroupGetId() throws NotExecutableException, RepositoryException { Group gr = getTestGroup(superuser); assertNotNull(gr.getID()); }