Use encrypt.fail-on-error in DecryptEnvironmentPostProcessor
Fixes gh-882
This commit is contained in:
@@ -26,6 +26,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
|
||||
public class EncryptionIntegrationTests {
|
||||
@@ -66,6 +67,28 @@ public class EncryptionIntegrationTests {
|
||||
then(context.getBean(PasswordProperties.class).getPassword()).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void symmetricPropertyValuesFailOnError() {
|
||||
assertThatThrownBy(() -> {
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(TestAutoConfiguration.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.properties("spring.config.use-legacy-processing=false", "encrypt.key:pie",
|
||||
"foo.password:{cipher}ZZZbf29452295df354e6153c5b31b03ef23c70e55fba24299aa85c63438f1c43c95")
|
||||
.run();
|
||||
}).isInstanceOf(IllegalStateException.class).hasMessageContaining("Cannot decrypt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void symmetricPropertyValuesFailOnErrorFalse() {
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(TestAutoConfiguration.class)
|
||||
.web(WebApplicationType.NONE)
|
||||
.properties("encrypt.fail-on-error=false", "spring.config.use-legacy-processing=false",
|
||||
"encrypt.key:pie",
|
||||
"foo.password:{cipher}ZZZbf29452295df354e6153c5b31b03ef23c70e55fba24299aa85c63438f1c43c95")
|
||||
.run();
|
||||
then(context.getEnvironment().getProperty("foo.password")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void symmetricPropertyValues() {
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(TestAutoConfiguration.class)
|
||||
|
||||
Reference in New Issue
Block a user