Skip to content

Commit

Permalink
#102: added test for bcrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
firaja committed Feb 15, 2023
1 parent 74983bc commit 004b8fe
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/test/com/password4j/PasswordTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,25 @@ public void testGenericUpdate6()
assertTrue(updated5.isUpdated());
}

@Test
public void testGenericUpdate7()
{
String password = "password";

HashingFunction oldFunction = BcryptFunction.getInstance(6);
Hash hash = Password.hash(password).with(oldFunction);

HashUpdate notUpdated = Password.check(password, hash.getResult())
.andUpdate().with(oldFunction, oldFunction);

HashUpdate updated = Password.check(password, hash.getResult())
.andUpdate().forceUpdate().with(oldFunction, oldFunction);

assertFalse(notUpdated.isUpdated());
assertTrue(updated.isUpdated());
assertNotEquals(hash.getSalt(), updated.getHash().getSalt());
}

@Test
public void testBcryptNonStandardParams()
{
Expand Down

0 comments on commit 004b8fe

Please sign in to comment.