VVeritia documentation

Original sources · POC — modules

PDS — manual testing

poc-code/pds/TESTING.md POC EN updated 2026-12-01 25 KBraw file · styled HTML version

Summarised in: Status & testing · Known inconsistencies

Testing the PDS — manual guide

How to compile, run, and exercise this module by hand — locally, and via the PDS's own Keycloak container (docker/docker-compose.yml). The PDS app itself now also has a Dockerfile (build step 8, ../deploy/compose.yaml), but everything below still describes running the jar directly with ./mvnw/java -jar, which remains the faster inner loop for manual testing. Keep this file in sync when endpoints, error codes, env vars, seed data, or docker/ change (see Maintenance).

Wire contracts: ../contracts.md §2 §4 §8. Module design: spec.md.

A more visual companion, TESTING.html, sits next to this file — same content, sticky TOC, collapsible sections, copy buttons. Self-contained (no external libraries), open it directly in a browser. Regenerate it by hand if this file changes; there is no committed conversion script yet.

What's verified below: every Maven command, every curl that doesn't require a Keycloak token (§4, §6, §7), and §7's @modelcontextprotocol/inspector calls were executed live against a locally-running jar while writing this doc (§7: 2026-09-11, build step 4). This sandbox has no podman installed, so §5's container commands — and, as a consequence, the /accounts/me curl round-trip that depends on them — were not exercised here; the response shown is what AccountControllerTest asserts (JWT mocked, same seed data), not a live capture. Do a first dry run of §5 before relying on it.


Prerequisites

NeedVersionNote
JDK21 (target)the POM targets --release 21; a newer JDK toolchain (e.g. 25) compiles it fine too — confirmed this session
Maven—not required — use the committed wrapper, ./mvnw (pinned 3.9.9)
Podman≥ 4.4, with podman compose (or a docker-compose-compatible tool)needed for GET /accounts/me (the PDS's own Keycloak, bqt realm) and for §8's containerized PDS. Every other section runs the jar directly — no container needed
Node / npx—optional — only to drive /mcp with a raw MCP client (@modelcontextprotocol/inspector, §7 below) by hand. Not needed to compile, test, or run the module itself

The module itself is pure Java/Maven — npm/Node is only for the optional §7 raw-client demo.


1. Compile

Run from poc-code/pds/:

bash
cd poc-code/pds
./mvnw -q compile

2. Automated tests

bash
cd poc-code/pds
./mvnw test

No container needed — every test runs against an in-memory H2 (application-test.yml, jdbc:h2:mem:bqt_test) with the real Flyway migrations applied, and mocks the Keycloak JWT via Spring Security's jwt() test support (no live Keycloak, no network). 51/51 green (re-run 2026-11-30; this section used to say 18/18, the count at build step 4):

ClassTestsCovers
UserControllerUnitTest5pre-existing demo scaffolding (/api/profile, /api/admin/users, /api/public/health) — kept as-is per spec.md §1, not part of this module's own design
accounts.AccountControllerTest3GET /accounts/me — 200 with seeded data, 401 no token, 403 wrong role
linking.AccountLinkControllerTest4GET /pds-jwks.json, POST /account-link/assert — 401/400/200, and the 200 case's JWS is parsed + Ed25519-verified against the JWKS response in the test itself
mcp.GetBalanceToolTest4GetBalanceTool's logic called directly (no HTTP/MCP transport) with a hand-pushed McpPrincipal — no-principal branch, unknown_account (S10), happy path + mcp_call_audit rows, tool definition shape
mcp.ListTransactionsToolTest16list_transactions (step 4b) — max_results/period validation, filtering against the customer's own latest row, and the tool_constraints caps (S18: max_results_exceeds_mandate / period_exceeds_mandate)
mcp.MandateDpopFilterTest15the isolated /mcp/** filter (step 6) driven directly with real signed material — happy path, S2/S3/S5–S9/S14/S15, plus the discovery exemption (initialize/notifications/initialized/tools/list pass, unauthenticated tools/call denied) and tool_constraints carried opaquely into the principal
mcp.McpAuditControllerTest2GET /mcp-audit/:jti (step 9b) — rows for a known jti, 200 [] for an unknown one
mcp.McpRouteIntegrationTest2a real MCP Java SDK client over Streamable HTTP against /mcp on a random port — discovery succeeds with no Authorization header; tools/call with none is rejected by the isolated filter

3. Package

bash
cd poc-code/pds
./mvnw -DskipTests package

Produces target/keycloak-spring-boot-oauth2-1.0.0.jar (the Maven artifactId/version — unchanged from the cloned base repo, not renamed).

4. Run it locally

Two equivalent ways, both from poc-code/pds/, both on port 8081:

bash
# A — dev loop (recompiles on next run, not live-reload)
./mvnw spring-boot:run

# B — the packaged jar (what step 3 above produced)
java -jar target/keycloak-spring-boot-oauth2-1.0.0.jar

Boots in a few seconds with no other service running — Ctrl-C to stop. On first boot it:

  • creates ./data/bqt.mv.db (H2 file-mode DB) and runs the two Flyway migrations (seeds cust-001..003 / pacr_bqt_* / 3 accounts — exact contracts.md §4 rows);
  • generates ./data/pds-assertion.jwk.json (the bqt-assertion-1 Ed25519 signing key) if it doesn't already exist, and reuses it on every later boot (same public key — verified by restarting and diffing GET /pds-jwks.json while writing this doc).

Both paths are git-ignored (poc-code/**/data/, repo .gitignore) — delete ./data/ to reset to a clean seeded state, or to force a fresh assertion key.

Works immediately, no Keycloak needed: GET /pds-jwks.json, POST /account-link/assert. Needs the Keycloak container below: GET /accounts/me only.


5. The PDS's own Keycloak (only needed for /accounts/me)

This is the bank's pre-existing identity system (bqt realm) — unrelated to the platform's mandate JWT / DPoP layer, which doesn't exist yet (steps 4/6). docker/realm-export.json defines client bqt-rest (secret bqt-secret, direct-access-grants on) and three users — pieter / sofie / noah, password demo for all, realm role CUSTOMER.

Option A — podman compose (uses the committed docker/docker-compose.yml)

bash
cd poc-code/pds/docker
podman compose up -d
podman compose ps            # wait until "healthy" — first boot can take ~30-60s

Stop it:

bash
cd poc-code/pds/docker
podman compose down          # KC_DB=dev-mem — in-memory, nothing to lose, no -v needed

Option B — bare podman run (no compose; matches spec.md §11)

bash
cd poc-code/pds/docker
podman run -d --name bqt-keycloak \
  -p 8080:8080 \
  -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin -e KC_DB=dev-mem \
  -v "$(pwd)/realm-export.json:/opt/keycloak/data/import/bqt-realm.json:ro,Z" \
  quay.io/keycloak/keycloak:26.0 start-dev --import-realm

(:Z on the volume mount is for SELinux hosts — Fedora/RHEL — harmless to leave on other Linux; drop it if podman run complains about it.)

bash
podman logs -f bqt-keycloak   # watch boot / confirm "Imported realm bqt"
podman stop bqt-keycloak && podman rm bqt-keycloak

Get a token and call /accounts/me

The PDS app (step 4 above) must already be running on :8081.

bash
TOKEN=$(curl -s -X POST http://localhost:8080/realms/bqt/protocol/openid-connect/token \
  -d grant_type=password -d client_id=bqt-rest -d client_secret=bqt-secret \
  -d username=sofie -d password=demo | grep -o '"access_token":"[^"]*"' | cut -d'"' -f4)

curl -s -H "Authorization: Bearer $TOKEN" http://localhost:8081/accounts/me; echo
# {"customer_id":"cust-002","display_name":"Sofie Maes","iban":"BE71 0961 2345 6769",
#  "currency":"EUR","balance":"12802.50","as_of":"2026-09-01T00:00:00Z"}

curl -s -w '\n[%{http_code}]\n' http://localhost:8081/accounts/me   # no token → 401

Swap username=sofie for pieter (→ cust-001) or noah (→ cust-003) to see the other two seeded accounts. The 403-wrong-role case isn't easily reachable by hand (every seeded user has CUSTOMER) — it's covered by AccountControllerTest in the automated suite instead.


6. The account-linking flow (contracts.md §8) — no Keycloak needed

Only the PDS app (step 4) needs to be running. X-Poc-Dev-Auth: poc-dev-secret is the whole "customer authentication" here — see the loud comment in AccountLinkController for what that replaces in production.

bash
B=http://localhost:8081

# the PDS's public assertion key
curl -s $B/pds-jwks.json; echo
# {"keys":[{"kty":"OKP","use":"sig","crv":"Ed25519","kid":"bqt-assertion-1","x":"…","alg":"EdDSA"}]}

# 401 — missing the dev-secret header
curl -s -w '\n[%{http_code}]\n' -X POST $B/account-link/assert \
  -H 'content-type: application/json' -d '{"pds_customer_id":"cust-002"}'

# 400 — header present, but the customer id isn't seeded
curl -s -w '\n[%{http_code}]\n' -X POST $B/account-link/assert \
  -H 'content-type: application/json' -H 'X-Poc-Dev-Auth: poc-dev-secret' \
  -d '{"pds_customer_id":"cust-999"}'

# 200 — the real path
ASSERTION=$(curl -s -X POST $B/account-link/assert \
  -H 'content-type: application/json' -H 'X-Poc-Dev-Auth: poc-dev-secret' \
  -d '{"pds_customer_id":"cust-002"}' | grep -o '"assertion":"[^"]*"' | cut -d'"' -f4)

echo "$ASSERTION" | cut -d. -f2 | tr '_-' '/+' | base64 -d 2>/dev/null; echo   # inspect claims
# {"iss":"9b7c1e40-2f6a-4c11-9e2a-000000000bqt","aud":"https://veritia.eu",
#  "sub":"pacr_bqt_2c8d40","exp":…,"iat":…,"jti":"…"}

Replaying the same cust_customer_id call again still succeeds (a fresh jti each time, by design — single-use enforcement is the stub's job, platform/stub/src/assertion.ts tracking usedAssertionJti, not the PDS's).

This is exactly what the platform stub's POST /account-link/initiate calls server-to-server (PDS_ASSERT_URI / PDS_ASSERTION_JWKS_URI) — see ../platform/stub/TESTING.md for that half, and point its env at this PDS instance (PDS_ASSERT_URI=http://localhost:8081/account-link/assert, PDS_ASSERTION_JWKS_URI=http://localhost:8081/pds-jwks.json) to run the two modules together.


7. The MCP route (contracts.md §2, spec.md §8/§9) — /mcp, no Keycloak needed

Only the PDS app needs to be running. /mcp/** is protected by the isolated filter (MandateDpopFilter, build step 6, spec.md §9) — but initialize / notifications/initialized / tools/list are deliberately exempt (discovery, contracts §5.2), so they work with no auth at all. tools/call is never exempt — it needs a real signed mandate JWT + DPoP proof, which plain curl/inspector can't produce (see below for what exercises that instead).

Streamable HTTP negotiates protocol 2025-11-25 (session-scoped — spike-notes.md), so a bare tools/list doesn't work; a client must initialize first.

@modelcontextprotocol/inspector --cli does NOT currently work for anonymous discovery, despite tools/list being exempt — verified live 2026-09-25. Its Streamable HTTP client opens a GET /mcp request (the session-bound SSE stream) as part of connecting, interleaved with the initialize/notifications/initialized POSTs; GET /mcp carries no body, so the filter's method-based exemption (which only inspects POST JSON-RPC bodies) can't recognize it as a discovery call, and it gets the normal 401 missing_dpop like any other unauthenticated request — which appears to fail the whole CLI session, not just that one call. This is not a regression (pre-fix, discovery was blocked entirely too) but it does mean the exemption is complete for what this product actually needs — the platform stub's registration-time discovery, platform/stub/src/mcp-discover.ts, which never opens a GET stream, only three plain POSTs — without being complete for every spec-compliant Streamable HTTP client. Use the curl sequence below to verify discovery by hand instead; it mirrors mcp-discover.ts exactly.

bash
B=http://localhost:8081

# 1. initialize — no auth headers, exempt
curl -s -i -X POST $B/mcp -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"curl-test","version":"0.0.1"}}}'
# HTTP/1.1 200, header Mcp-Session-Id: <uuid> — save it as SID below
# {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-11-25",...,"serverInfo":{"name":"bqt-pds","version":"0.0.1"}}}

SID=<paste the Mcp-Session-Id header value>

# 2. notifications/initialized — still no auth headers
curl -s -o /dev/null -w "status: %{http_code}\n" -X POST $B/mcp -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' -H "Mcp-Session-Id: $SID" -H "MCP-Protocol-Version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}'
# status: 202

# 3. tools/list — still no auth headers
curl -s -X POST $B/mcp -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' -H "Mcp-Session-Id: $SID" -H "MCP-Protocol-Version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'
# real tool list back, e.g.:
# data:{"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"get_balance",...},{"name":"list_transactions",...}]}}

# 4. tools/call — same no-auth request, but this one IS gated (contracts §2 step 1)
curl -s -i -X POST $B/mcp -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' -H "Mcp-Session-Id: $SID" -H "MCP-Protocol-Version: 2025-11-25" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_balance","arguments":{}}}'
# HTTP/1.1 401, WWW-Authenticate: DPoP error="missing_dpop", {"error":"missing_dpop"}

What's not exercisable from plain curl

A real tools/call needs a genuine signed delegation JWT + DPoP proof (contracts §2 steps 1–18) — curl can't produce those by hand. Two things do exercise the full path:

  • MandateDpopFilterTest (pds/src/test/java/.../mcp/) — hand-forges real signed material against an in-process platform test double, covering the happy path and every fail code (S2/S3/S5–S9/S14/S15) at the filter level, no HTTP transport involved.
  • The real Outil Local, end to end — a real minted mandate, a real Ed25519 agent keypair, a real DPoP-signed tools/call over Streamable HTTP against this exact route. Live-verified 2026-09-19 (poc-code/step-6-checklist.md).

8. Containerized PDS (Dockerfile + deploy/compose.yaml, build step 8)

Unlike the stub's Dockerfile (platform/stub/TESTING.md's Option B), the PDS image is rarely useful standalone — /accounts/me needs pds-keycloak reachable and /mcp/** (step 6's filter) needs the platform stub's JWKS/introspection reachable, so in practice this runs as part of the full stack, not on its own. Live-tested 2026-10-09 as part of deploy/compose.yaml's first real compose up (step 9) — see Troubleshooting for the two healthcheck bugs found then. (Corrected 2026-11-30: this used to say "not yet live-tested".)

Full stack (recommended — brings up pds-keycloak + web-platform-stub too):

bash
cd poc-code/deploy
./gen-keys.sh                # once, if deploy/keys/ is empty
podman compose up -d --build  # --build: a plain `up -d` reuses a cached image even after
                               # source changes (jar/dist/) — see demo/testing-guide.md §2.3
podman compose ps             # all three healthy?
podman compose logs -f pds

Standalone build/run (only useful to check the image itself boots — /accounts/me will 401/disconnect without a reachable Keycloak, and /mcp/** will fail-closed without a reachable stub, per step 6):

bash
cd poc-code/pds
podman build -t veritia/pds:poc .
podman run --rm -d \
  --name pds \
  -p 8081:8081 \
  -v "$(pwd)/data:/app/data" \
  -e KC_ISSUER_URI=http://localhost:8080/realms/bqt \
  -e MCP_CANONICAL_URI=http://localhost:8081/mcp \
  -e PLATFORM_JWKS_URI=http://localhost:3000/jwks.json \
  -e PLATFORM_INTROSPECT_BASE=http://localhost:3000/introspect \
  -e PLATFORM_EXPECTED_ISS=https://veritia.eu \
  -e PDS_PROVIDER_ID=9b7c1e40-2f6a-4c11-9e2a-000000000bqt \
  -e PDS_ASSERT_DEV_SECRET=poc-dev-secret \
  veritia/pds:poc
podman logs -f pds            # boot log
podman stop pds                # --rm above means it's removed automatically

(Those -e values assume Keycloak and the stub are running on the host, reachable at localhost from inside the container — true on Docker Desktop's default bridge networking, but not true for rootless Podman on Linux/WSL2, where a container's localhost is itself, not the host. On Podman use --network host, or just use the full-stack compose command above, which sidesteps the question entirely via service names.)

Rebuild after a code change — the image is not live-reloading; repeat podman build, then podman stop pds + re-run.


9. Trace Prestataire (GET /mcp-audit/:jti, build step 9b) — no Keycloak needed

Added 2026-10-09 while actually rehearsing demo beat 8 ("two audit trails") — found that mcp_call_audit had existed since steps 3/4 with no way to see it (no log line despite pds/spec.md §5.4 saying there'd be one, no endpoint, no console). This endpoint is what the SPA dashboard's "Trace Prestataire" panel calls directly from the browser (contracts §8.6).

bash
curl -s http://localhost:8081/mcp-audit/<jti-from-a-real-mandate> | jq
# {"jti":"...","provider_trace":[{"ts":"...","decision":"ALLOW","tool_name":"get_balance",
#  "deny_reason":null,"agent_jkt":"...","provider_account_ref":"pacr_bqt_2c8d40",
#  "dpop_jti":"...","request_htu":"http://localhost:8081/mcp"}]}

curl -s http://localhost:8081/mcp-audit/no-such-jti
# {"jti":"no-such-jti","provider_trace":[]}   — 200, not 404 (contracts §8.6)

No auth, no CORS restriction (@CrossOrigin(origins:"*")) — same posture as /pds-jwks.json.


Config (env)

VarDefaultPurpose
KC_ISSUER_URIhttp://localhost:8080/realms/bqt/accounts/me's own Keycloak — unrelated to the platform JWKS below
MCP_CANONICAL_URIhttp://localhost:8081/mcpconsumed by the isolated filter's aud/htu check (step 6). The route path itself still comes from spring.ai.mcp.server.streamable-http.mcp-endpoint (hardcoded /mcp)
PLATFORM_JWKS_URIhttp://localhost:3000/jwks.jsonconsumed by the isolated filter to verify the delegation JWT's RS256 signature (step 6)
PLATFORM_INTROSPECT_BASEhttp://localhost:3000/introspectconsumed by the isolated filter's per-call introspection (step 6)
PLATFORM_EXPECTED_ISShttps://veritia.euconsumed now — the account-link assertion's aud (contracts §8.2)
PDS_PROVIDER_ID9b7c1e40-2f6a-4c11-9e2a-000000000bqtthe assertion's iss
PDS_ASSERTION_KEY_PATH./data/pds-assertion.jwk.jsonwhere bqt-assertion-1 is generated once / reloaded
PDS_ASSERT_DEV_SECRETpoc-dev-secretthe X-Poc-Dev-Auth gate — must match the stub's own PDS_ASSERT_DEV_SECRET

server.port is hardcoded 8081 (not an env var) in application.yml.

Troubleshooting

SymptomCause / fix
./mvnw spring-boot:run fails immediately with a Keycloak connection errorshouldn't happen — jwtDecoder() is lazy (see SecurityConfig javadoc); if it does, something regressed the fix, check it wasn't reverted
/accounts/me → 401 even with a tokentoken from the wrong realm/client (bqt-rest, not the base repo's old demo-app), or expired (900 s lifespan — get a fresh one)
/accounts/me → 403token's realm_access.roles doesn't include CUSTOMER — check the username you authenticated as
/account-link/assert → 401 poc_dev_auth_requiredmissing/wrong X-Poc-Dev-Auth header
/account-link/assert → 400 unknown_customerpds_customer_id isn't one of cust-001/cust-002/cust-003
podman compose ps never shows "healthy" (using docker/docker-compose.yml, Option A)the compose healthcheck curls /health/ready, which Keycloak's start-dev doesn't always expose without KC_HEALTH_ENABLED=true (pre-existing in the cloned base, not changed here — the separate deploy/compose.yaml stack, §8, does set this) — check podman compose logs keycloak for "Imported realm bqt" instead of waiting on healthy
Flyway error on boot: checksum mismatchyou changed a migration file after ./data/bqt.mv.db was already created — delete ./data/ (dev-only, git-ignored)
Boot fails: Connection is broken: SocketTimeoutException: Connect timed out: 10.0.x.x:… (90067)H2 AUTO_SERVER=TRUE's known failure mode — Java's InetAddress.getLocalHost() picked a virtual network interface (rootless Podman's slirp4netns, default subnet 10.0.2.0/24, is the usual culprit on a dev box) instead of a reachable one, and the recorded data/bqt.lock.db host is unreachable. Fixed 2026-09-11 by dropping AUTO_SERVER=TRUE from the datasource URL (plain file mode, exclusive lock, no network server) — if you still hit this, pull the latest application.yml and delete ./data/ (a stale lock file from the old mode can linger)
stale assertion key / provider_jkt mismatch after editing PdsAssertionKeyServicedelete ./data/pds-assertion.jwk.json to force regeneration — only do this deliberately, it invalidates every mandate minted against the old key
podman: command not foundPodman isn't installed — you only need it for /accounts/me and §8's containerized PDS; everything else in this doc works without it
podman compose up -d → Cannot connect to the Docker daemon at unix:///run/user/…/podman/podman.sock (but podman compose version works)rootless Podman's API socket is systemd-activated and doesn't survive a wsl --shutdown/reboot on its own — version never touches the socket so it always "works". Fix: systemctl --user status podman.socket, then systemctl --user enable --now podman.socket if inactive; confirm with ls /run/user/$(id -u)/podman/podman.sock. If systemctl --user doesn't work in your WSL2 distro (systemd not PID 1 — check ps -p 1 -o comm=), start the API manually instead: podman system service --time=0 unix:///run/user/$(id -u)/podman/podman.sock & (leave it running), then retry
podman compose up -d picks /mnt/c/.../Rancher Desktop/.../docker-compose as the "external compose provider"cosmetic, not a conflict — podman compose shells out to whatever docker-compose-compatible binary is on PATH (here, one Rancher Desktop's WSL integration exposed) and points its DOCKER_HOST at Podman's own socket first. The actual failure underneath is almost always the socket issue above, not Rancher. To avoid the detour entirely, install podman-compose natively (apt/pipx) so nothing borrowed is in the loop
deploy/compose.yaml's pds-keycloak stays (unhealthy) forever (so pds never leaves Created)found live 2026-10-09, first real compose up (step 9) — two stacked causes, not the KC_HEALTH_ENABLED one above: (1) Keycloak 26 serves /health/ready on a separate management interface, port 9000, not :8080 — confirmed via its own boot log line "Management interface listening on http://0.0.0.0:9000"; (2) this image ships no curl/wget/which at all — confirmed via podman exec <container> which curl → "executable file not found" — so no HTTP-based healthcheck works on it regardless of port. Fixed in deploy/compose.yaml with a plain TCP-connect probe against :9000 via bash's /dev/tcp (bash -c 'exec 3<>/dev/tcp/127.0.0.1/9000' — kc.sh needs bash, so it's always present); weaker than a true readiness check but live-confirmed sufficient (podman ps -a → (healthy), pds then starts). Full detail: deploy/spec.md §2

Maintenance

Update this file in the same change that touches:

ChangeUpdate here
add/remove/rename an endpointthe relevant numbered section + its curl example
new/changed error codethe relevant curl block + Troubleshooting
new env var or defaultConfig table
docker/docker-compose.yml / docker/realm-export.json§5 (both options)
build step 4 (MCP route) lands✅ done — §7 added
build step 6 (isolated filter) lands✅ done 2026-09-19, discovery exemption fixed 2026-09-25 — §7 rewritten to match
a PDS Dockerfile / deploy/compose.yaml (step 8) lands✅ done 2026-09-26 — §8 added
Trace Prestataire endpoint (step 9b) lands✅ done 2026-10-09 — §9 added
Generated 2026-11-30 by documentation/build.mjs · edit the Markdown, never this HTML.