test: update security preferences tests to handle partial data and validation; add missing access check for recording preferences in update room preferences tests
This commit is contained in:
parent
44fbb25841
commit
8390133a5a
@ -60,8 +60,7 @@ describe('Security Preferences API Tests', () => {
|
||||
it('should update security preferences with valid partial data (roomCreationPolicy)', async () => {
|
||||
const validPreferences = {
|
||||
roomCreationPolicy: {
|
||||
allowRoomCreation: false,
|
||||
requireAuthentication: true
|
||||
allowRoomCreation: false
|
||||
}
|
||||
};
|
||||
let response = await updateSecurityPreferences(validPreferences);
|
||||
@ -71,7 +70,9 @@ describe('Security Preferences API Tests', () => {
|
||||
|
||||
response = await getSecurityPreferences();
|
||||
expect(response.status).toBe(200);
|
||||
expect(response.body.roomCreationPolicy).toEqual(validPreferences.roomCreationPolicy);
|
||||
expect(response.body.roomCreationPolicy.allowRoomCreation).toEqual(
|
||||
validPreferences.roomCreationPolicy.allowRoomCreation
|
||||
);
|
||||
expect(response.body.authentication).toEqual(defaultPreferences.authentication);
|
||||
});
|
||||
|
||||
@ -127,15 +128,8 @@ describe('Security Preferences API Tests', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should reject when allowRoomCreation or requireAuthentication is not provided', async () => {
|
||||
let response = await updateSecurityPreferences({
|
||||
roomCreationPolicy: {
|
||||
allowRoomCreation: true
|
||||
}
|
||||
});
|
||||
expectValidationError(response, 'roomCreationPolicy.requireAuthentication', 'Required');
|
||||
|
||||
response = await updateSecurityPreferences({
|
||||
it('should reject when allowRoomCreation is not provided', async () => {
|
||||
const response = await updateSecurityPreferences({
|
||||
roomCreationPolicy: {
|
||||
requireAuthentication: true
|
||||
}
|
||||
@ -143,6 +137,19 @@ describe('Security Preferences API Tests', () => {
|
||||
expectValidationError(response, 'roomCreationPolicy.allowRoomCreation', 'Required');
|
||||
});
|
||||
|
||||
it('should reject when allowRoomCreation is true and requireAuthentication is not provided', async () => {
|
||||
const response = await updateSecurityPreferences({
|
||||
roomCreationPolicy: {
|
||||
allowRoomCreation: true
|
||||
}
|
||||
});
|
||||
expectValidationError(
|
||||
response,
|
||||
'roomCreationPolicy.requireAuthentication',
|
||||
'requireAuthentication is required when allowRoomCreation is true'
|
||||
);
|
||||
});
|
||||
|
||||
it('should reject when authMode is not a valid enum value', async () => {
|
||||
const response = await updateSecurityPreferences({
|
||||
authentication: {
|
||||
@ -177,7 +184,7 @@ describe('Security Preferences API Tests', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should reject when authMode or method.type is not provided', async () => {
|
||||
it('should reject when authMode or method are not provided', async () => {
|
||||
let response = await updateSecurityPreferences({
|
||||
authentication: {
|
||||
authMode: AuthMode.NONE
|
||||
|
||||
@ -1,6 +1,12 @@
|
||||
import { afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
||||
import { MeetRecordingAccess } from '../../../../src/typings/ce/index.js';
|
||||
import { createRoom, deleteAllRooms, getRoom, startTestServer, updateRoomPreferences } from '../../../helpers/request-helpers.js';
|
||||
import {
|
||||
createRoom,
|
||||
deleteAllRooms,
|
||||
getRoom,
|
||||
startTestServer,
|
||||
updateRoomPreferences
|
||||
} from '../../../helpers/request-helpers.js';
|
||||
|
||||
describe('Room API Tests', () => {
|
||||
beforeAll(() => {
|
||||
@ -95,8 +101,7 @@ describe('Room API Tests', () => {
|
||||
// Invalid preferences (missing required fields)
|
||||
const invalidPreferences = {
|
||||
recordingPreferences: {
|
||||
enabled: false,
|
||||
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_PUBLISHER
|
||||
enabled: false
|
||||
},
|
||||
// Missing chatPreferences
|
||||
virtualBackgroundPreferences: { enabled: false }
|
||||
@ -144,13 +149,29 @@ describe('Room API Tests', () => {
|
||||
expect(response.body.error).toContain('Unprocessable Entity');
|
||||
});
|
||||
|
||||
it('should fail when recording is enabled but allowAccessTo is missing', async () => {
|
||||
const createdRoom = await createRoom({
|
||||
roomIdPrefix: 'missing-access'
|
||||
});
|
||||
const invalidPreferences = {
|
||||
recordingPreferences: {
|
||||
enabled: true // Missing allowAccessTo
|
||||
},
|
||||
chatPreferences: { enabled: false },
|
||||
virtualBackgroundPreferences: { enabled: false }
|
||||
};
|
||||
const response = await updateRoomPreferences(createdRoom.roomId, invalidPreferences);
|
||||
expect(response.status).toBe(422);
|
||||
expect(response.body.error).toContain('Unprocessable Entity');
|
||||
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,
|
||||
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_PUBLISHER
|
||||
enabled: false
|
||||
},
|
||||
chatPreferences: { enabled: false },
|
||||
virtualBackgroundPreferences: { enabled: false }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user