JPAUser implements User { @VisibleForTesting static String hashPassword(String password, String alg) { return chooseHashFunction(alg).apply(password); } protected  JPAUser();  JPAUser(String userName, String password, String alg); @Override Username getUserName(); @Override boolean setPassword(String newPass); @Override boolean verifyPassword(String pass); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test void hashPasswordShouldBeNoopWhenNone() { Assertions.assertThat(JPAUser.hashPassword(RANDOM_PASSWORD, "NONE")).isEqualTo("password"); }
@Test void hashPasswordShouldHashWhenMD5() { Assertions.assertThat(JPAUser.hashPassword(RANDOM_PASSWORD, "MD5")).isEqualTo("702000e50c9fd3755b8fc20ecb07d1ac"); }
@Test void hashPasswordShouldHashWhenSHA1() { Assertions.assertThat(JPAUser.hashPassword(RANDOM_PASSWORD, "SHA1")).isEqualTo("05dbbaa7b4bcae245f14d19ae58ef1b80adf3363"); }
@Test void hashPasswordShouldHashWhenSHA256() { Assertions.assertThat(JPAUser.hashPassword(RANDOM_PASSWORD, "SHA-256")).isEqualTo("6d06c72a578fe0b78ede2393b07739831a287774dcad0b18bc4bde8b0c948b82"); }
@Test void hashPasswordShouldHashWhenSHA512() { Assertions.assertThat(JPAUser.hashPassword(RANDOM_PASSWORD, "SHA-512")).isEqualTo("f9cc82d1c04bb2ce0494a51f7a21d07ac60b6f79a8a55397f454603acac29d8589fdfd694d5c01ba01a346c76b090abca9ad855b5b0c92c6062ad6d93cdc0d03"); }
@Test void hashPasswordShouldSha1WhenRandomString() { Assertions.assertThat(JPAUser.hashPassword(RANDOM_PASSWORD, "random")).isEqualTo("05dbbaa7b4bcae245f14d19ae58ef1b80adf3363"); }
@Test void hashPasswordShouldMD5WhenNull() { Assertions.assertThat(JPAUser.hashPassword(RANDOM_PASSWORD, null)).isEqualTo("702000e50c9fd3755b8fc20ecb07d1ac"); }