use of com.hotels.styx.api.extension.service.TlsSettings in project styx by ExpediaGroup.
the class StyxHttpClientTest method overridesTlsSettingsWithSecureBooleanFalse.
/*
* StyxHttpClientTransaction
* - secure(false) disables TLS protection
*/
@Test
public void overridesTlsSettingsWithSecureBooleanFalse() throws ExecutionException, InterruptedException {
StyxHttpClient client = new StyxHttpClient.Builder().tlsSettings(new TlsSettings.Builder().build()).build();
HttpResponse response = client.secure(false).send(httpRequest).get();
assertThat(response.status(), is(OK));
}
use of com.hotels.styx.api.extension.service.TlsSettings in project styx by ExpediaGroup.
the class StyxServerTest method proxiesToOriginViaHttps.
@Test
public void proxiesToOriginViaHttps() {
BackendService backendService = new BackendService().ssl().addOrigin(secureOriginServer.httpsPort());
styxServer = new StyxServer.Builder().addRoute("/", backendService).start();
StyxHttpClient tlsClient = new StyxHttpClient.Builder().tlsSettings(new TlsSettings.Builder().build()).build();
HttpResponse response = await(tlsClient.sendRequest(get(format("https://localhost:%d/", styxServer.proxyHttpsPort())).build()));
assertThat(response.status(), is(OK));
configureFor(secureOriginServer.port());
WireMock.verify(getRequestedFor(urlPathEqualTo("/")));
}
use of com.hotels.styx.api.extension.service.TlsSettings in project styx by ExpediaGroup.
the class TlsSettingsTest method obtainsTrustStorePathFromSystemProperty.
@Test
public void obtainsTrustStorePathFromSystemProperty() throws Exception {
System.setProperty("javax.net.ssl.trustStore", "/path/to/myTruststore");
System.setProperty("javax.net.ssl.trustStorePassword", "myPassword");
TlsSettings tlsSettings = new TlsSettings.Builder().build();
assertThat(tlsSettings.trustStorePath(), is("/path/to/myTruststore"));
assertThat(tlsSettings.trustStorePassword(), is("myPassword".toCharArray()));
}
use of com.hotels.styx.api.extension.service.TlsSettings in project styx by ExpediaGroup.
the class TlsSettingsTest method hashCodeConsidersProtocols.
@Test
public void hashCodeConsidersProtocols() throws Exception {
TlsSettings tlsSettings1 = new TlsSettings.Builder().protocols(List.of("TLSv1", "TLSv1.1")).build();
TlsSettings tlsSettings2 = new TlsSettings.Builder().build();
assertThat(tlsSettings1.hashCode() == tlsSettings2.hashCode(), is(false));
tlsSettings1 = new TlsSettings.Builder().protocols(List.of("TLSv1", "TLSv1.1")).build();
tlsSettings2 = new TlsSettings.Builder().protocols(List.of("TLSv1", "TLSv1.1")).build();
assertThat(tlsSettings1.hashCode() == tlsSettings2.hashCode(), is(true));
}
use of com.hotels.styx.api.extension.service.TlsSettings in project styx by ExpediaGroup.
the class TlsSettingsTest method isImmutable.
@Test
public void isImmutable() throws Exception {
List<String> protocols = new ArrayList<String>() {
{
add("TLSv1");
}
};
List<String> cipherSuites = new ArrayList<String>() {
{
add("x");
}
};
Certificate[] certificates = new Certificate[] { certificate("x", "x") };
TlsSettings tlsSettings = new TlsSettings.Builder().additionalCerts(certificates).protocols(protocols).cipherSuites(cipherSuites).build();
protocols.add("TLSv1.2");
cipherSuites.add("y");
certificates[0] = certificate("y", "y");
assertThat(tlsSettings.protocols(), equalTo(List.of("TLSv1")));
assertThat(tlsSettings.cipherSuites(), equalTo(List.of("x")));
assertThat(tlsSettings.additionalCerts(), equalTo(Set.of(certificate("x", "x"))));
}
Aggregations