From 65132561c61cebcd9e9322a20df5e1fbd8cddf06 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 15 Jan 2024 13:36:30 -0600 Subject: [PATCH 01/11] Issue #11273 - Add support for BSD based `expr` utility in `jetty.sh` Signed-off-by: Joakim Erdfelt --- jetty-home/src/main/resources/bin/jetty.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jetty-home/src/main/resources/bin/jetty.sh b/jetty-home/src/main/resources/bin/jetty.sh index fff4affd11c7..dae4692404dc 100755 --- a/jetty-home/src/main/resources/bin/jetty.sh +++ b/jetty-home/src/main/resources/bin/jetty.sh @@ -233,7 +233,7 @@ testFileSystemPermissions() # Don't test if setuid is specified # as the Jetty process will switch to a different user id on startup - if expr "${JETTY_ARGS[*]}" : '.*setuid.*' >/dev/null + if expr -- "${JETTY_ARGS[*]}" : '.*setuid.*' >/dev/null then (( DEBUG )) && echo "Not testing file system permissions: setuid in use" return 0 @@ -459,7 +459,7 @@ then (( DEBUG )) && echo "$JETTY_CONF: (begin read) JETTY_ARGS.length=${#JETTY_ARGS[@]}" while read -r CONF do - if expr "$CONF" : '#' >/dev/null ; then + if expr -- "$CONF" : '#' >/dev/null ; then continue fi @@ -573,7 +573,7 @@ RUN_ARGS=($JETTY_SYS_PROPS ${JETTY_DRY_RUN[@]}) if (( DEBUG )) then - if expr "${RUN_ARGS[*]}" : '.*/etc/console-capture.xml.*' > /dev/null + if expr -- "${RUN_ARGS[*]}" : '.*/etc/console-capture.xml.*' > /dev/null then echo "WARNING: Disable console-capture module for best DEBUG results" fi @@ -649,7 +649,7 @@ case "$ACTION" in fi - if expr "${JETTY_ARGS[*]}" : '.*jetty\.state=.*' >/dev/null + if expr -- "${JETTY_ARGS[*]}" : '.*jetty\.state=.*' >/dev/null then if started "$JETTY_STATE" "$JETTY_PID" "$JETTY_START_TIMEOUT" then From 8368deea7eec4d66c5f9d10d15faca967278b41e Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 16 Jan 2024 10:46:58 -0600 Subject: [PATCH 02/11] Issue #11263 - Reduce usage of glob lib/foo/*.jar in modules (#11264) * Using @foo.version@ technique and proper lib lists to allow arbitrary version updates from properties * Fix spotless * Remove duplicate entries * Only replace System property "jetty.version" with manifest-ver if blank/null * Fixing bad module definitions --- .../src/main/config/modules/http2.mod | 4 +++- .../src/main/config/modules/http2c.mod | 4 +++- .../src/main/config/modules/http3.mod | 9 ++++++++- .../main/java/org/eclipse/jetty/start/StartArgs.java | 2 +- .../src/main/config/modules/unixdomain-http.mod | 2 +- .../src/main/config/modules/ee10-annotations.mod | 10 +++++++++- .../src/main/config/modules/ee10-apache-jsp.mod | 12 +++++++++++- .../src/main/config/modules/ee10-glassfish-jstl.mod | 7 ++++++- .../src/main/config/modules/ee10-jaspi.mod | 5 ++++- .../src/main/resources/ee10-maven.mod | 2 +- .../src/main/config/modules/ee8-annotations.mod | 10 +++++++++- .../src/main/config/modules/ee8-apache-jsp.mod | 8 +++++++- .../src/main/config/modules/ee8-glassfish-jstl.mod | 7 ++++++- ...mod => ee8-jaspi-default-auth-config-factory.mod} | 0 .../{ee9-jaspi-demo.mod => ee8-jaspi-demo.mod} | 0 .../config/modules/{ee9-jaspi.mod => ee8-jaspi.mod} | 5 ++++- jetty-ee8/pom.xml | 10 ++++------ .../src/main/config/modules/ee9-annotations.mod | 10 +++++++++- .../src/main/config/modules/ee9-apache-jsp.mod | 8 +++++++- .../src/main/config/modules/ee9-glassfish-jstl.mod | 7 ++++++- .../src/main/config/modules/ee9-jaspi.mod | 5 ++++- jetty-home/src/main/resources/modules/conscrypt.mod | 3 ++- .../sessions/session-data-cache/xmemcached.mod | 2 +- .../src/main/config/modules/session-store-mongo.mod | 2 +- pom.xml | 7 ++++++- 25 files changed, 113 insertions(+), 28 deletions(-) rename jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/{ee9-jaspi-default-auth-config-factory.mod => ee8-jaspi-default-auth-config-factory.mod} (100%) rename jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/{ee9-jaspi-demo.mod => ee8-jaspi-demo.mod} (100%) rename jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/{ee9-jaspi.mod => ee8-jaspi.mod} (72%) diff --git a/jetty-core/jetty-http2/jetty-http2-server/src/main/config/modules/http2.mod b/jetty-core/jetty-http2/jetty-http2-server/src/main/config/modules/http2.mod index 2447ef364ec9..34081544e885 100644 --- a/jetty-core/jetty-http2/jetty-http2-server/src/main/config/modules/http2.mod +++ b/jetty-core/jetty-http2/jetty-http2-server/src/main/config/modules/http2.mod @@ -12,7 +12,9 @@ ssl alpn [lib] -lib/http2/*.jar +lib/http2/jetty-http2-common-${jetty.version}.jar +lib/http2/jetty-http2-hpack-${jetty.version}.jar +lib/http2/jetty-http2-server-${jetty.version}.jar [xml] etc/jetty-http2.xml diff --git a/jetty-core/jetty-http2/jetty-http2-server/src/main/config/modules/http2c.mod b/jetty-core/jetty-http2/jetty-http2-server/src/main/config/modules/http2c.mod index eb40a13ed66c..573d4158a50a 100644 --- a/jetty-core/jetty-http2/jetty-http2-server/src/main/config/modules/http2c.mod +++ b/jetty-core/jetty-http2/jetty-http2-server/src/main/config/modules/http2c.mod @@ -10,7 +10,9 @@ http http [lib] -lib/http2/*.jar +lib/http2/jetty-http2-common-${jetty.version}.jar +lib/http2/jetty-http2-hpack-${jetty.version}.jar +lib/http2/jetty-http2-server-${jetty.version}.jar [xml] etc/jetty-http2c.xml diff --git a/jetty-core/jetty-http3/jetty-http3-server/src/main/config/modules/http3.mod b/jetty-core/jetty-http3/jetty-http3-server/src/main/config/modules/http3.mod index eff3d069164e..7069e512d3d3 100644 --- a/jetty-core/jetty-http3/jetty-http3-server/src/main/config/modules/http3.mod +++ b/jetty-core/jetty-http3/jetty-http3-server/src/main/config/modules/http3.mod @@ -15,7 +15,14 @@ quiche work [lib] -lib/http3/*.jar +lib/http3/jetty-http3-common-${jetty.version}.jar +lib/http3/jetty-http3-qpack-${jetty.version}.jar +lib/http3/jetty-http3-server-${jetty.version}.jar +lib/http3/jetty-quic-common-${jetty.version}.jar +lib/http3/jetty-quic-quiche-common-${jetty.version}.jar +lib/http3/jetty-quic-quiche-foreign-incubator-${jetty.version}.jar +lib/http3/jetty-quic-quiche-jna-${jetty.version}.jar +lib/http3/jetty-quic-server-${jetty.version}.jar [xml] etc/jetty-http3.xml diff --git a/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java b/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java index 30d73fa2f089..de9008af6a87 100644 --- a/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java +++ b/jetty-core/jetty-start/src/main/java/org/eclipse/jetty/start/StartArgs.java @@ -67,7 +67,7 @@ public class StartArgs String tag = System.getProperty(JETTY_TAG_NAME_KEY); // Use META-INF/MANIFEST.MF versions - if (ver == null) + if (Utils.isBlank(ver)) { ver = ManifestUtils.getManifest(StartArgs.class) .map(Manifest::getMainAttributes) diff --git a/jetty-core/jetty-unixdomain-server/src/main/config/modules/unixdomain-http.mod b/jetty-core/jetty-unixdomain-server/src/main/config/modules/unixdomain-http.mod index 689b226e904f..1614cce12752 100644 --- a/jetty-core/jetty-unixdomain-server/src/main/config/modules/unixdomain-http.mod +++ b/jetty-core/jetty-unixdomain-server/src/main/config/modules/unixdomain-http.mod @@ -9,7 +9,7 @@ unixdomain server [lib] -lib/jetty-unixdomain-server-*.jar +lib/jetty-unixdomain-server-${jetty.version}.jar [xml] etc/jetty-unixdomain-http.xml diff --git a/jetty-ee10/jetty-ee10-annotations/src/main/config/modules/ee10-annotations.mod b/jetty-ee10/jetty-ee10-annotations/src/main/config/modules/ee10-annotations.mod index b617100a5dca..c3b24d3716f2 100644 --- a/jetty-ee10/jetty-ee10-annotations/src/main/config/modules/ee10-annotations.mod +++ b/jetty-ee10/jetty-ee10-annotations/src/main/config/modules/ee10-annotations.mod @@ -9,9 +9,17 @@ ee10 [depend] ee10-plus +[ini] +ee10.asm.version?=@asm.version@ +ee10.jakarta.annotation.api.version?=@jakarta.annotation.api.version@ + [lib] lib/jetty-ee10-annotations-${jetty.version}.jar -lib/ee10-annotations/*.jar +lib/ee10-annotations/asm-${ee10.asm.version}.jar +lib/ee10-annotations/asm-analysis-${ee10.asm.version}.jar +lib/ee10-annotations/asm-commons-${ee10.asm.version}.jar +lib/ee10-annotations/asm-tree-${ee10.asm.version}.jar +lib/ee10-annotations/jakarta.annotation-api-${ee10.jakarta.annotation.api.version}.jar [jpms] add-modules:org.objectweb.asm diff --git a/jetty-ee10/jetty-ee10-apache-jsp/src/main/config/modules/ee10-apache-jsp.mod b/jetty-ee10/jetty-ee10-apache-jsp/src/main/config/modules/ee10-apache-jsp.mod index 77cce3ca8abe..e06a1bddb299 100644 --- a/jetty-ee10/jetty-ee10-apache-jsp/src/main/config/modules/ee10-apache-jsp.mod +++ b/jetty-ee10/jetty-ee10-apache-jsp/src/main/config/modules/ee10-apache-jsp.mod @@ -10,7 +10,17 @@ ee10 ee10-servlet ee10-annotations +[ini] +ee10.jakarta.el.api.version?=@jakarta.el.api.version@ +ee10.jakarta.servlet.jsp.api.version?=@jakarta.servlet.jsp.api.version@ +eclipse.jdt.ecj.version?=@eclipse.jdt.ecj.version@ +ee10.jsp.impl.version?=@jsp.impl.version@ + [lib] -lib/ee10-apache-jsp/*.jar +lib/ee10-apache-jsp/jakarta.el.jakarta.el-api-${ee10.jakarta.el.api.version}.jar +lib/ee10-apache-jsp/jakarta.servlet.jsp.jakarta.servlet.jsp-api-${ee10.jakarta.servlet.jsp.api.version}.jar +lib/ee10-apache-jsp/org.eclipse.jdt.ecj-${eclipse.jdt.ecj.version}.jar +lib/ee10-apache-jsp/org.mortbay.jasper.apache-el-${ee10.jsp.impl.version}.jar +lib/ee10-apache-jsp/org.mortbay.jasper.apache-jsp-${ee10.jsp.impl.version}.jar lib/jetty-ee10-apache-jsp-${jetty.version}.jar diff --git a/jetty-ee10/jetty-ee10-glassfish-jstl/src/main/config/modules/ee10-glassfish-jstl.mod b/jetty-ee10/jetty-ee10-glassfish-jstl/src/main/config/modules/ee10-glassfish-jstl.mod index 4bb6bb07b567..18405bc1b141 100644 --- a/jetty-ee10/jetty-ee10-glassfish-jstl/src/main/config/modules/ee10-glassfish-jstl.mod +++ b/jetty-ee10/jetty-ee10-glassfish-jstl/src/main/config/modules/ee10-glassfish-jstl.mod @@ -9,5 +9,10 @@ ee10 [depends] ee10-apache-jsp +[ini] +ee10.jakarta.servlet.jsp.jstl.api.version?=@jakarta.servlet.jsp.jstl.api.version@ +ee10.jakarta.servlet.jsp.jstl.impl.version?=@jakarta.servlet.jsp.jstl.impl.version@ + [lib] -lib/ee10-glassfish-jstl/*.jar +lib/ee10-glassfish-jstl/jakarta.servlet.jsp.jstl.jakarta.servlet.jsp.jstl-api-${ee10.jakarta.servlet.jsp.jstl.api.version}.jar +lib/ee10-glassfish-jstl/org.glassfish.web.jakarta.servlet.jsp.jstl-${ee10.jakarta.servlet.jsp.jstl.impl.version}.jar diff --git a/jetty-ee10/jetty-ee10-jaspi/src/main/config/modules/ee10-jaspi.mod b/jetty-ee10/jetty-ee10-jaspi/src/main/config/modules/ee10-jaspi.mod index f463d213d06c..9b65c07c0b9c 100644 --- a/jetty-ee10/jetty-ee10-jaspi/src/main/config/modules/ee10-jaspi.mod +++ b/jetty-ee10/jetty-ee10-jaspi/src/main/config/modules/ee10-jaspi.mod @@ -13,9 +13,12 @@ security ee10-security auth-config-factory +[ini] +ee10.jakarta.authentication.api.version?=@jakarta.authentication.api.version@ + [lib] lib/jetty-ee10-jaspi-${jetty.version}.jar -lib/ee10-jaspi/*.jar +lib/ee10-jaspi/jakarta.authentication-api-${ee10.jakarta.authentication.api.version}.jar [xml] etc/jaspi/jetty-ee10-jaspi-authmoduleconfig.xml diff --git a/jetty-ee10/jetty-ee10-maven-plugin/src/main/resources/ee10-maven.mod b/jetty-ee10/jetty-ee10-maven-plugin/src/main/resources/ee10-maven.mod index 8920fbe1cd81..344d4aaaa825 100644 --- a/jetty-ee10/jetty-ee10-maven-plugin/src/main/resources/ee10-maven.mod +++ b/jetty-ee10/jetty-ee10-maven-plugin/src/main/resources/ee10-maven.mod @@ -12,7 +12,7 @@ ee10-webapp ee10-annotations [lib] -lib/maven-ee10/**.jar +lib/maven-ee10/*.jar [xml] etc/jetty-ee10-maven.xml diff --git a/jetty-ee8/jetty-ee8-annotations/src/main/config/modules/ee8-annotations.mod b/jetty-ee8/jetty-ee8-annotations/src/main/config/modules/ee8-annotations.mod index 4a6762fb020d..539543afec03 100644 --- a/jetty-ee8/jetty-ee8-annotations/src/main/config/modules/ee8-annotations.mod +++ b/jetty-ee8/jetty-ee8-annotations/src/main/config/modules/ee8-annotations.mod @@ -10,9 +10,17 @@ ee8 plus ee8-plus +[ini] +ee8.asm.version?=@asm.version@ +ee8.jakarta.annotation.api.version?=@jakarta.annotation.api.version@ + [lib] lib/jetty-ee8-annotations-${jetty.version}.jar -lib/ee8-annotations/*.jar +lib/ee8-annotations/asm-${ee8.asm.version}.jar +lib/ee8-annotations/asm-analysis-${ee8.asm.version}.jar +lib/ee8-annotations/asm-commons-${ee8.asm.version}.jar +lib/ee8-annotations/asm-tree-${ee8.asm.version}.jar +lib/ee8-annotations/jakarta.annotation-api-${ee8.jakarta.annotation.api.version}.jar [jpms] add-modules:org.objectweb.asm diff --git a/jetty-ee8/jetty-ee8-apache-jsp/src/main/config/modules/ee8-apache-jsp.mod b/jetty-ee8/jetty-ee8-apache-jsp/src/main/config/modules/ee8-apache-jsp.mod index abc42f5a466f..1680801a899c 100644 --- a/jetty-ee8/jetty-ee8-apache-jsp/src/main/config/modules/ee8-apache-jsp.mod +++ b/jetty-ee8/jetty-ee8-apache-jsp/src/main/config/modules/ee8-apache-jsp.mod @@ -10,6 +10,12 @@ ee8 ee8-servlet ee8-annotations +[ini] +eclipse.jdt.ecj.version?=@eclipse.jdt.ecj.version@ +ee8.jsp.impl.version?=@jsp.impl.version@ + [lib] -lib/ee8-apache-jsp/*.jar +lib/ee8-apache-jsp/org.eclipse.jdt.ecj-${eclipse.jdt.ecj.version}.jar +lib/ee8-apache-jsp/org.mortbay.jasper.apache-el-${ee8.jsp.impl.version}.jar +lib/ee8-apache-jsp/org.mortbay.jasper.apache-jsp-${ee8.jsp.impl.version}.jar lib/jetty-ee8-apache-jsp-${jetty.version}.jar diff --git a/jetty-ee8/jetty-ee8-glassfish-jstl/src/main/config/modules/ee8-glassfish-jstl.mod b/jetty-ee8/jetty-ee8-glassfish-jstl/src/main/config/modules/ee8-glassfish-jstl.mod index dc45914255ba..7c2ac4e540cc 100644 --- a/jetty-ee8/jetty-ee8-glassfish-jstl/src/main/config/modules/ee8-glassfish-jstl.mod +++ b/jetty-ee8/jetty-ee8-glassfish-jstl/src/main/config/modules/ee8-glassfish-jstl.mod @@ -6,5 +6,10 @@ Enables the glassfish version of JSTL for all webapps. [environment] ee8 +[ini] +ee8.jakarta.servlet.jsp.jstl.api.version?=@jakarta.servlet.jsp.jstl.api.version@ +ee8.javax.servlet.jsp.jstl.impl.version?=@javax.servlet.jsp.jstl.impl.version@ + [lib] -lib/ee8-glassfish-jstl/*.jar +lib/ee8-glassfish-jstl/jakarta.servlet.jsp.jstl.jakarta.servlet.jsp.jstl-api-${ee8.jakarta.servlet.jsp.jstl.api.version}.jar +lib/ee8-glassfish-jstl/org.glassfish.web.javax.servlet.jsp.jstl-${ee8.javax.servlet.jsp.jstl.impl.version}.jar diff --git a/jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee9-jaspi-default-auth-config-factory.mod b/jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee8-jaspi-default-auth-config-factory.mod similarity index 100% rename from jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee9-jaspi-default-auth-config-factory.mod rename to jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee8-jaspi-default-auth-config-factory.mod diff --git a/jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee9-jaspi-demo.mod b/jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee8-jaspi-demo.mod similarity index 100% rename from jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee9-jaspi-demo.mod rename to jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee8-jaspi-demo.mod diff --git a/jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee9-jaspi.mod b/jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee8-jaspi.mod similarity index 72% rename from jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee9-jaspi.mod rename to jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee8-jaspi.mod index c2c6ac352368..085c635bb900 100644 --- a/jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee9-jaspi.mod +++ b/jetty-ee8/jetty-ee8-jaspi/src/main/config/modules/ee8-jaspi.mod @@ -10,9 +10,12 @@ security ee8-security ee8-auth-config-factory +[ini] +ee8.jakarta.authentication.api.version?=@jakarta.authentication.api.version@ + [lib] lib/jetty-ee8-jaspi-${jetty.version}.jar -lib/jaspi/*.jar +lib/ee8-jaspi/jakarta.authentication-api-${ee8.jakarta.authentication.api.version}.jar [xml] etc/jaspi/jetty-ee8-jaspi-authmoduleconfig.xml diff --git a/jetty-ee8/pom.xml b/jetty-ee8/pom.xml index 3141fb978563..ba3f4cfc7ab3 100644 --- a/jetty-ee8/pom.xml +++ b/jetty-ee8/pom.xml @@ -37,23 +37,21 @@ - - true - true ${maven.multiModuleProjectDirectory}/jetty-ee9/${ee9.module} 1.3.5 + 1.2.7 1.3.3 1.1.2 1.4.1.v201005082020 + 1.2.5 4.0.6 9.0.83.1 1.0.9 true 3.1.9.Final - @@ -78,7 +76,7 @@ jakarta.servlet.jsp.jstl jakarta.servlet.jsp.jstl-api - 1.2.7 + ${jakarta.servlet.jsp.jstl.api.version} jakarta.transaction @@ -238,7 +236,7 @@ org.glassfish.web javax.servlet.jsp.jstl - 1.2.5 + ${javax.servlet.jsp.jstl.impl.version} org.mortbay.jasper diff --git a/jetty-ee9/jetty-ee9-annotations/src/main/config/modules/ee9-annotations.mod b/jetty-ee9/jetty-ee9-annotations/src/main/config/modules/ee9-annotations.mod index 85bed0d2fc38..28e426698143 100644 --- a/jetty-ee9/jetty-ee9-annotations/src/main/config/modules/ee9-annotations.mod +++ b/jetty-ee9/jetty-ee9-annotations/src/main/config/modules/ee9-annotations.mod @@ -9,9 +9,17 @@ ee9 [depend] ee9-plus +[ini] +ee9.asm.version?=@asm.version@ +ee9.jakarta.annotation.api.version?=@jakarta.annotation.api.version@ + [lib] lib/jetty-ee9-annotations-${jetty.version}.jar -lib/ee9-annotations/*.jar +lib/ee9-annotations/asm-${ee9.asm.version}.jar +lib/ee9-annotations/asm-analysis-${ee9.asm.version}.jar +lib/ee9-annotations/asm-commons-${ee9.asm.version}.jar +lib/ee9-annotations/asm-tree-${ee9.asm.version}.jar +lib/ee9-annotations/jakarta.annotation-api-${ee9.jakarta.annotation.api.version}.jar [jpms] add-modules:org.objectweb.asm diff --git a/jetty-ee9/jetty-ee9-apache-jsp/src/main/config/modules/ee9-apache-jsp.mod b/jetty-ee9/jetty-ee9-apache-jsp/src/main/config/modules/ee9-apache-jsp.mod index 43383d0f7ce0..b942a5d79821 100644 --- a/jetty-ee9/jetty-ee9-apache-jsp/src/main/config/modules/ee9-apache-jsp.mod +++ b/jetty-ee9/jetty-ee9-apache-jsp/src/main/config/modules/ee9-apache-jsp.mod @@ -10,6 +10,12 @@ ee9 ee9-servlet ee9-annotations +[ini] +eclipse.jdt.ecj.version?=@eclipse.jdt.ecj.version@ +ee9.jsp.impl.version?=@jsp.impl.version@ + [lib] -lib/ee9-apache-jsp/*.jar +lib/ee9-apache-jsp/org.eclipse.jdt.ecj-${eclipse.jdt.ecj.version}.jar +lib/ee9-apache-jsp/org.mortbay.jasper.apache-el-${ee9.jsp.impl.version}.jar +lib/ee9-apache-jsp/org.mortbay.jasper.apache-jsp-${ee9.jsp.impl.version}.jar lib/jetty-ee9-apache-jsp-${jetty.version}.jar diff --git a/jetty-ee9/jetty-ee9-glassfish-jstl/src/main/config/modules/ee9-glassfish-jstl.mod b/jetty-ee9/jetty-ee9-glassfish-jstl/src/main/config/modules/ee9-glassfish-jstl.mod index 90cfc70abcd6..82bbb833ea0b 100644 --- a/jetty-ee9/jetty-ee9-glassfish-jstl/src/main/config/modules/ee9-glassfish-jstl.mod +++ b/jetty-ee9/jetty-ee9-glassfish-jstl/src/main/config/modules/ee9-glassfish-jstl.mod @@ -6,5 +6,10 @@ Enables the glassfish version of JSTL for all webapps. [environment] ee9 +[ini] +ee9.jakarta.servlet.jsp.jstl.api.version?=@jakarta.servlet.jsp.jstl.api.version@ +ee9.jakarta.servlet.jsp.jstl.impl.version?=@jakarta.servlet.jsp.jstl.impl.version@ + [lib] -lib/ee9-glassfish-jstl/*.jar +lib/ee9-glassfish-jstl/jakarta.servlet.jsp.jstl.jakarta.servlet.jsp.jstl-api-${ee9.jakarta.servlet.jsp.jstl.api.version}.jar +lib/ee9-glassfish-jstl/org.glassfish.web.jakarta.servlet.jsp.jstl-${ee9.jakarta.servlet.jsp.jstl.impl.version}.jar diff --git a/jetty-ee9/jetty-ee9-jaspi/src/main/config/modules/ee9-jaspi.mod b/jetty-ee9/jetty-ee9-jaspi/src/main/config/modules/ee9-jaspi.mod index 50f57661b01e..071f79a1a9ed 100644 --- a/jetty-ee9/jetty-ee9-jaspi/src/main/config/modules/ee9-jaspi.mod +++ b/jetty-ee9/jetty-ee9-jaspi/src/main/config/modules/ee9-jaspi.mod @@ -10,9 +10,12 @@ security ee9-security ee9-auth-config-factory +[ini] +ee9.jakarta.authentication.api.version?=@jakarta.authentication.api.version@ + [lib] lib/jetty-ee9-jaspi-${jetty.version}.jar -lib/jaspi/*.jar +lib/ee9-jaspi/jakarta.authentication-api-${ee9.jakarta.authentication.api.version}.jar [xml] etc/jaspi/jetty-ee9-jaspi-authmoduleconfig.xml diff --git a/jetty-home/src/main/resources/modules/conscrypt.mod b/jetty-home/src/main/resources/modules/conscrypt.mod index d82148980521..174fe11bbb78 100644 --- a/jetty-home/src/main/resources/modules/conscrypt.mod +++ b/jetty-home/src/main/resources/modules/conscrypt.mod @@ -19,7 +19,8 @@ basehome:modules/conscrypt/conscrypt.xml|etc/conscrypt.xml etc/conscrypt.xml [lib] -lib/conscrypt/**.jar +lib/conscrypt/conscrypt-uber-${conscrypt.version}.jar +lib/conscrypt/conscrypt-${conscrypt.version}-linux-x86_64.jar lib/jetty-alpn-conscrypt-server-${jetty.version}.jar [license] diff --git a/jetty-integrations/jetty-memcached/jetty-memcached-sessions/src/main/config/modules/sessions/session-data-cache/xmemcached.mod b/jetty-integrations/jetty-memcached/jetty-memcached-sessions/src/main/config/modules/sessions/session-data-cache/xmemcached.mod index 8f12f871e2c0..b503e6c46e96 100644 --- a/jetty-integrations/jetty-memcached/jetty-memcached-sessions/src/main/config/modules/sessions/session-data-cache/xmemcached.mod +++ b/jetty-integrations/jetty-memcached/jetty-memcached-sessions/src/main/config/modules/sessions/session-data-cache/xmemcached.mod @@ -18,7 +18,7 @@ xmemcached.version?=@xmemcached.version@ [lib] lib/jetty-memcached-sessions-${jetty.version}.jar -lib/xmemcached/*.jar +lib/xmemcached/xmemcached-${xmemcached.version}.jar [license] Xmemcached is an open source project hosted on Github and released under the Apache 2.0 license. diff --git a/jetty-integrations/jetty-nosql/src/main/config/modules/session-store-mongo.mod b/jetty-integrations/jetty-nosql/src/main/config/modules/session-store-mongo.mod index 1f74348c7e06..cc896ed62802 100644 --- a/jetty-integrations/jetty-nosql/src/main/config/modules/session-store-mongo.mod +++ b/jetty-integrations/jetty-nosql/src/main/config/modules/session-store-mongo.mod @@ -18,7 +18,7 @@ maven://org.mongodb/mongo-java-driver/${mongodb.version}|lib/nosql/mongo-java-dr [lib] lib/jetty-nosql-${jetty.version}.jar -lib/nosql/*.jar +lib/nosql/mongo-java-driver-${mongodb.version}.jar [license] The java driver for the MongoDB document-based database system is hosted on GitHub and released under the Apache 2.0 license. diff --git a/pom.xml b/pom.xml index 09cd637d0947..2f87b9c24cb6 100644 --- a/pom.xml +++ b/pom.xml @@ -176,7 +176,7 @@ 2.5.2 2.7.10 1.5.0 - 3.4.2 + 3.33.0 7.0.5 3.0.2 1.5.0 @@ -568,6 +568,11 @@ conscrypt-openjdk-uber ${conscrypt.version} + + org.eclipse.jdt + ecj + ${eclipse.jdt.ecj.version} + org.eclipse.jetty jetty-alpn-client From 8cc7abe4125324a929876ec15f88ed6b79a52818 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 18 Jan 2024 09:27:05 -0600 Subject: [PATCH 03/11] Adding testHostOnlyPort example from Issue #11287 --- .../eclipse/jetty/server/HttpConnectionTest.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java index 5e7b46a85c87..885bc213560c 100644 --- a/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java +++ b/jetty-core/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java @@ -760,10 +760,23 @@ public void testHeadChunked() throws Exception assertEquals(postHeaders, headHeaders); } + @Test + public void testHostOnlyPort() throws Exception + { + String response; + + response = _connector.getResponse(""" + GET /foo HTTP/1.1 + Host: :1234 + Connection: close + + """); + checkContains(response, 0, "HTTP/1.1 400"); + } + @Test public void testBadHostPort() throws Exception { - LOG.info("badMessage: Number formate exception expected ..."); String response; response = _connector.getResponse("GET http://localhost:EXPECTED_NUMBER_FORMAT_EXCEPTION/ HTTP/1.1\r\n" + From a2d86c7f674a831fcd6cf2c27961b95ab0bab417 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 19 Jan 2024 09:21:43 +1100 Subject: [PATCH 04/11] Fix #11290 empty field (#11291) Fixed cacheable empty field for #11290 --- .../org/eclipse/jetty/http/HttpParser.java | 2 +- .../eclipse/jetty/http/HttpParserTest.java | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 0a407f776469..5bacaf6d67e0 100644 --- a/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -2128,7 +2128,7 @@ else if (!_cache.put(field)) public boolean cacheable(HttpHeader header, String valueString) { - return isEnabled() && header != null && valueString.length() <= _size; + return isEnabled() && header != null && valueString != null && valueString.length() <= _size; } private void prepare() diff --git a/jetty-core/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java b/jetty-core/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java index 59823a34d89a..4d03188cae0f 100644 --- a/jetty-core/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java +++ b/jetty-core/jetty-http/src/test/java/org/eclipse/jetty/http/HttpParserTest.java @@ -557,12 +557,23 @@ public void testNoValue(String eoln) ByteBuffer buffer = BufferUtil.toBuffer( "GET / HTTP/1.0" + eoln + "Host: localhost" + eoln + - "Name0: " + eoln + + "Name0: " + eoln + "Name1:" + eoln + + "Authorization: " + eoln + + "Authorization:" + eoln + eoln); - HttpParser.RequestHandler handler = new Handler(); + HttpParser.RequestHandler handler = new Handler() + { + @Override + public void badMessage(HttpException failure) + { + ((Throwable)failure).printStackTrace(); + super.badMessage(failure); + } + }; HttpParser parser = new HttpParser(handler); + parser.setHeaderCacheSize(1024); parseAll(parser, buffer); assertTrue(_headerCompleted); @@ -576,7 +587,11 @@ public void testNoValue(String eoln) assertEquals("", _val[1]); assertEquals("Name1", _hdr[2]); assertEquals("", _val[2]); - assertEquals(2, _headers); + assertEquals("Authorization", _hdr[3]); + assertEquals("", _val[3]); + assertEquals("Authorization", _hdr[4]); + assertEquals("", _val[4]); + assertEquals(4, _headers); } @ParameterizedTest From 8163219ddae62d16b0bfbea237e6476155e37e4d Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 24 Jan 2024 06:46:29 +0100 Subject: [PATCH 05/11] Issue #11296 Fix javadoc on AbstractLoginModule (#11297) * Issue #11296 Fix javadoc on AbstractLoginModule --- .../eclipse/jetty/security/jaas/spi/AbstractLoginModule.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/jaas/spi/AbstractLoginModule.java b/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/jaas/spi/AbstractLoginModule.java index 318e835adc1e..48227ca90b7f 100644 --- a/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/jaas/spi/AbstractLoginModule.java +++ b/jetty-core/jetty-security/src/main/java/org/eclipse/jetty/security/jaas/spi/AbstractLoginModule.java @@ -34,8 +34,9 @@ /** * AbstractLoginModule * - * Abstract base class for all LoginModules. Subclasses should - * just need to implement getUserInfo method. + * Abstract base class for all {@link LoginModule LoginModules}. Subclasses should + * implement {@link #getUser(String)} method, and subclass {@link JAASUser} to implement + * {@link JAASUser#doFetchRoles()} method. */ public abstract class AbstractLoginModule implements LoginModule { From 676d76c1ff1ce68b270e586b80991e69f6a82410 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 24 Jan 2024 06:47:05 +0100 Subject: [PATCH 06/11] Issue #11280 update ee10 osgi embedded xml files (#11284) * Issue #11280 update ee10 osgi embedded xml files and add test --- .../jettyhome/etc/jetty-deploy.xml | 2 +- .../jettyhome/etc/jetty-http.xml | 4 +- .../jettyhome/etc/jetty.xml | 49 ++++------ .../etc/jetty-http-connector-listener.xml | 26 ++++++ .../src/test/config/etc/jetty-http.xml | 48 ---------- .../TestJettyOSGiBootWithBundleJettyHome.java | 92 +++++++++++++++++++ .../jetty/ee10/osgi/test/TestOSGiUtil.java | 21 +++++ 7 files changed, 161 insertions(+), 81 deletions(-) create mode 100644 jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-http-connector-listener.xml delete mode 100644 jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-http.xml create mode 100644 jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithBundleJettyHome.java diff --git a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty-deploy.xml b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty-deploy.xml index 88fc1a79e598..e630c9a766e1 100644 --- a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty-deploy.xml +++ b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty-deploy.xml @@ -1,5 +1,5 @@ - + diff --git a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty-http.xml b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty-http.xml index bbd9ab19ed56..cbf909a9518b 100644 --- a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty-http.xml +++ b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty-http.xml @@ -1,5 +1,5 @@ - + @@ -20,7 +20,7 @@ - + diff --git a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty.xml b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty.xml index 5d006b44c9af..ed1e4f3433e4 100644 --- a/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty.xml +++ b/jetty-ee10/jetty-ee10-osgi/jetty-ee10-osgi-boot/jettyhome/etc/jetty.xml @@ -1,5 +1,5 @@ - + @@ -24,45 +24,34 @@ - - - - - - - - - - - - + - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - - - + + java.naming.factory.initial diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-http-connector-listener.xml b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-http-connector-listener.xml new file mode 100644 index 000000000000..de169be5ef0f --- /dev/null +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-http-connector-listener.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + boot.http.port + + + + + + diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-http.xml b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-http.xml deleted file mode 100644 index 98f6d4e56d25..000000000000 --- a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/config/etc/jetty-http.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - foo.foo - - - - - - - - - - - diff --git a/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithBundleJettyHome.java b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithBundleJettyHome.java new file mode 100644 index 000000000000..d2bfb7afd8fb --- /dev/null +++ b/jetty-ee10/jetty-ee10-osgi/test-jetty-ee10-osgi/src/test/java/org/eclipse/jetty/ee10/osgi/test/TestJettyOSGiBootWithBundleJettyHome.java @@ -0,0 +1,92 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.ee10.osgi.test; + +import java.util.ArrayList; +import javax.inject.Inject; + +import org.eclipse.jetty.client.ContentResponse; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.http.HttpStatus; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.CoreOptions; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.osgi.framework.BundleContext; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; + +/** + * Pax-Exam to make sure the jetty-ee10-osgi-boot can be started along with the + * httpservice web-bundle. Then make sure we can deploy an OSGi service on the + * top of this. + */ +@RunWith(PaxExam.class) +public class TestJettyOSGiBootWithBundleJettyHome +{ + @Inject + BundleContext bundleContext = null; + + @Configuration + public static Option[] configure() + { + ArrayList """.replace("$P", String.valueOf(fcgiPort)), StandardOpenOption.CREATE); - int httpPort = distribution.freePort(); + int httpPort = Tester.freePort(); try (JettyHomeTester.Run run2 = distribution.start("jetty.http.port=" + httpPort, "etc/fcgi-connector.xml")) { assertTrue(run2.awaitConsoleLogsFor("Started oejs.Server@", START_TIMEOUT, TimeUnit.SECONDS)); @@ -1395,7 +1403,7 @@ public void testEEFastCGIProxying(String env) throws Exception Files.writeString(jettyLogging, loggingConfig, StandardOpenOption.TRUNCATE_EXISTING); // Add a FastCGI connector to simulate, for example, php-fpm. - int fcgiPort = distribution.freePort(); + int fcgiPort = Tester.freePort(); Path jettyBaseEtc = jettyBase.resolve("etc"); Files.createDirectories(jettyBaseEtc); Path fcgiConnectorXML = jettyBaseEtc.resolve("fcgi-connector.xml"); @@ -1476,7 +1484,7 @@ public void testEEFastCGIProxying(String env) throws Exception environment=$ENV """.replace("$ENV", env), StandardOpenOption.CREATE); - int httpPort = distribution.freePort(); + int httpPort = Tester.freePort(); try (JettyHomeTester.Run run2 = distribution.start("jetty.http.port=" + httpPort, "etc/fcgi-connector.xml")) { assertTrue(run2.awaitConsoleLogsFor("Started oejs.Server@", START_TIMEOUT, TimeUnit.SECONDS)); @@ -1507,7 +1515,7 @@ public void testVirtualThreadPoolPreview() throws Exception assertTrue(run1.awaitFor(10, TimeUnit.SECONDS)); assertEquals(0, run1.getExitValue()); - int httpPort = distribution.freePort(); + int httpPort = Tester.freePort(); try (JettyHomeTester.Run run2 = distribution.start(List.of("jetty.http.selectors=1", "jetty.http.port=" + httpPort))) { assertTrue(run2.awaitConsoleLogsFor("Started oejs.Server@", 10, TimeUnit.SECONDS)); @@ -1537,7 +1545,7 @@ public void testVirtualThreadPool() throws Exception assertTrue(run1.awaitFor(START_TIMEOUT, TimeUnit.SECONDS)); assertEquals(0, run1.getExitValue()); - int httpPort = distribution.freePort(); + int httpPort = Tester.freePort(); try (JettyHomeTester.Run run2 = distribution.start(List.of("jetty.http.selectors=1", "jetty.http.port=" + httpPort))) { assertTrue(run2.awaitConsoleLogsFor("Started oejs.Server@", START_TIMEOUT, TimeUnit.SECONDS)); @@ -1580,7 +1588,7 @@ public void testRangeRequestMultiPartRangeResponse(String env) throws Exception """; Files.writeString(jettyLogging, loggingConfig, StandardOpenOption.TRUNCATE_EXISTING); - int httpPort = distribution.freePort(); + int httpPort = Tester.freePort(); String contextPath = "/" + toEnvironment("demo-simple", env); try (JettyHomeTester.Run run2 = distribution.start(List.of("jetty.http.selectors=1", "jetty.http.port=" + httpPort))) { @@ -1618,7 +1626,7 @@ public void testXmlDeployWarNotInWebapps(String env) throws Exception .jettyBase(jettyBase) .build(); - int httpPort = distribution.freePort(); + int httpPort = Tester.freePort(); String[] argsConfig = { "--add-modules=http," + toEnvironment("deploy", env) + "," + toEnvironment("webapp", env) @@ -1635,11 +1643,11 @@ public void testXmlDeployWarNotInWebapps(String env) throws Exception }; // Put war into ${jetty.base}/wars/ directory - File srcWar = distribution.resolveArtifact("org.eclipse.jetty." + env + ".demos:jetty-" + env + "-demo-simple-webapp:war:" + jettyVersion); + Path srcWar = distribution.resolveArtifact("org.eclipse.jetty." + env + ".demos:jetty-" + env + "-demo-simple-webapp:war:" + jettyVersion); Path warsDir = jettyBase.resolve("wars"); FS.ensureDirExists(warsDir); Path destWar = warsDir.resolve("demo.war"); - Files.copy(srcWar.toPath(), destWar); + Files.copy(srcWar, destWar); // Create XML for deployable String xml = """ @@ -1702,7 +1710,7 @@ public void testInetAccessHandler() throws Exception assertTrue(run1.awaitFor(10, TimeUnit.SECONDS)); assertEquals(0, run1.getExitValue()); - int httpPort = distribution.freePort(); + int httpPort = Tester.freePort(); List args = List.of( "jetty.inetaccess.exclude=|/excludedPath/*", "jetty.http.port=" + httpPort); @@ -1739,7 +1747,7 @@ public void testCrossOriginModule() throws Exception run1.awaitFor(START_TIMEOUT, TimeUnit.SECONDS); assertThat(run1.getExitValue(), is(0)); - int httpPort1 = distribution.freePort(); + int httpPort1 = Tester.freePort(); try (JettyHomeTester.Run run2 = distribution.start(List.of("jetty.http.port=" + httpPort1))) { assertThat(run2.awaitConsoleLogsFor("Started oejs.Server", START_TIMEOUT, TimeUnit.SECONDS), is(true)); @@ -1756,7 +1764,7 @@ public void testCrossOriginModule() throws Exception assertTrue(response.getHeaders().contains(HttpHeader.ACCESS_CONTROL_ALLOW_ORIGIN)); } - int httpPort2 = distribution.freePort(); + int httpPort2 = Tester.freePort(); List args = List.of( "jetty.http.port=" + httpPort2, // Allow a different origin. diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DynamicListenerTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DynamicListenerTests.java index 0c0748c4e636..1d94802a5962 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DynamicListenerTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DynamicListenerTests.java @@ -18,7 +18,8 @@ import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; -import org.eclipse.jetty.tests.hometester.JettyHomeTester; +import org.eclipse.jetty.tests.testers.JettyHomeTester; +import org.eclipse.jetty.tests.testers.Tester; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -53,7 +54,7 @@ public void testSimpleWebAppWithJSP(String env) throws Exception assertEquals(0, run1.getExitValue()); } - int port = distribution.freePort(); + int port = Tester.freePort(); try (JettyHomeTester.Run run2 = distribution.start("jetty.http.port=" + port)) { assertTrue(run2.awaitConsoleLogsFor("Started oejs.Server@", START_TIMEOUT, TimeUnit.SECONDS)); diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/GzipModuleTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/GzipModuleTests.java index 352b63f06d9f..7a100b1280b5 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/GzipModuleTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/GzipModuleTests.java @@ -13,14 +13,14 @@ package org.eclipse.jetty.tests.distribution; -import java.io.File; import java.nio.file.Path; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; -import org.eclipse.jetty.tests.hometester.JettyHomeTester; +import org.eclipse.jetty.tests.testers.JettyHomeTester; +import org.eclipse.jetty.tests.testers.Tester; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -46,7 +46,7 @@ public void testGzipDefault(String env) throws Exception .jettyBase(jettyBase) .build(); - int httpPort = distribution.freePort(); + int httpPort = Tester.freePort(); String[] argsConfig = { "--add-modules=http,gzip," + toEnvironment("deploy", env) + "," + toEnvironment("webapp", env) @@ -61,8 +61,8 @@ public void testGzipDefault(String env) throws Exception "jetty.http.port=" + httpPort }; - File war = distribution.resolveArtifact("org.eclipse.jetty." + env + ".demos:jetty-" + env + "-demo-simple-webapp:war:" + jettyVersion); - distribution.installWarFile(war, "demo"); + Path war = distribution.resolveArtifact("org.eclipse.jetty." + env + ".demos:jetty-" + env + "-demo-simple-webapp:war:" + jettyVersion); + distribution.installWar(war, "demo"); try (JettyHomeTester.Run runStart = distribution.start(argsStart)) { @@ -88,7 +88,7 @@ public void testGzipDefaultExcludedMimeType(String env) throws Exception .jettyBase(jettyBase) .build(); - int httpPort = distribution.freePort(); + int httpPort = Tester.freePort(); String[] argsConfig = { "--add-modules=gzip,http," + toEnvironment("deploy", env) + "," + toEnvironment("webapp", env) @@ -103,8 +103,8 @@ public void testGzipDefaultExcludedMimeType(String env) throws Exception "jetty.http.port=" + httpPort }; - File war = distribution.resolveArtifact("org.eclipse.jetty." + env + ".demos:jetty-" + env + "-demo-simple-webapp:war:" + jettyVersion); - distribution.installWarFile(war, "demo"); + Path war = distribution.resolveArtifact("org.eclipse.jetty." + env + ".demos:jetty-" + env + "-demo-simple-webapp:war:" + jettyVersion); + distribution.installWar(war, "demo"); try (JettyHomeTester.Run runStart = distribution.start(argsStart)) { @@ -131,7 +131,7 @@ public void testGzipAddWebappSpecificExcludeMimeType(String env) throws Exceptio .jettyBase(jettyBase) .build(); - int httpPort = distribution.freePort(); + int httpPort = Tester.freePort(); String[] argsConfig = { "--add-modules=gzip,http," + toEnvironment("deploy", env) + "," + toEnvironment("webapp", env) @@ -147,8 +147,8 @@ public void testGzipAddWebappSpecificExcludeMimeType(String env) throws Exceptio "jetty.gzip.excludedMimeTypeList=image/vnd.microsoft.icon" }; - File war = distribution.resolveArtifact("org.eclipse.jetty." + env + " .demos:jetty-" + env + "-demo-simple-webapp:war:" + jettyVersion); - distribution.installWarFile(war, "demo"); + Path war = distribution.resolveArtifact("org.eclipse.jetty." + env + " .demos:jetty-" + env + "-demo-simple-webapp:war:" + jettyVersion); + distribution.installWar(war, "demo"); try (JettyHomeTester.Run runStart = distribution.start(argsStart)) { diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java index e51359ffad40..34a50de73128 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/LoggingOptionsTests.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.tests.distribution; -import java.io.File; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; @@ -24,7 +23,8 @@ import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; -import org.eclipse.jetty.tests.hometester.JettyHomeTester; +import org.eclipse.jetty.tests.testers.JettyHomeTester; +import org.eclipse.jetty.tests.testers.Tester; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; @@ -169,10 +169,10 @@ public void testLoggingConfiguration(String env, String loggingModules, List(Collections.singletonList("jetty.http.port=" + port)); args.addAll(getSecondStartExtraArgs()); argsStart = args.toArray(new String[0]); diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java index 4fe9d1150f0f..2a3afa57778b 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/session/HazelcastSessionDistributionTests.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.tests.distribution.session; -import java.io.File; import java.io.OutputStream; import java.net.InetAddress; import java.nio.charset.StandardCharsets; @@ -29,7 +28,8 @@ import org.eclipse.jetty.client.ContentResponse; import org.eclipse.jetty.http.HttpStatus; -import org.eclipse.jetty.tests.hometester.JettyHomeTester; +import org.eclipse.jetty.tests.testers.JettyHomeTester; +import org.eclipse.jetty.tests.testers.Tester; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.slf4j.Logger; @@ -161,10 +161,10 @@ public void testHazelcastRemoteAndPartOfCluster() throws Exception assertTrue(run1.awaitFor(START_TIMEOUT, TimeUnit.SECONDS)); assertEquals(0, run1.getExitValue()); - File war = distribution.resolveArtifact("org.eclipse.jetty.tests:test-simple-session-webapp:war:" + jettyVersion); - distribution.installWarFile(war, "test"); + Path war = distribution.resolveArtifact("org.eclipse.jetty.tests:test-simple-session-webapp:war:" + jettyVersion); + distribution.installWar(war, "test"); - int port = distribution.freePort(); + int port = Tester.freePort(); List argsStart = Arrays.asList( "jetty.http.port=" + port, "jetty.session.hazelcast.onlyClient=false", diff --git a/tests/test-distribution/test-ee10-distribution/pom.xml b/tests/test-distribution/test-ee10-distribution/pom.xml index 5be75047bdd0..3c664deea446 100644 --- a/tests/test-distribution/test-ee10-distribution/pom.xml +++ b/tests/test-distribution/test-ee10-distribution/pom.xml @@ -13,41 +13,9 @@ ${project.groupId}.ee10.distribution - - true - - - - - - - - - - - - - - - org.eclipse.jetty.tests - test-distribution-common - - - org.eclipse.jetty.toolchain - jetty-test-helper - - - org.junit.jupiter - junit-jupiter - - - - org.slf4j - slf4j-api - org.eclipse.jetty jetty-client @@ -56,14 +24,11 @@ org.eclipse.jetty jetty-openid - ${project.version} test - org.eclipse.jetty jetty-slf4j-impl - ${project.version} test @@ -79,6 +44,11 @@ war test + + org.eclipse.jetty.tests + jetty-testers + test + org.eclipse.jetty.tests test-distribution-common diff --git a/tests/test-distribution/test-ee10-distribution/src/test/java/org/eclipse/jetty/ee10/tests/distribution/OpenIdTests.java b/tests/test-distribution/test-ee10-distribution/src/test/java/org/eclipse/jetty/ee10/tests/distribution/OpenIdTests.java index 8746d2796394..78d8f31fa518 100644 --- a/tests/test-distribution/test-ee10-distribution/src/test/java/org/eclipse/jetty/ee10/tests/distribution/OpenIdTests.java +++ b/tests/test-distribution/test-ee10-distribution/src/test/java/org/eclipse/jetty/ee10/tests/distribution/OpenIdTests.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.ee10.tests.distribution; -import java.io.File; import java.nio.file.Path; import java.util.concurrent.TimeUnit; @@ -21,7 +20,8 @@ import org.eclipse.jetty.ee10.tests.distribution.openid.OpenIdProvider; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.distribution.AbstractJettyHomeTest; -import org.eclipse.jetty.tests.hometester.JettyHomeTester; +import org.eclipse.jetty.tests.testers.JettyHomeTester; +import org.eclipse.jetty.tests.testers.Tester; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -56,10 +56,10 @@ public void testOpenID() throws Exception assertTrue(run1.awaitFor(START_TIMEOUT, TimeUnit.SECONDS)); assertEquals(0, run1.getExitValue()); - File webApp = distribution.resolveArtifact("org.eclipse.jetty.ee10:jetty-ee10-test-openid-webapp:war:" + jettyVersion); - distribution.installWarFile(webApp, "test"); + Path webApp = distribution.resolveArtifact("org.eclipse.jetty.ee10:jetty-ee10-test-openid-webapp:war:" + jettyVersion); + distribution.installWar(webApp, "test"); - int port = distribution.freePort(); + int port = Tester.freePort(); openIdProvider.addRedirectUri("http://localhost:" + port + "/test/j_security_check"); openIdProvider.start(); String[] args2 = { diff --git a/tests/test-distribution/test-ee9-distribution/pom.xml b/tests/test-distribution/test-ee9-distribution/pom.xml index d41933d8c204..2b93c7353124 100644 --- a/tests/test-distribution/test-ee9-distribution/pom.xml +++ b/tests/test-distribution/test-ee9-distribution/pom.xml @@ -13,40 +13,9 @@ ${project.groupId}.ee9.distribution - - - - - - - - - - - - - - - - - org.eclipse.jetty.tests - test-distribution-common - - - org.eclipse.jetty.toolchain - jetty-test-helper - - - org.junit.jupiter - junit-jupiter - - - org.slf4j - slf4j-api - org.eclipse.jetty jetty-client @@ -55,7 +24,6 @@ org.eclipse.jetty jetty-slf4j-impl - ${project.version} test @@ -77,6 +45,11 @@ war test + + org.eclipse.jetty.tests + jetty-testers + test + org.eclipse.jetty.tests test-distribution-common diff --git a/tests/test-distribution/test-ee9-distribution/src/test/java/org/eclipse/jetty/ee9/tests/distribution/OpenIdTests.java b/tests/test-distribution/test-ee9-distribution/src/test/java/org/eclipse/jetty/ee9/tests/distribution/OpenIdTests.java index ff8b0fb236c6..410dd07f49c1 100644 --- a/tests/test-distribution/test-ee9-distribution/src/test/java/org/eclipse/jetty/ee9/tests/distribution/OpenIdTests.java +++ b/tests/test-distribution/test-ee9-distribution/src/test/java/org/eclipse/jetty/ee9/tests/distribution/OpenIdTests.java @@ -13,7 +13,6 @@ package org.eclipse.jetty.ee9.tests.distribution; -import java.io.File; import java.nio.file.Path; import java.util.concurrent.TimeUnit; @@ -21,7 +20,8 @@ import org.eclipse.jetty.ee9.tests.distribution.openid.OpenIdProvider; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.tests.distribution.AbstractJettyHomeTest; -import org.eclipse.jetty.tests.hometester.JettyHomeTester; +import org.eclipse.jetty.tests.testers.JettyHomeTester; +import org.eclipse.jetty.tests.testers.Tester; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -59,10 +59,10 @@ public void testOpenID() throws Exception assertTrue(run1.awaitFor(START_TIMEOUT, TimeUnit.SECONDS)); assertEquals(0, run1.getExitValue()); - File webApp = distribution.resolveArtifact("org.eclipse.jetty.ee9:jetty-ee9-test-openid-webapp:war:" + jettyVersion); - distribution.installWarFile(webApp, "test"); + Path webApp = distribution.resolveArtifact("org.eclipse.jetty.ee9:jetty-ee9-test-openid-webapp:war:" + jettyVersion); + distribution.installWar(webApp, "test"); - int port = distribution.freePort(); + int port = Tester.freePort(); openIdProvider.addRedirectUri("http://localhost:" + port + "/test/j_security_check"); openIdProvider.start(); String[] args2 = { From 7fbd51a95233d492c2bbe85d77265cd2a9983799 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Wed, 24 Jan 2024 21:53:30 +0100 Subject: [PATCH 10/11] Restore DefaultServlet.doPost to the previous major releases' behavior (#11300) #11299 restore DefaultServlet.doPost to the previous major releases' behavior Signed-off-by: Ludovic Orban --- .../java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java | 4 ++-- .../org/eclipse/jetty/ee9/servlet/DefaultServletTest.java | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java index 39bef9d81550..d832167283c6 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java +++ b/jetty-ee9/jetty-ee9-servlet/src/main/java/org/eclipse/jetty/ee9/servlet/DefaultServlet.java @@ -514,7 +514,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); + doGet(request, response); } @Override @@ -535,7 +535,7 @@ protected void doTrace(HttpServletRequest request, HttpServletResponse response) protected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.setHeader("Allow", "GET, HEAD, OPTIONS"); + response.setHeader("Allow", "GET,HEAD,POST,OPTIONS"); } @Override diff --git a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/DefaultServletTest.java b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/DefaultServletTest.java index d9fed8fc4fc6..d49324a6eb6a 100644 --- a/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/DefaultServletTest.java +++ b/jetty-ee9/jetty-ee9-servlet/src/test/java/org/eclipse/jetty/ee9/servlet/DefaultServletTest.java @@ -2229,7 +2229,7 @@ public void testPost() throws Exception abcde """); response = HttpTester.parseResponse(rawResponse); - assertThat(response.toString(), response.getStatus(), is(HttpStatus.METHOD_NOT_ALLOWED_405)); + assertThat(response.toString(), response.getStatus(), is(HttpStatus.NOT_FOUND_404)); Files.writeString(file, "How now brown cow", UTF_8); @@ -2242,7 +2242,8 @@ public void testPost() throws Exception abcde """); response = HttpTester.parseResponse(rawResponse); - assertThat(response.toString(), response.getStatus(), is(HttpStatus.METHOD_NOT_ALLOWED_405)); + assertThat(response.toString(), response.getStatus(), is(HttpStatus.OK_200)); + assertThat(response.getContent(), is("How now brown cow")); } @Test @@ -2279,7 +2280,7 @@ public void testOptions() throws Exception """); response = HttpTester.parseResponse(rawResponse); assertThat(response.toString(), response.getStatus(), is(HttpStatus.OK_200)); - assertThat(response.get(HttpHeader.ALLOW), is("GET, HEAD, OPTIONS")); + assertThat(response.get(HttpHeader.ALLOW), is("GET,HEAD,POST,OPTIONS")); } @Test From b571c6a2d34651364bc3b3ab70274548d2b93cbe Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 24 Jan 2024 18:23:19 -0600 Subject: [PATCH 11/11] Issue #11292 - Missing Date Response Header. (#11293) * Add Unit Tests for Date Response header in ee10 and Distribution --- .../jetty/ee10/servlet/RequestTest.java | 99 +++++++++++++++++++ .../tests/distribution/DistributionTests.java | 65 ++++++++++++ 2 files changed, 164 insertions(+) diff --git a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/RequestTest.java b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/RequestTest.java index 71ab7849f199..df689870a1c1 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/RequestTest.java +++ b/jetty-ee10/jetty-ee10-servlet/src/test/java/org/eclipse/jetty/ee10/servlet/RequestTest.java @@ -14,7 +14,14 @@ package org.eclipse.jetty.ee10.servlet; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.io.UnsupportedEncodingException; +import java.net.InetAddress; +import java.net.Socket; +import java.net.URI; +import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; @@ -24,26 +31,37 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Consumer; +import java.util.stream.Stream; import jakarta.servlet.MultipartConfigElement; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http.HttpTester; import org.eclipse.jetty.http.UriCompliance; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.server.FormFields; import org.eclipse.jetty.server.ForwardedRequestCustomizer; +import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.LocalConnector; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.component.LifeCycle; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; @@ -56,13 +74,21 @@ import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.sameInstance; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class RequestTest { + private static final Logger LOG = LoggerFactory.getLogger(RequestTest.class); private Server _server; private LocalConnector _connector; private void startServer(HttpServlet servlet) throws Exception + { + startServer(null, servlet); + } + + private void startServer(Consumer configureServer, HttpServlet servlet) throws Exception { _server = new Server(); @@ -80,6 +106,9 @@ private void startServer(HttpServlet servlet) throws Exception servletContextHandler.addServlet(servlet, "/*").getRegistration().setMultipartConfig(new MultipartConfigElement("here")); _server.setHandler(servletContextHandler); + + if (configureServer != null) + configureServer.accept(_server); _server.start(); } @@ -473,4 +502,74 @@ protected void service(HttpServletRequest request, HttpServletResponse resp) thr HttpTester.Response response = HttpTester.parseResponse(rawResponse); assertThat(response.getStatus(), is(HttpStatus.OK_200)); } + + public static Stream requestHostHeaders() + { + List hostHeader = new ArrayList<>(); + hostHeader.add("localhost"); + hostHeader.add("127.0.0.1"); + try + { + InetAddress localhost = InetAddress.getLocalHost(); + hostHeader.add(localhost.getHostName()); + hostHeader.add(localhost.getHostAddress()); + } + catch (UnknownHostException e) + { + LOG.debug("Unable to obtain InetAddress.LocalHost", e); + } + return hostHeader.stream().map(Arguments::of); + } + + @ParameterizedTest + @MethodSource("requestHostHeaders") + public void testDateResponseHeader(String hostHeader) throws Exception + { + startServer( + (server) -> + { + HttpConfiguration httpConfiguration = new HttpConfiguration(); + // httpConfiguration.setSendDateHeader(true); + ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration)); + connector.setPort(0); + server.addConnector(connector); + }, + new HttpServlet() + { + @Override + protected void service(HttpServletRequest request, HttpServletResponse resp) throws IOException + { + resp.setCharacterEncoding("utf-8"); + resp.setContentType("text/plain"); + resp.getWriter().println("Foo"); + } + }); + + URI serverURI = _server.getURI(); + + String rawRequest = """ + GET /foo HTTP/1.1 + Host: %s + Connection: close + + """.formatted(hostHeader); + + try (Socket client = new Socket(hostHeader, serverURI.getPort())) + { + OutputStream out = client.getOutputStream(); + out.write(rawRequest.getBytes(StandardCharsets.UTF_8)); + out.flush(); + + InputStream in = client.getInputStream(); + HttpTester.Response response = HttpTester.parseResponse(in); + assertThat(response.getStatus(), is(HttpStatus.OK_200)); + String date = response.get(HttpHeader.DATE); + assertNotNull(date); + // asserting an exact value is tricky as the Date header is dynamic, + // so we just assert that it has some content and isn't blank + assertTrue(StringUtil.isNotBlank(date)); + assertThat(date, containsString(",")); + assertThat(date, containsString(":")); + } + } } diff --git a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java index ff6b97c07762..1482b9899f09 100644 --- a/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java +++ b/tests/test-distribution/test-distribution-common/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java @@ -16,7 +16,9 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.net.InetAddress; import java.net.URI; +import java.net.UnknownHostException; import java.net.http.WebSocket; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -67,6 +69,8 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.ValueSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.awaitility.Awaitility.await; import static org.hamcrest.MatcherAssert.assertThat; @@ -75,6 +79,7 @@ import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.startsWith; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -83,6 +88,8 @@ public class DistributionTests extends AbstractJettyHomeTest { + private static final Logger LOG = LoggerFactory.getLogger(DistributionTests.class); + @Test public void testStartStop() throws Exception { @@ -1734,6 +1741,64 @@ public void testInetAccessHandler() throws Exception } } + @Test + public void testSendDateHeader() throws Exception + { + Path jettyBase = newTestJettyBaseDirectory(); + String jettyVersion = System.getProperty("jettyVersion"); + JettyHomeTester distribution = JettyHomeTester.Builder.newInstance() + .jettyVersion(jettyVersion) + .jettyBase(jettyBase) + .build(); + + try (JettyHomeTester.Run run1 = distribution.start("--add-modules=http")) + { + assertTrue(run1.awaitFor(10, TimeUnit.SECONDS)); + assertEquals(0, run1.getExitValue()); + + int httpPort = distribution.freePort(); + List args = List.of( + "jetty.http.port=" + httpPort, + "jetty.httpConfig.sendDateHeader=true" + ); + try (JettyHomeTester.Run run2 = distribution.start(args)) + { + assertTrue(run2.awaitConsoleLogsFor("Started oejs.Server@", START_TIMEOUT, TimeUnit.SECONDS)); + startHttpClient(); + + List hostHeaders = new ArrayList<>(); + hostHeaders.add("localhost"); + hostHeaders.add("127.0.0.1"); + try + { + InetAddress localhost = InetAddress.getLocalHost(); + hostHeaders.add(localhost.getHostName()); + hostHeaders.add(localhost.getHostAddress()); + } + catch (UnknownHostException e) + { + LOG.debug("Unable to obtain InetAddress.LocalHost", e); + } + + for (String hostHeader: hostHeaders) + { + ContentResponse response = client.newRequest("http://" + hostHeader + ":" + httpPort + "/") + .timeout(15, TimeUnit.SECONDS) + .send(); + assertEquals(HttpStatus.NOT_FOUND_404, response.getStatus()); + String date = response.getHeaders().get(HttpHeader.DATE); + String msg = "Request to [%s]: Response Header [Date]".formatted(hostHeader); + assertThat(msg, date, notNullValue()); + // asserting an exact value is tricky as the Date header is dynamic, + // so we just assert that it has some content and isn't blank + assertTrue(StringUtil.isNotBlank(date), msg); + assertThat(msg, date, containsString(",")); + assertThat(msg, date, containsString(":")); + } + } + } + } + @Test public void testCrossOriginModule() throws Exception {