From 6c129b3aab620967b6bb755ca2a9fbefde72c2c8 Mon Sep 17 00:00:00 2001 From: "James R. Perkins" Date: Mon, 22 Jan 2024 16:24:17 -0800 Subject: [PATCH] [341] Upgrade Wiremock, which also upgrades Jetty. Also upgrade TestNG. All these upgrades required some additional changes. Signed-off-by: James R. Perkins --- api/pom.xml | 2 +- tck/README.adoc | 10 ++++---- tck/pom.xml | 24 +++++++------------ .../rest/client/tck/ProxyServerTest.java | 5 ++-- .../client/tck/WiremockArquillianTest.java | 4 ++-- .../client/tck/sse/MyEventSourceServlet.java | 4 ++-- .../rest/client/tck/ssl/HttpsServer.java | 16 +++++++++---- .../rest/client/tck/ssl/SslContextTest.java | 2 +- 8 files changed, 32 insertions(+), 35 deletions(-) diff --git a/api/pom.xml b/api/pom.xml index ad05c5da..fd534dd1 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -60,7 +60,7 @@ org.testng testng - 7.5.1 + 7.8.0 test diff --git a/tck/README.adoc b/tck/README.adoc index 8db7650c..61ecbe47 100644 --- a/tck/README.adoc +++ b/tck/README.adoc @@ -35,7 +35,7 @@ To enable the tests in your project you need to add the following dependency to [source, xml] ---- - 3.0 + 3.1 @@ -53,13 +53,12 @@ To enable the tests in your project you need to add the following dependency to org.testng testng - 7.4.0 test com.github.tomakehurst wiremock - 2.27.2 + 3.0.1 test ---- @@ -73,7 +72,7 @@ WireMock can be run as a maven plugin. Below is one example configuration: uk.co.deliverymind wiremock-maven-plugin - 2.7.0 + 7.3.0 generate-test-sources @@ -156,7 +155,6 @@ If you use Apache Maven then the tests are run via the `maven-surefire-plugin` org.apache.maven.plugins maven-surefire-plugin - 2.19.1 tck-suite.xml @@ -194,4 +192,4 @@ TBD. == Running against CDI Lite -For all tests under the https://github.com/eclipse/microprofile-rest-client/tree/master/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/cditests[cditest] folder, the implementation needs to provide a way to enable the injection working on the Arquillian subclass. \ No newline at end of file +For all tests under the https://github.com/eclipse/microprofile-rest-client/tree/master/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/cditests[cditest] folder, the implementation needs to provide a way to enable the injection working on the Arquillian subclass. diff --git a/tck/pom.xml b/tck/pom.xml index 0e98d388..43f92cfa 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -53,18 +53,8 @@ jakarta.enterprise.cdi-api - - org.apache.geronimo.specs - geronimo-annotation_1.2_spec - 1.0 - provided - true - - - org.apache.geronimo.specs - geronimo-atinject_1.0_spec - 1.0 - provided + jakarta.inject + jakarta.inject-api jakarta.json @@ -74,6 +64,10 @@ jakarta.json.bind jakarta.json.bind-api + + jakarta.servlet + jakarta.servlet-api + org.testng testng @@ -85,7 +79,7 @@ com.github.tomakehurst wiremock - 2.27.2 + 3.0.1 jakarta.ws.rs @@ -98,5 +92,5 @@ - - \ No newline at end of file + + diff --git a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ProxyServerTest.java b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ProxyServerTest.java index 91961696..cfb245b3 100644 --- a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ProxyServerTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ProxyServerTest.java @@ -26,9 +26,6 @@ import java.io.PrintWriter; import java.net.URI; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; @@ -39,6 +36,8 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; import org.testng.annotations.Test; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import jakarta.ws.rs.core.Response; public class ProxyServerTest extends WiremockArquillianTest { diff --git a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/WiremockArquillianTest.java b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/WiremockArquillianTest.java index e48402a9..3546a049 100644 --- a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/WiremockArquillianTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/WiremockArquillianTest.java @@ -59,7 +59,7 @@ protected static URL getServerURL() { protected static String getStringURL() { int port = getPort(); - return scheme + "://" + host + ":" + port + "" + context; + return scheme + "://" + host + ":" + port + (context.isBlank() ? "/" : context); } @BeforeClass @@ -73,6 +73,6 @@ private static void setupWireMockConnection() { host = System.getProperty("wiremock.server.host", "localhost"); port = Integer.parseInt(System.getProperty("wiremock.server.port", "8765")); scheme = System.getProperty("wiremock.server.scheme", "http"); - context = System.getProperty("wiremock.server.context", "/"); + context = System.getProperty("wiremock.server.context", ""); } } diff --git a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/sse/MyEventSourceServlet.java b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/sse/MyEventSourceServlet.java index c73b3218..e777c6e6 100644 --- a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/sse/MyEventSourceServlet.java +++ b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/sse/MyEventSourceServlet.java @@ -19,11 +19,11 @@ import java.util.Set; import java.util.function.Consumer; -import javax.servlet.http.HttpServletRequest; - import org.eclipse.jetty.servlets.EventSource; import org.eclipse.jetty.servlets.EventSourceServlet; +import jakarta.servlet.http.HttpServletRequest; + public class MyEventSourceServlet extends EventSourceServlet { private static final long serialVersionUID = -45238967561209543L; diff --git a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ssl/HttpsServer.java b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ssl/HttpsServer.java index 59b81e86..b7fedf58 100644 --- a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ssl/HttpsServer.java +++ b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ssl/HttpsServer.java @@ -18,20 +18,21 @@ import java.io.IOException; import java.io.PrintWriter; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.http.entity.ContentType; +import org.apache.hc.core5.http.ContentType; import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.SecureRequestCustomizer; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + /** * * HTTPS server which returns {@link #responseContent} on each request. @@ -44,7 +45,7 @@ public class HttpsServer { private static final String CONTENT_TYPE = "Content-Type"; private final Server server = new Server(); - private SslContextFactory sslContextFactory = new SslContextFactory(); + private SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); private String responseContent = "{\"foo\": \"bar\"}"; private String responseContentType = ContentType.APPLICATION_JSON.getMimeType(); @@ -83,6 +84,11 @@ public void handle(String path, HttpConfiguration httpsConfig = new HttpConfiguration(); // httpConfig); httpsConfig.setSecureScheme("https"); httpsConfig.setSecurePort(httpsPort); + // We need to disable SNI checking as localhost is restricted. + final SecureRequestCustomizer customizer = new SecureRequestCustomizer(); + customizer.setSniRequired(false); + customizer.setSniHostCheck(false); + httpsConfig.addCustomizer(customizer); ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), diff --git a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ssl/SslContextTest.java b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ssl/SslContextTest.java index 5d6c1e3b..86109648 100644 --- a/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ssl/SslContextTest.java +++ b/tck/src/main/java/org/eclipse/microprofile/rest/client/tck/ssl/SslContextTest.java @@ -17,7 +17,7 @@ import javax.net.ssl.SSLContext; -import org.apache.http.ssl.SSLContextBuilder; +import org.apache.hc.core5.ssl.SSLContextBuilder; import org.eclipse.microprofile.rest.client.RestClientBuilder; import org.eclipse.microprofile.rest.client.tck.interfaces.JsonPClient; import org.jboss.arquillian.container.test.api.Deployment;