From e4f0935f98996b0381478eba20b9233646ccc483 Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Fri, 4 Sep 2026 17:58:11 -0400 Subject: [PATCH] Keep the second auth test under a subscriber, so the tripwire is not flaky `gates_every_route_and_never_logs_the_token` failed about one full-suite run in ten, on the assertion that a rejection *was* logged. Its sibling ends with an unauthenticated request of its own, made with no subscriber on that thread -- and tracing caches a callsite's interest process-wide the first time it is reached, so whichever test got there first decided whether the warning would ever be recorded. That is the rule already written at the top of "Things that have bitten", applied to one member of a set: the combined gating+logging test exists because of it, and the enrollment test added later did not get it. Twenty runs clean since. Co-Authored-By: Claude Opus 5 --- server/src/auth.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/src/auth.rs b/server/src/auth.rs index 7719bce..b8dc6ac 100644 --- a/server/src/auth.rs +++ b/server/src/auth.rs @@ -207,6 +207,20 @@ mod tests { /// like any other. #[tokio::test] async fn a_spooled_enrollment_is_adopted_on_first_use() { + // Under a subscriber, like every other exercise of this middleware. + // `tracing` caches a callsite's interest process-wide the first time it + // is reached, so the refusal at the end of this test -- reached with no + // subscriber on this thread -- could cache the rejection warning as + // never-enabled and make the tripwire above see an empty log. That + // failed about one full-suite run in ten, in the test that exists to + // notice a credential leak, which is the worst place for a flake. + let _guard = tracing::subscriber::set_default( + tracing_subscriber::fmt() + .with_max_level(tracing::Level::TRACE) + .with_writer(std::io::sink) + .finish(), + ); + let dir = tempfile::tempdir().expect("tempdir"); let manager = manager_with_token(dir.path(), "first"); let spooled = generate_token();