test: Remove moderatorToken from start and stop recording tests

This commit is contained in:
CSantosM 2026-01-28 18:06:06 +01:00
parent 3f91e281b3
commit 2fe720c90b
2 changed files with 39 additions and 39 deletions

View File

@ -24,7 +24,7 @@ import { TestContext } from '../../../interfaces/scenarios.js';
describe('Recording API Tests', () => { describe('Recording API Tests', () => {
let context: TestContext | null = null; let context: TestContext | null = null;
let room: MeetRoom, moderatorToken: string; let room: MeetRoom;
beforeAll(async () => { beforeAll(async () => {
await startTestServer(); await startTestServer();
@ -40,7 +40,7 @@ describe('Recording API Tests', () => {
beforeAll(async () => { beforeAll(async () => {
// Create a room and join a participant // Create a room and join a participant
context = await setupMultiRoomTestContext(1, true); context = await setupMultiRoomTestContext(1, true);
({ room, moderatorToken } = context.getRoomByIndex(0)!); ({ room } = context.getRoomByIndex(0)!);
}); });
afterAll(async () => { afterAll(async () => {
@ -50,16 +50,16 @@ describe('Recording API Tests', () => {
}); });
it('should return 201 with proper response and location header when recording starts successfully', async () => { it('should return 201 with proper response and location header when recording starts successfully', async () => {
const response = await startRecording(room.roomId, moderatorToken); const response = await startRecording(room.roomId);
const recordingId = response.body.recordingId; const recordingId = response.body.recordingId;
expectValidStartRecordingResponse(response, room.roomId, room.roomName); expectValidStartRecordingResponse(response, room.roomId, room.roomName);
const stopResponse = await stopRecording(recordingId, moderatorToken); const stopResponse = await stopRecording(recordingId);
expectValidStopRecordingResponse(stopResponse, recordingId, room.roomId, room.roomName); expectValidStopRecordingResponse(stopResponse, recordingId, room.roomId, room.roomName);
}); });
it('should create secrets when recording starts', async () => { it('should create secrets when recording starts', async () => {
const response = await startRecording(room.roomId, moderatorToken); const response = await startRecording(room.roomId);
const recordingId = response.body.recordingId; const recordingId = response.body.recordingId;
expectValidStartRecordingResponse(response, room.roomId, room.roomName); expectValidStartRecordingResponse(response, room.roomId, room.roomName);
@ -70,24 +70,24 @@ describe('Recording API Tests', () => {
expect(recSecrets?.publicAccessSecret).toBeDefined(); expect(recSecrets?.publicAccessSecret).toBeDefined();
expect(recSecrets?.privateAccessSecret).toBeDefined(); expect(recSecrets?.privateAccessSecret).toBeDefined();
const stopResponse = await stopRecording(recordingId, moderatorToken); const stopResponse = await stopRecording(recordingId);
expectValidStopRecordingResponse(stopResponse, recordingId, room.roomId, room.roomName); expectValidStopRecordingResponse(stopResponse, recordingId, room.roomId, room.roomName);
}); });
it('should successfully start recording, stop it, and start again (sequential operations)', async () => { it('should successfully start recording, stop it, and start again (sequential operations)', async () => {
const firstStartResponse = await startRecording(room.roomId, moderatorToken); const firstStartResponse = await startRecording(room.roomId);
const firstRecordingId = firstStartResponse.body.recordingId; const firstRecordingId = firstStartResponse.body.recordingId;
expectValidStartRecordingResponse(firstStartResponse, room.roomId, room.roomName); expectValidStartRecordingResponse(firstStartResponse, room.roomId, room.roomName);
const firstStopResponse = await stopRecording(firstRecordingId, moderatorToken); const firstStopResponse = await stopRecording(firstRecordingId);
expectValidStopRecordingResponse(firstStopResponse, firstRecordingId, room.roomId, room.roomName); expectValidStopRecordingResponse(firstStopResponse, firstRecordingId, room.roomId, room.roomName);
const secondStartResponse = await startRecording(room.roomId, moderatorToken); const secondStartResponse = await startRecording(room.roomId);
expectValidStartRecordingResponse(secondStartResponse, room.roomId, room.roomName); expectValidStartRecordingResponse(secondStartResponse, room.roomId, room.roomName);
const secondRecordingId = secondStartResponse.body.recordingId; const secondRecordingId = secondStartResponse.body.recordingId;
const secondStopResponse = await stopRecording(secondRecordingId, moderatorToken); const secondStopResponse = await stopRecording(secondRecordingId);
expectValidStopRecordingResponse(secondStopResponse, secondRecordingId, room.roomId, room.roomName); expectValidStopRecordingResponse(secondStopResponse, secondRecordingId, room.roomId, room.roomName);
}); });
@ -97,8 +97,8 @@ describe('Recording API Tests', () => {
const roomDataA = context.getRoomByIndex(0)!; const roomDataA = context.getRoomByIndex(0)!;
const roomDataB = context.getRoomByIndex(1)!; const roomDataB = context.getRoomByIndex(1)!;
const firstResponse = await startRecording(roomDataA.room.roomId, roomDataA.moderatorToken); const firstResponse = await startRecording(roomDataA.room.roomId);
const secondResponse = await startRecording(roomDataB.room.roomId, roomDataB.moderatorToken); const secondResponse = await startRecording(roomDataB.room.roomId);
expectValidStartRecordingResponse(firstResponse, roomDataA.room.roomId, roomDataA.room.roomName); expectValidStartRecordingResponse(firstResponse, roomDataA.room.roomId, roomDataA.room.roomName);
expectValidStartRecordingResponse(secondResponse, roomDataB.room.roomId, roomDataB.room.roomName); expectValidStartRecordingResponse(secondResponse, roomDataB.room.roomId, roomDataB.room.roomName);
@ -107,8 +107,8 @@ describe('Recording API Tests', () => {
const secondRecordingId = secondResponse.body.recordingId; const secondRecordingId = secondResponse.body.recordingId;
const [firstStopResponse, secondStopResponse] = await Promise.all([ const [firstStopResponse, secondStopResponse] = await Promise.all([
stopRecording(firstRecordingId, roomDataA.moderatorToken), stopRecording(firstRecordingId),
stopRecording(secondRecordingId, roomDataB.moderatorToken) stopRecording(secondRecordingId)
]); ]);
expectValidStopRecordingResponse( expectValidStopRecordingResponse(
firstStopResponse, firstStopResponse,
@ -129,16 +129,16 @@ describe('Recording API Tests', () => {
beforeAll(async () => { beforeAll(async () => {
// Create a room without participants // Create a room without participants
context = await setupMultiRoomTestContext(1, false); context = await setupMultiRoomTestContext(1, false);
({ room, moderatorToken } = context.getRoomByIndex(0)!); ({ room } = context.getRoomByIndex(0)!);
}); });
afterEach(async () => { afterEach(async () => {
await disconnectFakeParticipants(); await disconnectFakeParticipants();
await stopAllRecordings(moderatorToken); await stopAllRecordings();
}); });
it('should accept valid roomId but reject with 409', async () => { it('should accept valid roomId but reject with 409', async () => {
const response = await startRecording(room.roomId, moderatorToken); const response = await startRecording(room.roomId);
// Room exists but it has no participants // Room exists but it has no participants
expect(response.status).toBe(409); expect(response.status).toBe(409);
expect(response.body.message).toContain(`Room '${room.roomId}' has no participants`); expect(response.body.message).toContain(`Room '${room.roomId}' has no participants`);
@ -146,7 +146,7 @@ describe('Recording API Tests', () => {
it('should sanitize roomId and reject the request with 409 due to no participants', async () => { it('should sanitize roomId and reject the request with 409 due to no participants', async () => {
const malformedRoomId = ' .<!?' + room.roomId + ' '; const malformedRoomId = ' .<!?' + room.roomId + ' ';
const response = await startRecording(malformedRoomId, moderatorToken); const response = await startRecording(malformedRoomId);
console.log('Response:', response.body); console.log('Response:', response.body);
expect(response.status).toBe(409); expect(response.status).toBe(409);
@ -154,25 +154,25 @@ describe('Recording API Tests', () => {
}); });
it('should reject request with roomId that becomes empty after sanitization', async () => { it('should reject request with roomId that becomes empty after sanitization', async () => {
const response = await startRecording('!@#$%^&*()', moderatorToken); const response = await startRecording('!@#$%^&*()');
expectValidationError(response, 'roomId', 'cannot be empty after sanitization'); expectValidationError(response, 'roomId', 'cannot be empty after sanitization');
}); });
it('should reject request with non-string roomId', async () => { it('should reject request with non-string roomId', async () => {
const response = await startRecording(123 as unknown as string, moderatorToken); const response = await startRecording(123 as unknown as string);
expectValidationError(response, 'roomId', 'Expected string'); expectValidationError(response, 'roomId', 'Expected string');
}); });
it('should reject request with very long roomId', async () => { it('should reject request with very long roomId', async () => {
const longRoomId = 'a'.repeat(101); const longRoomId = 'a'.repeat(101);
const response = await startRecording(longRoomId, moderatorToken); const response = await startRecording(longRoomId);
expectValidationError(response, 'roomId', 'cannot exceed 100 characters'); expectValidationError(response, 'roomId', 'cannot exceed 100 characters');
}); });
it('should handle room that does not exist', async () => { it('should handle room that does not exist', async () => {
const response = await startRecording('non-existing-room-id', moderatorToken); const response = await startRecording('non-existing-room-id');
const error = errorRoomNotFound('non-existing-room-id'); const error = errorRoomNotFound('non-existing-room-id');
expect(response.status).toBe(404); expect(response.status).toBe(404);
expect(response.body).toEqual({ expect(response.body).toEqual({
@ -183,14 +183,14 @@ describe('Recording API Tests', () => {
it('should return 409 when recording is already in progress', async () => { it('should return 409 when recording is already in progress', async () => {
await joinFakeParticipant(room.roomId, 'fakeParticipantId'); await joinFakeParticipant(room.roomId, 'fakeParticipantId');
const firstResponse = await startRecording(room.roomId, moderatorToken); const firstResponse = await startRecording(room.roomId);
const recordingId = firstResponse.body.recordingId; const recordingId = firstResponse.body.recordingId;
expectValidStartRecordingResponse(firstResponse, room.roomId, room.roomName); expectValidStartRecordingResponse(firstResponse, room.roomId, room.roomName);
const secondResponse = await startRecording(room!.roomId, moderatorToken); const secondResponse = await startRecording(room!.roomId);
expect(secondResponse.status).toBe(409); expect(secondResponse.status).toBe(409);
expect(secondResponse.body.message).toContain('already'); expect(secondResponse.body.message).toContain('already');
const stopResponse = await stopRecording(recordingId, moderatorToken); const stopResponse = await stopRecording(recordingId);
expectValidStopRecordingResponse(stopResponse, recordingId, room.roomId, room.roomName); expectValidStopRecordingResponse(stopResponse, recordingId, room.roomId, room.roomName);
}); });
@ -199,7 +199,7 @@ describe('Recording API Tests', () => {
RECORDING_STARTED_TIMEOUT: '1s' RECORDING_STARTED_TIMEOUT: '1s'
}); });
await joinFakeParticipant(room.roomId, 'fakeParticipantId'); await joinFakeParticipant(room.roomId, 'fakeParticipantId');
const response = await startRecording(room.roomId, moderatorToken); const response = await startRecording(room.roomId);
expect(response.status).toBe(503); expect(response.status).toBe(503);
expect(response.body.message).toContain('timed out while starting'); expect(response.body.message).toContain('timed out while starting');
setInternalConfig({ setInternalConfig({

View File

@ -15,7 +15,7 @@ import { TestContext } from '../../../interfaces/scenarios';
describe('Recording API Tests', () => { describe('Recording API Tests', () => {
let context: TestContext | null = null; let context: TestContext | null = null;
let room: MeetRoom, moderatorToken: string; let room: MeetRoom;
beforeAll(async () => { beforeAll(async () => {
await startTestServer(); await startTestServer();
@ -23,7 +23,7 @@ describe('Recording API Tests', () => {
}); });
afterAll(async () => { afterAll(async () => {
await stopAllRecordings(moderatorToken); await stopAllRecordings();
await disconnectFakeParticipants(); await disconnectFakeParticipants();
await Promise.all([deleteAllRooms(), deleteAllRecordings()]); await Promise.all([deleteAllRooms(), deleteAllRecordings()]);
}); });
@ -33,13 +33,13 @@ describe('Recording API Tests', () => {
beforeAll(async () => { beforeAll(async () => {
// Create a room and join a participant // Create a room and join a participant
context = await setupMultiRoomTestContext(1, true); context = await setupMultiRoomTestContext(1, true);
({ room, moderatorToken } = context.getRoomByIndex(0)!); ({ room } = context.getRoomByIndex(0)!);
const response = await startRecording(room.roomId, moderatorToken); const response = await startRecording(room.roomId);
recordingId = response.body.recordingId; recordingId = response.body.recordingId;
}); });
it('should stop an active recording and return 202', async () => { it('should stop an active recording and return 202', async () => {
const response = await stopRecording(recordingId, moderatorToken); const response = await stopRecording(recordingId);
expectValidStopRecordingResponse(response, recordingId, room.roomId, room.roomName); expectValidStopRecordingResponse(response, recordingId, room.roomId, room.roomName);
}); });
@ -47,18 +47,18 @@ describe('Recording API Tests', () => {
const context = await setupMultiRoomTestContext(2, true); const context = await setupMultiRoomTestContext(2, true);
const roomDataA = context.getRoomByIndex(0); const roomDataA = context.getRoomByIndex(0);
const roomDataB = context.getRoomByIndex(1); const roomDataB = context.getRoomByIndex(1);
const responseA = await startRecording(roomDataA!.room.roomId, roomDataA!.moderatorToken); const responseA = await startRecording(roomDataA!.room.roomId);
const responseB = await startRecording(roomDataB!.room.roomId, roomDataB!.moderatorToken); const responseB = await startRecording(roomDataB!.room.roomId);
const recordingIdA = responseA.body.recordingId; const recordingIdA = responseA.body.recordingId;
const recordingIdB = responseB.body.recordingId; const recordingIdB = responseB.body.recordingId;
const stopResponseA = await stopRecording(recordingIdA, roomDataA!.moderatorToken); const stopResponseA = await stopRecording(recordingIdA);
expectValidStopRecordingResponse( expectValidStopRecordingResponse(
stopResponseA, stopResponseA,
recordingIdA, recordingIdA,
roomDataA!.room.roomId, roomDataA!.room.roomId,
roomDataA!.room.roomName roomDataA!.room.roomName
); );
const stopResponseB = await stopRecording(recordingIdB, roomDataB!.moderatorToken); const stopResponseB = await stopRecording(recordingIdB);
expectValidStopRecordingResponse( expectValidStopRecordingResponse(
stopResponseB, stopResponseB,
recordingIdB, recordingIdB,
@ -69,7 +69,7 @@ describe('Recording API Tests', () => {
describe('Stop Recording Validation failures', () => { describe('Stop Recording Validation failures', () => {
it('should return 404 when recordingId does not exist', async () => { it('should return 404 when recordingId does not exist', async () => {
const response = await stopRecording(`${room.roomId}--EG_123--444`, moderatorToken); const response = await stopRecording(`${room.roomId}--EG_123--444`);
expect(response.status).toBe(404); expect(response.status).toBe(404);
expect(response.body.error).toBe('Recording Error'); expect(response.body.error).toBe('Recording Error');
expect(response.body.message).toContain('not found'); expect(response.body.message).toContain('not found');
@ -77,17 +77,17 @@ describe('Recording API Tests', () => {
it('should return 400 when recording is already stopped', async () => { it('should return 400 when recording is already stopped', async () => {
// First stop the recording // First stop the recording
await stopRecording(recordingId, moderatorToken); await stopRecording(recordingId);
// Try to stop it again // Try to stop it again
const response = await stopRecording(recordingId, moderatorToken); const response = await stopRecording(recordingId);
console.log('Response:', response.body); console.log('Response:', response.body);
expectErrorResponse(response, 409, '', `Recording '${recordingId}' is already stopped`); expectErrorResponse(response, 409, '', `Recording '${recordingId}' is already stopped`);
}); });
it('should return 404 when recordingId is not in the correct format', async () => { it('should return 404 when recordingId is not in the correct format', async () => {
const response = await stopRecording('invalid-recording-id', moderatorToken); const response = await stopRecording('invalid-recording-id');
expect(response.status).toBe(422); expect(response.status).toBe(422);
expect(response.body.error).toBe('Unprocessable Entity'); expect(response.body.error).toBe('Unprocessable Entity');
expect(response.body.message).toContain('Invalid request'); expect(response.body.message).toContain('Invalid request');