Carlos Santos 8aa1bbc64b Refactor storage service and interfaces for improved separation of concerns
- Updated StorageFactory to create basic storage providers and key builders.
- Simplified StorageProvider interface to focus on basic CRUD operations.
- Enhanced MeetStorageService to handle domain-specific logic while delegating storage operations.
- Implemented Redis caching for room data to improve performance.
- Added error handling and logging improvements throughout the service.
- Removed deprecated methods and streamlined object retrieval processes.
refactor: update storage service and interfaces to include user key handling and improve initialization logic

refactor: update beforeAll hooks in recording tests to clear rooms and recordings

refactor: optimize integration recordings test command

Revert "refactor: optimize integration recordings test command"

This reverts commit d517a44fa282b91613f8c55130916c2af5f07267.

refactor: enhance Redis cache storage operations

refactor: streamline test setup and teardown for security and recordings APIs
2025-06-04 11:14:04 +02:00

127 lines
3.6 KiB
TypeScript

import { beforeAll, beforeEach, describe, expect, it } from '@jest/globals';
import { expectValidationError } from '../../../helpers/assertion-helpers.js';
import {
getSecurityPreferences,
startTestServer,
updateSecurityPreferences
} from '../../../helpers/request-helpers.js';
import { AuthMode, AuthType } from '../../../../src/typings/ce/index.js';
import { container } from '../../../../src/config/dependency-injector.config.js';
import { MeetStorageService } from '../../../../src/services/index.js';
const defaultPreferences = {
authentication: {
authMethod: {
type: AuthType.SINGLE_USER
},
authModeToAccessRoom: AuthMode.NONE
}
};
const restoreDefaultGlobalPreferences = async () => {
const defaultPref = await container.get(MeetStorageService)['buildDefaultPreferences']();
await container.get(MeetStorageService).saveGlobalPreferences(defaultPref);
};
describe('Security Preferences API Tests', () => {
beforeAll(async () => {
startTestServer();
});
beforeEach(async () => {
await restoreDefaultGlobalPreferences();
});
describe('Update security preferences', () => {
it('should update security preferences with valid complete data', async () => {
const validPreferences = {
authentication: {
authMethod: {
type: AuthType.SINGLE_USER
},
authModeToAccessRoom: AuthMode.ALL_USERS
}
};
let response = await updateSecurityPreferences(validPreferences);
expect(response.status).toBe(200);
expect(response.body.message).toBe('Security preferences updated successfully');
response = await getSecurityPreferences();
expect(response.status).toBe(200);
expect(response.body).toEqual(validPreferences);
});
});
describe('Update security preferences validation', () => {
it('should reject when authModeToAccessRoom is not a valid enum value', async () => {
const response = await updateSecurityPreferences({
authentication: {
authMethod: {
type: AuthType.SINGLE_USER
},
authModeToAccessRoom: 'invalid'
}
});
expectValidationError(
response,
'authentication.authModeToAccessRoom',
"Invalid enum value. Expected 'none' | 'moderators_only' | 'all_users', received 'invalid'"
);
});
it('should reject when authType is not a valid enum value', async () => {
const response = await updateSecurityPreferences({
authentication: {
authMethod: {
type: 'invalid'
},
authModeToAccessRoom: AuthMode.ALL_USERS
}
});
expectValidationError(
response,
'authentication.authMethod.type',
"Invalid enum value. Expected 'single-user', received 'invalid'"
);
});
it('should reject when authModeToAccessRoom or authMethod are not provided', async () => {
let response = await updateSecurityPreferences({
authentication: {
authMode: AuthMode.NONE
}
});
expectValidationError(response, 'authentication.authMethod', 'Required');
response = await updateSecurityPreferences({
authentication: {
method: {
type: AuthType.SINGLE_USER
}
}
});
expectValidationError(response, 'authentication.authModeToAccessRoom', 'Required');
});
it('should reject when authentication is not an object', async () => {
const response = await updateSecurityPreferences({
authentication: 'invalid'
});
expectValidationError(response, 'authentication', 'Expected object, received string');
});
});
describe('Get security preferences', () => {
it('should return security preferences when authenticated as admin', async () => {
const response = await getSecurityPreferences();
expect(response.status).toBe(200);
expect(response.body).toEqual(defaultPreferences);
});
});
});