Repository navigation
refactor(auth): tests sign browsers in through one Browser helper - #573
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
e4042be to
2fe8e36
Compare
5c9a78d to
d47cd4b
Compare
d47cd4b to
93f2765
Compare
…ests read the stored handle
93f2765 to
f1517e4
Compare
Part of #544. Builds on #571 (merged), whose fixtures this uses.
crate::tests::Browseralready signs a browser in, but test modules copied it anyway:Session::createin a transaction, a commit, then the cookie pair formatted by hand. That copy was in the emails, federation, recovery, OIDC and step-up tests, and at four passkey sites. Account creation copiedInsertUser::namedin six modules.Browser::sign_in_by(database, context, user, credential)signs in from any request context with any credential, such as a given passkey, or a recovery's probation passkey.sign_in_withnow calls it, and the copies use it.passkey::tests::Fixture::social_sign_incovers the four passkey sites.insert_named. Where a test reads the display name ("Browser test", "Test user"), it keeps it.Replicas::database()connects throughDatabase::test(), which it used to repeat with the same pool size and time limits.deletion/tests.rsstill callsSession::createdirectly, because it asserts that the sign-in fails.Differences
mail-…string. They now compare it with the account's stored handle, which is the same value, so they don't depend on the fixture's handle format.Unchanged
origin/main.Checks
cargo clippy -p auth-serviceand-p sourceorigin-repository,--all-targets, pass with and without--all-features,-D warnings.just db teston the top of the stack passes, but for a knownaudit::testsrace that predates this stack and passes when re-run (reported separately).Council review
Rounds: 2
Round 2 found no code defects. Its should-fixes were these descriptions, and its nits are applied.
Note
Written by Claude Opus 5.5 in Claude Code and reviewed by GPT 6.1 Sol, Claude Opus 5.5 and Claude Fable 5.2 (via T3 Code)
Scope: 11 files changed in
apps/auth-service. Diff size: +95 / -189 lines.Shared test infrastructure (
src/tests.rs)Browser::sign_in_by(database, context, user_id, credential). It creates a session from the suppliedRequestContextandCredential, then returns the browser.Browser::sign_in_withkeeps its signature. It now delegates tosign_in_bywithRequestContext::TEST.Replicas::database()callsDatabase::test(). It no longer builds a 5-connection pool and runs migrations directly.Browser::new_accountusesInsertUser::named("browser")and keeps the display name"Browser test".Passkey tests (
src/passkey/tests/)Fixture::newseeds its account withInsertUser::named("key"). It takes the generated ID and handle from the record.Fixture::social_sign_in(). It signs another browser into the seeded account usingAuthenticationMethod::Federation. The session stays unconfirmed.confirmation.rsandsign_in.rsreplace direct session creation withsocial_sign_in().Session setup in other test modules
federation/tests/mod.rs: theuserfixture usesinsert_named("fed"). Thesessionfixture usessign_in_with.emails/tests.rs:Harness::accountusesinsert_namedandsign_in_by. It drops direct user and session construction.oidc/tests/mod.rsandoidc/tests/step_up.rs: session cookies come fromBrowserhelpers, not manual construction.recovery/tests/mod.rs:Scenario::signed_in_withusessign_in_byand returns the cookie.Account fixtures and assertions
admin/tests/mod.rs:Harness::signed_inusesinsert_named("admin").deliveries/email/tests.rs: usesinsert_named("mail"). Adds astored_handlehelper. Handle assertions compare against the stored handle, not a literalmail-…value.Not changed
deletion/tests.rsstill usesSession::create, because its test asserts that sign-in fails.Not verified here