Search in sources :

Example 1 with VersionedHttpsProduceConnection

use of com.adaptris.http.legacy.VersionedHttpsProduceConnection in project interlok by adaptris.

the class HttpsConsumerTest method testTLS_ConsumeWorkflow.

@Test
public void testTLS_ConsumeWorkflow() throws Exception {
    String oldName = Thread.currentThread().getName();
    Thread.currentThread().setName(getName());
    HttpConnection connection = createConnection(null);
    ((HttpsConnection) connection).getSslProperties().add(new KeyValuePair(SslProperty.ExcludeProtocols.name(), "SSLv3,TLSv1.1,"));
    MockMessageProducer mockProducer = new MockMessageProducer();
    SimpleHttpProducer myHttpProducer = createProducer(new VersionedHttpsProduceConnection("TLSv1.2"));
    Channel channel = JettyHelper.createChannel(connection, JettyHelper.createConsumer(URL_TO_POST_TO), mockProducer);
    try {
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
        msg.addMetadata(CONTENT_TYPE_METADATA_KEY, "text/xml");
        myHttpProducer.setUrl(createProduceDestinationUrl(connection.getPort()));
        start(myHttpProducer);
        AdaptrisMessage reply = myHttpProducer.request(msg);
        assertEquals("Reply Payloads", XML_PAYLOAD, reply.getContent());
        doAssertions(mockProducer);
    } finally {
        stop(myHttpProducer);
        channel.requestClose();
        PortManager.release(connection.getPort());
        Thread.currentThread().setName(oldName);
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleHttpProducer(com.adaptris.http.legacy.SimpleHttpProducer) Channel(com.adaptris.core.Channel) VersionedHttpsProduceConnection(com.adaptris.http.legacy.VersionedHttpsProduceConnection) Test(org.junit.Test)

Example 2 with VersionedHttpsProduceConnection

use of com.adaptris.http.legacy.VersionedHttpsProduceConnection in project interlok by adaptris.

the class HttpsConsumerTest method testTLS_ConsumeWorkflow_ClientUsesSSL.

@Test
public void testTLS_ConsumeWorkflow_ClientUsesSSL() throws Exception {
    String oldName = Thread.currentThread().getName();
    Thread.currentThread().setName(getName());
    HttpConnection connection = createConnection(null);
    ((HttpsConnection) connection).getSslProperties().add(new KeyValuePair(SslProperty.ExcludeProtocols.name(), "SSLv3"));
    MockMessageProducer mockProducer = new MockMessageProducer();
    SimpleHttpProducer myHttpProducer = createProducer(new VersionedHttpsProduceConnection("SSLv3"));
    Channel channel = JettyHelper.createChannel(connection, JettyHelper.createConsumer(URL_TO_POST_TO), mockProducer);
    try {
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
        msg.addMetadata(CONTENT_TYPE_METADATA_KEY, "text/xml");
        myHttpProducer.setUrl(createProduceDestinationUrl(connection.getPort()));
        start(myHttpProducer);
        AdaptrisMessage reply = myHttpProducer.request(msg);
        // SSLv3 context shouldn't be allowed to connect to TLSv1.2 only
        fail();
    } catch (CoreException expected) {
    } finally {
        stop(myHttpProducer);
        channel.requestClose();
        PortManager.release(connection.getPort());
        Thread.currentThread().setName(oldName);
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) SimpleHttpProducer(com.adaptris.http.legacy.SimpleHttpProducer) Channel(com.adaptris.core.Channel) VersionedHttpsProduceConnection(com.adaptris.http.legacy.VersionedHttpsProduceConnection) Test(org.junit.Test)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 Channel (com.adaptris.core.Channel)2 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)2 SimpleHttpProducer (com.adaptris.http.legacy.SimpleHttpProducer)2 VersionedHttpsProduceConnection (com.adaptris.http.legacy.VersionedHttpsProduceConnection)2 KeyValuePair (com.adaptris.util.KeyValuePair)2 Test (org.junit.Test)2 CoreException (com.adaptris.core.CoreException)1