public void testReadOnlyIsntAdmin() throws NotExecutableException, RepositoryException { Session s = getHelper().getReadOnlySession(); try { User user = getTestUser(s); assertFalse(user.isAdmin()); } finally { s.logout(); } }
public void testUserHasCredentials() throws RepositoryException, NotExecutableException { User user = getTestUser(superuser); Credentials creds = user.getCredentials(); assertTrue(creds != null); }
public void testNotIsGroup() throws NotExecutableException, RepositoryException { User user = getTestUser(superuser); assertFalse(user.isGroup()); }
public void testDisable() throws Exception { boolean remove = false; Session s = getHelper().getReadOnlySession(); User readonlyUser = getTestUser(s); if (readonlyUser.isAdmin()) { userID = getUserManager(superuser).createUser(getTestPrincipal().getName(), pw).getID(); remove = true; } else { user = (User) getUserManager(superuser).getAuthorizable(userID); assertFalse(user.isDisabled()); assertNull(user.getDisabledReason()); save(superuser); assertTrue(user.isDisabled()); assertEquals(reason, user.getDisabledReason()); assertNotNull(getUserManager(superuser).getAuthorizable(userID)); assertTrue(((JackrabbitSession) superuser).getPrincipalManager().hasPrincipal(user.getPrincipal().getName())); Session ss = getHelper().getRepository().login(new SimpleCredentials(userID, pw.toCharArray())); ss.logout(); fail("A disabled user must not be allowed to login any more"); } catch (LoginException e) { Session ss = superuser.impersonate(new SimpleCredentials(userID, new char[0]));
public void testChangePassword2() throws RepositoryException, NotExecutableException { String oldPw = getHelper().getProperty("javax.jcr.tck.superuser.pwd"); if (oldPw == null) { // missing property throw new NotExecutableException(); } User user = getTestUser(superuser); try { user.changePassword("pw"); save(superuser); Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), oldPw.toCharArray())); s.logout(); fail("superuser pw has changed. login must fail."); } catch (LoginException e) { // success } finally { user.changePassword(oldPw); save(superuser); } }
public void testChangePassword() throws RepositoryException, NotExecutableException { String oldPw = getHelper().getProperty("javax.jcr.tck.superuser.pwd"); if (oldPw == null) { // missing property throw new NotExecutableException(); } User user = getTestUser(superuser); try { user.changePassword("pw"); save(superuser); // make sure the user can login with the new pw Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), "pw".toCharArray())); s.logout(); } finally { user.changePassword(oldPw); save(superuser); } }
public void testChangePasswordWithOldPassword2() throws RepositoryException, NotExecutableException { String oldPw = getHelper().getProperty("javax.jcr.tck.superuser.pwd"); if (oldPw == null) { // missing property throw new NotExecutableException(); } User user = getTestUser(superuser); try { user.changePassword("pw", oldPw); save(superuser); Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), oldPw.toCharArray())); s.logout(); fail("superuser pw has changed. login must fail."); } catch (LoginException e) { // success } finally { user.changePassword(oldPw); save(superuser); } }
public void testChangePasswordWithOldPassword() throws RepositoryException, NotExecutableException { String oldPw = getHelper().getProperty("javax.jcr.tck.superuser.pwd"); if (oldPw == null) { // missing property throw new NotExecutableException(); } User user = getTestUser(superuser); try { try { user.changePassword("pw", "wrongOldPw"); save(superuser); fail("old password didn't match -> changePassword(String,String) should fail."); } catch (RepositoryException e) { // success. } user.changePassword("pw", oldPw); save(superuser); // make sure the user can login with the new pw Session s = getHelper().getRepository().login(new SimpleCredentials(user.getID(), "pw".toCharArray())); s.logout(); } finally { user.changePassword(oldPw); save(superuser); } }
public void testSuperuserIsAdmin() throws NotExecutableException, RepositoryException { User user = getTestUser(superuser); assertTrue(user.isAdmin()); }