Show better message for missing config keystore props (#232)

* Show better message for missing config keystore props

* Removes unused ExpectedException

Fixes #230
This commit is contained in:
Biju Kunjummen
2017-08-04 12:53:35 -07:00
committed by Spencer Gibb
parent 54d55010de
commit a6b7f70b8e
2 changed files with 35 additions and 10 deletions

View File

@@ -1,12 +1,13 @@
package org.springframework.cloud.bootstrap.encrypt;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
public class EncryptionBootstrapConfigurationTests {
@Test
@@ -35,4 +36,23 @@ public class EncryptionBootstrapConfigurationTests {
context.close();
}
@Test
public void nonExistentKeystoreLocationShouldNotBeAllowed() {
try {
new SpringApplicationBuilder(EncryptionBootstrapConfiguration.class)
.web(false)
.properties("encrypt.key-store.location:classpath:/server.jks1",
"encrypt.key-store.password:letmein",
"encrypt.key-store.alias:mytestkey",
"encrypt.key-store.secret:changeme")
.run();
assertThat(false)
.as("Should not create an application context with invalid keystore location")
.isTrue();
}
catch (Exception e) {
assertThat(e).hasRootCauseInstanceOf(IllegalStateException.class);
}
}
}