@Override public void performVoid() throws RepositoryException { getDelegate().changePassword(password); } });
@Override public void performVoid() throws RepositoryException { getDelegate().changePassword(password); } });
@Override public void performVoid() throws RepositoryException { getDelegate().changePassword(password); } });
@Test(expected = ConstraintViolationException.class) public void testHistoryViolation() throws Exception { User user = getTestUser(); user.changePassword("abc"); user.changePassword("def"); user.changePassword("abc"); }
public void testChangePassword() throws RepositoryException { testUser = userManager.createUser(testId, null); superuser.save(); String newPassword = null; // EXERCISE : define valid value(s) testUser.changePassword(newPassword); String oldPassword = null; // EXERCISE : fill in the correct value newPassword = null; // EXERCISE : fill in a valid value; Q: can you use null? testUser.changePassword(newPassword, oldPassword); superuser.save(); } }
@Override public void changePassword(String pw, String oldPw) throws RepositoryException { try { getDelegate().changePassword(pw, oldPw); } finally { getMgr().autosave(); } }
@Override public void changePassword(String pw) throws RepositoryException { try { getDelegate().changePassword(pw); } finally { getMgr().autosave(); } }
@Override public void changePassword(String pw, String oldPw) throws RepositoryException { try { getDelegate().changePassword(pw, oldPw); } finally { getMgr().autosave(); } }
@Test public void testChangePasswordNull() throws RepositoryException, NotExecutableException { // invalid 'null' pw string try { user.changePassword(null); superuser.save(); fail("invalid pw null"); } catch (Exception e) { // success } }
@Test public void testChangePasswordWithInvalidOldPassword() throws RepositoryException, NotExecutableException { try { user.changePassword("changed", "wrongOldPw"); superuser.save(); fail("old password didn't match -> changePassword(String,String) should fail."); } catch (RepositoryException e) { // success. } }
@Test public void testChangePassword() throws RepositoryException, NotExecutableException { try { String hash = getNode(user, superuser).getProperty(UserConstants.REP_PASSWORD).getString(); user.changePassword("changed"); superuser.save(); assertFalse(hash.equals(getNode(user, superuser).getProperty(UserConstants.REP_PASSWORD).getString())); } catch (Exception e) { // success } }
public void testChangePasswordNull() throws RepositoryException { User u = (User) userMgr.getAuthorizable(uID); // invalid 'null' pw string try { u.changePassword(null); fail("invalid pw null"); } catch (Exception e) { // success } }
@Test public void testChangePassword() throws Exception { user = createUser(uid); try { user.changePassword("pw"); superuser.save(); fail(); } catch (UnsupportedRepositoryOperationException e) { // success } }
@Test(expected = ConstraintViolationException.class) public void testHistoryViolationAtFirstChange() throws Exception { User user = getTestUser(); user.changePassword(user.getID()); }
@Test public void testActionIsCalled() throws Exception { user = getUserManager(root).createUser("testUser", "testUser12345"); root.commit(); assertEquals(1, testAction.onCreateCalled); user.changePassword("pW12345678"); assertEquals(1, testAction.onPasswordChangeCalled); user.changePassword("pW1234567890", "pW12345678"); assertEquals(2, testAction.onPasswordChangeCalled); }
@Test public void testChangePassword() throws Exception { createUser(userId); // after granting user-mgt privilege changing the pw must succeed. modify("/", PrivilegeConstants.REP_USER_MANAGEMENT, true); UserManager testUserMgr = getUserManager(testSession); User user = (User) testUserMgr.getAuthorizable(userId); user.changePassword("pw2"); testSession.save(); }
@Test public void testSetPassword() throws RepositoryException, CommitFailedException { systemUser.changePassword(ExerciseUtility.TEST_PW); Tree systemUserTree = root.getTree(systemUser.getPath()); String expectedPw = null; // EXERCISE assertEquals(expectedPw, TreeUtil.getString(systemUserTree, UserConstants.REP_PASSWORD)); systemUserTree.setProperty(UserConstants.REP_PASSWORD, "anotherPw"); root.commit(); }
@Test public void testAuthenticatePasswordExpiredChangePassword() throws Exception { Authentication a = new UserAuthentication(getUserConfiguration(), root, userId); // set password last modified to beginning of epoch root.getTree(user.getPath()).getChild(UserConstants.REP_PWD).setProperty(UserConstants.REP_PASSWORD_LAST_MODIFIED, 0); root.commit(); // changing the password should reset the pw last mod and the pw no longer be expired user.changePassword(userId); root.commit(); assertTrue(a.authenticate(new SimpleCredentials(userId, userId.toCharArray()))); } }
@Test public void testAuthenticatePasswordExpiredChangePassword() throws Exception { Authentication a = new UserAuthentication(getUserConfiguration(), root, userId); // set password last modified to beginning of epoch root.getTree(getTestUser().getPath()).getChild(UserConstants.REP_PWD).setProperty(UserConstants.REP_PASSWORD_LAST_MODIFIED, 0); root.commit(); // changing the password should reset the pw last mod and the pw no longer be expired getTestUser().changePassword(userId); root.commit(); assertTrue(a.authenticate(new SimpleCredentials(userId, userId.toCharArray()))); }
@Test public void testChangePassword() throws Exception { PropertyState p1 = root.getTree(user.getPath()).getChild(UserConstants.REP_PWD).getProperty(UserConstants.REP_PASSWORD_LAST_MODIFIED); long oldModTime = p1.getValue(Type.LONG, 0); assertTrue(oldModTime > 0); waitForSystemTimeIncrement(oldModTime); user.changePassword(user.getID()); root.commit(); PropertyState p2 = root.getTree(user.getPath()).getChild(UserConstants.REP_PWD).getProperty(UserConstants.REP_PASSWORD_LAST_MODIFIED); long newModTime = p2.getValue(Type.LONG, 0); assertTrue(newModTime > oldModTime); }