Skip to content

Pairwise Integration & E2E Requirements Matrix ​

This document defines the canonical pairwise requirements matrix, interaction coverage tables, and end-to-end verification contracts for the Model Context Gateway (MCG).

Living Test Catalog & SRS: For automated requirement-to-test traceability and fail-closed safety guardrails, see the Software Requirements Specification (SRS) & Test Verification Catalog and Test Catalog Guide.


1. Matrix Dimensions & Value Domains ​

The router operates across 6 primary orthogonal dimensions:

DimensionTested Parameter Variants
1. Auth MethodsAppKey | SSO Headers | OIDC Bearer | Anonymous / Unauthenticated
2. Identity / SIDsAdmin (S-1-5-32-544 / full_admin) | Group-Mapped Operator | Denied | Invalid
3. AppKey Scopes*/all | server:{id} | category:{cat} | tool:/prompt:/resource:
4. Capabilitiestools/call | prompts/get | resources/read | templates | completion | meta
5. TransportsSSE (/sse) | HTTP (/mcp) | Target Proxy (/{server}) | STDIO Subprocess
6. Persistence DBSQLite | Microsoft SQL Server (MSSQL) | MySQL

Dimension Definitions ​

DimensionDomain ValuesDescriptions
Auth MethodAppKey, SSO, OIDC, AnonymousCredential mechanism (X-App-Key header, Remote-User/Remote-Groups headers, Authorization: Bearer <jwt>, or unauthenticated).
Identity / RoleAdmin (S-1-5-32-544), Operator, DeniedUser, InvalidSidSecurity principle context: bypass admin, group-mapped RBAC operator, explicit deny policy, or non-resolving SID.
AppKey Scope*/all, server:{id}, category:{name}, group:{name}, tool:{id}, prompt:{id}, resource:{uri}, ExpiredGranular permission boundaries embedded into API keys.
Capabilitytools/call, prompts/get, resources/read, resources/templates/list, completion/complete, search_tools, execute_toolMCP protocol primitives and meta-mode dynamic discovery router tools.
TransportSSE, HTTP Stream, Target Proxy (/{server}), STDIOClient-to-router and router-to-backend communication mechanisms.
Persistence EngineSQLite, MSSQL, MySQLRelational database backends storing servers, appkeys, settings, access policies, and audit logs.

2. Pairwise Interaction Matrices ​

2.1 Auth Method × Identity Context Matrix ​

Auth MethodIdentity ContextTarget PolicyExpected Router ResultHTTP StatusTest File Reference
SSO HeadersAdmin (S-1-5-32-544)None (Unseeded)Allowed (Admin bypass)200 OKPairwiseIntegrationMatrixTests
SSO HeadersAdmin (full_admin)Explicit DenyAllowed (Admin SID bypass takes precedence)200 OKAdminPolicySidOnlyTests
SSO HeadersOperator (SmartHomeOperators via group mapping)server:ha -> SmartHomeOperators AllowedAllowed (Group mapped via GroupMappings)200 OKGroupMappingsAndSpecAuthTests
SSO HeadersDenied User (Guests)server:ha -> Guests Denied (IsAllowed=0)Denied (Explicit Deny overrides allow)403 Forbidden / ErrorUnifiedMcpAuthorizationTests
SSO HeadersInvalid / Unknown SID (S-1-5-21-999)No policy matchesDenied (Fail-closed default)403 Forbidden / ErrorPairwiseIntegrationMatrixTests
AppKeyAdmin Key (* scope)NoneAllowed (Key scope * + Owner admin)200 OKAppKeyAuthenticationTests
AppKeyCategory-Scoped Key (category:smarthome)server:ha (Category: smarthome)Allowed (Resolved category matches server)200 OKCategoryScopedAppKeysTests
AppKeyExpired Key (ExpiresAt < Now)AnyDenied (Key validation fails before policy check)401 UnauthorizedAppKeyAuthenticationTests
OIDCOperator (oidc_user with scopes)server:docker -> DevOps AllowedAllowed (JWT claims mapped to user groups)200 OKOpenIddictProductionTests
AnonymousNone (DefaultHttpContext)AnyDenied (Anonymous fails closed on protected resources)401 / 403EndpointAuthorizationTests

2.2 AppKey Scopes × MCP Capabilities Matrix ​

AppKey Scopetools/call (ha__turn_on)prompts/get (ha__summary)resources/read (mcp://ha/states)templates (mcp://ha/sensor/{id})completion (ha__summary)search_tools / execute_tool
* / all / mcp_client✅ Allow✅ Allow✅ Allow✅ Allow✅ Allow✅ Allow
server:ha✅ Allow✅ Allow✅ Allow✅ Allow✅ Allow✅ Allow (ha tools only)
category:smarthome✅ Allow (if ha in category)✅ Allow (if ha in category)✅ Allow (if ha in category)✅ Allow (if ha in category)✅ Allow (if ha in category)✅ Allow (smarthome tools)
group:smarthome✅ Allow (group alias)✅ Allow (group alias)✅ Allow (group alias)✅ Allow (group alias)✅ Allow (group alias)✅ Allow (group alias)
tool:ha__turn_on✅ Allow❌ Denied❌ Denied❌ Denied❌ Denied✅ Allow (specific tool)
prompt:ha__summary❌ Denied✅ Allow❌ Denied❌ Denied✅ Allow (ha__summary)❌ Denied
resource:mcp://ha/states❌ Denied❌ Denied✅ Allow❌ Denied❌ Denied❌ Denied
server:other_server❌ Denied❌ Denied❌ Denied❌ Denied❌ Denied❌ Denied
Invalid / Expired Scope❌ Denied❌ Denied❌ Denied❌ Denied❌ Denied❌ Denied

2.3 Transports × Auth Shapes & Upstream Target Matrix ​

Client TransportUpstream Server TypeAuthShape ConfigurationSecret ProviderForwarding Transformation
SSE (/sse)ssebearerDirect Key / DBAuthorization: Bearer <secret>
SSE (/sse)httpx-api-keyHashiCorp VaultX-API-Key: <vault_retrieved_secret>
SSE (/sse)httpbearerWindows Registry (DPAPI)Authorization: Bearer <dpapi_decrypted_secret>
HTTP (/mcp)httpcustom-headerEnvironment Var<CustomHeaderName>: <env_secret>
HTTP (/mcp)httpbearerWindows Registry (DPAPI)Authorization: Bearer <dpapi_decrypted_secret>
HTTP (/mcp)httpqueryDirect Key?api_key=<secret> URL parameter rewrite
Target Proxy (/{id})sse / httpbasicDirect KeyAuthorization: Basic <base64> header rewrite
STDIO SubprocessstdioEnvironment argsWindows Registry (DPAPI)Decrypted DPAPI secret injected into process environment
STDIO SubprocessstdioEnvironment argsSystem EnvironmentProcess environment variable injection

2.4 Persistence Engines × Dialect & Upgrade Matrix ​

EngineParam PrefixTimestamp FormatSchema Auto-MigrationTable QuotingConnection Testing
SQLite@paramTEXT (ISO-8601 UTC)CREATE TABLE IF NOT EXISTS"" or noneDbConnectionFactoryTests
MSSQL@paramDATETIME2IF NOT EXISTS (SELECT * FROM sysobjects ...)[]DatabaseSchemaUpgradeAndContractTests
MySQL@paramDATETIME(6)CREATE TABLE IF NOT EXISTSDatabaseSchemaUpgradeAndContractTests

2.5 Fail-Closed & Malformed Request Boundary Matrix ​

Fault ScenarioInput ConditionExpected BehaviorSafety Assertion
Unregistered BackendtargetId = "ghost__tool1"Reject with UnauthorizedAccessException or 404No downstream network leak
Malformed Target URItargetId = "invalid-uri-format"Reject with UnauthorizedAccessExceptionFail closed default
Null / Empty TargettargetId = null or "" or " "Reject with false authorization resultNo exception thrown, returns false
Corrupted Scope JSONAppKeyScopes = "{invalid json}"Log warning, fail closed (deny request)AppKey rejected safely
Database DisconnectionDB factory returns closed/nullCatch exception, fail closed (deny request)Does not bypass to allow
Malformed JSON-RPCMissing "id" or "method"Return standard JSON-RPC 2.0 error object (-32600)Clean error serialization

2.6 Windows Native Host & IIS In-Process Matrix ​

Test Probe / TargetMechanism / SubsystemExpected BehaviorVerification Proof
IIS ANCM v2 In-Processaspnetcorev2.dll inside w3wp.exeHigh-throughput in-process request pipelineDeploy-IIS.ps1, GET /health -> 200 OK
Unbuffered SSE Streaming<handlerSetting name="responseBufferLimit" value="0" />Immediate SSE frame dispatch to LLM clientLive curl /sse stream verification
DPAPI LocalMachine SecretsProtectedData.Protect / UnprotectMachine-level AES decryption from REG_BINARYWindowsRegistrySecretRetrieverTests, Set-RegistrySecrets.ps1
Windows Caller SID ResolutionIWindowsIdentityAccessor / ClaimsIdentityExtraction of User SID & group token SIDsActiveDirectoryWindowsIdentityTests, GET /api/me
Admin SID Bypass (S-1-5-32-544)ActiveDirectoryIdentityProviderAutomatic mapping to Administrator roleAdminPolicySidOnlyTests, Test-WindowsEnvironment.ps1

3. End-to-End Multi-User Context Fixtures ​

Playwright E2E tests are parameterized using 4 distinct caller contexts defined in frontend/e2e/fixtures/userContexts.ts:

Context Definitions ​

  1. Admin Context (adminUser):

    • Remote-User: admin_user
    • Remote-Groups: full_admin,devops
    • Remote-Name: Admin User
    • Remote-User-Sid: S-1-5-32-544
    • Access: Unrestricted dashboard, server creation, RBAC policies, settings, key generation.
  2. Operator Context (operatorUser):

    • Remote-User: operator_user
    • Remote-Groups: SmartHomeOperators
    • Remote-Name: SmartHome Operator
    • Remote-User-Sid: S-1-5-21-1002
    • Access: Access to permitted smart home tools and dashboard overview; denied admin settings and unauthorized servers.
  3. Read-Only / Denied Context (guestUser):

    • Remote-User: guest_user
    • Remote-Groups: Guests
    • Remote-Name: Guest User
    • Remote-User-Sid: S-1-5-21-9999
    • Access: Overview visibility only, denied tool execution on protected servers.
  4. AppKey Direct Header Context (appKeyUser):

    • X-App-Key: mcp_live_pairwise_test_key
    • Access: Scoped strictly according to the issued key's JSON scope list (category:smarthome, server:ha, etc.).

4. Automation & CI Verification ​

To execute pairwise test theories and validation locally:

bash
# Run backend pairwise contract and integration theories
CI=true dotnet test ModelContextGateway.slnx --filter "FullyQualifiedName~PairwiseIntegrationMatrixTests"

# Run all backend tests
CI=true dotnet test ModelContextGateway.slnx

# Run frontend lint, build, and E2E specs
cd frontend
npm run lint
npm run build
npx playwright test

Released under the Apache 2.0 License.