(t *testing.T)
| 323 | } |
| 324 | |
| 325 | func TestMissingCodeShowsErrorMessage(t *testing.T) { |
| 326 | identityUrl, _ := url.Parse("http://localhost") |
| 327 | ctx := createNonConfidentialAuthContext(*identityUrl) |
| 328 | loginUrl, _ := callAuthenticator(ctx) |
| 329 | |
| 330 | redirectUri := loginUrl.Query().Get("redirect_uri") |
| 331 | state := loginUrl.Query().Get("state") |
| 332 | request, err := http.NewRequestWithContext(t.Context(), http.MethodGet, redirectUri+"?code=&state="+state, nil) |
| 333 | if err != nil { |
| 334 | t.Fatalf("Unexpected error calling login url: %v", err) |
| 335 | } |
| 336 | response, err := http.DefaultClient.Do(request) |
| 337 | if err != nil { |
| 338 | t.Fatalf("Unexpected error calling login url: %v", err) |
| 339 | } |
| 340 | defer func() { _ = response.Body.Close() }() |
| 341 | |
| 342 | responseBody, err := io.ReadAll(response.Body) |
| 343 | if err != nil { |
| 344 | t.Fatalf("Login url response body cannot be read: %v", err) |
| 345 | } |
| 346 | |
| 347 | if string(responseBody) != "Could not find query string 'code' in redirect_url" { |
| 348 | t.Errorf("Expected error message that state does not match, but got: %v", string(responseBody)) |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | func TestOAuthFlowRedactsClientSecretAndRefreshToken(t *testing.T) { |
| 353 | identityServerFake := identityServerFake{ |
nothing calls this directly
no test coverage detected