backend: update appearance config route to allow anonymous access and adjust related tests
This commit is contained in:
parent
c499dbf6e3
commit
67dfd5df63
@ -5,6 +5,7 @@ import * as appearanceConfigCtrl from '../controllers/global-config/appearance-c
|
||||
import * as securityConfigCtrl from '../controllers/global-config/security-config.controller.js';
|
||||
import * as webhookConfigCtrl from '../controllers/global-config/webhook-config.controller.js';
|
||||
import {
|
||||
allowAnonymous,
|
||||
tokenAndRoleValidator,
|
||||
validateRoomsAppearanceConfig,
|
||||
validateSecurityConfig,
|
||||
@ -34,7 +35,7 @@ configRouter.put(
|
||||
validateSecurityConfig,
|
||||
securityConfigCtrl.updateSecurityConfig
|
||||
);
|
||||
configRouter.get('/security', securityConfigCtrl.getSecurityConfig);
|
||||
configRouter.get('/security', withAuth(allowAnonymous), securityConfigCtrl.getSecurityConfig);
|
||||
|
||||
// Appearance config
|
||||
configRouter.put(
|
||||
@ -43,8 +44,4 @@ configRouter.put(
|
||||
validateRoomsAppearanceConfig,
|
||||
appearanceConfigCtrl.updateRoomsAppearanceConfig
|
||||
);
|
||||
configRouter.get(
|
||||
'/rooms/appearance',
|
||||
withAuth(tokenAndRoleValidator(UserRole.ADMIN)),
|
||||
appearanceConfigCtrl.getRoomsAppearanceConfig
|
||||
);
|
||||
configRouter.get('/rooms/appearance', withAuth(allowAnonymous), appearanceConfigCtrl.getRoomsAppearanceConfig);
|
||||
|
||||
@ -80,10 +80,8 @@ export const getApiKeys = async () => {
|
||||
export const getRoomsAppearanceConfig = async () => {
|
||||
checkAppIsRunning();
|
||||
|
||||
const adminCookie = await loginUser();
|
||||
const response = await request(app)
|
||||
.get(`${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/config/rooms/appearance`)
|
||||
.set('Cookie', adminCookie)
|
||||
.send();
|
||||
return response;
|
||||
};
|
||||
|
||||
@ -152,21 +152,9 @@ describe('Global Config API Security Tests', () => {
|
||||
});
|
||||
|
||||
describe('Get Rooms Appearance Config Tests', () => {
|
||||
it('should fail when request includes API key', async () => {
|
||||
const response = await request(app)
|
||||
.get(`${CONFIG_PATH}/rooms/appearance`)
|
||||
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_INITIAL_API_KEY);
|
||||
expect(response.status).toBe(401);
|
||||
});
|
||||
|
||||
it('should succeed when user is authenticated as admin', async () => {
|
||||
const response = await request(app).get(`${CONFIG_PATH}/rooms/appearance`).set('Cookie', adminCookie);
|
||||
expect(response.status).toBe(200);
|
||||
});
|
||||
|
||||
it('should fail when user is not authenticated', async () => {
|
||||
it('should succeed when user is not authenticated', async () => {
|
||||
const response = await request(app).get(`${CONFIG_PATH}/rooms/appearance`);
|
||||
expect(response.status).toBe(401);
|
||||
expect(response.status).toBe(200);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user