feat(19.4-01): neutral wristband resource default and OIDC provider docs

- DefaultOptions().Resource is empty; comments name the host application,
  no consuming application (folded todo)
- Tests set an explicit neutral resource; TestDefaultOptionsResourceEmpty
- wristband README: new summary, two flavours, OIDC usage, API reference,
  OIDC defaults, dependencies, testing; root README row matches
- docs/services/oauth-server.md: OpenID Connect provider section;
  Resource described as required with an empty default
- ExampleNewOIDCServer and the newOIDCServer docs region
This commit is contained in:
2026-10-19 18:32:03 +02:00
parent e25e73378c
commit ddda59a12b
12 changed files with 274 additions and 66 deletions

View File

@@ -4,8 +4,10 @@ import (
"encoding/json"
"net/http"
"net/http/httptest"
"reflect"
"strings"
"testing"
"time"
)
// TestPhase8RedMetadata is the Phase 8 Wave 1 RED anchor (08-CONTEXT.md
@@ -15,7 +17,7 @@ import (
// stub. scripts/check-phase8-red.sh verifies this failure is fail-closed.
func TestPhase8RedMetadata(t *testing.T) {
opts := DefaultOptions()
opts.Issuer = "https://plytarium.com"
opts.Issuer = "https://issuer.example.test"
srv := NewServer(opts)
req := httptest.NewRequest(http.MethodGet, "/.well-known/oauth-authorization-server", nil)
@@ -27,7 +29,7 @@ func TestPhase8RedMetadata(t *testing.T) {
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}`
const want = `{"issuer":"https://issuer.example.test","authorization_endpoint":"https://issuer.example.test/oauth/mcp/authorize","token_endpoint":"https://issuer.example.test/oauth/mcp/token","registration_endpoint":"https://issuer.example.test/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://issuer.example.test/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)
@@ -44,7 +46,7 @@ func TestPhase8RedMetadata(t *testing.T) {
// TestPhase8RedMetadata: same PHP-fixture bytes, now expected to pass.
func TestMetadataExactBytes(t *testing.T) {
opts := DefaultOptions()
opts.Issuer = "https://plytarium.com"
opts.Issuer = "https://issuer.example.test"
srv := NewServer(opts)
req := httptest.NewRequest(http.MethodGet, "/.well-known/oauth-authorization-server", nil)
@@ -56,7 +58,7 @@ func TestMetadataExactBytes(t *testing.T) {
t.Fatalf("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}`
const want = `{"issuer":"https://issuer.example.test","authorization_endpoint":"https://issuer.example.test/oauth/mcp/authorize","token_endpoint":"https://issuer.example.test/oauth/mcp/token","registration_endpoint":"https://issuer.example.test/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://issuer.example.test/help","authorization_response_iss_parameter_supported":true}`
if got := rec.Body.String(); got != want {
t.Fatalf("body mismatch\n got: %s\nwant: %s", got, want)
@@ -121,3 +123,29 @@ func decodeAsMap(t *testing.T, body []byte) map[string]any {
}
return m
}
// TestDefaultOptionsResourceEmpty pins the folded 19.4 todo: the framework
// default names no resource (the host application sets its own), and every
// other default is unchanged.
func TestDefaultOptionsResourceEmpty(t *testing.T) {
got := DefaultOptions()
if got.Resource != "" {
t.Fatalf("Resource = %q, want empty", got.Resource)
}
want := Options{
ServiceDocumentationPath: "/help",
ScopesSupported: []string{"read", "write", "ai", "offline_access"},
TokenEndpointAuthMethodsSupported: []string{"none", "client_secret_post", "client_secret_basic"},
AuthorizationResponseIssParameterSupported: true,
DCRClientCap: 200,
DCRUnconsentedSweepAge: 24 * time.Hour,
RegisterMaxBodyBytes: 65536,
PendingRequestTTL: 600 * time.Second,
CodeTTL: 600 * time.Second,
AccessTokenTTL: 3600 * time.Second,
RefreshTokenTTL: 30 * 24 * time.Hour,
}
if !reflect.DeepEqual(got, want) {
t.Fatalf("DefaultOptions() = %+v, want %+v", got, want)
}
}