(t *testing.T)
| 41 | } |
| 42 | |
| 43 | func 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 | } |
nothing calls this directly
no test coverage detected