feat(api): defer account creation until Garmin actually connects
This commit is contained in:
@@ -203,3 +203,24 @@ func TestIsolation_GarminConnectedNeverLeaksAcrossUsers(t *testing.T) {
|
||||
t.Fatal("userA's successful Garmin auth leaked into userB's garmin_connected flag")
|
||||
}
|
||||
}
|
||||
|
||||
// TestIsolation_SetupSessionsNeverLeakAcrossSubjects confirms one OIDC
|
||||
// subject's pending ephemeral Garmin session is invisible to another
|
||||
// subject -- e.g. subject B completing MFA must not accidentally continue
|
||||
// subject A's in-progress attempt.
|
||||
func TestIsolation_SetupSessionsNeverLeakAcrossSubjects(t *testing.T) {
|
||||
s, _, _ := newUnprovisionedServer(t)
|
||||
router := s.Router()
|
||||
|
||||
rec := doJSON(t, router, http.MethodPost, "/api/setup/garmin/login", map[string]any{
|
||||
"garmin_email": "a@example.com", "garmin_password": "pw-a",
|
||||
})
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("login(a) status = %d, body = %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
|
||||
rec = doJSONAs(t, router, "user-b", http.MethodPost, "/api/setup/garmin/mfa", map[string]any{"code": "000000"})
|
||||
if rec.Code != http.StatusConflict {
|
||||
t.Fatalf("user-b mfa (no login attempt of their own) status = %d, want 409, body = %s", rec.Code, rec.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user