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

Function TestOAuth2ErrorResponseFormat

coderd/oauth2_error_compliance_test.go:24–49  ·  view source on GitHub ↗

TestOAuth2ErrorResponseFormat tests that OAuth2 error responses follow proper RFC format

(t *testing.T)

Source from the content-addressed store, hash-verified

22
23// TestOAuth2ErrorResponseFormat tests that OAuth2 error responses follow proper RFC format
24func TestOAuth2ErrorResponseFormat(t *testing.T) {
25 t.Parallel()
26
27 t.Run("ContentTypeHeader", func(t *testing.T) {
28 t.Parallel()
29
30 client := coderdtest.New(t, nil)
31 _ = coderdtest.CreateFirstUser(t, client)
32 ctx := testutil.Context(t, testutil.WaitLong)
33
34 // Make a request that will definitely fail
35 req := codersdk.OAuth2ClientRegistrationRequest{
36 // Missing required redirect_uris
37 }
38
39 _, err := client.PostOAuth2ClientRegistration(ctx, req)
40 require.Error(t, err)
41
42 // Check that it's an HTTP error with JSON content type
43 var httpErr *codersdk.Error
44 require.ErrorAs(t, err, &httpErr)
45
46 // The error should be a 400 status for invalid client metadata
47 require.Equal(t, http.StatusBadRequest, httpErr.StatusCode())
48 })
49}
50
51// TestOAuth2RegistrationErrorCodes tests all RFC 7591 error codes
52func TestOAuth2RegistrationErrorCodes(t *testing.T) {

Callers

nothing calls this directly

Calls 8

StatusCodeMethod · 0.95
NewFunction · 0.92
CreateFirstUserFunction · 0.92
ContextFunction · 0.92
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected