Skip to content

test(csp-strict): add push and lazy chunk scenarios - #26976

Open
heruan wants to merge 3 commits into
mainfrom
test/csp-strict-push
Open

heruan wants to merge 3 commits into
mainfrom
test/csp-strict-push

Conversation

@heruan

@heruan heruan commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #26975, Part of #26154, Part of #26155, Part of vaadin/platform#9488

test · flow-tests · the strict csp test module; no application

Push was on the list of things still to verify with csp=strict, and loading a lazy chunk had no test in the strict module. The module now covers push over WebSocket, push over long polling, and navigation to a view whose frontend module is in a lazy chunk. All pass on main with no policy violation, so no fix is needed in Flow.

Risks:

  • ❓ @Push is on the application class, so every scenario of the module now runs with a push connection open. This is how a real application uses push, but it changes the setup of the existing tests.

  • ❓ The long polling view cannot just set the transport when it is attached: the browser still opened a WebSocket. The view closes push on attach and opens it again over long polling on the click. I did not look into why; it is not related to the policy.

  • ✅ A test module only: no API, behavior, security, serialization, threading, performance or migration impact

  • Added push.PushView and PushIT: a click starts a background task that updates the page 500 ms later through UI.access, after the response to the click is sent

  • Added push.LongPollingPushView and LongPollingPushIT, the same over long polling

  • Added PushTransportRecorder, a servlet filter that records the transport of every push request of a session; the views show it with the update and the tests assert it, so a silent fallback from WebSocket to long polling fails PushIT

  • Application implements AppShellConfigurator with @Push

  • Added spring-boot-starter-websocket, without it push falls back to long polling in an embedded server

  • Added chunk.LazyChunkView, chunk.LazyChunkStartView and LazyChunkIT: the test checks that the module of the target view is not loaded with the page, then navigates to it

  • Added the scenarios to the module README

@heruan

heruan commented Nov 11, 2026 •

Copy link
Copy Markdown
Member Author

Type of change

Test only.

How to test

mvn install -pl :flow-server,:flow-client,:flow-html-components,:flow-build-tools,:flow-tests,:flow-test-util-junit6 -DskipTests
mvn verify -f flow-tests/test-csp-strict/pom.xml

Expected: Tests run: 13, Failures: 0, Errors: 0, Skipped: 0.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

 1 694 files  +3   1 784 suites  +3   2h 16m 22s ⏱️ - 2m 43s
13 482 tests +3  13 410 ✅ +3  72 💤 ±0  0 ❌ ±0 
14 116 runs  +3  14 044 ✅ +3  72 💤 ±0  0 ❌ ±0 

Results for commit 81dfcdb. ± Comparison against base commit 468d0aa.

♻️ This comment has been updated with latest results.

Push is enabled for the whole test application with @Push, over WebSocket. The view updates the page from a background thread after the response to a click, so the update can only arrive over the push connection.
@heruan
heruan force-pushed the test/csp-strict-push branch from 7a8c966 to 50ff07f Compare November 11, 2026 15:16
@heruan
heruan marked this pull request as ready for review November 11, 2026 15:16

@vaadin-review-bot vaadin-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the changes — left 1 comment.

Finding
🧪 The test never checks which transport delivered the update, so it can't show that WebSocket works under the strict policy.


$(NativeButtonElement.class).id("start").click();

waitUntil(ExpectedConditions.textToBe(By.id("pushed"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧪 The test never checks which transport delivered the update, so it can't show that WebSocket works under the strict policy.

If the WebSocket upgrade fails without a policy violation, Atmosphere quietly falls back to long polling and the update still arrives. One way this happens is when the websocket starter is dropped or not picked up. The test passes either way, even though the README row and the pom comment both claim WebSocket coverage.

Assert the transport the client actually used, as PushConfigurationWebSocketIT does in test-root-context. That way, losing WebSocket fails the test.

PushIT.java:42 · tests

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The server now records the transport of every push request, the view shows it with the pushed update, and PushIT asserts it is only websocket. A fallback to long polling fails the test. PushConfigurationWebSocketIT reads the configured transport, not the one used, so I did not copy it.

@vaadin-bot

Copy link
Copy Markdown
Collaborator

@heruan this "chore:"/"test:"/"refactor:" PR has been approved automatically, but auto merge has not been enabled for it. You can enable the auto merge by yourself, or ask another member for another review. [Message is sent from bot]

The server records the transport of every push request, and the push views show it with the pushed update. The WebSocket test fails when the browser falls back to long polling, and a second view pushes over long polling.
@heruan heruan changed the title test(csp-strict): add push scenario test(csp-strict): add push and lazy chunk scenarios Nov 11, 2026
@vaadin-bot

Copy link
Copy Markdown
Collaborator

@heruan this "chore:"/"test:"/"refactor:" PR has been approved automatically, but auto merge has not been enabled for it. You can enable the auto merge by yourself, or ask another member for another review. [Message is sent from bot]

@mcollovati mcollovati added the csp label Nov 11, 2026
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants