Skip to content

test(ledger): assert full scope matrix per endpoint - #139

Merged
tiana-code merged 1 commit into
mainfrom
feat/E-01-authz-contract-matrix
Jun 16, 2026
Merged

test(ledger): assert full scope matrix per endpoint#139
tiana-code merged 1 commit into
mainfrom
feat/E-01-authz-contract-matrix

Conversation

@tiana-code

Copy link
Copy Markdown
Owner

What

Upgrades ScopeAuthorizationMatrixIT to a full per-endpoint authorization contract: for every ledger endpoint it asserts the matching scope grants a genuine 2xx, the opposite scope returns 403, and a request with no token returns 401.

Why

The prior matrix only checked wrong-scope 403 and a weak != 403/401 proxy against unseeded ids, so it could never observe a real 2xx and had no no-token case. This guards against authorization regressions when endpoints are added.

How

  • Lazy data-driven table (method, path supplier, required scope, optional body), the single extension point for new endpoints.
  • @BeforeEach seeds two accounts, a read-target transaction, and a dedicated POSTED reversal target via the application services, so the correct-scope path executes against real state.
  • Balanced double-entry seed body uses signed amounts (DEBIT 100.00 / CREDIT -100.00) summing to zero.
  • In-process alg=none JwtDecoder maps the bearer value to the scope claim, exercising the real SecurityConfig matchers without a live Keycloak.
  • Outbox cleaned @AfterEach; hikari pool capped at 2; UUID correlation id on every request.

Test-only slice, no production code changed. integrationTest runs on CI (no Docker in the dev WSL).

Closes #60

Upgrade ScopeAuthorizationMatrixIT to assert, per ledger endpoint, that the
matching scope grants a genuine 2xx, the opposite scope returns 403, and a
request with no token returns 401. Seed real accounts and a dedicated reversal
target so the correct-scope path executes against existing state instead of a
not-forbidden proxy. The single data-driven table is the only extension point
for new endpoints.

Closes #60
@tiana-code
tiana-code merged commit c8efc35 into main Jun 16, 2026
6 checks passed
@tiana-code
tiana-code deleted the feat/E-01-authz-contract-matrix branch June 16, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Authz contract test per endpoint (scope matrix)

1 participant