package wristband import ( "net/http" "net/http/httptest" "testing" ) // TestPhase8RedMetadata is the Phase 8 Wave 1 RED anchor (08-CONTEXT.md // D-06). It asserts the exact unwrapped RFC 8414 metadata document recorded // from the live PHP fixture (parity/fixtures/routes/GET__.well-known_oauth-authorization-server_oauth.yaml) // and fails with the PHASE8_RED:metadata sentinel while Server.Metadata is a // stub. scripts/check-phase8-red.sh verifies this failure is fail-closed. func TestPhase8RedMetadata(t *testing.T) { opts := DefaultOptions() opts.Issuer = "https://plytarium.com" srv := NewServer(opts) req := httptest.NewRequest(http.MethodGet, "/.well-known/oauth-authorization-server", nil) req.Header.Set("Accept", "application/json") rec := httptest.NewRecorder() srv.Metadata(rec, req) if rec.Code != http.StatusOK { t.Fatalf("PHASE8_RED:metadata: status = %d, want %d", rec.Code, http.StatusOK) } const want = `{"issuer":"https://plytarium.com","authorization_endpoint":"https://plytarium.com/oauth/mcp/authorize","token_endpoint":"https://plytarium.com/oauth/mcp/token","registration_endpoint":"https://plytarium.com/oauth/mcp/register","response_types_supported":["code"],"grant_types_supported":["authorization_code","refresh_token"],"code_challenge_methods_supported":["S256"],"token_endpoint_auth_methods_supported":["none","client_secret_post","client_secret_basic"],"scopes_supported":["read","write","ai","offline_access"],"service_documentation":"https://plytarium.com/help","authorization_response_iss_parameter_supported":true}` if got := rec.Body.String(); got != want { t.Fatalf("PHASE8_RED:metadata: body mismatch\n got: %s\nwant: %s", got, want) } if ct := rec.Header().Get("Content-Type"); ct != "application/json" { t.Fatalf("PHASE8_RED:metadata: Content-Type = %q, want application/json", ct) } if cc := rec.Header().Get("Cache-Control"); cc != "no-cache, private" { t.Fatalf("PHASE8_RED:metadata: Cache-Control = %q, want \"no-cache, private\"", cc) } }