test: update getRecordingUrl tests to use new URL format
This commit is contained in:
parent
d017e13d63
commit
e039e48e06
@ -448,7 +448,7 @@ export const expectValidGetRecordingUrlResponse = (response: any, recordingId: s
|
|||||||
|
|
||||||
const parsedUrl = new URL(recordingUrl);
|
const parsedUrl = new URL(recordingUrl);
|
||||||
expect(parsedUrl.pathname).toBe(
|
expect(parsedUrl.pathname).toBe(
|
||||||
`${INTERNAL_CONFIG.API_BASE_PATH_V1}/recordings/${recordingId}/media`
|
`/recording/${recordingId}`
|
||||||
);
|
);
|
||||||
expect(parsedUrl.searchParams.get('secret')).toBeDefined();
|
expect(parsedUrl.searchParams.get('secret')).toBeDefined();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import {
|
|||||||
} from '../../../helpers/request-helpers.js';
|
} from '../../../helpers/request-helpers.js';
|
||||||
import { setupSingleRoomWithRecording } from '../../../helpers/test-scenarios.js';
|
import { setupSingleRoomWithRecording } from '../../../helpers/test-scenarios.js';
|
||||||
import { expectValidGetRecordingUrlResponse } from '../../../helpers/assertion-helpers.js';
|
import { expectValidGetRecordingUrlResponse } from '../../../helpers/assertion-helpers.js';
|
||||||
|
import INTERNAL_CONFIG from '../../../../src/config/internal-config.js';
|
||||||
|
|
||||||
describe('Recording API Tests', () => {
|
describe('Recording API Tests', () => {
|
||||||
let app: Express;
|
let app: Express;
|
||||||
@ -30,30 +31,36 @@ describe('Recording API Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Get Recording URL Tests', () => {
|
describe('Get Recording URL Tests', () => {
|
||||||
|
const RECORDINGS_PATH = `${INTERNAL_CONFIG.API_BASE_PATH_V1}/recordings`;
|
||||||
|
|
||||||
it('should get public recording URL', async () => {
|
it('should get public recording URL', async () => {
|
||||||
const response = await getRecordingUrl(recordingId);
|
const response = await getRecordingUrl(recordingId);
|
||||||
expectValidGetRecordingUrlResponse(response, recordingId);
|
expectValidGetRecordingUrlResponse(response, recordingId);
|
||||||
|
|
||||||
// Parse the URL to extract the path
|
// Parse the URL to extract the secret from the query parameters
|
||||||
const parsedUrl = new URL(response.body.url);
|
const parsedUrl = new URL(response.body.url);
|
||||||
const recordingPath = parsedUrl.pathname + parsedUrl.search;
|
const secret = parsedUrl.searchParams.get('secret');
|
||||||
|
|
||||||
// Verify that the URL is publicly accessible
|
// Verify that the URL is publicly accessible
|
||||||
const publicResponse = await request(app).get(recordingPath);
|
const recordingResponse = await request(app).get(
|
||||||
expect(publicResponse.status).toBe(200);
|
`${RECORDINGS_PATH}/${recordingId}/media?secret=${secret}`
|
||||||
|
);
|
||||||
|
expect(recordingResponse.status).toBe(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get private recording URL', async () => {
|
it('should get private recording URL', async () => {
|
||||||
const response = await getRecordingUrl(recordingId, true);
|
const response = await getRecordingUrl(recordingId, true);
|
||||||
expectValidGetRecordingUrlResponse(response, recordingId);
|
expectValidGetRecordingUrlResponse(response, recordingId);
|
||||||
|
|
||||||
// Parse the URL to extract the path
|
// Parse the URL to extract the secret from the query parameters
|
||||||
const parsedUrl = new URL(response.body.url);
|
const parsedUrl = new URL(response.body.url);
|
||||||
const recordingPath = parsedUrl.pathname + parsedUrl.search;
|
const secret = parsedUrl.searchParams.get('secret');
|
||||||
|
|
||||||
// Verify that the URL is not publicly accessible
|
// Verify that the URL is not publicly accessible
|
||||||
const publicResponse = await request(app).get(recordingPath);
|
const recordingResponse = await request(app).get(
|
||||||
expect(publicResponse.status).toBe(401);
|
`${RECORDINGS_PATH}/${recordingId}/media?secret=${secret}`
|
||||||
|
);
|
||||||
|
expect(recordingResponse.status).toBe(401);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail with a 404 error when the recording does not exist', async () => {
|
it('should fail with a 404 error when the recording does not exist', async () => {
|
||||||
|
|||||||
@ -525,11 +525,11 @@ describe('Recording API Security Tests', () => {
|
|||||||
const recordingUrl = recordingUrlResponse.body.url;
|
const recordingUrl = recordingUrlResponse.body.url;
|
||||||
expect(recordingUrl).toBeDefined();
|
expect(recordingUrl).toBeDefined();
|
||||||
|
|
||||||
// Parse the URL to extract the path
|
// Parse the URL to extract the secret from the query parameters
|
||||||
const parsedUrl = new URL(recordingUrl);
|
const parsedUrl = new URL(recordingUrl);
|
||||||
const recordingPath = parsedUrl.pathname + parsedUrl.search;
|
const secret = parsedUrl.searchParams.get('secret');
|
||||||
|
|
||||||
const response = await request(app).get(recordingPath);
|
const response = await request(app).get(`${RECORDINGS_PATH}/${recordingId}/media?secret=${secret}`);
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -539,11 +539,11 @@ describe('Recording API Security Tests', () => {
|
|||||||
const recordingUrl = recordingUrlResponse.body.url;
|
const recordingUrl = recordingUrlResponse.body.url;
|
||||||
expect(recordingUrl).toBeDefined();
|
expect(recordingUrl).toBeDefined();
|
||||||
|
|
||||||
// Parse the URL to extract the path
|
// Parse the URL to extract the secret from the query parameters
|
||||||
const parsedUrl = new URL(recordingUrl);
|
const parsedUrl = new URL(recordingUrl);
|
||||||
const recordingPath = parsedUrl.pathname + parsedUrl.search;
|
const secret = parsedUrl.searchParams.get('secret');
|
||||||
|
|
||||||
const response = await request(app).get(recordingPath);
|
const response = await request(app).get(`${RECORDINGS_PATH}/${recordingId}/media?secret=${secret}`);
|
||||||
expect(response.status).toBe(401);
|
expect(response.status).toBe(401);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -553,11 +553,13 @@ describe('Recording API Security Tests', () => {
|
|||||||
const recordingUrl = recordingUrlResponse.body.url;
|
const recordingUrl = recordingUrlResponse.body.url;
|
||||||
expect(recordingUrl).toBeDefined();
|
expect(recordingUrl).toBeDefined();
|
||||||
|
|
||||||
// Parse the URL to extract the path
|
// Parse the URL to extract the secret from the query parameters
|
||||||
const parsedUrl = new URL(recordingUrl);
|
const parsedUrl = new URL(recordingUrl);
|
||||||
const recordingPath = parsedUrl.pathname + parsedUrl.search;
|
const secret = parsedUrl.searchParams.get('secret');
|
||||||
|
|
||||||
const response = await request(app).get(recordingPath).set('Cookie', adminCookie);
|
const response = await request(app)
|
||||||
|
.get(`${RECORDINGS_PATH}/${recordingId}/media?secret=${secret}`)
|
||||||
|
.set('Cookie', adminCookie);
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user