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.
This commit is contained in:
Kenneth Jenkins 2024-01-03 17:18:18 -08:00 committed by GitHub
parent fb9eb31be9
commit 915c230d8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
})
}
}