package auth import ( "context" "errors" "io" "log/slog" "net/http" "net/url" "slices" "strings" "testing" ) // signInWith completes a login whose ID token has claims edited by edit. func (h *harness) signInWith(t *testing.T, edit func(claims map[string]any)) *http.Response { t.Helper() l := h.login(t, LoginPath) c := h.provider.claims(l.query.Get("nonce")) edit(c) return h.callback(l, l.query.Get("state"), h.provider.signRS256(c)) } // assertRefused checks resp is the refused-sign-in page and starts no // session. func assertRefused(t *testing.T, resp *http.Response) { t.Helper() if resp.StatusCode != http.StatusForbidden { t.Fatalf("callback status = %d, want 403", resp.StatusCode) } if ct := resp.Header.Get("Content-Type"); ct != "text/html; charset=utf-8" { t.Errorf("Content-Type = %q, want text/html; charset=utf-8", ct) } body, err := io.ReadAll(resp.Body) if err != nil { t.Fatal(err) } for _, want := range []string{ "This kitchen is for the household only", `