Search in sources :

Example 1 with TlsContextFactory

use of org.mule.runtime.api.tls.TlsContextFactory in project mule by mulesoft.

the class PetStoreTlsConfigTestCase method tls.

@Test
public void tls() throws Exception {
    PetStoreConnector connector = getConfigurationFromRegistry(configName, testEvent(), muleContext);
    TlsContextFactory tls = connector.getTlsContext();
    assertTls(tls);
    TlsContextFactory tlsInsidePojo = connector.getCage().getTls();
    assertTls(tlsInsidePojo);
}
Also used : PetStoreConnector(org.mule.test.petstore.extension.PetStoreConnector) TlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory) Test(org.junit.Test)

Example 2 with TlsContextFactory

use of org.mule.runtime.api.tls.TlsContextFactory in project mule by mulesoft.

the class DefaultTlsContextFactoryBuilderTestCase method buildsContext.

@Test
public void buildsContext() throws Exception {
    TlsContextFactory contextFactory = builder.enabledCipherSuites("TLS_SOMETHING").enabledProtocols("TLSv1.1").keyStorePath("serverKeystore").keyStorePassword("mulepassword").keyAlias("muleserver").keyPassword("mulepassword").keyStoreAlgorithm("PKIX").trustStorePath("trustStore").trustStorePassword("mulepassword").trustStoreType("jceks").insecureTrustStore(true).build();
    assertThat(contextFactory.getEnabledProtocols(), is(arrayContaining("TLSv1.1")));
    assertThat(contextFactory.getEnabledCipherSuites(), is(arrayContaining("TLS_SOMETHING")));
    TlsContextKeyStoreConfiguration keyStoreConfiguration = contextFactory.getKeyStoreConfiguration();
    assertThat(keyStoreConfiguration.getPath(), endsWith("serverKeystore"));
    assertThat(keyStoreConfiguration.getPassword(), is("mulepassword"));
    assertThat(keyStoreConfiguration.getKeyPassword(), is("mulepassword"));
    assertThat(keyStoreConfiguration.getAlias(), is("muleserver"));
    assertThat(keyStoreConfiguration.getType(), is(KeyStore.getDefaultType()));
    assertThat(keyStoreConfiguration.getAlgorithm(), is("PKIX"));
    TlsContextTrustStoreConfiguration trustStoreConfiguration = contextFactory.getTrustStoreConfiguration();
    assertThat(trustStoreConfiguration.getPath(), endsWith("trustStore"));
    assertThat(trustStoreConfiguration.getPassword(), is("mulepassword"));
    assertThat(trustStoreConfiguration.getType(), is("jceks"));
    assertThat(trustStoreConfiguration.getAlgorithm(), is(KeyManagerFactory.getDefaultAlgorithm()));
}
Also used : TlsContextKeyStoreConfiguration(org.mule.runtime.api.tls.TlsContextKeyStoreConfiguration) TlsContextFactory(org.mule.runtime.api.tls.TlsContextFactory) TlsContextTrustStoreConfiguration(org.mule.runtime.api.tls.TlsContextTrustStoreConfiguration) Test(org.junit.Test)

Example 3 with TlsContextFactory

use of org.mule.runtime.api.tls.TlsContextFactory 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 4 with TlsContextFactory

use of org.mule.runtime.api.tls.TlsContextFactory 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)

Aggregations

Test (org.junit.Test)4 TlsContextFactory (org.mule.runtime.api.tls.TlsContextFactory)4 DefaultTlsContextFactory (org.mule.runtime.module.tls.internal.DefaultTlsContextFactory)2 TlsContextKeyStoreConfiguration (org.mule.runtime.api.tls.TlsContextKeyStoreConfiguration)1 TlsContextTrustStoreConfiguration (org.mule.runtime.api.tls.TlsContextTrustStoreConfiguration)1 PetStoreConnector (org.mule.test.petstore.extension.PetStoreConnector)1