Skip to content

Commit 1d00485

Browse files
committed
wip: auth tests
1 parent f10d1cc commit 1d00485

File tree

3 files changed

+531
-52
lines changed

3 files changed

+531
-52
lines changed

frontend/app/middleware/auth.global.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default defineNuxtRouteMiddleware(async (to) => {
22
// Skip auth check for callback page
3-
if (to.path.includes('/callback')) {
3+
if (to.path === '/callback') {
44
return
55
}
66

frontend/test/unit/AUTH_TESTS.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Tests pure functions related to authentication:
2121

2222
**Run:** `pnpm test -- auth-helpers.test.ts`
2323

24-
### `auth.test.ts` (88 tests - **41 IMPLEMENTED, 47 SCAFFOLDED**)
24+
### `auth.test.ts` (87 tests - **57 IMPLEMENTED, 30 SCAFFOLDED**)
2525

26-
**Status:** Core auth functionality and callback page tests implemented and passing
26+
**Status:** Core auth functionality, callback page, and middleware tests implemented and passing
2727

2828
Implemented tests for:
2929

@@ -70,9 +70,28 @@ Implemented tests for:
7070
- Hash preservation in redirects
7171
- Array redirect parameter handling
7272

73-
Still scaffolded (placeholders - 47 tests):
73+
-**Global Auth Middleware** (6 tests)
74+
- Callback page access without token
75+
- Redirect to login for protected routes
76+
- Allow access with valid token
77+
- Token check on every navigation
78+
- Callback route variations
79+
- Routes containing 'callback' in path
80+
81+
-**Admin Middleware** (10 tests)
82+
- Superadmin access to admin routes
83+
- Admin access to admin routes
84+
- Block regular users (403 error)
85+
- Redirect to login if no token
86+
- Return 403 for non-admin users
87+
- Wait for me query to complete
88+
- Timeout handling for slow queries
89+
- Handle me query errors
90+
- Only check /admin routes
91+
- Nested admin routes
92+
93+
Still scaffolded (placeholders - 30 tests):
7494

75-
- Middleware protection
7695
- Security tests
7796
- Integration tests
7897

@@ -313,16 +332,16 @@ pnpm test -- auth --watch
313332
| useAuth Composable - Role Authorization | 100% ✅ | 100% |
314333
| useAuth Composable - Me Query | 100% ✅ | 100% |
315334
| Callback Page Token Validation | 100% ✅ | 100% |
316-
| Auth Middleware | 0% | 95% |
317-
| Admin Middleware | 0% | 90% |
335+
| Global Auth Middleware | 100% ✅ | 100% |
336+
| Admin Middleware | 100% ✅ | 100% |
318337
| Integration | 0% | 80% |
319338

320-
**Total Progress: 124 tests passing (77 fully implemented, 47 scaffolded)**
339+
**Total Progress: 123 tests passing (93 fully implemented, 30 scaffolded)**
321340

322341
**Breakdown:**
323342

324343
- `auth-helpers.test.ts`: 36 tests (100% implemented)
325-
- `auth.test.ts`: 41 implemented + 47 scaffolded = 88 tests
344+
- `auth.test.ts`: 57 implemented + 30 scaffolded = 87 tests
326345

327346
## Next Steps
328347

@@ -332,9 +351,9 @@ pnpm test -- auth --watch
332351
4.**Completed:** Implemented role-based authorization tests (9 tests)
333352
5.**Completed:** Implemented GraphQL me query tests (6 tests)
334353
6.**Completed:** Implemented callback page validation tests (12 tests)
335-
7. **Next:** Implement auth middleware protection tests
336-
8. **Next:** Implement admin middleware tests
337-
9. **Future:** Complete security and integration tests
354+
7. **Completed:** Implemented global auth middleware tests (6 tests)
355+
8. **Completed:** Implemented admin middleware tests (10 tests)
356+
9. **Future:** Complete security and integration tests (30 remaining scaffolded tests)
338357

339358
## References
340359

0 commit comments

Comments
 (0)