This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat-tck.git
commit 59e9c2aea93e23c058d160e9efb83f2afe1cc8a0 Author: Mark Thomas <ma...@apache.org> AuthorDate: Mon Mar 25 16:48:40 2024 +0000 Update WebSocket for recent changes including addition of signature test --- README.md | 3 + pom.xml | 4 +- websocket-tck/pom.xml | 69 ++++++++++++++++++--- .../websocket/TomcatWebSocketTckConfiguration.java | 60 +++++++++++++++++- websocket-tck/src/test/resources/arquillian.xml | 16 +++++ websocket-tck/src/test/resources/ca.jks | Bin 0 -> 1766 bytes websocket-tck/src/test/resources/localhost-rsa.jks | Bin 0 -> 4403 bytes 7 files changed, 138 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fae4622..afd14f6 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,9 @@ At the moment, you will need to build the TCK locally (see below). cd $TCK/signaturetest mvn install + + cd $TCK/user_guides + mvn install ``` 6. Install the TCKs Tomcat tests against diff --git a/pom.xml b/pom.xml index 9c89f62..0613af1 100644 --- a/pom.xml +++ b/pom.xml @@ -38,10 +38,10 @@ <api.el.version>6.0.0</api.el.version> <tck.servlet.version>6.1.0-SNAPSHOT</tck.servlet.version> <tck.jsp.version>4.0.0</tck.jsp.version> - <tck.websocket.version>10.0.0-SNAPSHOT</tck.websocket.version> + <tck.websocket.version>2.2.0</tck.websocket.version> <!-- TCK dependency versions --> - <tck.common.version>10.0.0-SNAPSHOT</tck.common.version> + <tck.common.version>11.0.0-SNAPSHOT</tck.common.version> <arquillian.version>1.8.0.Final</arquillian.version> <arquillian.tomcat.version>1.2.0.Final</arquillian.tomcat.version> <junit.jupiter.version>5.9.1</junit.jupiter.version> diff --git a/websocket-tck/pom.xml b/websocket-tck/pom.xml index 8a180fe..9d28894 100644 --- a/websocket-tck/pom.xml +++ b/websocket-tck/pom.xml @@ -31,7 +31,7 @@ <dependencies> <dependency> <groupId>jakarta.tck</groupId> - <artifactId>websocket-tck</artifactId> + <artifactId>websocket-tck-dist</artifactId> <version>${tck.websocket.version}</version> <!-- Use the WebSocket API provided by Tomcat --> <exclusions> @@ -39,6 +39,10 @@ <groupId>jakarta.websocket</groupId> <artifactId>jakarta.websocket-client-api</artifactId> </exclusion> + <exclusion> + <groupId>jakarta.websocket</groupId> + <artifactId>jakarta.websocket-client-api</artifactId> + </exclusion> </exclusions> </dependency> <dependency> @@ -84,6 +88,11 @@ <artifactId>arquillian-junit5-core</artifactId> <version>${arquillian.version}</version> </dependency> + <dependency> + <groupId>jakarta.tck</groupId> + <artifactId>sigtest-maven-plugin</artifactId> + <version>2.1</version> + </dependency> </dependencies> <build> @@ -94,30 +103,72 @@ <version>${failsafe.plugin.version}</version> <executions> <execution> + <id>http</id> <goals> <goal>integration-test</goal> - <goal>verify</goal> </goals> <configuration> <excludes> - <exclude>**/platform/**</exclude> + <exclude>**/cdi/**</exclude> + <exclude>**/authenticatedssl/**</exclude> </excludes> - <dependenciesToScan>jakarta.tck:websocket-tck</dependenciesToScan> + <dependenciesToScan> + <dependency>jakarta.tck:websocket-tck-spec-tests</dependency> + <dependency>jakarta.tck:websocket-tck-platform-tests</dependency> + </dependenciesToScan> + <forkCount>20</forkCount> + <reuseForks>false</reuseForks> + <systemPropertyVariables> + <arquillian.launch>http</arquillian.launch> + <ws_wait>5</ws_wait> + <lib.name>websockettck</lib.name> + <junit.log.traceflag>true</junit.log.traceflag> + <user>j2ee</user> + <password>j2ee</password> + <porting.ts.url.class.1>com.sun.ts.tests.websocket.lib.implementation.sun.common.SunRIURL</porting.ts.url.class.1> + <org.apache.tomcat.websocket.DEFAULT_PROCESS_PERIOD>0</org.apache.tomcat.websocket.DEFAULT_PROCESS_PERIOD> + <sigTestClasspath>${settings.localRepository}/org/apache/tomcat/tomcat-websocket-api/${tomcat.version}/tomcat-websocket-api-${tomcat.version}.jar:${settings.localRepository}/org/apache/tomcat/tomcat-websocket-client-api/${tomcat.version}/tomcat-websocket-client-api-${tomcat.version}.jar:${env.JAVA_HOME}/jmods/java.base</sigTestClasspath> + </systemPropertyVariables> + <summaryFile>target/failsafe-reports/failsafe-summary-http.xml</summaryFile> + </configuration> + </execution> + <execution> + <id>https</id> + <goals> + <goal>integration-test</goal> + </goals> + <configuration> + <includes> + <include>**/authenticatedssl/**</include> + </includes> + <dependenciesToScan> + <dependency>jakarta.tck:websocket-tck-spec-tests</dependency> + <dependency>jakarta.tck:websocket-tck-platform-tests</dependency> + </dependenciesToScan> <reuseForks>false</reuseForks> <systemPropertyVariables> - <webServerHost>localhost</webServerHost> - <webServerPort>8080</webServerPort> - <securedWebServicePort>8443</securedWebServicePort> + <arquillian.launch>https</arquillian.launch> <ws_wait>5</ws_wait> <lib.name>websockettck</lib.name> <junit.log.traceflag>true</junit.log.traceflag> <user>j2ee</user> <password>j2ee</password> - <authuser>javajoe</authuser> - <authpassword>javajoe</authpassword> <porting.ts.url.class.1>com.sun.ts.tests.websocket.lib.implementation.sun.common.SunRIURL</porting.ts.url.class.1> <org.apache.tomcat.websocket.DEFAULT_PROCESS_PERIOD>0</org.apache.tomcat.websocket.DEFAULT_PROCESS_PERIOD> </systemPropertyVariables> + <summaryFile>target/failsafe-reports/failsafe-summary-https.xml</summaryFile> + </configuration> + </execution> + <execution> + <id>verify</id> + <goals> + <goal>verify</goal> + </goals> + <configuration> + <summaryFiles> + <summaryFile>target/failsafe-reports/failsafe-summary-http.xml</summaryFile> + <summaryFile>target/failsafe-reports/failsafe-summary-https.xml</summaryFile> + </summaryFiles> </configuration> </execution> </executions> diff --git a/websocket-tck/src/test/java/org/apache/tomcat/tck/websocket/TomcatWebSocketTckConfiguration.java b/websocket-tck/src/test/java/org/apache/tomcat/tck/websocket/TomcatWebSocketTckConfiguration.java index a653c96..dabd35b 100644 --- a/websocket-tck/src/test/java/org/apache/tomcat/tck/websocket/TomcatWebSocketTckConfiguration.java +++ b/websocket-tck/src/test/java/org/apache/tomcat/tck/websocket/TomcatWebSocketTckConfiguration.java @@ -17,8 +17,14 @@ package org.apache.tomcat.tck.websocket; import java.lang.reflect.Field; +import java.net.URL; import org.apache.catalina.Host; +import org.apache.catalina.connector.Connector; +import org.apache.catalina.startup.Tomcat; +import org.apache.tomcat.util.net.SSLHostConfig; +import org.apache.tomcat.util.net.SSLHostConfigCertificate; +import org.apache.tomcat.util.net.SSLHostConfigCertificate.Type; import org.apache.tomcat.util.scan.StandardJarScanner; import org.jboss.arquillian.container.spi.event.container.BeforeDeploy; import org.jboss.arquillian.core.api.annotation.Observes; @@ -38,10 +44,58 @@ public class TomcatWebSocketTckConfiguration implements LoadableExtension { public void configureContext(@Observes final BeforeDeploy beforeDeploy) { Tomcat10EmbeddedContainer container = (Tomcat10EmbeddedContainer) beforeDeploy.getDeployableContainer(); try { - Field hostField = Tomcat10EmbeddedContainer.class.getDeclaredField("host"); - hostField.setAccessible(true); - Host host = (Host) hostField.get(container); + // Obtain reference to Tomcat instance + Field tomcatField = Tomcat10EmbeddedContainer.class.getDeclaredField("tomcat"); + tomcatField.setAccessible(true); + Tomcat tomcat = (Tomcat) tomcatField.get(container); + Connector connectorHttp = tomcat.getConnector(); + int localPort; + + // Add expected users + tomcat.addUser("j2ee", "j2ee"); + tomcat.addRole("j2ee", "staff"); + + if ("https".equals(System.getProperty("arquillian.launch"))) { + // Need to enabled HTTPS - only used for client-cert tests + Connector connectorHttps = new Connector(); + connectorHttps.setPort(0); + connectorHttps.setSecure(true); + connectorHttps.setProperty("SSLEnabled", "true"); + + SSLHostConfig sslHostConfig = new SSLHostConfig(); + SSLHostConfigCertificate certificateConfig = new SSLHostConfigCertificate(sslHostConfig, Type.UNDEFINED); + sslHostConfig.addCertificate(certificateConfig); + connectorHttps.addSslHostConfig(sslHostConfig); + + // Can't use TLSv1.3 else certificate authentication won't work + sslHostConfig.setSslProtocol("TLS"); + sslHostConfig.setProtocols("TLSv1.2"); + + // Server certificate + certificateConfig.setCertificateKeystoreFile( + this.getClass().getResource("/localhost-rsa.jks").toExternalForm()); + + tomcat.getService().addConnector(connectorHttps); + localPort = connectorHttps.getLocalPort(); + + // Configure the client + URL trustStoreUrl = this.getClass().getResource("/ca.jks"); + System.setProperty("javax.net.ssl.trustStore", trustStoreUrl.getFile()); + } else { + localPort = connectorHttp.getLocalPort(); + } + + // Configure JAR scanner + Host host = tomcat.getHost(); host.setConfigClass(EmbeddedWebSocketContextConfig.class.getName()); + + // Update Arquillian configuration with port being used by Tomcat + Field configurationField = Tomcat10EmbeddedContainer.class.getDeclaredField("configuration"); + configurationField.setAccessible(true); + Object configuration = configurationField.get(container); + Field portField = container.getConfigurationClass().getDeclaredField("bindHttpPort"); + portField.setAccessible(true); + portField.set(configuration, Integer.valueOf(localPort)); } catch (ReflectiveOperationException e) { throw new RuntimeException(e); } diff --git a/websocket-tck/src/test/resources/arquillian.xml b/websocket-tck/src/test/resources/arquillian.xml new file mode 100644 index 0000000..2f7f5d4 --- /dev/null +++ b/websocket-tck/src/test/resources/arquillian.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://jboss.org/schema/arquillian" + xsi:schemaLocation="http://jboss.org/schema/arquillian http://www.jboss.org/schema/arquillian/arquillian_1_0.xsd"> + + <container qualifier="http" default="true"> + <configuration> + <property name="bindHttpPort">0</property> + </configuration> + </container> + <container qualifier="https"> + <configuration> + <property name="bindHttpPort">0</property> + </configuration> + </container> +</arquillian> diff --git a/websocket-tck/src/test/resources/ca.jks b/websocket-tck/src/test/resources/ca.jks new file mode 100644 index 0000000..61076e4 Binary files /dev/null and b/websocket-tck/src/test/resources/ca.jks differ diff --git a/websocket-tck/src/test/resources/localhost-rsa.jks b/websocket-tck/src/test/resources/localhost-rsa.jks new file mode 100644 index 0000000..918fa65 Binary files /dev/null and b/websocket-tck/src/test/resources/localhost-rsa.jks differ --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org