UserServiceImpl implements UserService { @Override public boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName) { return AuthenticatorHelper.verifyPasswordStrength(oldPassword, newPassword, principalName); } UserServiceImpl(); @Override User createUser(final String firstName, final String lastName, final String eMail); @Override User createAndPersistUser(final String firstName, final String lastName, final String email); @Override Identity findIdentityByEmail(final String email); @Override User findUserByEmail(final String email); @Override boolean userExist(final String email); @Override User loadUserByKey(final Long key); @Override void updateUser(final User usr); @Override void saveUser(final User user); @Override boolean updateUserFromIdentity(final Identity identity); @Override void setUserCharset(final Identity identity, final String charset); @Override String getUserCharset(final Identity identity); @Override void deleteUserProperties(User user); @Override boolean verifyPasswordStrength(String oldPassword, String newPassword, String principalName); @Override boolean syntaxCheckOlatLogin(final String login); @Override UserPropertiesConfig getUserPropertiesConfig(); @Override List<UserPropertyHandler> getUserPropertyHandlersFor(final String usageIdentifyer, final boolean isAdministrativeUser); @Override List<UserPropertyHandler> getAllUserPropertyHandlers(); @Override boolean isMandatoryUserProperty(final String usageIdentifyer, final UserPropertyHandler propertyHandler); @Override boolean isUserViewReadOnly(final String usageIdentifyer, final UserPropertyHandler propertyHandler); @Override void setUserNameAndPasswordSyntaxChecker(final UserNameAndPasswordSyntaxChecker userNameAndPasswordSyntaxChecker); @Override void setUserPropertiesConfig(final UserPropertiesConfig userPropertiesConfig); @Override String getUserProperty(User user, String propertyName, Locale locale); @Override String getUserProperty(User user, String propertyName); @Override String getFirstAndLastname(User user); @Override String getInstitutionalIdentifier(User user); @Override void setUserProperty(final User user, final String propertyName, final String propertyValue); @Override String getPropertyOrIdentityEnvAttribute(final User user, final String propertyName, final Locale locale);  }
@Test public void verifyPasswordStrength_OK() { boolean newPasswordOK = userServiceImpl.verifyPasswordStrength("test2", "aBc_123_X", "test2"); assertTrue(newPasswordOK); }
@Test public void verifyPasswordStrength_tooShort() { boolean newPasswordOK = userServiceImpl.verifyPasswordStrength("test2", "aBc_123", "test2"); assertFalse(newPasswordOK); }
@Test public void verifyPasswordStrength_newUser() { boolean newPasswordOK = userServiceImpl.verifyPasswordStrength("", "aBc_123_X", "test2"); assertTrue(newPasswordOK); newPasswordOK = userServiceImpl.verifyPasswordStrength(null, "aBc_123_X", "test2"); assertTrue(newPasswordOK); }
@Test public void verifyPasswordStrength_NOK_onlyLowerCase() { boolean newPasswordOK = userServiceImpl.verifyPasswordStrength("test2", "abcdefghij", "test2"); assertFalse(newPasswordOK); }
@Test public void verifyPasswordStrength_OK_verifyOnlyPasswordNotThePrincipal() { boolean newPasswordOK = userServiceImpl.verifyPasswordStrength(null, "aBc_123_X", null); assertTrue(newPasswordOK); }
@Test public void verifyPasswordStrength_NOK_passwordMatchesUsername() { boolean newPasswordOK = userServiceImpl.verifyPasswordStrength("abc", "teST2134", "test2134"); assertFalse(newPasswordOK); }