Adds support for Tls to config data.
Moves common setup to new ConfigClientRequestTemplateFactory class that was replicated between two implementations. Fixes gh-1689
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2013-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.config.client.tls;
|
||||
|
||||
public class ConfigClientConfigDataTlsTests extends ConfigClientTlsTests {
|
||||
|
||||
@Override
|
||||
protected TlsConfigClientRunner createConfigClient(boolean optional) {
|
||||
String importValue = "configserver:";
|
||||
if (optional) {
|
||||
importValue = "optional:" + importValue;
|
||||
}
|
||||
return new TlsConfigClientRunner(TestApp.class, server, "spring.config.import", importValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TlsConfigClientRunner createConfigClient() {
|
||||
return new TlsConfigClientRunner(TestApp.class, server, "spring.config.import", "optional:configserver:");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class ConfigClientTlsTests extends AbstractTlsSetup {
|
||||
|
||||
private static TlsConfigServerRunner server;
|
||||
protected static TlsConfigServerRunner server;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupAll() throws Exception {
|
||||
@@ -95,7 +95,7 @@ public class ConfigClientTlsTests extends AbstractTlsSetup {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void wrongPasswordCauseFailure() {
|
||||
TlsConfigClientRunner client = createConfigClient();
|
||||
TlsConfigClientRunner client = createConfigClient(false);
|
||||
enableTlsClient(client);
|
||||
client.setKeyStore(clientCert, WRONG_PASSWORD, WRONG_PASSWORD);
|
||||
client.start();
|
||||
@@ -103,7 +103,7 @@ public class ConfigClientTlsTests extends AbstractTlsSetup {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void nonExistKeyStoreCauseFailure() {
|
||||
TlsConfigClientRunner client = createConfigClient();
|
||||
TlsConfigClientRunner client = createConfigClient(false);
|
||||
enableTlsClient(client);
|
||||
client.setKeyStore(new File("nonExistFile"));
|
||||
client.start();
|
||||
@@ -119,7 +119,15 @@ public class ConfigClientTlsTests extends AbstractTlsSetup {
|
||||
}
|
||||
}
|
||||
|
||||
private TlsConfigClientRunner createConfigClient() {
|
||||
protected TlsConfigClientRunner createConfigClient(boolean optional) {
|
||||
TlsConfigClientRunner runner = createConfigClient();
|
||||
if (!optional) {
|
||||
runner.property("spring.cloud.config.fail-fast", "true");
|
||||
}
|
||||
return runner;
|
||||
}
|
||||
|
||||
protected TlsConfigClientRunner createConfigClient() {
|
||||
return new TlsConfigClientRunner(TestApp.class, server);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,15 @@ import java.io.File;
|
||||
public class TlsConfigClientRunner extends AppRunner {
|
||||
|
||||
public TlsConfigClientRunner(Class<?> appClass, AppRunner server) {
|
||||
this(appClass, server, "spring.config.use-legacy-processing", "true");
|
||||
}
|
||||
|
||||
public TlsConfigClientRunner(Class<?> appClass, AppRunner server, String importKey, String importValue) {
|
||||
super(appClass);
|
||||
|
||||
property("spring.cloud.config.uri", server.root());
|
||||
property("spring.cloud.config.enabled", "true");
|
||||
property("spring.config.use-legacy-processing", "true");
|
||||
property(importKey, importValue);
|
||||
}
|
||||
|
||||
public void enableTls() {
|
||||
|
||||
Reference in New Issue
Block a user