tests: update participant token tests to include participantIdentity parameter
This commit is contained in:
parent
13c88d201c
commit
7bffed69f0
@ -492,7 +492,11 @@ export const expectValidRoomRoleAndPermissionsResponse = (
|
||||
});
|
||||
};
|
||||
|
||||
export const getPermissions = (roomId: string, role: ParticipantRole, addJoinPermission = true): ParticipantPermissions => {
|
||||
export const getPermissions = (
|
||||
roomId: string,
|
||||
role: ParticipantRole,
|
||||
addJoinPermission = true
|
||||
): ParticipantPermissions => {
|
||||
switch (role) {
|
||||
case ParticipantRole.MODERATOR:
|
||||
return {
|
||||
@ -536,6 +540,7 @@ export const expectValidParticipantTokenResponse = (
|
||||
roomId: string,
|
||||
participantRole: ParticipantRole,
|
||||
participantName?: string,
|
||||
participantIdentity?: string,
|
||||
otherRoles: ParticipantRole[] = []
|
||||
) => {
|
||||
expect(response.status).toBe(200);
|
||||
@ -558,8 +563,16 @@ export const expectValidParticipantTokenResponse = (
|
||||
}
|
||||
|
||||
if (participantName) {
|
||||
expect(decodedToken).toHaveProperty('sub', participantName);
|
||||
expect(decodedToken).toHaveProperty('name', participantName);
|
||||
expect(decodedToken).toHaveProperty('sub');
|
||||
|
||||
if (participantIdentity) {
|
||||
expect(decodedToken.sub).toBe(participantIdentity);
|
||||
} else {
|
||||
expect(decodedToken.sub).toContain(participantName.replace(/\s+/g, '')); // Ensure sub contains the name without spaces
|
||||
}
|
||||
} else {
|
||||
expect(decodedToken).not.toHaveProperty('name');
|
||||
expect(decodedToken).not.toHaveProperty('sub');
|
||||
}
|
||||
|
||||
|
||||
@ -82,6 +82,7 @@ describe('Participant API Tests', () => {
|
||||
roomData.room.roomId,
|
||||
ParticipantRole.SPEAKER,
|
||||
`${participantName}_SPEAKER`,
|
||||
undefined,
|
||||
[ParticipantRole.MODERATOR]
|
||||
);
|
||||
});
|
||||
|
||||
@ -41,7 +41,8 @@ describe('Participant API Tests', () => {
|
||||
{
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.moderatorSecret,
|
||||
participantName
|
||||
participantName,
|
||||
participantIdentity: participantName
|
||||
},
|
||||
roomData.moderatorCookie
|
||||
);
|
||||
@ -49,6 +50,7 @@ describe('Participant API Tests', () => {
|
||||
response,
|
||||
roomData.room.roomId,
|
||||
ParticipantRole.MODERATOR,
|
||||
participantName,
|
||||
participantName
|
||||
);
|
||||
});
|
||||
@ -58,7 +60,8 @@ describe('Participant API Tests', () => {
|
||||
{
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.speakerSecret,
|
||||
participantName
|
||||
participantName,
|
||||
participantIdentity: participantName
|
||||
},
|
||||
roomData.speakerCookie
|
||||
);
|
||||
@ -66,6 +69,7 @@ describe('Participant API Tests', () => {
|
||||
response,
|
||||
roomData.room.roomId,
|
||||
ParticipantRole.SPEAKER,
|
||||
participantName,
|
||||
participantName
|
||||
);
|
||||
});
|
||||
@ -75,7 +79,8 @@ describe('Participant API Tests', () => {
|
||||
{
|
||||
roomId: roomData.room.roomId,
|
||||
secret: 'invalid_secret',
|
||||
participantName
|
||||
participantName,
|
||||
participantIdentity: participantName
|
||||
},
|
||||
roomData.moderatorCookie
|
||||
);
|
||||
@ -87,7 +92,8 @@ describe('Participant API Tests', () => {
|
||||
{
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.moderatorSecret,
|
||||
participantName
|
||||
participantName,
|
||||
participantIdentity: participantName
|
||||
},
|
||||
''
|
||||
);
|
||||
@ -95,13 +101,26 @@ describe('Participant API Tests', () => {
|
||||
expect(response.body.message).toBe('No participant token provided');
|
||||
});
|
||||
|
||||
it('should fail with 400 when participantIdentity is not provided', async () => {
|
||||
const response = await refreshParticipantToken(
|
||||
{
|
||||
roomId: roomData.room.roomId,
|
||||
secret: 'invalid_secret',
|
||||
participantName
|
||||
},
|
||||
roomData.moderatorCookie
|
||||
);
|
||||
expect(response.status).toBe(400);
|
||||
});
|
||||
|
||||
it('should fail with 404 when participant does not exist in the room', async () => {
|
||||
const newRoomData = await setupSingleRoom();
|
||||
const response = await refreshParticipantToken(
|
||||
{
|
||||
roomId: newRoomData.room.roomId,
|
||||
secret: newRoomData.moderatorSecret,
|
||||
participantName
|
||||
participantName,
|
||||
participantIdentity: participantName
|
||||
},
|
||||
roomData.moderatorCookie
|
||||
);
|
||||
@ -113,7 +132,8 @@ describe('Participant API Tests', () => {
|
||||
{
|
||||
roomId: 'non_existent_room',
|
||||
secret: roomData.moderatorSecret,
|
||||
participantName
|
||||
participantName,
|
||||
participantIdentity: participantName
|
||||
},
|
||||
roomData.moderatorCookie
|
||||
);
|
||||
@ -126,7 +146,8 @@ describe('Participant API Tests', () => {
|
||||
const response = await refreshParticipantToken(
|
||||
{
|
||||
secret: roomData.moderatorSecret,
|
||||
participantName
|
||||
participantName,
|
||||
participantIdentity: participantName
|
||||
},
|
||||
roomData.moderatorCookie
|
||||
);
|
||||
@ -137,7 +158,8 @@ describe('Participant API Tests', () => {
|
||||
const response = await refreshParticipantToken(
|
||||
{
|
||||
roomId: roomData.room.roomId,
|
||||
participantName
|
||||
participantName,
|
||||
participantIdentity: participantName
|
||||
},
|
||||
roomData.moderatorCookie
|
||||
);
|
||||
@ -149,7 +171,8 @@ describe('Participant API Tests', () => {
|
||||
{
|
||||
roomId: roomData.room.roomId,
|
||||
secret: '',
|
||||
participantName
|
||||
participantName,
|
||||
participantIdentity: participantName
|
||||
},
|
||||
roomData.moderatorCookie
|
||||
);
|
||||
|
||||
@ -162,7 +162,8 @@ describe('Participant API Security Tests', () => {
|
||||
.send({
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.speakerSecret,
|
||||
participantName: PARTICIPANT_NAME
|
||||
participantName: PARTICIPANT_NAME,
|
||||
participantIdentity: PARTICIPANT_NAME
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
});
|
||||
@ -176,7 +177,8 @@ describe('Participant API Security Tests', () => {
|
||||
.send({
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.moderatorSecret,
|
||||
participantName: PARTICIPANT_NAME
|
||||
participantName: PARTICIPANT_NAME,
|
||||
participantIdentity: PARTICIPANT_NAME
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
});
|
||||
@ -190,7 +192,8 @@ describe('Participant API Security Tests', () => {
|
||||
.send({
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.speakerSecret,
|
||||
participantName: PARTICIPANT_NAME
|
||||
participantName: PARTICIPANT_NAME,
|
||||
participantIdentity: PARTICIPANT_NAME
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
});
|
||||
@ -204,7 +207,8 @@ describe('Participant API Security Tests', () => {
|
||||
.send({
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.moderatorSecret,
|
||||
participantName: PARTICIPANT_NAME
|
||||
participantName: PARTICIPANT_NAME,
|
||||
participantIdentity: PARTICIPANT_NAME
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
});
|
||||
@ -218,7 +222,8 @@ describe('Participant API Security Tests', () => {
|
||||
.send({
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.moderatorSecret,
|
||||
participantName: PARTICIPANT_NAME
|
||||
participantName: PARTICIPANT_NAME,
|
||||
participantIdentity: PARTICIPANT_NAME
|
||||
});
|
||||
expect(response.status).toBe(401);
|
||||
});
|
||||
@ -232,7 +237,8 @@ describe('Participant API Security Tests', () => {
|
||||
.send({
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.speakerSecret,
|
||||
participantName: PARTICIPANT_NAME
|
||||
participantName: PARTICIPANT_NAME,
|
||||
participantIdentity: PARTICIPANT_NAME
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
});
|
||||
@ -246,7 +252,8 @@ describe('Participant API Security Tests', () => {
|
||||
.send({
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.speakerSecret,
|
||||
participantName: PARTICIPANT_NAME
|
||||
participantName: PARTICIPANT_NAME,
|
||||
participantIdentity: PARTICIPANT_NAME
|
||||
});
|
||||
expect(response.status).toBe(401);
|
||||
});
|
||||
@ -260,7 +267,8 @@ describe('Participant API Security Tests', () => {
|
||||
.send({
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.moderatorSecret,
|
||||
participantName: PARTICIPANT_NAME
|
||||
participantName: PARTICIPANT_NAME,
|
||||
participantIdentity: PARTICIPANT_NAME
|
||||
});
|
||||
expect(response.status).toBe(200);
|
||||
});
|
||||
@ -274,7 +282,8 @@ describe('Participant API Security Tests', () => {
|
||||
.send({
|
||||
roomId: roomData.room.roomId,
|
||||
secret: roomData.moderatorSecret,
|
||||
participantName: PARTICIPANT_NAME
|
||||
participantName: PARTICIPANT_NAME,
|
||||
participantIdentity: PARTICIPANT_NAME
|
||||
});
|
||||
expect(response.status).toBe(401);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user