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

Function TestOAuth2AuthorizationServerMetadata

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

Source from the content-addressed store, hash-verified

14)
15
16func TestOAuth2AuthorizationServerMetadata(t *testing.T) {
17 t.Parallel()
18
19 client := coderdtest.New(t, nil)
20 serverURL := client.URL
21
22 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
23 defer cancel()
24
25 // Use a plain HTTP client since this endpoint doesn't require authentication.
26 // Add a short readiness wait to avoid rare races with server startup.
27 endpoint := serverURL.ResolveReference(&url.URL{Path: "/.well-known/oauth-authorization-server"}).String()
28 var metadata codersdk.OAuth2AuthorizationServerMetadata
29 testutil.RequireEventuallyResponseOK(ctx, t, endpoint, &metadata)
30
31 // Verify the metadata
32 require.NotEmpty(t, metadata.Issuer)
33 require.NotEmpty(t, metadata.AuthorizationEndpoint)
34 require.NotEmpty(t, metadata.TokenEndpoint)
35 require.Contains(t, metadata.ResponseTypesSupported, codersdk.OAuth2ProviderResponseTypeCode)
36 require.Contains(t, metadata.GrantTypesSupported, codersdk.OAuth2ProviderGrantTypeAuthorizationCode)
37 require.Contains(t, metadata.GrantTypesSupported, codersdk.OAuth2ProviderGrantTypeRefreshToken)
38 require.Contains(t, metadata.CodeChallengeMethodsSupported, codersdk.OAuth2PKCECodeChallengeMethodS256)
39 // Supported scopes are published from the curated catalog
40 require.Equal(t, rbac.ExternalScopeNames(), metadata.ScopesSupported)
41}
42
43func TestOAuth2ProtectedResourceMetadata(t *testing.T) {
44 t.Parallel()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected