TestOAuth2ErrorHTTPHeaders tests that error responses have correct HTTP headers
(t *testing.T)
| 328 | |
| 329 | // TestOAuth2ErrorHTTPHeaders tests that error responses have correct HTTP headers |
| 330 | func TestOAuth2ErrorHTTPHeaders(t *testing.T) { |
| 331 | t.Parallel() |
| 332 | |
| 333 | t.Run("ContentTypeJSON", func(t *testing.T) { |
| 334 | t.Parallel() |
| 335 | |
| 336 | client := coderdtest.New(t, nil) |
| 337 | _ = coderdtest.CreateFirstUser(t, client) |
| 338 | ctx := testutil.Context(t, testutil.WaitLong) |
| 339 | |
| 340 | // Make a request that will fail |
| 341 | req := codersdk.OAuth2ClientRegistrationRequest{ |
| 342 | // Missing required fields |
| 343 | } |
| 344 | |
| 345 | _, err := client.PostOAuth2ClientRegistration(ctx, req) |
| 346 | require.Error(t, err) |
| 347 | |
| 348 | // The error should indicate proper JSON response format |
| 349 | var httpErr *codersdk.Error |
| 350 | require.ErrorAs(t, err, &httpErr) |
| 351 | require.NotEmpty(t, httpErr.Message) |
| 352 | }) |
| 353 | } |
| 354 | |
| 355 | // TestOAuth2SpecificErrorScenarios tests specific error scenarios from RFC specifications |
| 356 | func TestOAuth2SpecificErrorScenarios(t *testing.T) { |
nothing calls this directly
no test coverage detected