backend: moved update room endpoint from internal to public

This commit is contained in:
Carlos Santos 2025-07-30 13:28:19 +02:00
parent f5b0944599
commit 583941fbd9
6 changed files with 41 additions and 42 deletions

View File

@ -28,8 +28,6 @@ paths:
$ref: './paths/internal/global-preferences.yaml#/~1preferences~1security'
/preferences/appearance:
$ref: './paths/internal/global-preferences.yaml#/~1preferences~1appearance'
/rooms/{roomId}:
$ref: './paths/internal/rooms.yaml#/~1rooms~1{roomId}'
/rooms/{roomId}/preferences:
$ref: './paths/internal/rooms.yaml#/~1rooms~1{roomId}~1preferences'
/rooms/{roomId}/recording-token:

View File

@ -1,30 +1,3 @@
/rooms/{roomId}:
put:
operationId: updateRoom
summary: Update a room
description: >
Updates the preferences of an OpenVidu Meet room with the specified room ID.
tags:
- Internal API - Rooms
security:
- accessTokenCookie: []
parameters:
- $ref: '../../components/parameters/room-id-path.yaml'
requestBody:
$ref: '../../components/requestBodies/internal/update-room-request.yaml'
responses:
'200':
$ref: '../../components/responses/internal/success-update-room.yaml'
'401':
$ref: '../../components/responses/unauthorized-error.yaml'
'403':
$ref: '../../components/responses/forbidden-error.yaml'
'404':
$ref: '../../components/responses/error-room-not-found.yaml'
'422':
$ref: '../../components/responses/validation-error.yaml'
'500':
$ref: '../../components/responses/internal-server-error.yaml'
/rooms/{roomId}/preferences:
get:
operationId: getRoomPreferences

View File

@ -118,6 +118,33 @@
$ref: '../components/responses/validation-error.yaml'
'500':
$ref: '../components/responses/internal-server-error.yaml'
put:
operationId: updateRoom
summary: Update a room
description: >
Updates the preferences of an OpenVidu Meet room with the specified room ID.
tags:
- OpenVidu Meet - Room
security:
- accessTokenCookie: []
parameters:
- $ref: '../components/parameters/room-id-path.yaml'
requestBody:
$ref: '../components/requestBodies/internal/update-room-request.yaml'
responses:
'200':
$ref: '../components/responses/internal/success-update-room.yaml'
'401':
$ref: '../components/responses/unauthorized-error.yaml'
'403':
$ref: '../components/responses/forbidden-error.yaml'
'404':
$ref: '../components/responses/error-room-not-found.yaml'
'422':
$ref: '../components/responses/validation-error.yaml'
'500':
$ref: '../components/responses/internal-server-error.yaml'
delete:
operationId: deleteRoom
summary: Delete a room

View File

@ -50,6 +50,14 @@ roomRouter.get(
configureRoomAuthorization,
roomCtrl.getRoom
);
roomRouter.put(
'/:roomId',
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
withValidRoomId,
withValidRoomPreferences,
roomCtrl.updateRoomPreferences
);
roomRouter.delete(
'/:roomId',
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
@ -62,13 +70,6 @@ export const internalRoomRouter = Router();
internalRoomRouter.use(bodyParser.urlencoded({ extended: true }));
internalRoomRouter.use(bodyParser.json());
internalRoomRouter.put(
'/:roomId',
withAuth(tokenAndRoleValidator(UserRole.ADMIN)),
withValidRoomId,
withValidRoomPreferences,
roomCtrl.updateRoomPreferences
);
internalRoomRouter.get(
'/:roomId/preferences',
withAuth(participantTokenValidator),

View File

@ -251,7 +251,7 @@ export const updateRoomPreferences = async (roomId: string, preferences: any) =>
const adminCookie = await loginUser();
return await request(app)
.put(`${INTERNAL_CONFIG.INTERNAL_API_BASE_PATH_V1}/rooms/${roomId}`)
.put(`${INTERNAL_CONFIG.API_BASE_PATH_V1}/rooms/${roomId}`)
.set('Cookie', adminCookie)
.send(preferences);
};

View File

@ -194,24 +194,24 @@ describe('Room API Security Tests', () => {
roomId = room.roomId;
});
it('should fail when request includes API key', async () => {
it('should succeed when request includes API key', async () => {
const response = await request(app)
.put(`${INTERNAL_ROOMS_PATH}/${roomId}`)
.put(`${ROOMS_PATH}/${roomId}`)
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_API_KEY)
.send(roomPreferences);
expect(response.status).toBe(401);
expect(response.status).toBe(200);
});
it('should succeed when user is authenticated as admin', async () => {
const response = await request(app)
.put(`${INTERNAL_ROOMS_PATH}/${roomId}`)
.put(`${ROOMS_PATH}/${roomId}`)
.set('Cookie', adminCookie)
.send(roomPreferences);
expect(response.status).toBe(200);
});
it('should fail when user is not authenticated', async () => {
const response = await request(app).put(`${INTERNAL_ROOMS_PATH}/${roomId}`).send(roomPreferences);
const response = await request(app).put(`${ROOMS_PATH}/${roomId}`).send(roomPreferences);
expect(response.status).toBe(401);
});
});