diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommand.java index 96a9289350..6fa4137061 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommand.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommand.java @@ -100,7 +100,7 @@ public class EncodePasswordCommand extends OptionParsingCommand { .collectionToCommaDelimitedString(ENCODERS.keySet())); return ExitStatus.ERROR; } - Log.info(encoder.get().encode(password)); + Log.info("{" + algorithm + "}" + encoder.get().encode(password)); return ExitStatus.OK; } diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java index 8e1c5e7899..f197dbd996 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/encodepassword/EncodePasswordCommandTests.java @@ -25,8 +25,7 @@ import org.mockito.MockitoAnnotations; import org.springframework.boot.cli.command.status.ExitStatus; import org.springframework.boot.cli.util.MockLog; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder; +import org.springframework.security.crypto.factory.PasswordEncoderFactories; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verify; @@ -59,8 +58,9 @@ public class EncodePasswordCommandTests { EncodePasswordCommand command = new EncodePasswordCommand(); ExitStatus status = command.run("boot"); verify(this.log).info(this.message.capture()); - assertThat(new BCryptPasswordEncoder().matches("boot", this.message.getValue())) - .isTrue(); + assertThat(this.message.getValue()).startsWith("{bcrypt}"); + assertThat(PasswordEncoderFactories.createDelegatingPasswordEncoder() + .matches("boot", this.message.getValue())).isTrue(); assertThat(status).isEqualTo(ExitStatus.OK); } @@ -69,8 +69,9 @@ public class EncodePasswordCommandTests { EncodePasswordCommand command = new EncodePasswordCommand(); ExitStatus status = command.run("-a", "pbkdf2", "boot"); verify(this.log).info(this.message.capture()); - assertThat(new Pbkdf2PasswordEncoder().matches("boot", this.message.getValue())) - .isTrue(); + assertThat(this.message.getValue()).startsWith("{pbkdf2}"); + assertThat(PasswordEncoderFactories.createDelegatingPasswordEncoder() + .matches("boot", this.message.getValue())).isTrue(); assertThat(status).isEqualTo(ExitStatus.OK); }