Polish BCrypt upgrade

Issue gh-7042
This commit is contained in:
Rob Winch 2019-07-03 13:55:00 -05:00
parent d3d6a8743e
commit 742df2cd1d
1 changed files with 12 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
@ -215,8 +216,17 @@ public class DelegatingPasswordEncoderTests {
}
@Test
public void upgradeEncodingWhenSameIdThenEncoderDecides() {
this.passwordEncoder.upgradeEncoding(this.bcryptEncodedPassword);
public void upgradeEncodingWhenSameIdAndEncoderFalseThenEncoderDecidesFalse() {
assertThat(this.passwordEncoder.upgradeEncoding(this.bcryptEncodedPassword)).isFalse();
verify(bcrypt).upgradeEncoding(this.encodedPassword);
}
@Test
public void upgradeEncodingWhenSameIdAndEncoderTrueThenEncoderDecidesTrue() {
when(this.bcrypt.upgradeEncoding(any())).thenReturn(true);
assertThat(this.passwordEncoder.upgradeEncoding(this.bcryptEncodedPassword)).isTrue();
verify(bcrypt).upgradeEncoding(this.encodedPassword);
}