From 915c230d8d4e34f0fd5c1e284c8803c99d69b140 Mon Sep 17 00:00:00 2001 From: Kenneth Jenkins <51246568+kenjenkins@users.noreply.github.com> Date: Wed, 3 Jan 2024 17:18:18 -0800 Subject: [PATCH] authenticateflow: verify redirect in Callback test (#4894) Add assertions for the redirect URL in the unit test for the stateful authentication flow Callback() method. Remove a commented-out line of debug logging. --- internal/authenticateflow/stateful_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/authenticateflow/stateful_test.go b/internal/authenticateflow/stateful_test.go index a219677be..8d4aae270 100644 --- a/internal/authenticateflow/stateful_test.go +++ b/internal/authenticateflow/stateful_test.go @@ -261,7 +261,6 @@ func TestStatefulCallback(t *testing.T) { } r := httptest.NewRequest(http.MethodGet, uri.String(), nil) - // fmt.Println(uri.String()) r.Host = r.URL.Host r.Header.Set("Accept", "application/json") @@ -272,13 +271,14 @@ func TestStatefulCallback(t *testing.T) { if err != nil { t.Errorf("unexpected error: %v", err) } + location, _ := url.Parse(w.Result().Header.Get("Location")) + assert.Equal(t, "example.com", location.Host) + assert.Equal(t, "ok", location.Query().Get("pomerium_callback_uri")) } else { if err == nil || !strings.Contains(err.Error(), tt.wantErrorMsg) { t.Errorf("expected error containing %q; got %v", tt.wantErrorMsg, err) } } - - // XXX: assert redirect URL }) } }