From 3f11127567a590065d76021ab09216752922cae8 Mon Sep 17 00:00:00 2001 From: Colm O hEigeartaigh Date: Mon, 26 Aug 2019 15:42:03 +0100 Subject: [PATCH] AMQ-7289 - Fix failing HTTP tests --- .../activemq/transport/SecureSocketConnectorFactory.java | 2 +- .../apache/activemq/transport/WebTransportServerSupport.java | 3 ++- .../apache/activemq/transport/http/HttpTraceTestSupport.java | 4 ++-- .../apache/activemq/transport/ws/MQTTWSSubProtocolTest.java | 2 +- .../org/apache/activemq/transport/ws/MQTTWSTransportTest.java | 2 +- .../apache/activemq/transport/ws/MQTTWSTransportWillTest.java | 2 +- .../apache/activemq/transport/ws/StompWSSubProtocolTest.java | 2 +- .../apache/activemq/transport/ws/StompWSTransportTest.java | 2 +- .../org/apache/activemq/transport/ws/WSTransportTest.java | 2 +- .../activemq/transport/wss/WSSTransportHttpTraceTest.java | 3 ++- .../transport/wss/WSSTransportNeedClientAuthTest.java | 4 ++-- .../org/apache/activemq/transport/wss/WSSTransportTest.java | 3 ++- 12 files changed, 17 insertions(+), 14 deletions(-) diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/SecureSocketConnectorFactory.java b/activemq-http/src/main/java/org/apache/activemq/transport/SecureSocketConnectorFactory.java index 1999c8fe7b..b99f549d96 100644 --- a/activemq-http/src/main/java/org/apache/activemq/transport/SecureSocketConnectorFactory.java +++ b/activemq-http/src/main/java/org/apache/activemq/transport/SecureSocketConnectorFactory.java @@ -67,7 +67,7 @@ public class SecureSocketConnectorFactory extends SocketConnectorFactory { SslContextFactory factory; if (contextFactory == null) { - factory = new SslContextFactory(); + factory = new SslContextFactory.Server(); if (context != null) { // Should not be using this method since it does not use all of the values // from the passed SslContext instance..... diff --git a/activemq-http/src/main/java/org/apache/activemq/transport/WebTransportServerSupport.java b/activemq-http/src/main/java/org/apache/activemq/transport/WebTransportServerSupport.java index eba63abeb4..86d784ebbe 100644 --- a/activemq-http/src/main/java/org/apache/activemq/transport/WebTransportServerSupport.java +++ b/activemq-http/src/main/java/org/apache/activemq/transport/WebTransportServerSupport.java @@ -27,6 +27,7 @@ import org.eclipse.jetty.security.ConstraintMapping; import org.eclipse.jetty.security.ConstraintSecurityHandler; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.security.Constraint; import org.eclipse.jetty.xml.XmlConfiguration; import org.slf4j.Logger; @@ -61,7 +62,7 @@ abstract public class WebTransportServerSupport extends TransportServerSupport { if (!file.exists()) { throw new IllegalArgumentException("Jetty XML not found: " + file.getAbsolutePath()); } - XmlConfiguration xmlConfiguration = new XmlConfiguration(file.toURI().toURL()); + XmlConfiguration xmlConfiguration = new XmlConfiguration(Resource.newResource(file)); server = (Server) xmlConfiguration.configure(); } catch (Throwable t) { throw new IllegalStateException("Jetty configuration can't be loaded", t); diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpTraceTestSupport.java b/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpTraceTestSupport.java index a313ba649a..cde0e05166 100644 --- a/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpTraceTestSupport.java +++ b/activemq-http/src/test/java/org/apache/activemq/transport/http/HttpTraceTestSupport.java @@ -47,13 +47,13 @@ public class HttpTraceTestSupport { } public static void testHttpTraceEnabled(final String uri, final int expectedStatus) throws Exception { - testHttpTraceEnabled(uri, expectedStatus, new SslContextFactory()); + testHttpTraceEnabled(uri, expectedStatus, new SslContextFactory.Client()); } public static void testHttpTraceEnabled(final String uri, final int expectedStatus, SslContextFactory sslContextFactory) throws Exception { HttpClient httpClient = sslContextFactory != null ? new HttpClient(sslContextFactory) : - new HttpClient(new SslContextFactory()); + new HttpClient(new SslContextFactory.Client()); httpClient.start(); final CountDownLatch latch = new CountDownLatch(1); diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSSubProtocolTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSSubProtocolTest.java index ea8c262beb..8030ed851c 100644 --- a/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSSubProtocolTest.java +++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSSubProtocolTest.java @@ -39,7 +39,7 @@ public class MQTTWSSubProtocolTest extends WSTransportTestSupport { public void setUp() throws Exception { super.setUp(); - wsClient = new WebSocketClient(new SslContextFactory(true)); + wsClient = new WebSocketClient(new SslContextFactory.Client(true)); wsClient.start(); } diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportTest.java index 74652453f0..ddaac6bfa0 100644 --- a/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportTest.java +++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportTest.java @@ -68,7 +68,7 @@ public class MQTTWSTransportTest extends WSTransportTestSupport { public void setUp() throws Exception { super.setUp(); - wsClient = new WebSocketClient(new SslContextFactory(true)); + wsClient = new WebSocketClient(new SslContextFactory.Client(true)); wsClient.start(); request = new ClientUpgradeRequest(); diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportWillTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportWillTest.java index 6d05ab8c03..b78f15267d 100644 --- a/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportWillTest.java +++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/MQTTWSTransportWillTest.java @@ -78,7 +78,7 @@ public class MQTTWSTransportWillTest extends WSTransportTestSupport { //turn off advisory support broker = createBroker(true, false); - wsClient = new WebSocketClient(new SslContextFactory(true)); + wsClient = new WebSocketClient(new SslContextFactory.Client(true)); wsClient.start(); request = new ClientUpgradeRequest(); diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/ws/StompWSSubProtocolTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/ws/StompWSSubProtocolTest.java index 492428ee95..1858224570 100644 --- a/activemq-http/src/test/java/org/apache/activemq/transport/ws/StompWSSubProtocolTest.java +++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/StompWSSubProtocolTest.java @@ -150,7 +150,7 @@ public class StompWSSubProtocolTest extends WSTransportTestSupport { request.setSubProtocols(subProtocol); } - wsClient = new WebSocketClient(new SslContextFactory(true)); + wsClient = new WebSocketClient(new SslContextFactory.Client(true)); wsClient.start(); wsClient.connect(wsStompConnection, wsConnectUri, request); diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/ws/StompWSTransportTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/ws/StompWSTransportTest.java index 03818083f4..c1b506916f 100644 --- a/activemq-http/src/test/java/org/apache/activemq/transport/ws/StompWSTransportTest.java +++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/StompWSTransportTest.java @@ -57,7 +57,7 @@ public class StompWSTransportTest extends WSTransportTestSupport { ClientUpgradeRequest request = new ClientUpgradeRequest(); request.setSubProtocols("v11.stomp"); - wsClient = new WebSocketClient(new SslContextFactory(true)); + wsClient = new WebSocketClient(new SslContextFactory.Client(true)); wsClient.start(); wsClient.connect(wsStompConnection, wsConnectUri, request); diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java index ca118769c2..0b53e349b5 100644 --- a/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java +++ b/activemq-http/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java @@ -163,7 +163,7 @@ public class WSTransportTest extends WSTransportTestSupport { protected void testGet(final String uri, SslContextFactory sslContextFactory) throws Exception { HttpClient httpClient = sslContextFactory != null ? new HttpClient(sslContextFactory) : - new HttpClient(new SslContextFactory()); + new HttpClient(new SslContextFactory.Client()); httpClient.start(); final CountDownLatch latch = new CountDownLatch(1); diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportHttpTraceTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportHttpTraceTest.java index a21ff4d635..f225c2443b 100644 --- a/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportHttpTraceTest.java +++ b/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportHttpTraceTest.java @@ -38,7 +38,8 @@ public class WSSTransportHttpTraceTest extends WSTransportHttpTraceTest { @Override @Test(timeout=10000) public void testHttpTraceEnabled() throws Exception { - SslContextFactory factory = new SslContextFactory(); + SslContextFactory factory = new SslContextFactory.Client(); + factory.setEndpointIdentificationAlgorithm(null); // service cert does not contain a SAN factory.setSslContext(broker.getSslContext().getSSLContext()); HttpTraceTestSupport.testHttpTraceEnabled("https://127.0.0.1:61623", expectedStatus, factory); diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportNeedClientAuthTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportNeedClientAuthTest.java index 793edd5b40..2fdef4011c 100644 --- a/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportNeedClientAuthTest.java +++ b/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportNeedClientAuthTest.java @@ -77,7 +77,7 @@ public class WSSTransportNeedClientAuthTest { public void testStompNeedClientAuth() throws Exception { StompWSConnection wsStompConnection = new StompWSConnection(); System.out.println("starting connection"); - SslContextFactory factory = new SslContextFactory(); + SslContextFactory factory = new SslContextFactory.Client(); factory.setKeyStorePath(KEYSTORE); factory.setKeyStorePassword(PASSWORD); factory.setKeyStoreType(KEYSTORE_TYPE); @@ -110,7 +110,7 @@ public class WSSTransportNeedClientAuthTest { @Test public void testMQTTNeedClientAuth() throws Exception { - SslContextFactory factory = new SslContextFactory(); + SslContextFactory factory = new SslContextFactory.Client(); factory.setKeyStorePath(KEYSTORE); factory.setKeyStorePassword(PASSWORD); factory.setKeyStoreType(KEYSTORE_TYPE); diff --git a/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportTest.java b/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportTest.java index a3722c2f7b..78494fc4ca 100644 --- a/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportTest.java +++ b/activemq-http/src/test/java/org/apache/activemq/transport/wss/WSSTransportTest.java @@ -46,7 +46,8 @@ public class WSSTransportTest extends WSTransportTest { @Override @Test(timeout=10000) public void testGet() throws Exception { - SslContextFactory factory = new SslContextFactory(); + SslContextFactory factory = new SslContextFactory.Client(); + factory.setEndpointIdentificationAlgorithm(null); // service cert does not contain a SAN factory.setSslContext(broker.getSslContext().getSSLContext()); testGet("https://127.0.0.1:" + port, factory);