test: update security config tests to include authentication transport mode
This commit is contained in:
parent
f7a53403eb
commit
b62c626a3f
@ -9,7 +9,7 @@ import {
|
|||||||
rejectRequestFromMeetError
|
rejectRequestFromMeetError
|
||||||
} from '../models/error.model.js';
|
} from '../models/error.model.js';
|
||||||
import { LoggerService, ParticipantService, RoomService, TokenService } from '../services/index.js';
|
import { LoggerService, ParticipantService, RoomService, TokenService } from '../services/index.js';
|
||||||
import { getAuthTransportMode, getCookieOptions, getRecordingToken } from '../utils/index.js';
|
import { getAuthTransportMode, getCookieOptions, getParticipantToken } from '../utils/index.js';
|
||||||
|
|
||||||
export const generateParticipantToken = async (req: Request, res: Response) => {
|
export const generateParticipantToken = async (req: Request, res: Response) => {
|
||||||
const logger = container.get(LoggerService);
|
const logger = container.get(LoggerService);
|
||||||
@ -61,7 +61,7 @@ export const refreshParticipantToken = async (req: Request, res: Response) => {
|
|||||||
const participantService = container.get(ParticipantService);
|
const participantService = container.get(ParticipantService);
|
||||||
|
|
||||||
// Check if there is a previous token
|
// Check if there is a previous token
|
||||||
const previousToken = await getRecordingToken(req);
|
const previousToken = await getParticipantToken(req);
|
||||||
|
|
||||||
if (!previousToken) {
|
if (!previousToken) {
|
||||||
logger.verbose('No previous participant token found. Cannot refresh.');
|
logger.verbose('No previous participant token found. Cannot refresh.');
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import { createApp, registerDependencies } from '../../src/server.js';
|
|||||||
import { RecordingService, RoomService } from '../../src/services/index.js';
|
import { RecordingService, RoomService } from '../../src/services/index.js';
|
||||||
import {
|
import {
|
||||||
AuthMode,
|
AuthMode,
|
||||||
|
AuthTransportMode,
|
||||||
AuthType,
|
AuthType,
|
||||||
MeetRecordingAccess,
|
MeetRecordingAccess,
|
||||||
MeetRecordingInfo,
|
MeetRecordingInfo,
|
||||||
@ -157,6 +158,7 @@ export const changeSecurityConfig = async (authMode: AuthMode) => {
|
|||||||
authMethod: {
|
authMethod: {
|
||||||
type: AuthType.SINGLE_USER
|
type: AuthType.SINGLE_USER
|
||||||
},
|
},
|
||||||
|
authTransportMode: AuthTransportMode.COOKIE,
|
||||||
authModeToAccessRoom: authMode
|
authModeToAccessRoom: authMode
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
import { afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
||||||
import { container } from '../../../../src/config/dependency-injector.config.js';
|
import { container } from '../../../../src/config/dependency-injector.config.js';
|
||||||
import { MeetStorageService } from '../../../../src/services/index.js';
|
import { MeetStorageService } from '../../../../src/services/index.js';
|
||||||
import { AuthMode, AuthType } from '../../../../src/typings/ce/index.js';
|
import { AuthMode, AuthTransportMode, AuthType } from '../../../../src/typings/ce/index.js';
|
||||||
import { expectValidationError } from '../../../helpers/assertion-helpers.js';
|
import { expectValidationError } from '../../../helpers/assertion-helpers.js';
|
||||||
import { getSecurityConfig, startTestServer, updateSecurityConfig } from '../../../helpers/request-helpers.js';
|
import { getSecurityConfig, startTestServer, updateSecurityConfig } from '../../../helpers/request-helpers.js';
|
||||||
|
|
||||||
@ -10,6 +10,7 @@ const defaultConfig = {
|
|||||||
authMethod: {
|
authMethod: {
|
||||||
type: AuthType.SINGLE_USER
|
type: AuthType.SINGLE_USER
|
||||||
},
|
},
|
||||||
|
authTransportMode: AuthTransportMode.COOKIE,
|
||||||
authModeToAccessRoom: AuthMode.NONE
|
authModeToAccessRoom: AuthMode.NONE
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -35,6 +36,7 @@ describe('Security Config API Tests', () => {
|
|||||||
authMethod: {
|
authMethod: {
|
||||||
type: AuthType.SINGLE_USER
|
type: AuthType.SINGLE_USER
|
||||||
},
|
},
|
||||||
|
authTransportMode: AuthTransportMode.COOKIE,
|
||||||
authModeToAccessRoom: AuthMode.ALL_USERS
|
authModeToAccessRoom: AuthMode.ALL_USERS
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -84,19 +86,49 @@ describe('Security Config API Tests', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reject when authModeToAccessRoom or authMethod are not provided', async () => {
|
it('should reject when authTransportMode is not a valid enum value', async () => {
|
||||||
|
const response = await updateSecurityConfig({
|
||||||
|
authentication: {
|
||||||
|
authMethod: {
|
||||||
|
type: AuthType.SINGLE_USER
|
||||||
|
},
|
||||||
|
authModeToAccessRoom: AuthMode.ALL_USERS,
|
||||||
|
authTransportMode: 'invalid'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expectValidationError(
|
||||||
|
response,
|
||||||
|
'authentication.authTransportMode',
|
||||||
|
"Invalid enum value. Expected 'cookie' | 'header', received 'invalid'"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject when authModeToAccessRoom, authTransportMode or authMethod are not provided', async () => {
|
||||||
let response = await updateSecurityConfig({
|
let response = await updateSecurityConfig({
|
||||||
authentication: {
|
authentication: {
|
||||||
authMode: AuthMode.NONE
|
authMode: AuthMode.NONE,
|
||||||
|
authTransportMode: AuthTransportMode.COOKIE
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
expectValidationError(response, 'authentication.authMethod', 'Required');
|
expectValidationError(response, 'authentication.authMethod', 'Required');
|
||||||
|
|
||||||
response = await updateSecurityConfig({
|
response = await updateSecurityConfig({
|
||||||
authentication: {
|
authentication: {
|
||||||
method: {
|
authMethod: {
|
||||||
type: AuthType.SINGLE_USER
|
type: AuthType.SINGLE_USER
|
||||||
}
|
},
|
||||||
|
authModeToAccessRoom: AuthMode.NONE
|
||||||
|
}
|
||||||
|
});
|
||||||
|
expectValidationError(response, 'authentication.authTransportMode', 'Required');
|
||||||
|
|
||||||
|
response = await updateSecurityConfig({
|
||||||
|
authentication: {
|
||||||
|
authMethod: {
|
||||||
|
type: AuthType.SINGLE_USER
|
||||||
|
},
|
||||||
|
authTransportMode: AuthTransportMode.COOKIE
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
expectValidationError(response, 'authentication.authModeToAccessRoom', 'Required');
|
expectValidationError(response, 'authentication.authModeToAccessRoom', 'Required');
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { container } from '../../../../src/config/dependency-injector.config.js'
|
|||||||
import INTERNAL_CONFIG from '../../../../src/config/internal-config.js';
|
import INTERNAL_CONFIG from '../../../../src/config/internal-config.js';
|
||||||
import { MEET_INITIAL_API_KEY } from '../../../../src/environment.js';
|
import { MEET_INITIAL_API_KEY } from '../../../../src/environment.js';
|
||||||
import { MeetStorageService } from '../../../../src/services/index.js';
|
import { MeetStorageService } from '../../../../src/services/index.js';
|
||||||
import { AuthMode, AuthType, MeetRoomThemeMode } from '../../../../src/typings/ce/index.js';
|
import { AuthMode, AuthTransportMode, AuthType, MeetRoomThemeMode } from '../../../../src/typings/ce/index.js';
|
||||||
import { loginUser, startTestServer } from '../../../helpers/request-helpers.js';
|
import { loginUser, startTestServer } from '../../../helpers/request-helpers.js';
|
||||||
|
|
||||||
const CONFIG_PATH = `${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/config`;
|
const CONFIG_PATH = `${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/config`;
|
||||||
@ -79,6 +79,7 @@ describe('Global Config API Security Tests', () => {
|
|||||||
authMethod: {
|
authMethod: {
|
||||||
type: AuthType.SINGLE_USER
|
type: AuthType.SINGLE_USER
|
||||||
},
|
},
|
||||||
|
authTransportMode: AuthTransportMode.COOKIE,
|
||||||
authModeToAccessRoom: AuthMode.ALL_USERS
|
authModeToAccessRoom: AuthMode.ALL_USERS
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user