Skip to content

test: authorization-outcome matrix across auth mechanisms and impersonation e2e#24498

Merged
netroms merged 2 commits into
masterfrom
test/auth-matrix-e2e
Jul 21, 2026
Merged

test: authorization-outcome matrix across auth mechanisms and impersonation e2e#24498
netroms merged 2 commits into
masterfrom
test/auth-matrix-e2e

Conversation

@netroms

@netroms netroms commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

E2e tests (default profile, every PR) asserting authorization outcomes are IDENTICAL regardless of authentication mechanism, plus full impersonation flow coverage. Part of the auth coverage initiative preceding the UserDetails/interceptor refactoring; companion to #24497.

  • AuthMechanism: turns credentials into authenticated request headers for SESSION_COOKIE, BASIC, PAT.
  • AuthorizationMatrixTest (parameterized over mechanisms): exact @RequiresAuthority 403 message contract, authority-granted, implicit ALL bypass, sharing ACL (private metadata 404 to others); plus org-unit capture scope on data value writes (E8011 pin) and basic-auth rejection for TOTP-2FA users.
  • ImpersonationTest (cookie jar): impersonate -> act as target -> /me shows impersonator USERNAME -> exit; negative cases with exact message contracts; pin that re-login in the same session invalidates impersonation state.
  • Infra: impersonation enabled in the e2e dhis.conf; fixed compose subnet + static test-container IP (the IP allowlist is an exact string match).

Testing

Verified against the local compose stack: 20/20 green, ~6s added to the default profile.

AI Assisted

…nation e2e

Adds e2e coverage (default profile, every PR) asserting that authorization
outcomes are identical regardless of authentication mechanism, and full
impersonation flow tests over a real session:

- AuthMechanism: turns (username, password) into authenticated request
  headers for SESSION_COOKIE (form login), BASIC, and PAT.
- AuthorizationMatrixTest, parameterized over the mechanisms: exact
  @RequiresAuthority 403 message contract, authority-granted, implicit
  ALL bypass, sharing ACL (private metadata invisible to others, 404
  pin); plus org-unit capture scope on data value writes (E8011 pin)
  and basic-auth rejection for TOTP-2FA-enabled users.
- ImpersonationTest: impersonate -> act as target (target's authorities
  apply) -> /me shows impersonator USERNAME -> exit restores original;
  negatives incl. the exact 403/400 message contracts, self- and
  superuser-impersonation refusals, and a pin that re-login in the same
  session invalidates impersonation state (exit denied).
- Impersonation enabled in the e2e dhis.conf; fixed compose subnet and
  a static IP for the test container because switch_user_allow_listed_ips
  is an exact string match.

Verified locally against the compose stack: 20/20 green, ~6s added to
the default profile.

AI Assisted
@netroms
netroms requested a review from a team as a code owner July 19, 2026 08:23
@netroms
netroms marked this pull request as draft July 19, 2026 08:44
@netroms
netroms marked this pull request as ready for review July 20, 2026 11:24
@sonarqubecloud

Copy link
Copy Markdown

@netroms
netroms merged commit ff51962 into master Jul 21, 2026
23 checks passed
@netroms
netroms deleted the test/auth-matrix-e2e branch July 21, 2026 09:09
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.

3 participants