Skip to content

nsc-events-fullstack_32_161_role_guard#165

Closed
NahomAlemu wants to merge 1 commit into
mainfrom
chore-161-role-auth-guard-test
Closed

nsc-events-fullstack_32_161_role_guard#165
NahomAlemu wants to merge 1 commit into
mainfrom
chore-161-role-auth-guard-test

Conversation

@NahomAlemu
Copy link
Copy Markdown
Contributor

Summary & Changes 📃

  • Resolves: Issue: Add Unit Tests for Role-Based Authorization Guard #161

  • Summary: Adds unit tests for the RoleGuard class to ensure proper role-based access control.

    • 🔨 Adds missing test coverage for the role-based authorization guard
    • 👀 Tests verify that routes enforce correct role restrictions (admin, creator, user)
    • 🗨️ Achieves 100% code coverage across statements, branches, functions, and lines
  • Changes:

    • ✅ Added role.guard.spec.ts with 26 test cases covering:
    • Guard instantiation and dependency injection
    • matchRoles method logic
    • Routes without @roles decorator (allow all)
    • Routes with @roles decorator (enforce restrictions)
    • RBAC scenarios (admin-only, admin-or-creator, etc.)
    • 🛠️ No breaking changes
    • 📝 Follows existing codebase testing patterns

Screenshots / Visual Aids 🔎

📌 Required for: UI changes, layout updates, or bug fixes.

Expand ⬇️ Screenshot 2026-02-26 at 12 36 26 PM Screenshot 2026-02-26 at 12 36 22 PM

How to Test 🧪

  1. Steps to Reproduce:
    - Step 1: Navigate to the nsc-events-nestjs directory
    - Step 2: Run with coverage: npm run test -- --coverage role.guard.spec.ts
  2. Expected Behavior: All 26 tests pass with 100% coverage

Checklist ✅

  • I have tested this PR locally and it works as expected.
  • This PR resolves an issue (Resolves #issue-number).
  • Reviewers, assignees(self), tags, and labels are correctly assigned.
  • Squash commits and enable auto-merge if approved.

@github-actions
Copy link
Copy Markdown

✅ Full E2E Test Results

Running full test suite (critical files changed)

Status Count
✅ Passed 47
❌ Failed 0
📊 Total 47

View detailed report

@NahomAlemu NahomAlemu changed the title nsc-events-fullstack_32_160_role_guard nsc-events-fullstack_32_161_role_guard Feb 27, 2026
@NahomAlemu NahomAlemu linked an issue Mar 7, 2026 that may be closed by this pull request
4 tasks
@gitbiruk2010 gitbiruk2010 self-requested a review April 27, 2026 18:34
Copy link
Copy Markdown
Contributor

@gitbiruk2010 gitbiruk2010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Copy link
Copy Markdown
Contributor

@TVW96 TVW96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image Screenshot 2026-04-28 at 2 12 08 PM

@NahomAlemu
Copy link
Copy Markdown
Contributor Author

Since my practicum work has ended, I'm closing this PR to keep the repository tidy. I won't be able to address future feedback, but feel free to use this branch as a reference if the feature is needed later!

@NahomAlemu NahomAlemu closed this May 7, 2026
@NahomAlemu NahomAlemu deleted the chore-161-role-auth-guard-test branch May 7, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unit-test Small-scope logic validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue: Add Unit Tests for Role-Based Authorization Guard

3 participants