Repository navigation
test(dispatch,global,security): migrate leak-class specs to shared route helpers (PR3) - #4204
Conversation
…tes helpers (#4194) Route specs that redefine the table must restore it in afterEach or they leak stale state into later specs. routes, staticRoutes, namedRoutePositions, the urlFor caches (application- AND request-scoped) and #4183's router index are separate structures, so a partial restore is the #4192 bug class (and formsSpec already restored only routes + namedRoutePositions, dropping staticRoutes). Add three helpers to wheels.WheelsTest: - $snapshotRoutes() -> deep-copy snapshot of every route-derived structure present (#4183 fields behind StructKeyExists, so no rebase needed); - $restoreRoutes(snapshot) -> exact restore, deleting managed keys that were absent at snapshot time; - $clearRoutes() -> empty the table + invalidate every route cache (shared, replacing the per-spec shims). PR1 of a staged migration: helpers + a round-trip self-test (SnapshotRoutesSpec) + migrate the view/* specs (links, urls, paginationHelpers, forms). dispatch/mapper/global/middleware/security/hardener follow in area PRs. Design: shared-docs state/dev1-design/evidence/4194-*. Updates the CLAUDE.md / consumer-ai "Test-specific gotchas" line (and the app template) that said $clearRoutes is not inherited -- it now is. Verified locally, view 605/0/0 + wheelstest 267/0/0 on lucee7, adobe2023 AND adobe2025. Refs #4194 Refs #4183 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Peter Amiri <peter@alurium.com>
…4194 PR2) Replace each spec's hand-rolled route save/restore with $snapshotRoutes() / $restoreRoutes() and drop the local $clearRoutes shims (now inherited from wheels.WheelsTest, added in #4202). Several of these restored only a subset -- mapperSpec, mapperModernSpec, mapper/MapperSpec, mapper/MapperHardenerShouldSpec, mapper/MapperNullPatternSpec and mapper/MapperRobustnessSpec each dropped namedRoutePositions and/or staticRoutes -- so the shared helper also closes those latent leaks. PR2 of the staged migration; stacked on #4202 (the helper is not on develop yet). Depends on #4202; merge order #4202 then this. Verified locally: full core suite clean on lucee7 (6518 pass; the only failures are the known TestClient port-mapped loopback artifacts, 0 real), adobe2023 (6532/0/0) and adobe2025 (6532/0/0); 13 mapper bundles present. Refs #4194 Signed-off-by: Peter Amiri <peter@alurium.com>
…ute helpers (#4194 PR3) Migrate the remaining partial-clear / leak-class route specs onto $snapshotRoutes() / $restoreRoutes() and drop their local $clearRoutes shims: - dispatch/findMatchingRouteMegaSpec (partial-clear shim) - global/urlforSpec (partial-clear shim; keeps its URLRewriting + obfuscateUrls saves, which are not route-table state) - security/PaginationXssSpec (never saved staticRoutes -- the formsSpec leak class; its $clearRoutes CALL stays, now inherited) PR3 of the staged migration; stacked on #4203 (helper chain not on develop yet). Depends on #4203 (and #4202); merge order #4202, #4203, then this. Verified locally, full core suite clean on lucee7 (6518 pass; only the known TestClient port-mapped loopback artifacts, 0 real), adobe2023 (6532/0/0) and adobe2025 (6532/0/0). Refs #4194 Signed-off-by: Peter Amiri <peter@alurium.com>
|
rev1-r3 review @ df1101a: APPROVE (stacked on #4203; merge after it, once matrix The three remaining specs are migrated mechanically:
With #4202, #4203 and #4204 together, |
Wheels Test Results220 807 tests 216 087 ✅ 1h 20m 56s ⏱️ Results for commit 8a886a8. ♻️ This comment has been updated with latest results. |
…tes-leaks-4194 # Conflicts: # cli/lucli/templates/app/CLAUDE.md # docs/consumer-ai/CLAUDE.md # vendor/wheels/WheelsTest.cfc
Migrating urlforSpec onto the shared $snapshotRoutes/$restoreRoutes helpers brought urlForCache into the restored key set. urlForCache is a lazily-created persistent app-scope memo (routing.cfm), so when it was absent at snapshot time $restoreRoutes deleted it on the afterEach — cascading so every test ended with it gone. The issue-2955 'memo lives in application scope so it survives across requests' test then found the memo absent (Expected [false] to be true). Ensure urlForCache exists before the snapshot in the outer beforeEach, so the full-state restore preserves the key instead of deleting it — matching the framework's treatment of it as a persistent memo. All assertions are unchanged; the issue-2955 block still manages the cache contents via its own save/restore. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Peter Amiri <peter@alurium.com>
|
rev1-r3 review @ 8a886a8: code APPROVE (final sign-off after matrix run 37277585624 and PR CI) This moves the last three specs with their own route-state code onto the shared helpers: 3 files, +14/−29, and each local
Should the
Optional, not blocking: the guard sits in the outer |
|
rev1-r3 review @ 8a886a8: APPROVE (final; matrix run 37277585624 read leg by leg, PR CI checked)
|
PR3 (final) of the staged #4194 route-state-helper migration. Builds on the shared
$snapshotRoutes()/$restoreRoutes()/$clearRoutes()helpers (#4202) and the mapper-area migration (#4203), both on develop.What
Migrates the remaining leak-class specs onto the shared helpers:
dispatch/findMatchingRouteMegaSpecglobal/urlforSpecsecurity/PaginationXssSpecEach replaces hand-rolled route save/restore with
$snapshotRoutes()/$restoreRoutes()and drops its local$clearRoutesshim (now inherited fromwheels.WheelsTest).Why
These were the last specs on the partial-clear list — each restored only a subset of route state (dropping
namedRoutePositionsand/orstaticRoutes), the #4192 leak class. With these migrated, every route-manipulating spec in the suite uses the full-state helper, so none leaks stale routes into later specs.Verification
Local (SQLite), Lucee 7 and BoxLang, all scopes 0 fail / 0 error:
wheels.tests.specs.dispatch(27 bundles) — 261 passwheels.tests.specs.global(41 bundles) — 321 passwheels.tests.specs.security(36 bundles) — 403 passwheelstest.SnapshotRoutesSpec— 2 passinternal.RequireRepoPathSpec(WHEELS_EXPECT_REPO=true, env test exercised) — 4 passFull cross-engine matrix dispatched separately.
Closes #4194
🤖 Generated with Claude Code