|
|
@ -0,0 +1,27 @@ |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
import static org.junit.Assert.assertThrows; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
|
import static org.junit.jupiter.api.Assertions.assertNotNull; |
|
|
|
|
|
|
|
public class PasswordHasherTest { |
|
|
|
|
|
|
|
@Test |
|
|
|
void testHashPassword() { |
|
|
|
String password = "password123"; |
|
|
|
String hashedPassword = PasswordHasher.hashPassword(password); |
|
|
|
|
|
|
|
// Check that the hashed password is not null |
|
|
|
assertEquals(64, hashedPassword.length()); |
|
|
|
|
|
|
|
// Test with an empty password |
|
|
|
String emptyPassword = ""; |
|
|
|
String hashedEmptyPassword = PasswordHasher.hashPassword(emptyPassword); |
|
|
|
assertEquals(64, hashedEmptyPassword.length()); |
|
|
|
|
|
|
|
// Test with a null password |
|
|
|
assertThrows(IllegalArgumentException.class, () -> { |
|
|
|
PasswordHasher.hashPassword(null); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |