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

Function TestOAuth2ProtectedResourceMetadata

coderd/oauth2provider/metadata_test.go:43–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41}
42
43func TestOAuth2ProtectedResourceMetadata(t *testing.T) {
44 t.Parallel()
45
46 client := coderdtest.New(t, nil)
47 serverURL := client.URL
48
49 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
50 defer cancel()
51
52 // Use a plain HTTP client since this endpoint doesn't require authentication.
53 // Add a short readiness wait to avoid rare races with server startup.
54 endpoint := serverURL.ResolveReference(&url.URL{Path: "/.well-known/oauth-protected-resource"}).String()
55 var metadata codersdk.OAuth2ProtectedResourceMetadata
56 testutil.RequireEventuallyResponseOK(ctx, t, endpoint, &metadata)
57
58 // Verify the metadata
59 require.NotEmpty(t, metadata.Resource)
60 require.NotEmpty(t, metadata.AuthorizationServers)
61 require.Len(t, metadata.AuthorizationServers, 1)
62 require.Equal(t, metadata.Resource, metadata.AuthorizationServers[0])
63 // RFC 6750 bearer tokens are now supported as fallback methods
64 require.Contains(t, metadata.BearerMethodsSupported, "header")
65 require.Contains(t, metadata.BearerMethodsSupported, "query")
66 // Supported scopes are published from the curated catalog
67 require.Equal(t, rbac.ExternalScopeNames(), metadata.ScopesSupported)
68}

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
ExternalScopeNamesFunction · 0.92
NotEmptyMethod · 0.80
StringMethod · 0.45
LenMethod · 0.45
EqualMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected