LegacyNexusPasswordService implements PasswordService { @Override public boolean passwordsMatch(final Object submittedPlaintext, final String encrypted) { return sha1PasswordService.passwordsMatch(submittedPlaintext, encrypted) || md5PasswordService.passwordsMatch(submittedPlaintext, encrypted); } LegacyNexusPasswordService(); @Override String encryptPassword(final Object plaintextPassword); @Override boolean passwordsMatch(final Object submittedPlaintext, final String encrypted);  }
@Test public void testSha1Hash() { String password = "admin123"; String sha1Hash = "f865b53623b121fd34ee5426c792e5c33af8c227"; assertThat(underTest.passwordsMatch(password, sha1Hash), is(true)); }
@Test public void testMd5Hash() { String password = "admin123"; String md5Hash = "0192023a7bbd73250516f069df18b500"; assertThat(underTest.passwordsMatch(password, md5Hash), is(true)); }
@Test public void testInvalidSha1Hash() { String password = "admin123"; String sha1Hash = "f865b53623b121fd34ee5426c792e5c33af8c228"; assertThat(underTest.passwordsMatch(password, sha1Hash), is(false)); }
@Test public void testInvalidMd5Hash() { String password = "admin123"; String md5Hash = "0192023a7bbd73250516f069df18b501"; assertThat(underTest.passwordsMatch(password, md5Hash), is(false)); }