From 303cc58dc3316e22dbb6b0977d1a05ea0e7e673d Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 29 Sep 2026 11:30:15 -0700 Subject: [PATCH] docs(oe): fix stale docs and assert federator argument extraction Align provider config and HOW_TO_TEST examples with actual behavior, correct ConsumerAssertion ApplicationID comment, and assert ProviderSchemaCollector Arguments length in table-driven tests. Closes #513 Co-authored-by: Cursor --- cmd/oe/HOW_TO_TEST.md | 31 ++++++++++++++----------- cmd/oe/PROVIDER_CONFIGURATION.md | 2 +- internal/oe/auth/types.go | 2 +- internal/oe/federator/federator_test.go | 1 + 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/cmd/oe/HOW_TO_TEST.md b/cmd/oe/HOW_TO_TEST.md index 7d156bb53..9f5924424 100644 --- a/cmd/oe/HOW_TO_TEST.md +++ b/cmd/oe/HOW_TO_TEST.md @@ -169,7 +169,7 @@ curl -X POST http://localhost:4000/sdl/validate \ ### 5. Compatibility Checking Tests -#### TC-009: Check Backward Compatible Changes +#### TC-009: Detect Breaking Schema Changes **Command**: ```bash curl -X POST http://localhost:4000/sdl/check-compatibility \ @@ -186,9 +186,12 @@ curl -X POST http://localhost:4000/sdl/check-compatibility \ } ``` -### 6. Federator Integration Tests +### 6. Policy Gate Integration Tests -#### TC-010: Test Federator with Database Schema (Version 1.0.0) +These cases stop at PDP/CE rejection before federation runs. They confirm policy +integration wiring, not federator/schema-selection/array-processing success. + +#### TC-010: Federated Query Blocked by Consent Engine (Schema Version 1.0.0) **Command**: ```bash curl -X POST http://localhost:4000/ \ @@ -197,7 +200,7 @@ curl -X POST http://localhost:4000/ \ "query": "query GetData { personInfo(nic: \"199512345678\") { fullName } }" }' ``` -**Result**: **PASSED** - Federator using database schema: +**Result**: **PASSED** - Request reaches CE and is rejected while consent is pending: ```json { "data": null, @@ -214,7 +217,7 @@ curl -X POST http://localhost:4000/ \ } ``` -#### TC-011: Test Federator with Database Schema (Version 1.1.0) +#### TC-011: Federated Query Blocked by PDP (Schema Version 1.1.0) **Command**: ```bash curl -X POST http://localhost:4000/ \ @@ -223,7 +226,7 @@ curl -X POST http://localhost:4000/ \ "query": "query { hello }" }' ``` -**Result**: **PASSED** - Federator using new active schema from database: +**Result**: **PASSED** - Request reaches PDP and is rejected: ```json { "data": null, @@ -238,9 +241,12 @@ curl -X POST http://localhost:4000/ \ } ``` -### 7. Array and Non-Array Query Tests +### 7. Policy Gate Tests for Array and Nested Queries + +Same gate behavior as above; these queries never reach array/non-array federation +processing while PDP/CE reject the request. -#### TC-012: Array Query Test +#### TC-012: Array Query Blocked by PDP **Command**: ```bash curl -X POST http://localhost:4000/ \ @@ -249,7 +255,7 @@ curl -X POST http://localhost:4000/ \ "query": "query GetData { personInfo(nic: \"199512345678\") { ownedVehicles { regNo make model year } } }" }' ``` -**Result**: **PASSED** - Array processing working correctly: +**Result**: **PASSED** - Array-shaped query rejected by PDP before federation: ```json { "data": null, @@ -264,7 +270,7 @@ curl -X POST http://localhost:4000/ \ } ``` -#### TC-013: Non-Array Query Test +#### TC-013: Nested Query Blocked by Consent Engine **Command**: ```bash curl -X POST http://localhost:4000/ \ @@ -273,7 +279,7 @@ curl -X POST http://localhost:4000/ \ "query": "query GetData { personInfo(nic: \"199512345678\") { profession otherNames birthInfo { birthRegistrationNumber birthPlace } } }" }' ``` -**Result**: **PASSED** - Non-array processing working correctly: +**Result**: **PASSED** - Nested query rejected by CE before federation: ```json { "data": null, @@ -336,8 +342,7 @@ uses `unified_schemas` table from database and falls back to 3. **Schema Management**: Full CRUD operations working with database persistence 4. **Real-time Switching**: Schema activation changes immediately reflected in federator 5. **Error Handling**: Robust error handling with proper fallback mechanisms -6. **Array Processing**: Both array and non-array queries processed correctly -7. **Policy Integration**: PDP and CE integration working correctly +6. **Policy Integration**: PDP and CE rejection paths are exercised by federated queries (TC-010–TC-013) ## SQL Commands for Database Management diff --git a/cmd/oe/PROVIDER_CONFIGURATION.md b/cmd/oe/PROVIDER_CONFIGURATION.md index ffc546595..66026748d 100644 --- a/cmd/oe/PROVIDER_CONFIGURATION.md +++ b/cmd/oe/PROVIDER_CONFIGURATION.md @@ -104,7 +104,7 @@ new provider, Registrar General Department of Farajaland (RGDF), as an example. ```graphql query PersonInfoQueryrgdf { getPersonInfo { - name + fullName birthRegistrationNumber } } diff --git a/internal/oe/auth/types.go b/internal/oe/auth/types.go index b3e2cd3ae..baf4c174e 100644 --- a/internal/oe/auth/types.go +++ b/internal/oe/auth/types.go @@ -2,7 +2,7 @@ package auth // ConsumerAssertion represents the parsed and validated M2M token claims. type ConsumerAssertion struct { - ApplicationID string // Mapped from 'application_id' + ApplicationID string // Mapped from validated 'client_id' (application identity) ClientID string // Mapped from 'client_id' Subscriber string // Mapped from 'sub' or 'azp' Iss string // Mapped from 'iss' diff --git a/internal/oe/federator/federator_test.go b/internal/oe/federator/federator_test.go index d6948032d..58373037c 100644 --- a/internal/oe/federator/federator_test.go +++ b/internal/oe/federator/federator_test.go @@ -309,6 +309,7 @@ func TestSchemaCollection(t *testing.T) { assert.NoError(t, err, tt.description) assert.NotNil(t, response, "Response should not be nil") assert.EqualValues(t, response.ProviderFieldMap, tt.expectedFields, "Should contain field: %s", tt.expectedFields) + assert.Len(t, response.Arguments, tt.expectedArgs, "Should extract expected number of query arguments") }) } }