Skip to content

test(auth): add unit tests for RequireSuperAdmin and RequireAdminOrAbove#391

Open
zeevdr wants to merge 1 commit into
mainfrom
issue-301-require-superadmin-tests
Open

test(auth): add unit tests for RequireSuperAdmin and RequireAdminOrAbove#391
zeevdr wants to merge 1 commit into
mainfrom
issue-301-require-superadmin-tests

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 14, 2026

Summary

  • RequireSuperAdmin, RequireAdminOrAbove, and the package-level IsSuperAdmin had no direct unit tests — only indirect coverage through the service layer.
  • Adding table-driven tests that cover every role (superadmin, admin, user) plus the no-claims permissive path for each function, making regressions immediately visible at the lowest possible level.

Test plan

  • TestRequireSuperAdmin — 4 cases: no claims, superadmin, admin, user.
  • TestRequireAdminOrAbove — 4 cases: no claims, superadmin, admin, user.
  • TestIsSuperAdmin — 4 inline assertions covering no claims and all three roles.
  • All tests pass under go test ./internal/auth/....
  • make lint passes.

Closes #301

🤖 Generated with Claude Code

…, IsSuperAdmin

These access helpers had no direct tests. The table-driven tests cover
all three role levels (superadmin, admin, user) plus the no-claims
permissive path for each function.

Co-Authored-By: Claude <noreply@anthropic.com>
Closes #301
@zeevdr zeevdr added this to the v0.11.0-alpha.2 milestone May 14, 2026
@zeevdr zeevdr added enhancement New feature or request server Server changes size: S Quick win — a few hours or less priority: P2 Nice-to-have labels May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: P2 Nice-to-have server Server changes size: S Quick win — a few hours or less

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Direct unit tests for RequireSuperAdmin / RequireAdminOrAbove

1 participant