test: update security tests to use admin login for authentication
This commit is contained in:
parent
b2488544e3
commit
8ab8007c1d
@ -3,7 +3,7 @@ import { Express } from 'express';
|
||||
import request from 'supertest';
|
||||
import { INTERNAL_CONFIG } from '../../../../src/config/internal-config.js';
|
||||
import { MEET_ENV } from '../../../../src/environment.js';
|
||||
import { loginUser, startTestServer } from '../../../helpers/request-helpers.js';
|
||||
import { loginAdminUser, startTestServer } from '../../../helpers/request-helpers.js';
|
||||
|
||||
const ANALYTICS_PATH = `${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/analytics`;
|
||||
|
||||
@ -13,7 +13,7 @@ describe('Analytics API Security Tests', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
app = await startTestServer();
|
||||
adminAccessToken = await loginUser();
|
||||
adminAccessToken = await loginAdminUser();
|
||||
});
|
||||
|
||||
describe('Get Analytics Tests', () => {
|
||||
|
||||
@ -2,7 +2,12 @@ import { afterAll, beforeAll, describe, expect, it } from '@jest/globals';
|
||||
import { Express } from 'express';
|
||||
import request from 'supertest';
|
||||
import { INTERNAL_CONFIG } from '../../../../src/config/internal-config.js';
|
||||
import { generateApiKey, loginUser, restoreDefaultApiKeys, startTestServer } from '../../../helpers/request-helpers.js';
|
||||
import {
|
||||
generateApiKey,
|
||||
loginAdminUser,
|
||||
restoreDefaultApiKeys,
|
||||
startTestServer
|
||||
} from '../../../helpers/request-helpers.js';
|
||||
|
||||
const API_KEYS_PATH = `${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/api-keys`;
|
||||
|
||||
@ -12,7 +17,7 @@ describe('API Keys API Security Tests', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
app = await startTestServer();
|
||||
adminAccessToken = await loginUser();
|
||||
adminAccessToken = await loginAdminUser();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import { beforeAll, describe, expect, it } from '@jest/globals';
|
||||
import { AuthMode, AuthType, MeetRoomThemeMode } from '@openvidu-meet/typings';
|
||||
import { MeetRoomThemeMode } from '@openvidu-meet/typings';
|
||||
import { Express } from 'express';
|
||||
import request from 'supertest';
|
||||
import { INTERNAL_CONFIG } from '../../../../src/config/internal-config.js';
|
||||
import { MEET_ENV } from '../../../../src/environment.js';
|
||||
import { loginUser, restoreDefaultGlobalConfig, startTestServer } from '../../../helpers/request-helpers.js';
|
||||
import { loginAdminUser, restoreDefaultGlobalConfig, startTestServer } from '../../../helpers/request-helpers.js';
|
||||
|
||||
const CONFIG_PATH = `${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/config`;
|
||||
|
||||
@ -14,7 +14,7 @@ describe('Global Config API Security Tests', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
app = await startTestServer();
|
||||
adminAccessToken = await loginUser();
|
||||
adminAccessToken = await loginAdminUser();
|
||||
});
|
||||
|
||||
describe('Update Webhook Config Tests', () => {
|
||||
@ -71,10 +71,8 @@ describe('Global Config API Security Tests', () => {
|
||||
describe('Update Security Config Tests', () => {
|
||||
const securityConfig = {
|
||||
authentication: {
|
||||
authMethod: {
|
||||
type: AuthType.SINGLE_USER
|
||||
},
|
||||
authModeToAccessRoom: AuthMode.ALL_USERS
|
||||
allowUserCreation: true,
|
||||
oauthProviders: []
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import { getPermissions } from '../../../helpers/assertion-helpers.js';
|
||||
import {
|
||||
deleteAllRooms,
|
||||
disconnectFakeParticipants,
|
||||
loginUser,
|
||||
loginAdminUser,
|
||||
startTestServer,
|
||||
updateParticipantMetadata
|
||||
} from '../../../helpers/request-helpers.js';
|
||||
@ -24,7 +24,7 @@ describe('Meeting API Security Tests', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
app = await startTestServer();
|
||||
adminAccessToken = await loginUser();
|
||||
adminAccessToken = await loginAdminUser();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
@ -82,8 +82,9 @@ describe('Meeting API Security Tests', () => {
|
||||
beforeEach(async () => {
|
||||
const metadata: MeetRoomMemberTokenMetadata = {
|
||||
livekitUrl: MEET_ENV.LIVEKIT_URL,
|
||||
role: MeetRoomMemberRole.SPEAKER,
|
||||
permissions: getPermissions(roomData.room.roomId, MeetRoomMemberRole.SPEAKER, true, true).meet
|
||||
roomId: roomData.room.roomId,
|
||||
baseRole: MeetRoomMemberRole.SPEAKER,
|
||||
effectivePermissions: getPermissions(MeetRoomMemberRole.SPEAKER)
|
||||
};
|
||||
await updateParticipantMetadata(roomData.room.roomId, PARTICIPANT_NAME, metadata);
|
||||
});
|
||||
|
||||
@ -3,7 +3,7 @@ import { Express } from 'express';
|
||||
import request from 'supertest';
|
||||
import { INTERNAL_CONFIG } from '../../../../src/config/internal-config.js';
|
||||
import { MEET_ENV } from '../../../../src/environment.js';
|
||||
import { changePassword, loginUser, startTestServer } from '../../../helpers/request-helpers.js';
|
||||
import { changePassword, loginAdminUser, startTestServer } from '../../../helpers/request-helpers.js';
|
||||
|
||||
const USERS_PATH = `${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/users`;
|
||||
|
||||
@ -18,18 +18,18 @@ describe('User API Security Tests', () => {
|
||||
let adminAccessToken: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
adminAccessToken = await loginUser();
|
||||
adminAccessToken = await loginAdminUser();
|
||||
});
|
||||
|
||||
it('should succeed when user is authenticated as admin', async () => {
|
||||
const response = await request(app)
|
||||
.get(`${USERS_PATH}/profile`)
|
||||
.get(`${USERS_PATH}/me`)
|
||||
.set(INTERNAL_CONFIG.ACCESS_TOKEN_HEADER, adminAccessToken);
|
||||
expect(response.status).toBe(200);
|
||||
});
|
||||
|
||||
it('should fail when user is not authenticated', async () => {
|
||||
const response = await request(app).get(`${USERS_PATH}/profile`);
|
||||
const response = await request(app).get(`${USERS_PATH}/me`);
|
||||
expect(response.status).toBe(401);
|
||||
});
|
||||
});
|
||||
@ -43,7 +43,7 @@ describe('User API Security Tests', () => {
|
||||
let adminAccessToken: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
adminAccessToken = await loginUser();
|
||||
adminAccessToken = await loginAdminUser();
|
||||
});
|
||||
|
||||
it('should succeed when user is authenticated as admin', async () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user