use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.
the class PropertyFileInitialisationTest method tlsNotEnabledIfNotConfigured.
@Test
public void tlsNotEnabledIfNotConfigured() {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
ConnectionFactoryConfigurator.load(connectionFactory, Collections.emptyMap(), "");
verify(connectionFactory, never()).useSslProtocol(any(SSLContext.class));
}
use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.
the class PropertyFileInitialisationTest method propertyInitialisationFromFile.
@Test
public void propertyInitialisationFromFile() throws IOException {
for (String propertyFileLocation : Arrays.asList("./src/test/resources/property-file-initialisation/configuration.properties", "classpath:/property-file-initialisation/configuration.properties")) {
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.load(propertyFileLocation);
checkConnectionFactory(connectionFactory);
}
}
use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.
the class PropertyFileInitialisationTest method tlsBasicSetupShouldSetDefaultTrustManagerWhenServerValidationIsEnabled.
@Test
public void tlsBasicSetupShouldSetDefaultTrustManagerWhenServerValidationIsEnabled() throws Exception {
Map<String, String> configuration = new HashMap<>();
configuration.put(ConnectionFactoryConfigurator.SSL_ENABLED, "true");
configuration.put(ConnectionFactoryConfigurator.SSL_VALIDATE_SERVER_CERTIFICATE, "true");
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
ConnectionFactoryConfigurator.load(connectionFactory, configuration, "");
verify(connectionFactory, never()).useSslProtocol(anyString());
verify(connectionFactory, times(1)).useSslProtocol(any(SSLContext.class));
}
use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.
the class PropertyFileInitialisationTest method tlsBasicSetupShouldTrustEveryoneWhenServerValidationIsNotEnabled.
@Test
public void tlsBasicSetupShouldTrustEveryoneWhenServerValidationIsNotEnabled() throws Exception {
String algorithm = ConnectionFactory.computeDefaultTlsProtocol(SSLContext.getDefault().getSupportedSSLParameters().getProtocols());
Map<String, String> configuration = new HashMap<>();
configuration.put(ConnectionFactoryConfigurator.SSL_ENABLED, "true");
configuration.put(ConnectionFactoryConfigurator.SSL_VALIDATE_SERVER_CERTIFICATE, "false");
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
ConnectionFactoryConfigurator.load(connectionFactory, configuration, "");
verify(connectionFactory, times(1)).useSslProtocol(algorithm);
}
use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.
the class PropertyFileInitialisationTest method tlsSslContextSetIfTlsEnabled.
@Test
public void tlsSslContextSetIfTlsEnabled() {
AtomicBoolean sslProtocolSet = new AtomicBoolean(false);
ConnectionFactory connectionFactory = new ConnectionFactory() {
@Override
public void useSslProtocol(SSLContext context) {
sslProtocolSet.set(true);
super.useSslProtocol(context);
}
};
ConnectionFactoryConfigurator.load(connectionFactory, Collections.singletonMap(ConnectionFactoryConfigurator.SSL_ENABLED, "true"), "");
assertThat(sslProtocolSet).isTrue();
}
Aggregations