tests: Refactor room security tests to use INTERNAL_ROOMS_PATH constant for API calls
This commit is contained in:
parent
ba726fe90f
commit
b31a53e6d9
@ -8,6 +8,7 @@ import { MeetRoomHelper } from '../../../../src/helpers/room.helper.js';
|
|||||||
import { API_KEY_HEADER, changeSecurityPreferences, deleteAllRooms, loginUserAsRole } from '../../../utils/helpers.js';
|
import { API_KEY_HEADER, changeSecurityPreferences, deleteAllRooms, loginUserAsRole } from '../../../utils/helpers.js';
|
||||||
|
|
||||||
const ROOMS_PATH = `${MEET_API_BASE_PATH_V1}/rooms`;
|
const ROOMS_PATH = `${MEET_API_BASE_PATH_V1}/rooms`;
|
||||||
|
const INTERNAL_ROOMS_PATH = `${MEET_INTERNAL_API_BASE_PATH_V1}/rooms`;
|
||||||
|
|
||||||
describe('Room API Security Tests', () => {
|
describe('Room API Security Tests', () => {
|
||||||
let app: Express;
|
let app: Express;
|
||||||
@ -121,9 +122,8 @@ describe('Room API Security Tests', () => {
|
|||||||
let roomId: string;
|
let roomId: string;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
// Create a room and extract the roomId
|
const room = await createRoom();
|
||||||
const response = await request(app).post(ROOMS_PATH).set(API_KEY_HEADER, MEET_API_KEY).send({});
|
roomId = room.roomId;
|
||||||
roomId = response.body.roomId;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should succeed when request includes API key', async () => {
|
it('should succeed when request includes API key', async () => {
|
||||||
@ -306,7 +306,7 @@ describe('Room API Security Tests', () => {
|
|||||||
|
|
||||||
it('should succeed when user is authenticated as admin', async () => {
|
it('should succeed when user is authenticated as admin', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
.put(`${MEET_INTERNAL_API_BASE_PATH_V1}/rooms/${roomId}`)
|
.put(`${INTERNAL_ROOMS_PATH}/${roomId}`)
|
||||||
.set('Cookie', adminCookie)
|
.set('Cookie', adminCookie)
|
||||||
.send(roomPreferences);
|
.send(roomPreferences);
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
@ -314,16 +314,14 @@ describe('Room API Security Tests', () => {
|
|||||||
|
|
||||||
it('should fail when user is authenticated as user', async () => {
|
it('should fail when user is authenticated as user', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
.put(`${MEET_INTERNAL_API_BASE_PATH_V1}/rooms/${roomId}`)
|
.put(`${INTERNAL_ROOMS_PATH}/${roomId}`)
|
||||||
.set('Cookie', userCookie)
|
.set('Cookie', userCookie)
|
||||||
.send(roomPreferences);
|
.send(roomPreferences);
|
||||||
expect(response.status).toBe(403);
|
expect(response.status).toBe(403);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when user is not authenticated', async () => {
|
it('should fail when user is not authenticated', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app).put(`${INTERNAL_ROOMS_PATH}/${roomId}`).send(roomPreferences);
|
||||||
.put(`${MEET_INTERNAL_API_BASE_PATH_V1}/rooms/${roomId}`)
|
|
||||||
.send(roomPreferences);
|
|
||||||
expect(response.status).toBe(401);
|
expect(response.status).toBe(401);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -341,9 +339,7 @@ describe('Room API Security Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should succeed if user is not authenticated', async () => {
|
it('should succeed if user is not authenticated', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app).get(`${INTERNAL_ROOMS_PATH}/${roomId}/participant-role`).query({
|
||||||
.get(`${MEET_INTERNAL_API_BASE_PATH_V1}/rooms/${roomId}/participant-role`)
|
|
||||||
.query({
|
|
||||||
secret: moderatorSecret
|
secret: moderatorSecret
|
||||||
});
|
});
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user