handling null-values for salts properly now - fixes gh-4147

This commit is contained in:
Jan Brennenstuhl
2016-12-06 12:17:35 +01:00
committed by Rob Winch
parent f94399cff9
commit 09436649cc
2 changed files with 14 additions and 3 deletions

View File

@@ -14,10 +14,11 @@
package org.springframework.security.crypto.bcrypt;
import org.junit.Test;
import java.util.Arrays;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;
/**
* JUnit unit tests for BCrypt routines
@@ -271,6 +272,11 @@ public class BCryptTests {
assertThat(BCrypt.gensalt(31).startsWith("$2a$31$")).isTrue();
}
@Test(expected = IllegalArgumentException.class)
public void hashpwFailsWhenSaltIsNull() {
BCrypt.hashpw("password", null);
}
@Test(expected = IllegalArgumentException.class)
public void hashpwFailsWhenSaltSpecifiesTooFewRounds() {
BCrypt.hashpw("password", "$2a$03$......................");