diff --git a/ISSUE-TEMPLATE.md b/ISSUE-TEMPLATE.md index 304fccc..4c0d46e 100644 --- a/ISSUE-TEMPLATE.md +++ b/ISSUE-TEMPLATE.md @@ -1,7 +1,7 @@ ## Issue Template for helpyourneighbour ### Description -Brief description of the task to be done. +Describe the task to be done. ### Acceptance Criteria - [ ] Criterion 1 @@ -9,8 +9,8 @@ Brief description of the task to be done. - [ ] Criterion 3 ### Related Files -- File 1 -- File 2 +- `path/to/file1.js` +- `path/to/file2.js` ### Notes Any additional context or notes. \ No newline at end of file diff --git a/backend/tests/roles.test.js b/backend/tests/roles.test.js index 564a571..49e1502 100644 --- a/backend/tests/roles.test.js +++ b/backend/tests/roles.test.js @@ -1,32 +1,14 @@ const request = require('supertest'); -const app = require('../src/server'); -const { requireRole } = require('../middleware/role.middleware'); +const app = require('../src/server.js'); -describe('Role Middleware', () => { - // Test for a route that requires 'admin' role - it('should deny access to users without admin role', async () => { - const response = await request(app) - .get('/admin/users') - .set('Authorization', 'Bearer invalid-token'); - - expect(response.status).toBe(401); +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); }); - // Test for a route that requires 'moderator' role - it('should deny access to users without moderator role', async () => { - const response = await request(app) - .get('/moderator/reports') - .set('Authorization', 'Bearer invalid-token'); - - expect(response.status).toBe(401); - }); - - // Test for a route that requires 'user' role - it('should deny access to users without user role', async () => { - const response = await request(app) - .get('/profile') - .set('Authorization', 'Bearer invalid-token'); - - expect(response.status).toBe(401); + test('should deny access to protected route without authentication', async () => { + const response = await request(app).get('/test-role'); + expect(response.status).toBe(401); // Unauthorized }); }); \ No newline at end of file