2026-03-16 21:07:16 +00:00
|
|
|
const request = require('supertest');
|
2026-03-16 22:06:48 +00:00
|
|
|
const app = require('../src/server.js');
|
2026-03-16 21:07:16 +00:00
|
|
|
|
2026-03-16 22:06:48 +00:00
|
|
|
describe('Role Middleware Tests', () => {
|
|
|
|
|
test('should allow access to public route without authentication', async () => {
|
|
|
|
|
const response = await request(app).get('/health');
|
|
|
|
|
expect(response.status).toBe(200);
|
2026-03-16 21:07:16 +00:00
|
|
|
});
|
|
|
|
|
|
2026-03-16 22:06:48 +00:00
|
|
|
test('should deny access to protected route without authentication', async () => {
|
|
|
|
|
const response = await request(app).get('/test-role');
|
|
|
|
|
expect(response.status).toBe(401); // Unauthorized
|
2026-03-16 21:07:16 +00:00
|
|
|
});
|
|
|
|
|
});
|