2015-12-20 23:43:54 +01:00
|
|
|
package fr.xephi.authme.security.crypts;
|
|
|
|
|
2018-09-03 23:13:48 +02:00
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.nullValue;
|
|
|
|
import static org.hamcrest.Matchers.startsWith;
|
|
|
|
import static org.junit.Assert.assertThat;
|
|
|
|
|
2015-12-20 23:43:54 +01:00
|
|
|
/**
|
2017-03-17 18:49:30 +01:00
|
|
|
* Test for {@link BCrypt2y}.
|
2015-12-20 23:43:54 +01:00
|
|
|
*/
|
2017-03-17 18:49:30 +01:00
|
|
|
public class BCrypt2yTest extends AbstractEncryptionMethodTest {
|
2015-12-20 23:43:54 +01:00
|
|
|
|
2017-03-17 18:49:30 +01:00
|
|
|
public BCrypt2yTest() {
|
|
|
|
super(new BCrypt2y(),
|
2015-12-28 21:03:33 +01:00
|
|
|
"$2y$10$da641e404b982edf1c7c0uTU9BcKzfA2vWKV05q6r.dCvm/93wqVK", // password
|
|
|
|
"$2y$10$e52c48a76f5b86f5da899uiK/HYocyPsfQXESNbP278rIz08LKEP2", // PassWord1
|
|
|
|
"$2y$10$be6f11548dc5fb4088410ONdC0dXnJ04y1RHcJh5fVF3XK5d.qgqK", // &^%te$t?Pw@_
|
|
|
|
"$2y$10$a8097db1fa4423b93f1b2eF6rMAGFkSX178fpROf/OvCFtrDebp6K"); // âË_3(íù*
|
2015-12-20 23:43:54 +01:00
|
|
|
}
|
|
|
|
|
2018-09-03 23:13:48 +02:00
|
|
|
@Test
|
|
|
|
public void shouldGenerateWith2yPrefixAndCostFactor10() {
|
|
|
|
// given
|
|
|
|
BCrypt2y bCrypt2y = new BCrypt2y();
|
|
|
|
|
|
|
|
// when
|
|
|
|
HashedPassword result = bCrypt2y.computeHash("test", null);
|
|
|
|
|
|
|
|
// then
|
|
|
|
assertThat(result.getHash(), startsWith("$2y$10$"));
|
|
|
|
assertThat(result.getSalt(), nullValue());
|
|
|
|
}
|
2015-12-20 23:43:54 +01:00
|
|
|
}
|