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);
}
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()));
}
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"));
}
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"));
}
Aggregations