Skip to content

test: pin /api/me contract and AuthorityInterceptor authority-source behavior#24497

Merged
netroms merged 2 commits into
masterfrom
test/auth-fast-layer-pins
Jul 21, 2026
Merged

test: pin /api/me contract and AuthorityInterceptor authority-source behavior#24497
netroms merged 2 commits into
masterfrom
test/auth-fast-layer-pins

Conversation

@netroms

@netroms netroms commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Characterization tests that pin current security behavior.

  • AuthorityInterceptorTest (new, unit): pins that @RequiresAuthority reads authorities from Authentication.getAuthorities() (the token), never from the principal. Impersonation exit depends on this via SwitchUserGrantedAuthority. Also pins the implicit ALL bypass, method-over-class annotation precedence, and the exact 403 message format.
  • MeControllerTest (+4): pins the /api/me response shape — username vs display name, exact authorities set, /me/authorization/{auth} semantics incl. superuser bypass, impersonation fields absent by default.
  • ImpersonateUserControllerTest (+3): pins that /api/me impersonation carries the impersonator username (not display name) while impersonating, plus canImpersonate visibility rules.

These pins document current behavior; changing any of them should be a deliberate, reviewed decision.

Testing

All three classes run locally: 43/43 green (12 + 32 + 11).

AI Assisted

…behavior

Characterization tests protecting the security refactoring work:

- AuthorityInterceptorTest (new): pins that @RequiresAuthority reads
  authorities from Authentication.getAuthorities() (the token), never
  from the principal. Impersonation exit depends on this via
  SwitchUserGrantedAuthority. Also pins the ALL bypass, method-over-class
  annotation precedence, and the exact 403 message format.
- MeControllerTest: pins the /api/me response shape (username vs display
  name, exact authorities set, authorization endpoint semantics incl.
  superuser bypass, impersonation fields absent by default).
- ImpersonateUserControllerTest: pins that /api/me 'impersonation' is the
  impersonator USERNAME (not display name) during impersonation, and the
  canImpersonate visibility rules.

These pins document current behavior; changing any of them must be a
deliberate, reviewed decision.

AI Assisted
@netroms
netroms force-pushed the test/auth-fast-layer-pins branch from dfb6a22 to b6d003b Compare July 19, 2026 12:20
@netroms
netroms marked this pull request as ready for review July 20, 2026 11:22
@sonarqubecloud

Copy link
Copy Markdown

@netroms
netroms merged commit c4aa911 into master Jul 21, 2026
23 checks passed
@netroms
netroms deleted the test/auth-fast-layer-pins 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