Search in sources :

Example 6 with TlsSettings

use of com.hotels.styx.api.extension.service.TlsSettings in project styx by ExpediaGroup.

the class TlsSettingsTest method toStringPrintsAttributeNames.

@Test
public void toStringPrintsAttributeNames() throws Exception {
    TlsSettings tlsSettings = new TlsSettings.Builder().cipherSuites(List.of("x", "y")).protocols(List.of("TLSv1", "TLSv1.2")).build();
    assertThat(tlsSettings.toString(), containsString("protocols=[TLSv1, TLSv1.2]"));
    assertThat(tlsSettings.toString(), containsString("cipherSuites=[x, y]"));
}
Also used : TlsSettings(com.hotels.styx.api.extension.service.TlsSettings) Test(org.junit.jupiter.api.Test)

Example 7 with TlsSettings

use of com.hotels.styx.api.extension.service.TlsSettings in project styx by ExpediaGroup.

the class StyxHttpClientTest method usesDefaultTlsSettings.

/*
     * StyxHttpClient
     * - Applies default TLS settings
     */
@Test
public void usesDefaultTlsSettings() throws ExecutionException, InterruptedException {
    StyxHttpClient client = new StyxHttpClient.Builder().tlsSettings(new TlsSettings.Builder().build()).build();
    HttpResponse response = client.send(secureRequest).get();
    assertThat(response.status(), is(OK));
}
Also used : HttpResponse(com.hotels.styx.api.HttpResponse) LiveHttpResponse(com.hotels.styx.api.LiveHttpResponse) TlsSettings(com.hotels.styx.api.extension.service.TlsSettings) Test(org.junit.jupiter.api.Test)

Example 8 with TlsSettings

use of com.hotels.styx.api.extension.service.TlsSettings in project styx by ExpediaGroup.

the class StyxServerTest method startsProxyOnSpecifiedHttpsPort.

@Test
public void startsProxyOnSpecifiedHttpsPort() {
    styxServer = new StyxServer.Builder().proxyHttpsPort(0).addRoute("/", originServer1.port()).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));
}
Also used : StyxHttpClient(com.hotels.styx.client.StyxHttpClient) HttpResponse(com.hotels.styx.api.HttpResponse) LiveHttpResponse(com.hotels.styx.api.LiveHttpResponse) TlsSettings(com.hotels.styx.api.extension.service.TlsSettings) Test(org.junit.jupiter.api.Test)

Example 9 with TlsSettings

use of com.hotels.styx.api.extension.service.TlsSettings in project styx by ExpediaGroup.

the class TlsSettingsTest method serialisesTrustStorePathAndPassword.

@Test
public void serialisesTrustStorePathAndPassword() throws Exception {
    TlsSettings tlsSettings = new TlsSettings.Builder().trustStorePath("/path/to/truststore").trustStorePassword("foobar").build();
    String result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(tlsSettings);
    assertThat(result, containsString("\"trustStorePath\" : \"/path/to/truststore\""));
    assertThat(result, containsString("\"trustStorePassword\" : \"foobar\""));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) TlsSettings(com.hotels.styx.api.extension.service.TlsSettings) Test(org.junit.jupiter.api.Test)

Example 10 with TlsSettings

use of com.hotels.styx.api.extension.service.TlsSettings in project styx by ExpediaGroup.

the class TlsSettingsTest method appliesDefaultTruststoreSettings.

@Test
public void appliesDefaultTruststoreSettings() throws Exception {
    TlsSettings tlsSettings = new TlsSettings.Builder().build();
    assertThat(tlsSettings.trustAllCerts(), is(true));
    assertThat(tlsSettings.sslProvider(), is("JDK"));
    assertThat(tlsSettings.additionalCerts().isEmpty(), is(true));
    assertThat(tlsSettings.trustStorePath(), endsWith(new File("security/cacerts").getPath()));
    assertThat(tlsSettings.trustStorePassword(), is("".toCharArray()));
    assertThat(tlsSettings.protocols(), is(Collections.emptyList()));
    assertThat(tlsSettings.cipherSuites(), is(Collections.emptyList()));
    assertThat(tlsSettings.sendSni(), is(true));
    assertThat(tlsSettings.sniHost(), is(Optional.empty()));
}
Also used : File(java.io.File) TlsSettings(com.hotels.styx.api.extension.service.TlsSettings) Test(org.junit.jupiter.api.Test)

Aggregations

TlsSettings (com.hotels.styx.api.extension.service.TlsSettings)14 Test (org.junit.jupiter.api.Test)14 HttpResponse (com.hotels.styx.api.HttpResponse)4 LiveHttpResponse (com.hotels.styx.api.LiveHttpResponse)4 Matchers.containsString (org.hamcrest.Matchers.containsString)3 StyxHttpClient (com.hotels.styx.client.StyxHttpClient)2 Certificate (com.hotels.styx.api.extension.service.Certificate)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1