tests: adjust updateParticipantRole and updateRoomPreferences tests
This commit is contained in:
parent
4f0927dfbc
commit
fb589bd19b
@ -241,13 +241,13 @@ export const getRoom = async (roomId: string, fields?: string, cookie?: string,
|
|||||||
return await req;
|
return await req;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getRoomPreferences = async (roomId: string, cookie: string, role: ParticipantRole) => {
|
export const getRoomPreferences = async (roomId: string) => {
|
||||||
checkAppIsRunning();
|
checkAppIsRunning();
|
||||||
|
|
||||||
|
const adminCookie = await loginUser();
|
||||||
return await request(app)
|
return await request(app)
|
||||||
.get(`${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/rooms/${roomId}/preferences`)
|
.get(`${INTERNAL_CONFIG.API_BASE_PATH_V1}/rooms/${roomId}/preferences`)
|
||||||
.set('Cookie', cookie)
|
.set('Cookie', adminCookie)
|
||||||
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, role)
|
|
||||||
.send();
|
.send();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -256,9 +256,9 @@ export const updateRoomPreferences = async (roomId: string, preferences: any) =>
|
|||||||
|
|
||||||
const adminCookie = await loginUser();
|
const adminCookie = await loginUser();
|
||||||
return await request(app)
|
return await request(app)
|
||||||
.put(`${INTERNAL_CONFIG.API_BASE_PATH_V1}/rooms/${roomId}`)
|
.put(`${INTERNAL_CONFIG.API_BASE_PATH_V1}/rooms/${roomId}/preferences`)
|
||||||
.set('Cookie', adminCookie)
|
.set('Cookie', adminCookie)
|
||||||
.send(preferences);
|
.send({ preferences });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateRecordingAccessPreferencesInRoom = async (roomId: string, recordingAccess: MeetRecordingAccess) => {
|
export const updateRecordingAccessPreferencesInRoom = async (roomId: string, recordingAccess: MeetRecordingAccess) => {
|
||||||
@ -540,7 +540,7 @@ export const updateParticipant = async (
|
|||||||
checkAppIsRunning();
|
checkAppIsRunning();
|
||||||
|
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
.patch(`${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/meetings/${roomId}/participants/${participantIdentity}`)
|
.put(`${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/meetings/${roomId}/participants/${participantIdentity}/role`)
|
||||||
.set('Cookie', moderatorCookie)
|
.set('Cookie', moderatorCookie)
|
||||||
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.MODERATOR)
|
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.MODERATOR)
|
||||||
.send({ role: newRole });
|
.send({ role: newRole });
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { afterEach, beforeAll, describe, it } from '@jest/globals';
|
import { afterEach, beforeAll, describe, it } from '@jest/globals';
|
||||||
import { MeetRecordingAccess, ParticipantRole } from '../../../../src/typings/ce/index.js';
|
import { MeetRecordingAccess } from '../../../../src/typings/ce/index.js';
|
||||||
import { expectSuccessRoomPreferencesResponse } from '../../../helpers/assertion-helpers.js';
|
import { expectSuccessRoomPreferencesResponse } from '../../../helpers/assertion-helpers.js';
|
||||||
import { deleteAllRooms, getRoomPreferences, startTestServer } from '../../../helpers/request-helpers.js';
|
import { deleteAllRooms, getRoomPreferences, startTestServer } from '../../../helpers/request-helpers.js';
|
||||||
import { setupSingleRoom } from '../../../helpers/test-scenarios.js';
|
import { setupSingleRoom } from '../../../helpers/test-scenarios.js';
|
||||||
@ -27,9 +27,8 @@ describe('Room API Tests', () => {
|
|||||||
it('should successfully retrieve a room by its ID', async () => {
|
it('should successfully retrieve a room by its ID', async () => {
|
||||||
const roomData = await setupSingleRoom();
|
const roomData = await setupSingleRoom();
|
||||||
const roomId = roomData.room.roomId;
|
const roomId = roomData.room.roomId;
|
||||||
const cookie = roomData.moderatorCookie;
|
|
||||||
|
|
||||||
const response = await getRoomPreferences(roomId, cookie, ParticipantRole.MODERATOR);
|
const response = await getRoomPreferences(roomId);
|
||||||
expectSuccessRoomPreferencesResponse(response, DEFAULT_PREFERENCES);
|
expectSuccessRoomPreferencesResponse(response, DEFAULT_PREFERENCES);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -48,9 +47,8 @@ describe('Room API Tests', () => {
|
|||||||
|
|
||||||
const roomData = await setupSingleRoom(false, payload.roomName, payload.preferences);
|
const roomData = await setupSingleRoom(false, payload.roomName, payload.preferences);
|
||||||
const roomId = roomData.room.roomId;
|
const roomId = roomData.room.roomId;
|
||||||
const cookie = roomData.moderatorCookie;
|
|
||||||
|
|
||||||
const response = await getRoomPreferences(roomId, cookie, ParticipantRole.MODERATOR);
|
const response = await getRoomPreferences(roomId);
|
||||||
expectSuccessRoomPreferencesResponse(response, payload.preferences);
|
expectSuccessRoomPreferencesResponse(response, payload.preferences);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -69,8 +69,7 @@ describe('Room API Tests', () => {
|
|||||||
|
|
||||||
// Verify update response
|
// Verify update response
|
||||||
expect(updateResponse.status).toBe(200);
|
expect(updateResponse.status).toBe(200);
|
||||||
expect(updateResponse.body).toBeDefined();
|
expect(updateResponse.body).toHaveProperty('message');
|
||||||
expect(updateResponse.body.preferences).toEqual(updatedPreferences);
|
|
||||||
|
|
||||||
// Verify with a get request
|
// Verify with a get request
|
||||||
const getResponse = await getRoom(createdRoom.roomId);
|
const getResponse = await getRoom(createdRoom.roomId);
|
||||||
@ -105,7 +104,7 @@ describe('Room API Tests', () => {
|
|||||||
|
|
||||||
// Verify update response
|
// Verify update response
|
||||||
expect(updateResponse.status).toBe(200);
|
expect(updateResponse.status).toBe(200);
|
||||||
expect(updateResponse.body.preferences).toEqual(partialPreferences);
|
expect(updateResponse.body).toHaveProperty('message');
|
||||||
|
|
||||||
// Verify with a get request
|
// Verify with a get request
|
||||||
const getResponse = await getRoom(createdRoom.roomId);
|
const getResponse = await getRoom(createdRoom.roomId);
|
||||||
@ -187,22 +186,6 @@ describe('Room API Tests', () => {
|
|||||||
expect(JSON.stringify(response.body.details)).toContain('recordingPreferences.allowAccessTo');
|
expect(JSON.stringify(response.body.details)).toContain('recordingPreferences.allowAccessTo');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when room ID contains invalid characters', async () => {
|
|
||||||
const invalidRoomId = '!@#$%^&*()';
|
|
||||||
|
|
||||||
const preferences = {
|
|
||||||
recordingPreferences: {
|
|
||||||
enabled: false
|
|
||||||
},
|
|
||||||
chatPreferences: { enabled: false },
|
|
||||||
virtualBackgroundPreferences: { enabled: false }
|
|
||||||
};
|
|
||||||
const response = await updateRoomPreferences(invalidRoomId, preferences);
|
|
||||||
|
|
||||||
expect(response.status).toBe(422);
|
|
||||||
expect(JSON.stringify(response.body.details)).toContain('roomId cannot be empty after sanitization');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return 404 when updating non-existent room', async () => {
|
it('should return 404 when updating non-existent room', async () => {
|
||||||
const nonExistentRoomId = 'non-existent-room';
|
const nonExistentRoomId = 'non-existent-room';
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,7 @@ describe('Meeting API Security Tests', () => {
|
|||||||
|
|
||||||
it('should fail when request includes API key', async () => {
|
it('should fail when request includes API key', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
.patch(`${MEETINGS_PATH}/${roomData.room.roomId}/participants/${PARTICIPANT_NAME}`)
|
.put(`${MEETINGS_PATH}/${roomData.room.roomId}/participants/${PARTICIPANT_NAME}/role`)
|
||||||
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_INITIAL_API_KEY)
|
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_INITIAL_API_KEY)
|
||||||
.send({ role });
|
.send({ role });
|
||||||
expect(response.status).toBe(401);
|
expect(response.status).toBe(401);
|
||||||
@ -105,7 +105,7 @@ describe('Meeting API Security Tests', () => {
|
|||||||
|
|
||||||
it('should fail when user is authenticated as admin', async () => {
|
it('should fail when user is authenticated as admin', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
.patch(`${MEETINGS_PATH}/${roomData.room.roomId}/participants/${PARTICIPANT_NAME}`)
|
.put(`${MEETINGS_PATH}/${roomData.room.roomId}/participants/${PARTICIPANT_NAME}/role`)
|
||||||
.set('Cookie', adminCookie)
|
.set('Cookie', adminCookie)
|
||||||
.send({ role });
|
.send({ role });
|
||||||
expect(response.status).toBe(401);
|
expect(response.status).toBe(401);
|
||||||
@ -113,7 +113,7 @@ describe('Meeting API Security Tests', () => {
|
|||||||
|
|
||||||
it('should succeed when participant is moderator', async () => {
|
it('should succeed when participant is moderator', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
.patch(`${MEETINGS_PATH}/${roomData.room.roomId}/participants/${PARTICIPANT_NAME}`)
|
.put(`${MEETINGS_PATH}/${roomData.room.roomId}/participants/${PARTICIPANT_NAME}/role`)
|
||||||
.set('Cookie', roomData.moderatorCookie)
|
.set('Cookie', roomData.moderatorCookie)
|
||||||
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.MODERATOR)
|
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.MODERATOR)
|
||||||
.send({ role });
|
.send({ role });
|
||||||
@ -124,7 +124,7 @@ describe('Meeting API Security Tests', () => {
|
|||||||
const newRoomData = await setupSingleRoom();
|
const newRoomData = await setupSingleRoom();
|
||||||
|
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
.patch(`${MEETINGS_PATH}/${roomData.room.roomId}/participants/${PARTICIPANT_NAME}`)
|
.put(`${MEETINGS_PATH}/${roomData.room.roomId}/participants/${PARTICIPANT_NAME}/role`)
|
||||||
.set('Cookie', newRoomData.moderatorCookie)
|
.set('Cookie', newRoomData.moderatorCookie)
|
||||||
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.MODERATOR)
|
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.MODERATOR)
|
||||||
.send({ role });
|
.send({ role });
|
||||||
@ -133,7 +133,7 @@ describe('Meeting API Security Tests', () => {
|
|||||||
|
|
||||||
it('should fail when participant is speaker', async () => {
|
it('should fail when participant is speaker', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
.patch(`${MEETINGS_PATH}/${roomData.room.roomId}/participants/${PARTICIPANT_NAME}`)
|
.put(`${MEETINGS_PATH}/${roomData.room.roomId}/participants/${PARTICIPANT_NAME}/role`)
|
||||||
.set('Cookie', roomData.speakerCookie)
|
.set('Cookie', roomData.speakerCookie)
|
||||||
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.SPEAKER)
|
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.SPEAKER)
|
||||||
.send({ role });
|
.send({ role });
|
||||||
|
|||||||
@ -179,6 +179,69 @@ describe('Room API Security Tests', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Get Room Preferences Tests', () => {
|
||||||
|
let roomData: RoomData;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
roomData = await setupSingleRoom();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should succeed when request includes API key', async () => {
|
||||||
|
const response = await request(app)
|
||||||
|
.get(`${ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
||||||
|
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_INITIAL_API_KEY);
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should succeed when user is authenticated as admin', async () => {
|
||||||
|
const response = await request(app)
|
||||||
|
.get(`${ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
||||||
|
.set('Cookie', adminCookie);
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail when user is not authenticated', async () => {
|
||||||
|
const response = await request(app).get(`${ROOMS_PATH}/${roomData.room.roomId}/preferences`);
|
||||||
|
expect(response.status).toBe(401);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should succeed when participant is moderator', async () => {
|
||||||
|
const response = await request(app)
|
||||||
|
.get(`${ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
||||||
|
.set('Cookie', roomData.moderatorCookie)
|
||||||
|
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.MODERATOR);
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail when participant is moderator of a different room', async () => {
|
||||||
|
const newRoomData = await setupSingleRoom();
|
||||||
|
|
||||||
|
const response = await request(app)
|
||||||
|
.get(`${ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
||||||
|
.set('Cookie', newRoomData.moderatorCookie)
|
||||||
|
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.MODERATOR);
|
||||||
|
expect(response.status).toBe(403);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should succeed when participant is speaker', async () => {
|
||||||
|
const response = await request(app)
|
||||||
|
.get(`${ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
||||||
|
.set('Cookie', roomData.speakerCookie)
|
||||||
|
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.SPEAKER);
|
||||||
|
expect(response.status).toBe(200);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail when participant is speaker of a different room', async () => {
|
||||||
|
const newRoomData = await setupSingleRoom();
|
||||||
|
|
||||||
|
const response = await request(app)
|
||||||
|
.get(`${ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
||||||
|
.set('Cookie', newRoomData.speakerCookie)
|
||||||
|
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.SPEAKER);
|
||||||
|
expect(response.status).toBe(403);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Update Room Preferences Tests', () => {
|
describe('Update Room Preferences Tests', () => {
|
||||||
const roomPreferences = {
|
const roomPreferences = {
|
||||||
recordingPreferences: {
|
recordingPreferences: {
|
||||||
@ -198,89 +261,28 @@ describe('Room API Security Tests', () => {
|
|||||||
|
|
||||||
it('should succeed when request includes API key', async () => {
|
it('should succeed when request includes API key', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
.put(`${ROOMS_PATH}/${roomId}`)
|
.put(`${ROOMS_PATH}/${roomId}/preferences`)
|
||||||
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_INITIAL_API_KEY)
|
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_INITIAL_API_KEY)
|
||||||
.send(roomPreferences);
|
.send({ preferences: roomPreferences });
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
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(`${ROOMS_PATH}/${roomId}`)
|
.put(`${ROOMS_PATH}/${roomId}/preferences`)
|
||||||
.set('Cookie', adminCookie)
|
.set('Cookie', adminCookie)
|
||||||
.send(roomPreferences);
|
.send({ preferences: roomPreferences });
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when user is not authenticated', async () => {
|
it('should fail when user is not authenticated', async () => {
|
||||||
const response = await request(app).put(`${ROOMS_PATH}/${roomId}`).send(roomPreferences);
|
const response = await request(app)
|
||||||
|
.put(`${ROOMS_PATH}/${roomId}/preferences`)
|
||||||
|
.send({ preferences: roomPreferences });
|
||||||
expect(response.status).toBe(401);
|
expect(response.status).toBe(401);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Get Room Preferences Tests', () => {
|
|
||||||
let roomData: RoomData;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
roomData = await setupSingleRoom();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should fail when request includes API key', async () => {
|
|
||||||
const response = await request(app)
|
|
||||||
.get(`${INTERNAL_ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
|
||||||
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_INITIAL_API_KEY);
|
|
||||||
expect(response.status).toBe(401);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should fail when user is authenticated as admin', async () => {
|
|
||||||
const response = await request(app)
|
|
||||||
.get(`${INTERNAL_ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
|
||||||
.set('Cookie', adminCookie);
|
|
||||||
expect(response.status).toBe(401);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should fail when user is not authenticated', async () => {
|
|
||||||
const response = await request(app).get(`${INTERNAL_ROOMS_PATH}/${roomData.room.roomId}/preferences`);
|
|
||||||
expect(response.status).toBe(401);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should succeed when participant is moderator', async () => {
|
|
||||||
const response = await request(app)
|
|
||||||
.get(`${INTERNAL_ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
|
||||||
.set('Cookie', roomData.moderatorCookie)
|
|
||||||
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.MODERATOR);
|
|
||||||
expect(response.status).toBe(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should fail when participant is moderator of a different room', async () => {
|
|
||||||
const newRoomData = await setupSingleRoom();
|
|
||||||
|
|
||||||
const response = await request(app)
|
|
||||||
.get(`${INTERNAL_ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
|
||||||
.set('Cookie', newRoomData.moderatorCookie)
|
|
||||||
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.MODERATOR);
|
|
||||||
expect(response.status).toBe(403);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should succeed when participant is speaker', async () => {
|
|
||||||
const response = await request(app)
|
|
||||||
.get(`${INTERNAL_ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
|
||||||
.set('Cookie', roomData.speakerCookie)
|
|
||||||
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.SPEAKER);
|
|
||||||
expect(response.status).toBe(200);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should fail when participant is speaker of a different room', async () => {
|
|
||||||
const newRoomData = await setupSingleRoom();
|
|
||||||
|
|
||||||
const response = await request(app)
|
|
||||||
.get(`${INTERNAL_ROOMS_PATH}/${roomData.room.roomId}/preferences`)
|
|
||||||
.set('Cookie', newRoomData.speakerCookie)
|
|
||||||
.set(INTERNAL_CONFIG.PARTICIPANT_ROLE_HEADER, ParticipantRole.SPEAKER);
|
|
||||||
expect(response.status).toBe(403);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Generate Recording Token Tests', () => {
|
describe('Generate Recording Token Tests', () => {
|
||||||
let roomData: RoomData;
|
let roomData: RoomData;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user