From ae0f330f98dcfb61b04f2fad1ef20018ad961657 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Tue, 8 Jan 2019 11:54:01 -0600 Subject: [PATCH] Add BCrypt Test for Empty Raw Password Issue: gh-5548 --- .../crypto/bcrypt/BCryptPasswordEncoderTests.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crypto/src/test/java/org/springframework/security/crypto/bcrypt/BCryptPasswordEncoderTests.java b/crypto/src/test/java/org/springframework/security/crypto/bcrypt/BCryptPasswordEncoderTests.java index 25fbf422d4..33c8576283 100644 --- a/crypto/src/test/java/org/springframework/security/crypto/bcrypt/BCryptPasswordEncoderTests.java +++ b/crypto/src/test/java/org/springframework/security/crypto/bcrypt/BCryptPasswordEncoderTests.java @@ -27,6 +27,14 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class BCryptPasswordEncoderTests { + @Test + // gh-5548 + public void emptyRawPasswordDoesNotMatchPassword() { + BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); + String result = encoder.encode("password"); + assertThat(encoder.matches("", result)).isFalse(); + } + @Test public void $2yMatches() { // $2y is default version