tests: Simplify changeSecurityPreferences and update token generation functions to remove adminCookie parameter
This commit is contained in:
parent
ad928006d2
commit
edab6bba31
@ -54,12 +54,14 @@ export const startTestServer = (): Express => {
|
|||||||
/**
|
/**
|
||||||
* Updates global security preferences
|
* Updates global security preferences
|
||||||
*/
|
*/
|
||||||
export const changeSecurityPreferences = async (
|
export const changeSecurityPreferences = async ({
|
||||||
adminCookie: string,
|
usersCanCreateRooms = true,
|
||||||
{ usersCanCreateRooms = true, authRequired = true, authMode = AuthMode.NONE }
|
authRequired = true,
|
||||||
) => {
|
authMode = AuthMode.NONE
|
||||||
|
}) => {
|
||||||
checkAppIsRunning();
|
checkAppIsRunning();
|
||||||
|
|
||||||
|
const adminCookie = await loginUserAsRole(UserRole.ADMIN);
|
||||||
await request(app)
|
await request(app)
|
||||||
.put(`${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/preferences/security`)
|
.put(`${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/preferences/security`)
|
||||||
.set('Cookie', adminCookie)
|
.set('Cookie', adminCookie)
|
||||||
@ -223,7 +225,6 @@ export const deleteAllRooms = async () => {
|
|||||||
* Generates a participant token for a room and returns the cookie containing the token
|
* Generates a participant token for a room and returns the cookie containing the token
|
||||||
*/
|
*/
|
||||||
export const generateParticipantToken = async (
|
export const generateParticipantToken = async (
|
||||||
adminCookie: string,
|
|
||||||
roomId: string,
|
roomId: string,
|
||||||
participantName: string,
|
participantName: string,
|
||||||
secret: string
|
secret: string
|
||||||
@ -231,7 +232,7 @@ export const generateParticipantToken = async (
|
|||||||
checkAppIsRunning();
|
checkAppIsRunning();
|
||||||
|
|
||||||
// Disable authentication to generate the token
|
// Disable authentication to generate the token
|
||||||
await changeSecurityPreferences(adminCookie, {
|
await changeSecurityPreferences({
|
||||||
authMode: AuthMode.NONE
|
authMode: AuthMode.NONE
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -297,7 +298,7 @@ export const joinFakeParticipant = async (roomId: string, participantName: strin
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Store the process to be able to terminate it later
|
// Store the process to be able to terminate it later
|
||||||
fakeParticipantsProcesses.set(participantName, process);
|
fakeParticipantsProcesses.set(`${roomId}-${participantName}`, process);
|
||||||
await sleep('1s');
|
await sleep('1s');
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -314,11 +315,11 @@ export const disconnectFakeParticipants = async () => {
|
|||||||
/**
|
/**
|
||||||
* Generates a token for retrieving/deleting recordings from a room and returns the cookie containing the token
|
* Generates a token for retrieving/deleting recordings from a room and returns the cookie containing the token
|
||||||
*/
|
*/
|
||||||
export const generateRecordingToken = async (adminCookie: string, roomId: string, secret: string) => {
|
export const generateRecordingToken = async (roomId: string, secret: string) => {
|
||||||
checkAppIsRunning();
|
checkAppIsRunning();
|
||||||
|
|
||||||
// Disable authentication to generate the token
|
// Disable authentication to generate the token
|
||||||
await changeSecurityPreferences(adminCookie, {
|
await changeSecurityPreferences({
|
||||||
authMode: AuthMode.NONE
|
authMode: AuthMode.NONE
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user