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.
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
| Need | Version | Note |
|---|---|---|
| JDK | 21 (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/:
cd poc-code/pds
./mvnw -q compile▸2. Automated tests
cd poc-code/pds
./mvnw testNo 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). 18/18 green:
| Class | Tests | Covers |
|---|---|---|
UserControllerUnitTest | 5 | pre-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.AccountControllerTest | 3 | GET /accounts/me — 200 with seeded data, 401 no token, 403 wrong role |
linking.AccountLinkControllerTest | 4 | GET /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.GetBalanceToolTest | 4 | GetBalanceTool'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.McpRouteIntegrationTest | 2 | a real MCP Java SDK client (McpClient.sync(...)) over Streamable HTTP against /mcp on a random port — tools/list returns get_balance; tools/call without the (not-yet-built) step-6 filter returns the documented no_mandate_context tool error |
▸3. Package
cd poc-code/pds
./mvnw -DskipTests packageProduces 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:
# 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.jarBoots 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(thebqt-assertion-1Ed25519 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)
cd poc-code/pds/docker
podman compose up -d
podman compose ps # wait until "healthy" — first boot can take ~30-60sStop it:
cd poc-code/pds/docker
podman compose down # KC_DB=dev-mem — in-memory, nothing to lose, no -v neededOption B — bare podman run (no compose; matches spec.md §11)
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.)
podman logs -f bqt-keycloak # watch boot / confirm "Imported realm bqt"
podman stop bqt-keycloak && podman rm bqt-keycloakGet a token and call /accounts/me
The PDS app (step 4 above) must already be running on :8081.
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 → 401Swap 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.
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.
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. Not yet live-tested — no podman/docker in the sandbox that wrote this section (2026-09-26); first real run is step 9's job.
Full stack (recommended — brings up pds-keycloak + web-platform-stub too):
cd poc-code/deploy
./gen-keys.sh # once, if deploy/keys/ is empty
podman compose up -d --build # --build: avoids reusing a stale cached image after a source change
podman compose ps # all three healthy?
podman compose logs -f pdsStandalone 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):
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.
▸Config (env)
| Var | Default | Purpose |
|---|---|---|
KC_ISSUER_URI | http://localhost:8080/realms/bqt | /accounts/me's own Keycloak — unrelated to the platform JWKS below |
MCP_CANONICAL_URI | http://localhost:8081/mcp | consumed 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_URI | http://localhost:3000/jwks.json | consumed by the isolated filter to verify the delegation JWT's RS256 signature (step 6) |
PLATFORM_INTROSPECT_BASE | http://localhost:3000/introspect | consumed by the isolated filter's per-call introspection (step 6) |
PLATFORM_EXPECTED_ISS | https://veritia.eu | consumed now — the account-link assertion's aud (contracts §8.2) |
PDS_PROVIDER_ID | 9b7c1e40-2f6a-4c11-9e2a-000000000bqt | the assertion's iss |
PDS_ASSERTION_KEY_PATH | ./data/pds-assertion.jwk.json | where bqt-assertion-1 is generated once / reloaded |
PDS_ASSERT_DEV_SECRET | poc-dev-secret | the 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
| Symptom | Cause / fix |
|---|---|
./mvnw spring-boot:run fails immediately with a Keycloak connection error | shouldn'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 token | token 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 → 403 | token's realm_access.roles doesn't include CUSTOMER — check the username you authenticated as |
/account-link/assert → 401 poc_dev_auth_required | missing/wrong X-Poc-Dev-Auth header |
/account-link/assert → 400 unknown_customer | pds_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 mismatch | you 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 PdsAssertionKeyService | delete ./data/pds-assertion.jwk.json to force regeneration — only do this deliberately, it invalidates every mandate minted against the old key |
podman: command not found | Podman 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 |
▸Maintenance
Update this file in the same change that touches:
| Change | Update here |
|---|---|
| add/remove/rename an endpoint | the relevant numbered section + its curl example |
| new/changed error code | the relevant curl block + Troubleshooting |
| new env var or default | Config 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 |