Skip to content

Make the multiple-CryptoMapper tests in CryptoMapperTest deterministic - #1928

Open
dashorst wants to merge 1 commit into
wicket-10.xfrom
flaky-cryptomapper-test-10.x
Open

dashorst wants to merge 1 commit into
wicket-10.xfrom
flaky-cryptomapper-test-10.x

Conversation

@dashorst

Copy link
Copy Markdown
Contributor

Fixes the intermittent CryptoMapperTest failures analysed in #1923. The change is test-only.

bookmarkablePageDecryptMultipleCryptoMapper, pageInstanceDecryptMultipleCryptoMapper and the second half of mountedPageRequestListenerParameter wrapped the test mapper in a second CryptoMapper built from the application. That outer mapper uses the default KeyInSessionSunJceCryptFactory, which generates a random key per session.

PBEWithMD5AndDES has no integrity check. In about 1 in 256 runs, decrypting the inner mapper's URL with that wrong key yields valid padding, so the outer mapper passes on a garbage URL instead of null. The outer mapper now gets its own fixed SunJceCrypt key, so the result is the same in every run.

Testing:

  • Before the change, the page-instance test failed 7 times in 2000 repeats, on Java 17 and on Java 25.
  • After the change, each of the three tests passes 2000 repeats with no failures.
  • A full mvn clean verify on Java 25 passes.

master and 11.x use authenticated AES-GCM, where a wrong key always fails, so they need no change. If a 9.x license cleanup release is cut, this commit should be cherry-picked onto wicket-9.x.

🤖 Generated with Claude Code

GitHub issue #1923

bookmarkablePageDecryptMultipleCryptoMapper,
pageInstanceDecryptMultipleCryptoMapper and the second half of
mountedPageRequestListenerParameter wrapped the test mapper in a second
CryptoMapper built from the application. That outer mapper used the
default KeyInSessionSunJceCryptFactory, which generates a random key per
session, and first tried to decrypt the URL the inner mapper had
encrypted with a different key. PBEWithMD5AndDES has no integrity check:
in about 1 in 256 runs the wrong-key plaintext ends in valid PKCS#5
padding, decryptUrlSafe returns garbage instead of null, and the inner
mapper cannot map the resulting URL. Repeated 2000 times, the page
instance test failed 7 times, on Java 17 and 25 alike, and CI has hit
all three tests on 10.x and 9.x.

The outer mapper now gets its own fixed SunJceCrypt key, so the
wrong-key decryption gives the same result in every run. Only the test
changes; master and 11.x use authenticated AES-GCM, where a wrong key
always fails, and are not affected.

Generated-by: Claude Code (Claude Opus 5.5)

@papegaaij papegaaij left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants