test: #900 - Add TCK tests to verify filter processing after upgrade#974
test: #900 - Add TCK tests to verify filter processing after upgrade#974omatheusmesmo wants to merge 7 commits intojakartaee:mainfrom
Conversation
Creates TestUpgradeFilter to set response headers proving filter invocation. This ensures that Filters are processed after HttpServletRequest.upgrade() is called. Fixes jakartaee#900 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
…headers Modifies TCKHttpUpgradeHandler to capture and verify filter headers. Ensures that the handler can validate if the filter was invoked before initialization. Fixes jakartaee#900 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Updates TestServlet to pass filter header values to the handler. This allows the handler to verify that the filter execution occurred as expected during the upgrade process. Fixes jakartaee#900 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
|
I feel I must be missing something obvious. Where is the validation that the header is set at the correct point? How/why does the test fail if it isn't? |
…atus Updates TestUpgradeFilter to set a request attribute indicating it has been invoked. This allows servlets to verify filter execution before proceeding with protocol upgrades. Fixes jakartaee#900 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Updates TestServlet to check for the filter invocation attribute before executing the upgrade. Also adds support for verifying filters that only process the request before the upgrade call. Fixes jakartaee#900 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Enhances HttpUpgradeHandlerTests to include TestUpgradeFilter in the deployment and verify that the filter was correctly processed during the upgrade lifecycle. Fixes jakartaee#900 Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
7eb1e08 to
73e33c2
Compare
@markt-asf Great catch! You're absolutely right that the validation needed to be more explicit. I've updated the implementation to make the Filter timing validation much tighter. Here's how it now ensures the correct execution order: The Validation Chain
Why It Fails if Timing is Wrong
Local Verification (Curl)Running it manually shows the exact sequence: $ curl -v -X POST http://localhost:8080/test-upgrade/TestServlet \
-H "Upgrade: YES" -H "Connection: Upgrade" --data "Hello"
< HTTP/1.1 101
< X-Filter-Before-Upgrade: invoked ✓ Proves Filter ran BEFORE Servlet
< Upgrade: YES
< X-Filter-After-Upgrade: processed ✓ Proves Filter wrapped the call
...
===============TCKHttpUpgradeHandler.init
===============Filter-Header: invoked ✓ Validation passed!The combination of the Servlet guard and the Handler's output for the TCK assertion ensures we are validating the "correct point" as requested. Does this address your concerns? |
Problem
The Jakarta Servlet specification requires that Filters are processed after
HttpServletRequest.upgrade()is called but before theHttpUpgradeHandler.init()method is invoked. Currently, there are insufficient TCK tests to verify this specific order of execution, leading to potential non-compliance in implementations.Solution
This PR adds new TCK tests and modifies existing test artifacts to validate the correct execution order of filters during the upgrade process.
TestUpgradeFilterwhich sets response headers (X-Filter-Before-Upgrade,X-Filter-After-Upgrade) to prove filter invocation.TCKHttpUpgradeHandlerto capture and verify these filter headers during initialization.TestServletto pass the captured filter header values to the handler for verification.HttpUpgradeHandler.init()is called only after the filter chain has processed the request.Related Issue
Fixes #900
Verification Results