test: streamline password reset logic in user security tests and update change password method to use MEET_ADMIN_SECRET
This commit is contained in:
parent
0154947fcf
commit
13e651cf8d
@ -9,8 +9,6 @@ import {
|
|||||||
ParticipantRole
|
ParticipantRole
|
||||||
} from '../../src/typings/ce';
|
} from '../../src/typings/ce';
|
||||||
|
|
||||||
const RECORDINGS_PATH = `${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/recordings`;
|
|
||||||
|
|
||||||
export const expectErrorResponse = (
|
export const expectErrorResponse = (
|
||||||
response: any,
|
response: any,
|
||||||
status = 422,
|
status = 422,
|
||||||
@ -445,11 +443,9 @@ export const expectValidGetRecordingUrlResponse = (response: any, recordingId: s
|
|||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
const recordingUrl = response.body.url;
|
const recordingUrl = response.body.url;
|
||||||
expect(recordingUrl).toBeDefined();
|
expect(recordingUrl).toBeDefined();
|
||||||
|
|
||||||
const parsedUrl = new URL(recordingUrl);
|
const parsedUrl = new URL(recordingUrl);
|
||||||
expect(parsedUrl.pathname).toBe(
|
expect(parsedUrl.pathname).toBe(`/recording/${recordingId}`);
|
||||||
`/recording/${recordingId}`
|
|
||||||
);
|
|
||||||
expect(parsedUrl.searchParams.get('secret')).toBeDefined();
|
expect(parsedUrl.searchParams.get('secret')).toBeDefined();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import { beforeAll, describe, expect, it } from '@jest/globals';
|
import { afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
||||||
import { Express } from 'express';
|
import { Express } from 'express';
|
||||||
import request from 'supertest';
|
import request from 'supertest';
|
||||||
import INTERNAL_CONFIG from '../../../../src/config/internal-config.js';
|
import INTERNAL_CONFIG from '../../../../src/config/internal-config.js';
|
||||||
import { loginUser, startTestServer } from '../../../helpers/request-helpers.js';
|
import { MEET_ADMIN_SECRET } from '../../../../src/environment.js';
|
||||||
|
import { changePassword, loginUser, startTestServer } from '../../../helpers/request-helpers.js';
|
||||||
|
|
||||||
const USERS_PATH = `${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/users`;
|
const USERS_PATH = `${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/users`;
|
||||||
|
|
||||||
@ -42,6 +43,11 @@ describe('User API Security Tests', () => {
|
|||||||
adminCookie = await loginUser();
|
adminCookie = await loginUser();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
// Reset password
|
||||||
|
await changePassword(MEET_ADMIN_SECRET, adminCookie);
|
||||||
|
});
|
||||||
|
|
||||||
it('should succeed when user is authenticated as admin', async () => {
|
it('should succeed when user is authenticated as admin', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app)
|
||||||
.post(`${USERS_PATH}/change-password`)
|
.post(`${USERS_PATH}/change-password`)
|
||||||
@ -51,9 +57,7 @@ describe('User API Security Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when user is not authenticated', async () => {
|
it('should fail when user is not authenticated', async () => {
|
||||||
const response = await request(app)
|
const response = await request(app).post(`${USERS_PATH}/change-password`).send(changePasswordRequest);
|
||||||
.post(`${USERS_PATH}/change-password`)
|
|
||||||
.send(changePasswordRequest);
|
|
||||||
expect(response.status).toBe(401);
|
expect(response.status).toBe(401);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
import { afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
||||||
|
import { MEET_ADMIN_SECRET } from '../../../../src/environment.js';
|
||||||
import { expectValidationError } from '../../../helpers/assertion-helpers.js';
|
import { expectValidationError } from '../../../helpers/assertion-helpers.js';
|
||||||
import { changePassword, loginUser, startTestServer } from '../../../helpers/request-helpers.js';
|
import { changePassword, loginUser, startTestServer } from '../../../helpers/request-helpers.js';
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ describe('Users API Tests', () => {
|
|||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
// Reset password
|
// Reset password
|
||||||
await changePassword('admin', adminCookie);
|
await changePassword(MEET_ADMIN_SECRET, adminCookie);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Change Password Tests', () => {
|
describe('Change Password Tests', () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user