diff --git a/pkgs/mcpx/docs/spec/conformance-matrix.md b/pkgs/mcpx/docs/spec/conformance-matrix.md index 4552fd174b..6ec54052e3 100644 --- a/pkgs/mcpx/docs/spec/conformance-matrix.md +++ b/pkgs/mcpx/docs/spec/conformance-matrix.md @@ -2,7 +2,7 @@ Generated by `internal/conformance` (`MCPX_UPDATE_MATRIX=1 go test ./internal/conformance -run TestMatrix`); do not edit. -Generated from inputs `08efb95e7bca982c` (sha256 of docs/spec/requirements.md, internal/conformance/overrides/*.json, internal/conformance/coverage*.go). `TestMatrix` regenerates this file and fails when it differs, so it describes the tree it is committed in. +Generated from inputs `5791ee9656dda1e2` (sha256 of docs/spec/requirements.md, internal/conformance/overrides/*.json, internal/conformance/coverage*.go, internal/conformance/authsplit.json). `TestMatrix` regenerates this file and fails when it differs, so it describes the tree it is committed in. Every normative requirement of every revision (catalogue: `docs/spec/requirements.md`), for mcpx as a server and as a client. A requirement is *tested* when a named test verifies it in that revision, *n/a* when it does not bind mcpx in that role, and a *gap* when it binds mcpx and mcpx does not meet it yet, with the issue that tracks it. Run exactly the covering tests with `go run ./internal/conformance/cmd/covering`. @@ -2573,3 +2573,94 @@ Every normative requirement of every revision (catalogue: `docs/spec/requirement | [versioning-dual-era-server-selects-by-opening](https://modelcontextprotocol.io/specification/2026-07-28/basic/versioning#compatibility-matrix) | (normative description) | server | tested: `conformance.TestLifecycleServer/2026-07-28/versioning/versioning-dual-era-server-selects-by-opening` | n/a: addresses the other side | | [versioning-dual-era-both-concurrently](https://modelcontextprotocol.io/specification/2026-07-28/basic/versioning#compatibility-matrix) | MAY | server | tested: `conformance.TestLifecycleServer/2026-07-28/versioning/versioning-dual-era-both-concurrently` | n/a: addresses the other side | | [deprecated-should-not-adopt](https://modelcontextprotocol.io/specification/2026-07-28/deprecated#deprecated) | SHOULD NOT / SHOULD | both | tested: `conformance.TestLifecycleServer/2026-07-28/versioning/deprecated-should-not-adopt` | tested: `conformance.TestLifecycleClient/2026-07-28/versioning/deprecated-should-not-adopt` | + +## Authorization rows: accepts, or requires refusal (#1972) + +61 authorization rows are split per side of the wire into 82 bound row-sides: **69 permissive** and **13 validation**. A *permissive* row-side is satisfied by an interface that accepts every credential (#1950) — endpoint shape, discovery documents, registration, flows. A *validation* row-side cannot pass against such an interface: it needs a real check, named below, to refuse or challenge a credential (#1972). + +Validation row-sides per check: invalid 6, expired 5, wrong-resource 3, scope 5. Input: `internal/conformance/authsplit.json`; edits belong there, never in this file. + +| requirement | side | verdict | +|---|---|---| +| authorization-http-should-conform-stdio-should-not | server | permissive | +| authorization-http-should-conform-stdio-should-not | client | permissive | +| authorization-custom-auth-may | server | permissive | +| authorization-custom-auth-may | client | permissive | +| streamable-http-auth-discovery-version-header | client | permissive | +| authz-optional | server | permissive | +| authz-optional | client | permissive | +| authz-http-should-conform | server | permissive | +| authz-http-should-conform | client | permissive | +| authz-stdio-use-environment | server | permissive | +| authz-stdio-use-environment | client | permissive | +| authz-alt-transport-best-practice | server | permissive | +| authz-alt-transport-best-practice | client | permissive | +| authz-implement-oauth21 | server | permissive | +| authz-implement-oauth21 | client | permissive | +| authz-dcr-should | server | permissive | +| authz-dcr-should | client | permissive | +| authz-dcr-may-deprecated | client | permissive | +| authz-rfc8414-server-should-client-must | server | permissive | +| authz-rfc8414-server-should-client-must | client | permissive | +| authz-grant-types | server | permissive | +| authz-401-when-unauthorized | server | validation: invalid — an unproven or invalid credential must be refused with 401 | +| authz-base-url-discards-path | client | permissive | +| authz-default-endpoints-fallback | client | permissive | +| authz-bearer-header | client | permissive | +| authz-token-every-request | client | permissive | +| authz-no-token-in-query | client | permissive | +| authz-server-validates-token | server | validation: invalid, expired — tokens are validated; invalid or expired ones must get 401 | +| authz-server-validates-audience | server | validation: wrong-resource — the token must be issued for this server as audience | +| authz-client-sends-only-own-as-tokens | client | permissive | +| authz-accept-only-own-tokens | server | validation: wrong-resource — only tokens valid for this server's resources may be accepted | +| authz-no-token-passthrough | server | permissive | +| authz-error-status-codes | server | validation: invalid, expired, wrong-resource, scope — the refusal status code (401/403/400) for every authorization error | +| authz-2025-03-26-security-list | server | validation: invalid, expired — servers enforce token expiration and validate redirect URIs | +| authz-2025-03-26-security-list | client | permissive | +| authz-2025-03-26-implementation-reqs | server | validation: expired — token rotation and limited lifetimes are enforced server-side | +| authz-2025-03-26-implementation-reqs | client | permissive | +| authz-third-party-session-binding | server | validation: invalid, expired — third-party token status validated and expiration handled | +| authz-server-prm-rfc9728 | server | permissive | +| authz-server-prm-rfc9728 | client | permissive | +| authz-prm-lists-authorization-servers | server | permissive | +| authz-as-metadata-rfc8414 | server | permissive | +| authz-as-metadata-rfc8414 | client | permissive | +| authz-as-metadata-rfc8414-or-oidc | server | permissive | +| authz-as-metadata-rfc8414-or-oidc | client | permissive | +| authz-401-www-authenticate | server | validation: invalid — the 401 refusal must carry the WWW-Authenticate metadata pointer | +| authz-prm-discovery-header-or-well-known | server | permissive | +| authz-prm-discovery-header-or-well-known | client | permissive | +| authz-client-parses-www-authenticate | client | permissive | +| authz-client-rfc8414-discovery | client | permissive | +| authz-client-as-discovery-order | client | permissive | +| authz-client-validates-issuer-in-metadata | client | permissive — metadata is checked deterministically; no credential is inspected | +| authz-client-per-as-registration-state | client | permissive | +| authz-resource-indicator | client | permissive | +| authz-canonical-uri-guidance | server | permissive | +| authz-canonical-uri-guidance | client | permissive | +| authz-secure-token-storage | server | permissive | +| authz-secure-token-storage | client | permissive | +| authz-https-and-redirect-uris | server | permissive | +| authz-https-and-redirect-uris | client | permissive | +| authz-pkce | client | permissive | +| authz-pkce-verify-s256 | client | permissive — the client refuses to proceed on AS capability, not on a presented credential | +| authz-open-redirection | client | permissive | +| authz-proxy-consent-per-client | server | permissive — user consent is a flow gate, not a credential check; no credential is inspected | +| authz-client-registration-required | client | permissive | +| authz-registration-priority | client | permissive | +| authz-cimd | client | permissive | +| authz-preregistration | client | permissive | +| authz-dcr-application-type | client | permissive | +| authz-credentials-bound-to-issuer | client | permissive | +| authz-scope-in-challenge | server | validation: scope — the refusal challenge must name the scope required | +| authz-scope-in-challenge | client | permissive | +| authz-scope-selection-order | client | permissive | +| authz-insufficient-scope-403 | server | validation: scope — insufficient scope must be refused with 403 insufficient_scope | +| authz-all-scopes-single-challenge | server | validation: scope — one refusal challenge listing every scope the operation needs | +| authz-step-up | client | permissive — the client reacts to a refusal it is given; it validates nothing itself | +| authz-server-scope-hierarchy | server | validation: scope — scope hierarchies must be accounted for when enforcing scope | +| authz-iss-validation | client | permissive — discovery/issuer metadata is checked deterministically; no credential is inspected | +| authz-refresh-tokens | server | permissive | +| authz-refresh-tokens | client | permissive | +| authz-follow-security-considerations | server | permissive | +| authz-follow-security-considerations | client | permissive | diff --git a/pkgs/mcpx/internal/conformance/authsplit.go b/pkgs/mcpx/internal/conformance/authsplit.go new file mode 100644 index 0000000000..a2ee575e02 --- /dev/null +++ b/pkgs/mcpx/internal/conformance/authsplit.go @@ -0,0 +1,203 @@ +package conformance + +import ( + "encoding/json" + "fmt" + "os" + "sort" + "strings" +) + +// AuthSplitPath is the split of the authorization rows along accepts-vs- +// refuses, one verdict per requirement side. Like overrides/, it is data: +// the matrix renders it, and it never decides a cell's status. +const AuthSplitPath = "internal/conformance/authsplit.json" + +// The two verdicts for an authorization row-side. +const ( + // Permissive is satisfied by an interface that accepts every credential + // (#1950): endpoint shape, discovery documents, registration, flows. + Permissive = "permissive" + // Validation is not satisfiable by a permissive interface: it requires + // inspecting a presented credential and refusing it (#1972). + Validation = "validation" +) + +// AuthChecks are the validation checks a refusal-requiring row can need, +// matching #1972's split table. +var AuthChecks = []string{"invalid", "expired", "wrong-resource", "scope"} + +// AuthSide is the split verdict for one side of one requirement. +type AuthSide struct { + Verdict string `json:"verdict"` + Checks []string `json:"checks,omitempty"` + Why string `json:"why,omitempty"` +} + +// AuthCell keys the split by requirement and side: a row is split per side +// of the wire, since a permissive server and a permissive client answer +// different rows. +type AuthCell struct{ ID, Side string } + +type authSplitFile struct { + About string `json:"about"` + Checks []string `json:"checks"` + Rows map[string]map[string]AuthSide `json:"rows"` +} + +// IsAuthorization reports whether a requirement is an authorization row. +func IsAuthorization(r Requirement) bool { + return strings.Contains(strings.ToLower(r.Area), "authorization") +} + +// LoadAuthSplit reads the split and refuses one that does not cover exactly +// the bound sides of the authorization rows. +func LoadAuthSplit(path string, reqs []Requirement) (map[AuthCell]AuthSide, error) { + b, err := os.ReadFile(path) + if err != nil { + return nil, err + } + var f authSplitFile + if err := json.Unmarshal(b, &f); err != nil { + return nil, fmt.Errorf("%s: %w", path, err) + } + if strings.Join(f.Checks, ",") != strings.Join(AuthChecks, ",") { + return nil, fmt.Errorf("%s: checks are %v, want %v", path, f.Checks, AuthChecks) + } + + byID := map[string]Requirement{} + for _, r := range reqs { + byID[r.ID] = r + } + out := map[AuthCell]AuthSide{} + for id, sides := range f.Rows { + r, ok := byID[id] + if !ok { + return nil, fmt.Errorf("%s: unknown requirement %s", path, id) + } + if !IsAuthorization(r) { + return nil, fmt.Errorf("%s: %s is not an authorization row (%s)", path, id, r.Area) + } + for side, s := range sides { + k := AuthCell{id, side} + if side != Server && side != Client { + return nil, fmt.Errorf("%s: %s: side %q", path, id, side) + } + if strings.HasPrefix(r.Applicability[side], NAPrefix) { + return nil, fmt.Errorf("%s: %s/%s does not bind mcpx", path, id, side) + } + switch s.Verdict { + case Permissive: + if len(s.Checks) > 0 { + return nil, fmt.Errorf("%s: %s/%s is permissive but names checks %v", path, id, side, s.Checks) + } + case Validation: + if len(s.Checks) == 0 { + return nil, fmt.Errorf("%s: %s/%s requires validation but names no check", path, id, side) + } + for _, c := range s.Checks { + if !isAuthCheck(c) { + return nil, fmt.Errorf("%s: %s/%s: unknown check %q", path, id, side, c) + } + } + default: + return nil, fmt.Errorf("%s: %s/%s: verdict %q", path, id, side, s.Verdict) + } + out[k] = s + } + } + + var missing []string + for _, r := range reqs { + if !IsAuthorization(r) { + continue + } + for _, side := range []string{Server, Client} { + if strings.HasPrefix(r.Applicability[side], NAPrefix) { + continue + } + if _, ok := out[AuthCell{r.ID, side}]; !ok { + missing = append(missing, r.ID+"/"+side) + } + } + } + if len(missing) > 0 { + sort.Strings(missing) + return nil, fmt.Errorf("%s: %d bound authorization sides have no verdict:\n%s", + path, len(missing), strings.Join(missing, "\n")) + } + return out, nil +} + +func isAuthCheck(c string) bool { + for _, x := range AuthChecks { + if x == c { + return true + } + } + return false +} + +// AuthCounts is the size of the split. +type AuthCounts struct { + Rows int // authorization rows bound on at least one side + Sides int // bound row-sides + Permissive int // row-sides a permissive interface satisfies + Validation int // row-sides that need a real check + PerCheck map[string]int // validation row-sides per check +} + +// CountAuthSplit counts the split. +func CountAuthSplit(reqs []Requirement, sp map[AuthCell]AuthSide) AuthCounts { + c := AuthCounts{PerCheck: map[string]int{}} + bound := map[string]bool{} + for id, s := range sp { + c.Sides++ + bound[id.ID] = true + if s.Verdict == Permissive { + c.Permissive++ + } else { + c.Validation++ + for _, x := range s.Checks { + c.PerCheck[x]++ + } + } + } + c.Rows = len(bound) + return c +} + +// renderAuthSplit writes the split into the matrix, so the permissive +// interface's target and the validation work's target are both exact. +func renderAuthSplit(b *strings.Builder, reqs []Requirement, sp map[AuthCell]AuthSide) { + c := CountAuthSplit(reqs, sp) + fmt.Fprintf(b, "\n## Authorization rows: accepts, or requires refusal (#1972)\n\n") + fmt.Fprintf(b, "%d authorization rows are split per side of the wire into %d bound row-sides: **%d permissive** and **%d validation**. ", + c.Rows, c.Sides, c.Permissive, c.Validation) + b.WriteString("A *permissive* row-side is satisfied by an interface that accepts every credential (#1950) — endpoint shape, discovery documents, registration, flows. ") + b.WriteString("A *validation* row-side cannot pass against such an interface: it needs a real check, named below, to refuse or challenge a credential (#1972).\n\n") + fmt.Fprintf(b, "Validation row-sides per check: invalid %d, expired %d, wrong-resource %d, scope %d. ", + c.PerCheck["invalid"], c.PerCheck["expired"], c.PerCheck["wrong-resource"], c.PerCheck["scope"]) + fmt.Fprintf(b, "Input: `%s`; edits belong there, never in this file.\n\n", AuthSplitPath) + + b.WriteString("| requirement | side | verdict |\n|---|---|---|\n") + for _, r := range reqs { + if !IsAuthorization(r) { + continue + } + for _, side := range []string{Server, Client} { + s, ok := sp[AuthCell{r.ID, side}] + if !ok { + continue + } + v := "permissive" + if s.Verdict == Validation { + v = "validation: " + strings.Join(s.Checks, ", ") + } + if s.Why != "" { + v += " — " + mdEscape(s.Why) + } + fmt.Fprintf(b, "| %s | %s | %s |\n", r.ID, side, v) + } + } +} diff --git a/pkgs/mcpx/internal/conformance/authsplit.json b/pkgs/mcpx/internal/conformance/authsplit.json new file mode 100644 index 0000000000..0e08fe201d --- /dev/null +++ b/pkgs/mcpx/internal/conformance/authsplit.json @@ -0,0 +1,442 @@ +{ + "about": "The authorization rows split along accepts-vs-refuses (#1972): a permissive interface (#1950) satisfies a 'permissive' row-side; a 'validation' row-side needs a real check, named here. Checks: invalid, expired, wrong-resource, scope.", + "checks": [ + "invalid", + "expired", + "wrong-resource", + "scope" + ], + "rows": { + "authorization-custom-auth-may": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authorization-http-should-conform-stdio-should-not": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-2025-03-26-implementation-reqs": { + "server": { + "verdict": "validation", + "checks": [ + "expired" + ], + "why": "token rotation and limited lifetimes are enforced server-side" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-2025-03-26-security-list": { + "server": { + "verdict": "validation", + "checks": [ + "invalid", + "expired" + ], + "why": "servers enforce token expiration and validate redirect URIs" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-401-when-unauthorized": { + "server": { + "verdict": "validation", + "checks": [ + "invalid" + ], + "why": "an unproven or invalid credential must be refused with 401" + } + }, + "authz-401-www-authenticate": { + "server": { + "verdict": "validation", + "checks": [ + "invalid" + ], + "why": "the 401 refusal must carry the WWW-Authenticate metadata pointer" + } + }, + "authz-accept-only-own-tokens": { + "server": { + "verdict": "validation", + "checks": [ + "wrong-resource" + ], + "why": "only tokens valid for this server's resources may be accepted" + } + }, + "authz-all-scopes-single-challenge": { + "server": { + "verdict": "validation", + "checks": [ + "scope" + ], + "why": "one refusal challenge listing every scope the operation needs" + } + }, + "authz-alt-transport-best-practice": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-as-metadata-rfc8414": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-as-metadata-rfc8414-or-oidc": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-base-url-discards-path": { + "client": { + "verdict": "permissive" + } + }, + "authz-bearer-header": { + "client": { + "verdict": "permissive" + } + }, + "authz-canonical-uri-guidance": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-cimd": { + "client": { + "verdict": "permissive" + } + }, + "authz-client-as-discovery-order": { + "client": { + "verdict": "permissive" + } + }, + "authz-client-parses-www-authenticate": { + "client": { + "verdict": "permissive" + } + }, + "authz-client-per-as-registration-state": { + "client": { + "verdict": "permissive" + } + }, + "authz-client-registration-required": { + "client": { + "verdict": "permissive" + } + }, + "authz-client-rfc8414-discovery": { + "client": { + "verdict": "permissive" + } + }, + "authz-client-sends-only-own-as-tokens": { + "client": { + "verdict": "permissive" + } + }, + "authz-client-validates-issuer-in-metadata": { + "client": { + "verdict": "permissive", + "why": "metadata is checked deterministically; no credential is inspected" + } + }, + "authz-credentials-bound-to-issuer": { + "client": { + "verdict": "permissive" + } + }, + "authz-dcr-application-type": { + "client": { + "verdict": "permissive" + } + }, + "authz-dcr-may-deprecated": { + "client": { + "verdict": "permissive" + } + }, + "authz-dcr-should": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-default-endpoints-fallback": { + "client": { + "verdict": "permissive" + } + }, + "authz-error-status-codes": { + "server": { + "verdict": "validation", + "checks": [ + "invalid", + "expired", + "wrong-resource", + "scope" + ], + "why": "the refusal status code (401/403/400) for every authorization error" + } + }, + "authz-follow-security-considerations": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-grant-types": { + "server": { + "verdict": "permissive" + } + }, + "authz-http-should-conform": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-https-and-redirect-uris": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-implement-oauth21": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-insufficient-scope-403": { + "server": { + "verdict": "validation", + "checks": [ + "scope" + ], + "why": "insufficient scope must be refused with 403 insufficient_scope" + } + }, + "authz-iss-validation": { + "client": { + "verdict": "permissive", + "why": "discovery/issuer metadata is checked deterministically; no credential is inspected" + } + }, + "authz-no-token-in-query": { + "client": { + "verdict": "permissive" + } + }, + "authz-no-token-passthrough": { + "server": { + "verdict": "permissive" + } + }, + "authz-open-redirection": { + "client": { + "verdict": "permissive" + } + }, + "authz-optional": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-pkce": { + "client": { + "verdict": "permissive" + } + }, + "authz-pkce-verify-s256": { + "client": { + "verdict": "permissive", + "why": "the client refuses to proceed on AS capability, not on a presented credential" + } + }, + "authz-preregistration": { + "client": { + "verdict": "permissive" + } + }, + "authz-prm-discovery-header-or-well-known": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-prm-lists-authorization-servers": { + "server": { + "verdict": "permissive" + } + }, + "authz-proxy-consent-per-client": { + "server": { + "verdict": "permissive", + "why": "user consent is a flow gate, not a credential check; no credential is inspected" + } + }, + "authz-refresh-tokens": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-registration-priority": { + "client": { + "verdict": "permissive" + } + }, + "authz-resource-indicator": { + "client": { + "verdict": "permissive" + } + }, + "authz-rfc8414-server-should-client-must": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-scope-in-challenge": { + "server": { + "verdict": "validation", + "checks": [ + "scope" + ], + "why": "the refusal challenge must name the scope required" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-scope-selection-order": { + "client": { + "verdict": "permissive" + } + }, + "authz-secure-token-storage": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-server-prm-rfc9728": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-server-scope-hierarchy": { + "server": { + "verdict": "validation", + "checks": [ + "scope" + ], + "why": "scope hierarchies must be accounted for when enforcing scope" + } + }, + "authz-server-validates-audience": { + "server": { + "verdict": "validation", + "checks": [ + "wrong-resource" + ], + "why": "the token must be issued for this server as audience" + } + }, + "authz-server-validates-token": { + "server": { + "verdict": "validation", + "checks": [ + "invalid", + "expired" + ], + "why": "tokens are validated; invalid or expired ones must get 401" + } + }, + "authz-stdio-use-environment": { + "server": { + "verdict": "permissive" + }, + "client": { + "verdict": "permissive" + } + }, + "authz-step-up": { + "client": { + "verdict": "permissive", + "why": "the client reacts to a refusal it is given; it validates nothing itself" + } + }, + "authz-third-party-session-binding": { + "server": { + "verdict": "validation", + "checks": [ + "invalid", + "expired" + ], + "why": "third-party token status validated and expiration handled" + } + }, + "authz-token-every-request": { + "client": { + "verdict": "permissive" + } + }, + "streamable-http-auth-discovery-version-header": { + "client": { + "verdict": "permissive" + } + } + } +} diff --git a/pkgs/mcpx/internal/conformance/authsplit_test.go b/pkgs/mcpx/internal/conformance/authsplit_test.go new file mode 100644 index 0000000000..4b2569a6fd --- /dev/null +++ b/pkgs/mcpx/internal/conformance/authsplit_test.go @@ -0,0 +1,35 @@ +package conformance_test + +import ( + "path/filepath" + "testing" + + "github.com/dezren39/mcpx/internal/conformance" +) + +// TestAuthSplit pins the size of the accepts-vs-refuses split (#1972). The +// split is complete by construction (LoadAuthSplit refuses a bound +// authorization side with no verdict), so this guards the numbers the +// issues quote: a new authorization row must be judged, not absorbed. +func TestAuthSplit(t *testing.T) { + reqs, err := conformance.Load(filepath.Join(root(t), conformance.CataloguePath)) + if err != nil { + t.Fatal(err) + } + sp, err := conformance.LoadAuthSplit(filepath.Join(root(t), conformance.AuthSplitPath), reqs) + if err != nil { + t.Fatal(err) + } + c := conformance.CountAuthSplit(reqs, sp) + if c.Rows != 61 || c.Sides != 82 { + t.Errorf("split covers %d rows / %d row-sides, want 61 rows / 82 row-sides", c.Rows, c.Sides) + } + if c.Permissive != 69 || c.Validation != 13 { + t.Errorf("split is %d permissive / %d validation, want 69 / 13", c.Permissive, c.Validation) + } + for check, want := range map[string]int{"invalid": 6, "expired": 5, "wrong-resource": 3, "scope": 5} { + if c.PerCheck[check] != want { + t.Errorf("%d validation row-sides need %q, want %d", c.PerCheck[check], check, want) + } + } +} diff --git a/pkgs/mcpx/internal/conformance/matrix.go b/pkgs/mcpx/internal/conformance/matrix.go index 01948b1c25..059b46340a 100644 --- a/pkgs/mcpx/internal/conformance/matrix.go +++ b/pkgs/mcpx/internal/conformance/matrix.go @@ -202,7 +202,8 @@ func cellText(s Status) string { // inputs is InputDigest of the tree it was generated from: a file cannot // name the commit that contains it, but it can name its inputs, and // TestMatrix fails when they no longer hash to what the file says. -func Render(reqs []Requirement, st map[Cell]Status, inputs string) string { +// auth is the split of the authorization rows along accepts-vs-refuses. +func Render(reqs []Requirement, st map[Cell]Status, inputs string, auth map[AuthCell]AuthSide) string { var b strings.Builder b.WriteString("# MCP conformance matrix\n\n") b.WriteString("Generated by `internal/conformance` (`MCPX_UPDATE_MATRIX=1 go test ./internal/conformance -run TestMatrix`); do not edit.\n\n") @@ -249,5 +250,6 @@ func Render(reqs []Requirement, st map[Cell]Status, inputs string) string { } } } + renderAuthSplit(&b, reqs, auth) return b.String() } diff --git a/pkgs/mcpx/internal/conformance/matrix_test.go b/pkgs/mcpx/internal/conformance/matrix_test.go index d0e4f06b58..b52a5e50d9 100644 --- a/pkgs/mcpx/internal/conformance/matrix_test.go +++ b/pkgs/mcpx/internal/conformance/matrix_test.go @@ -143,5 +143,9 @@ func TestMatrix(t *testing.T) { if err != nil { t.Fatal(err) } - golden(t, conformance.MatrixPath, []byte(conformance.Render(reqs, st, inputs))) + auth, err := conformance.LoadAuthSplit(filepath.Join(root(t), conformance.AuthSplitPath), reqs) + if err != nil { + t.Fatal(err) + } + golden(t, conformance.MatrixPath, []byte(conformance.Render(reqs, st, inputs, auth))) } diff --git a/pkgs/mcpx/internal/conformance/paths.go b/pkgs/mcpx/internal/conformance/paths.go index 8d068b0383..aa7eeb0b66 100644 --- a/pkgs/mcpx/internal/conformance/paths.go +++ b/pkgs/mcpx/internal/conformance/paths.go @@ -57,8 +57,9 @@ func RunPatterns() []PkgPattern { } // InputGlobs are the files the matrix is computed from, relative to the -// module root: the catalogue, its overrides and the coverage registry. -var InputGlobs = []string{MarkdownPath, OverridesDir + "/*.json", "internal/conformance/coverage*.go"} +// module root: the catalogue, its overrides, the coverage registry and the +// authorization split. +var InputGlobs = []string{MarkdownPath, OverridesDir + "/*.json", "internal/conformance/coverage*.go", AuthSplitPath} // InputDigest hashes InputGlobs' files, names and contents, in order. func InputDigest(root string) (string, error) {