Skip to content

Commit ad12831

Browse files
committed
Fix test in "Truststore password if SSLstoreprovider present"
See gh-13088
1 parent e75d45c commit ad12831

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/SslConnectorCustomizerTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
import org.apache.tomcat.util.net.SSLHostConfig;
3232
import org.junit.After;
3333
import org.junit.Before;
34+
import org.junit.Rule;
3435
import org.junit.Test;
3536

37+
import org.springframework.boot.testsupport.rule.OutputCapture;
3638
import org.springframework.boot.web.server.Ssl;
3739
import org.springframework.boot.web.server.SslStoreProvider;
3840
import org.springframework.core.io.ClassPathResource;
@@ -54,6 +56,9 @@ public class SslConnectorCustomizerTests {
5456

5557
private Connector connector;
5658

59+
@Rule
60+
public OutputCapture output = new OutputCapture();
61+
5762
@Before
5863
public void setup() {
5964
this.tomcat = new Tomcat();
@@ -64,6 +69,7 @@ public void setup() {
6469

6570
@After
6671
public void stop() throws Exception {
72+
System.clearProperty("javax.net.ssl.trustStorePassword");
6773
ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance",
6874
null);
6975
ReflectionTestUtils.setField(URL.class, "factory", null);
@@ -167,10 +173,10 @@ public void customizeWhenSslStoreProviderProvidesOnlyTrustStoreShouldUseDefaultK
167173
@Test
168174
public void customizeWhenSslStoreProviderPresentShouldIgnorePasswordFromSsl()
169175
throws Exception {
176+
System.setProperty("javax.net.ssl.trustStorePassword", "trustStoreSecret");
170177
Ssl ssl = new Ssl();
171178
ssl.setKeyPassword("password");
172179
ssl.setKeyStorePassword("secret");
173-
ssl.setTrustStorePassword("trustStoreSecret");
174180
SslStoreProvider sslStoreProvider = mock(SslStoreProvider.class);
175181
given(sslStoreProvider.getTrustStore()).willReturn(loadStore());
176182
given(sslStoreProvider.getKeyStore()).willReturn(loadStore());
@@ -180,6 +186,7 @@ public void customizeWhenSslStoreProviderPresentShouldIgnorePasswordFromSsl()
180186
customizer.customize(connector);
181187
this.tomcat.start();
182188
assertThat(connector.getState()).isEqualTo(LifecycleState.STARTED);
189+
assertThat(this.output.toString()).doesNotContain("Password verification failed");
183190
}
184191

185192
private KeyStore loadStore() throws KeyStoreException, IOException,

0 commit comments

Comments
 (0)