Summary
wiremock's process-wide server pool keeps listener ports for the process lifetime, and the freed-port I12 tests bind an ephemeral port, free it, and fire requests at it expecting refusal. Under load the freed port can belong to a newly created pooled listener in the same process: ~1-4 failures per 300 stress runs. Independently reproduced by implementer and reviewer during #93.
The freed-port sites on main:
crates/bugwarden-core/tests/guard_wiremock.rs — api_key_absent_from_transport_error_i12 (bind at :413), whoami_api_key_absent_from_transport_error_i12 (:1141), valid_login_api_key_absent_from_transport_error_i12 (:1221); one binary, one shared pool.
- Siblings in their own processes:
crates/bugwarden/tests/preflight_wiremock.rs:269 and crates/bugwarden/tests/tools_wiremock.rs:1649.
Failure modes observed
unwrap_err() panicking on Ok carrying another test's corpus;
.expect(1) over-counting a foreign request;
- worst,
api_key_absent_from_transport_error_i12 silently not exercising I12 sanitization at all when the "refused" port answers — the test goes green without touching the invariant it exists for.
Why it matters
Two of the modes are flakes that poison unrelated tests' assertions; the third is a silent coverage loss on a security invariant (I12: the API key never appears in a transport error). #93/#112 fixed the one body-parsing victim; the hazard remains at every site above.
Suggested direction
Stop aiming real connects at recycled ephemeral ports: keep the listener bound and shut it down so the port is never returned to the OS while wiremock's pool is live, or use a reserved unroutable address.
Acceptance criteria
Summary
wiremock's process-wide server pool keeps listener ports for the process lifetime, and the freed-port I12 tests bind an ephemeral port, free it, and fire requests at it expecting refusal. Under load the freed port can belong to a newly created pooled listener in the same process: ~1-4 failures per 300 stress runs. Independently reproduced by implementer and reviewer during #93.
The freed-port sites on main:
crates/bugwarden-core/tests/guard_wiremock.rs—api_key_absent_from_transport_error_i12(bind at:413),whoami_api_key_absent_from_transport_error_i12(:1141),valid_login_api_key_absent_from_transport_error_i12(:1221); one binary, one shared pool.crates/bugwarden/tests/preflight_wiremock.rs:269andcrates/bugwarden/tests/tools_wiremock.rs:1649.Failure modes observed
unwrap_err()panicking onOkcarrying another test's corpus;.expect(1)over-counting a foreign request;api_key_absent_from_transport_error_i12silently not exercising I12 sanitization at all when the "refused" port answers — the test goes green without touching the invariant it exists for.Why it matters
Two of the modes are flakes that poison unrelated tests' assertions; the third is a silent coverage loss on a security invariant (I12: the API key never appears in a transport error). #93/#112 fixed the one body-parsing victim; the hazard remains at every site above.
Suggested direction
Stop aiming real connects at recycled ephemeral ports: keep the listener bound and shut it down so the port is never returned to the OS while wiremock's pool is live, or use a reserved unroutable address.
Acceptance criteria