Search in sources :

Example 6 with DefaultTlsContextFactory

use of org.mule.runtime.module.tls.internal.DefaultTlsContextFactory in project mule by mulesoft.

the class DefaultTlsContextFactoryTestCase method cannotMutateEnabledProtocols.

@Test
public void cannotMutateEnabledProtocols() throws InitialisationException {
    TlsContextFactory tlsContextFactory = new DefaultTlsContextFactory(emptyMap());
    initialiseIfNeeded(tlsContextFactory);
    tlsContextFactory.getEnabledProtocols()[0] = "TLSv1";
    assertThat(tlsContextFactory.getEnabledProtocols(), arrayWithSize(2));
    assertThat(tlsContextFactory.getEnabledProtocols(), arrayContaining("TLSv1.1", "TLSv1.2"));
}
Also used : TlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory) DefaultTlsContextFactory(org.mule.runtime.module.tls.internal.DefaultTlsContextFactory) DefaultTlsContextFactory(org.mule.runtime.module.tls.internal.DefaultTlsContextFactory) Test(org.junit.Test)

Example 7 with DefaultTlsContextFactory

use of org.mule.runtime.module.tls.internal.DefaultTlsContextFactory in project mule by mulesoft.

the class DefaultTlsContextFactoryTestCase method cannotMutateEnabledCipherSuites.

@Test
public void cannotMutateEnabledCipherSuites() throws InitialisationException {
    TlsContextFactory tlsContextFactory = new DefaultTlsContextFactory(emptyMap());
    initialiseIfNeeded(tlsContextFactory);
    tlsContextFactory.getEnabledCipherSuites()[0] = "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256";
    assertThat(tlsContextFactory.getEnabledCipherSuites(), arrayWithSize(2));
    assertThat(tlsContextFactory.getEnabledCipherSuites(), arrayContaining("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", "TLS_DHE_DSS_WITH_AES_128_CBC_SHA"));
}
Also used : TlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory) DefaultTlsContextFactory(org.mule.runtime.module.tls.internal.DefaultTlsContextFactory) DefaultTlsContextFactory(org.mule.runtime.module.tls.internal.DefaultTlsContextFactory) Test(org.junit.Test)

Example 8 with DefaultTlsContextFactory

use of org.mule.runtime.module.tls.internal.DefaultTlsContextFactory in project mule by mulesoft.

the class DefaultTlsContextFactoryTestCase method failIfTrustStoreIsNonexistent.

@Test
public void failIfTrustStoreIsNonexistent() throws Exception {
    DefaultTlsContextFactory tlsContextFactory = new DefaultTlsContextFactory(emptyMap());
    expectedException.expect(IOException.class);
    expectedException.expectMessage(containsString("Resource non-existent-trust-store could not be found"));
    tlsContextFactory.setTrustStorePath("non-existent-trust-store");
}
Also used : DefaultTlsContextFactory(org.mule.runtime.module.tls.internal.DefaultTlsContextFactory) Test(org.junit.Test)

Example 9 with DefaultTlsContextFactory

use of org.mule.runtime.module.tls.internal.DefaultTlsContextFactory in project mule by mulesoft.

the class DefaultTlsContextFactoryTestCase method useConfigFileIfDefaultProtocolsAndCipherSuites.

@Test
public void useConfigFileIfDefaultProtocolsAndCipherSuites() throws Exception {
    DefaultTlsContextFactory tlsContextFactory = new DefaultTlsContextFactory(emptyMap());
    tlsContextFactory.setEnabledCipherSuites("DEFAULT");
    tlsContextFactory.setEnabledProtocols("default");
    tlsContextFactory.initialise();
    assertThat(tlsContextFactory.getEnabledCipherSuites(), is(StringUtils.splitAndTrim(getFileEnabledCipherSuites(), ",")));
    assertThat(tlsContextFactory.getEnabledProtocols(), is(StringUtils.splitAndTrim(getFileEnabledProtocols(), ",")));
}
Also used : DefaultTlsContextFactory(org.mule.runtime.module.tls.internal.DefaultTlsContextFactory) Test(org.junit.Test)

Aggregations

DefaultTlsContextFactory (org.mule.runtime.module.tls.internal.DefaultTlsContextFactory)9 Test (org.junit.Test)8 TlsContextFactory (org.mule.runtime.api.tls.TlsContextFactory)2 SSLContext (javax.net.ssl.SSLContext)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1