MCPcopy Index your code
hub / github.com/coder/coder / TestOAuth2ErrorHTTPHeaders

Function TestOAuth2ErrorHTTPHeaders

coderd/oauth2_error_compliance_test.go:330–353  ·  view source on GitHub ↗

TestOAuth2ErrorHTTPHeaders tests that error responses have correct HTTP headers

(t *testing.T)

Source from the content-addressed store, hash-verified

328
329// TestOAuth2ErrorHTTPHeaders tests that error responses have correct HTTP headers
330func 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
356func TestOAuth2SpecificErrorScenarios(t *testing.T) {

Callers

nothing calls this directly

Calls 7

NewFunction · 0.92
CreateFirstUserFunction · 0.92
ContextFunction · 0.92
NotEmptyMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected