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 () => {
|
it('should update security preferences with valid partial data (roomCreationPolicy)', async () => {
|
||||||
const validPreferences = {
|
const validPreferences = {
|
||||||
roomCreationPolicy: {
|
roomCreationPolicy: {
|
||||||
allowRoomCreation: false,
|
allowRoomCreation: false
|
||||||
requireAuthentication: true
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let response = await updateSecurityPreferences(validPreferences);
|
let response = await updateSecurityPreferences(validPreferences);
|
||||||
@ -71,7 +70,9 @@ describe('Security Preferences API Tests', () => {
|
|||||||
|
|
||||||
response = await getSecurityPreferences();
|
response = await getSecurityPreferences();
|
||||||
expect(response.status).toBe(200);
|
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);
|
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 () => {
|
it('should reject when allowRoomCreation is not provided', async () => {
|
||||||
let response = await updateSecurityPreferences({
|
const response = await updateSecurityPreferences({
|
||||||
roomCreationPolicy: {
|
|
||||||
allowRoomCreation: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
expectValidationError(response, 'roomCreationPolicy.requireAuthentication', 'Required');
|
|
||||||
|
|
||||||
response = await updateSecurityPreferences({
|
|
||||||
roomCreationPolicy: {
|
roomCreationPolicy: {
|
||||||
requireAuthentication: true
|
requireAuthentication: true
|
||||||
}
|
}
|
||||||
@ -143,6 +137,19 @@ describe('Security Preferences API Tests', () => {
|
|||||||
expectValidationError(response, 'roomCreationPolicy.allowRoomCreation', 'Required');
|
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 () => {
|
it('should reject when authMode is not a valid enum value', async () => {
|
||||||
const response = await updateSecurityPreferences({
|
const response = await updateSecurityPreferences({
|
||||||
authentication: {
|
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({
|
let response = await updateSecurityPreferences({
|
||||||
authentication: {
|
authentication: {
|
||||||
authMode: AuthMode.NONE
|
authMode: AuthMode.NONE
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
import { afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
import { afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
||||||
import { MeetRecordingAccess } from '../../../../src/typings/ce/index.js';
|
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', () => {
|
describe('Room API Tests', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
@ -95,8 +101,7 @@ describe('Room API Tests', () => {
|
|||||||
// Invalid preferences (missing required fields)
|
// Invalid preferences (missing required fields)
|
||||||
const invalidPreferences = {
|
const invalidPreferences = {
|
||||||
recordingPreferences: {
|
recordingPreferences: {
|
||||||
enabled: false,
|
enabled: false
|
||||||
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_PUBLISHER
|
|
||||||
},
|
},
|
||||||
// Missing chatPreferences
|
// Missing chatPreferences
|
||||||
virtualBackgroundPreferences: { enabled: false }
|
virtualBackgroundPreferences: { enabled: false }
|
||||||
@ -144,13 +149,29 @@ describe('Room API Tests', () => {
|
|||||||
expect(response.body.error).toContain('Unprocessable Entity');
|
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 () => {
|
it('should fail when room ID contains invalid characters', async () => {
|
||||||
const invalidRoomId = '!@#$%^&*()';
|
const invalidRoomId = '!@#$%^&*()';
|
||||||
|
|
||||||
const preferences = {
|
const preferences = {
|
||||||
recordingPreferences: {
|
recordingPreferences: {
|
||||||
enabled: false,
|
enabled: false
|
||||||
allowAccessTo: MeetRecordingAccess.ADMIN_MODERATOR_PUBLISHER
|
|
||||||
},
|
},
|
||||||
chatPreferences: { enabled: false },
|
chatPreferences: { enabled: false },
|
||||||
virtualBackgroundPreferences: { enabled: false }
|
virtualBackgroundPreferences: { enabled: false }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user