use of org.springframework.cloud.config.server.environment.JGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class SshUriPropertyProcessorTest method testHttpsUriDoesNotAddEntry.
@Test
public void testHttpsUriDoesNotAddEntry() {
MultipleJGitEnvironmentProperties sshUriProperties = new MultipleJGitEnvironmentProperties();
sshUriProperties.setUri("https://user@github.com/proj/repo.git");
SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(sshUriProperties);
Map<String, JGitEnvironmentProperties> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname();
assertThat(sshKeysByHostname.values()).hasSize(0);
}
use of org.springframework.cloud.config.server.environment.JGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class SshUriPropertyProcessorTest method testSingleSshUriProperties.
@Test
public void testSingleSshUriProperties() {
SshUriPropertyProcessor sshUriPropertyProcessor = new SshUriPropertyProcessor(mainRepoPropertiesFixture());
Map<String, JGitEnvironmentProperties> sshKeysByHostname = sshUriPropertyProcessor.getSshKeysByHostname();
assertThat(sshKeysByHostname.values()).hasSize(1);
JGitEnvironmentProperties sshKey = sshKeysByHostname.get(HOST1);
assertMainRepo(sshKey);
}
use of org.springframework.cloud.config.server.environment.JGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class HttpClientSupportTest method httpsProxy.
@Test
@EnabledOnJre(JRE.JAVA_8)
public void httpsProxy() throws GeneralSecurityException, IOException {
WireMockServer wireMockProxyServer = new WireMockServer(options().httpDisabled(true).dynamicHttpsPort().enableBrowserProxying(true).trustAllProxyTargets(true));
WireMockServer wireMockServer = new WireMockServer(options().httpDisabled(true).dynamicHttpsPort());
wireMockProxyServer.start();
wireMockServer.start();
WireMock.configureFor("https", "localhost", wireMockServer.httpsPort());
stubFor(get("/test/proxy").willReturn(aResponse().withStatus(200)));
JGitEnvironmentProperties properties = new JGitEnvironmentProperties();
Map<ProxyHostProperties.ProxyForScheme, ProxyHostProperties> proxy = new HashMap<>();
ProxyHostProperties hostProperties = new ProxyHostProperties();
hostProperties.setHost("localhost");
hostProperties.setPort(wireMockProxyServer.httpsPort());
proxy.put(ProxyHostProperties.ProxyForScheme.HTTPS, hostProperties);
properties.setProxy(proxy);
properties.setSkipSslValidation(true);
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
try {
httpClient = HttpClientSupport.builder(properties).build();
response = httpClient.execute(new HttpGet("https://localhost:" + wireMockServer.httpsPort() + "/test/proxy"));
} finally {
if (response != null) {
response.close();
}
if (httpClient != null) {
httpClient.close();
}
verify(1, getRequestedFor(urlEqualTo("/test/proxy")));
}
}
use of org.springframework.cloud.config.server.environment.JGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class HttpClientSupportTest method setsTimeout.
@Test
public void setsTimeout() throws GeneralSecurityException, IOException {
JGitEnvironmentProperties properties = new JGitEnvironmentProperties();
properties.setTimeout(1);
CloseableHttpClient httpClient = HttpClientSupport.builder(properties).build();
Assertions.assertThatThrownBy(() -> {
httpClient.execute(new HttpGet(String.format("http://127.0.0.1:%s/test/endpoint", this.localServerPort)));
}).isInstanceOf(SocketTimeoutException.class);
}
use of org.springframework.cloud.config.server.environment.JGitEnvironmentProperties in project spring-cloud-config by spring-cloud.
the class PropertyBasedSshSessionFactoryTest method strictHostKeyCheckingIsOptional.
@Test
public void strictHostKeyCheckingIsOptional() {
JGitEnvironmentProperties sshKey = new JGitEnvironmentProperties();
sshKey.setUri("ssh://gitlab.example.local:3322/somerepo.git");
sshKey.setPrivateKey(PRIVATE_KEY);
setupSessionFactory(sshKey);
this.factory.configure(this.hc, this.session);
verify(this.session).setConfig("StrictHostKeyChecking", "no");
verifyNoMoreInteractions(this.session);
}
Aggregations