Search in sources :

Example 11 with TlsSettings

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

the class TlsSettingsTest method equalsToConsidersProtocols.

@Test
public void equalsToConsidersProtocols() throws Exception {
    TlsSettings tlsSettings1 = new TlsSettings.Builder().protocols(List.of("TLSv1", "TLSv1.1")).build();
    TlsSettings tlsSettings2 = new TlsSettings.Builder().build();
    assertThat(tlsSettings1.equals(tlsSettings2), 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.equals(tlsSettings2), is(true));
}
Also used : TlsSettings(com.hotels.styx.api.extension.service.TlsSettings) Test(org.junit.jupiter.api.Test)

Example 12 with TlsSettings

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

the class TlsSettingsTest method equalsToConsidersCipherSuites.

@Test
public void equalsToConsidersCipherSuites() throws Exception {
    TlsSettings tlsSettings1 = new TlsSettings.Builder().cipherSuites(List.of("x", "y")).build();
    TlsSettings tlsSettings2 = new TlsSettings.Builder().build();
    assertThat(tlsSettings1.equals(tlsSettings2), is(false));
    tlsSettings1 = new TlsSettings.Builder().cipherSuites(List.of("x", "y")).build();
    tlsSettings2 = new TlsSettings.Builder().cipherSuites(List.of("x", "y")).build();
    assertThat(tlsSettings1.equals(tlsSettings2), is(true));
}
Also used : TlsSettings(com.hotels.styx.api.extension.service.TlsSettings) Test(org.junit.jupiter.api.Test)

Example 13 with TlsSettings

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

the class TlsSettingsTest method serialisesAllAttributes.

@Test
public void serialisesAllAttributes() throws Exception {
    TlsSettings tlsSettings = new TlsSettings.Builder().trustAllCerts(true).sslProvider("JDK").trustStorePassword("bar").protocols(List.of("TLSv1.2")).cipherSuites(List.of("TLS_RSA_WITH_AES_128_CBC_SHA")).sendSni(false).sniHost("some.sni.host").build();
    String result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(tlsSettings);
    assertThat(result, containsString("\"trustAllCerts\" : true"));
    assertThat(result, containsString("\"sslProvider\" : \"JDK\""));
    assertThat(result, containsString("\"addlCerts\" : [ ]"));
    // trustStorePath is platform dependent - thus match only until just before the root path:
    assertThat(result, containsString("\"trustStorePath\" : \""));
    assertThat(result, containsString("\"trustStorePassword\" : \"bar"));
    assertThat(result, containsString("TLS_RSA_WITH_AES_128_CBC_SHA"));
    assertThat(result, containsString("\"sendSni\" : " + tlsSettings.sendSni()));
    assertThat(result, containsString("\"sniHost\" : \"" + tlsSettings.sniHost().orElse("") + "\""));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) TlsSettings(com.hotels.styx.api.extension.service.TlsSettings) Test(org.junit.jupiter.api.Test)

Example 14 with TlsSettings

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

the class TlsSettingsTest method hashCodeConsidersCipherSuites.

@Test
public void hashCodeConsidersCipherSuites() throws Exception {
    TlsSettings tlsSettings1 = new TlsSettings.Builder().cipherSuites(List.of("x", "y")).build();
    TlsSettings tlsSettings2 = new TlsSettings.Builder().build();
    assertThat(tlsSettings1.hashCode() == tlsSettings2.hashCode(), is(false));
    tlsSettings1 = new TlsSettings.Builder().cipherSuites(List.of("x", "y")).build();
    tlsSettings2 = new TlsSettings.Builder().cipherSuites(List.of("x", "y")).build();
    assertThat(tlsSettings1.hashCode() == tlsSettings2.hashCode(), is(true));
}
Also used : 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