backend: moved update room endpoint from internal to public
This commit is contained in:
parent
f5b0944599
commit
583941fbd9
@ -28,8 +28,6 @@ paths:
|
|||||||
$ref: './paths/internal/global-preferences.yaml#/~1preferences~1security'
|
$ref: './paths/internal/global-preferences.yaml#/~1preferences~1security'
|
||||||
/preferences/appearance:
|
/preferences/appearance:
|
||||||
$ref: './paths/internal/global-preferences.yaml#/~1preferences~1appearance'
|
$ref: './paths/internal/global-preferences.yaml#/~1preferences~1appearance'
|
||||||
/rooms/{roomId}:
|
|
||||||
$ref: './paths/internal/rooms.yaml#/~1rooms~1{roomId}'
|
|
||||||
/rooms/{roomId}/preferences:
|
/rooms/{roomId}/preferences:
|
||||||
$ref: './paths/internal/rooms.yaml#/~1rooms~1{roomId}~1preferences'
|
$ref: './paths/internal/rooms.yaml#/~1rooms~1{roomId}~1preferences'
|
||||||
/rooms/{roomId}/recording-token:
|
/rooms/{roomId}/recording-token:
|
||||||
|
|||||||
@ -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:
|
/rooms/{roomId}/preferences:
|
||||||
get:
|
get:
|
||||||
operationId: getRoomPreferences
|
operationId: getRoomPreferences
|
||||||
|
|||||||
@ -118,6 +118,33 @@
|
|||||||
$ref: '../components/responses/validation-error.yaml'
|
$ref: '../components/responses/validation-error.yaml'
|
||||||
'500':
|
'500':
|
||||||
$ref: '../components/responses/internal-server-error.yaml'
|
$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:
|
delete:
|
||||||
operationId: deleteRoom
|
operationId: deleteRoom
|
||||||
summary: Delete a room
|
summary: Delete a room
|
||||||
|
|||||||
@ -50,6 +50,14 @@ roomRouter.get(
|
|||||||
configureRoomAuthorization,
|
configureRoomAuthorization,
|
||||||
roomCtrl.getRoom
|
roomCtrl.getRoom
|
||||||
);
|
);
|
||||||
|
|
||||||
|
roomRouter.put(
|
||||||
|
'/:roomId',
|
||||||
|
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
|
||||||
|
withValidRoomId,
|
||||||
|
withValidRoomPreferences,
|
||||||
|
roomCtrl.updateRoomPreferences
|
||||||
|
);
|
||||||
roomRouter.delete(
|
roomRouter.delete(
|
||||||
'/:roomId',
|
'/:roomId',
|
||||||
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
|
withAuth(apiKeyValidator, tokenAndRoleValidator(UserRole.ADMIN)),
|
||||||
@ -62,13 +70,6 @@ export const internalRoomRouter = Router();
|
|||||||
internalRoomRouter.use(bodyParser.urlencoded({ extended: true }));
|
internalRoomRouter.use(bodyParser.urlencoded({ extended: true }));
|
||||||
internalRoomRouter.use(bodyParser.json());
|
internalRoomRouter.use(bodyParser.json());
|
||||||
|
|
||||||
internalRoomRouter.put(
|
|
||||||
'/:roomId',
|
|
||||||
withAuth(tokenAndRoleValidator(UserRole.ADMIN)),
|
|
||||||
withValidRoomId,
|
|
||||||
withValidRoomPreferences,
|
|
||||||
roomCtrl.updateRoomPreferences
|
|
||||||
);
|
|
||||||
internalRoomRouter.get(
|
internalRoomRouter.get(
|
||||||
'/:roomId/preferences',
|
'/:roomId/preferences',
|
||||||
withAuth(participantTokenValidator),
|
withAuth(participantTokenValidator),
|
||||||
|
|||||||
@ -251,7 +251,7 @@ export const updateRoomPreferences = async (roomId: string, preferences: any) =>
|
|||||||
|
|
||||||
const adminCookie = await loginUser();
|
const adminCookie = await loginUser();
|
||||||
return await request(app)
|
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)
|
.set('Cookie', adminCookie)
|
||||||
.send(preferences);
|
.send(preferences);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -194,24 +194,24 @@ describe('Room API Security Tests', () => {
|
|||||||
roomId = room.roomId;
|
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)
|
const response = await request(app)
|
||||||
.put(`${INTERNAL_ROOMS_PATH}/${roomId}`)
|
.put(`${ROOMS_PATH}/${roomId}`)
|
||||||
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_API_KEY)
|
.set(INTERNAL_CONFIG.API_KEY_HEADER, MEET_API_KEY)
|
||||||
.send(roomPreferences);
|
.send(roomPreferences);
|
||||||
expect(response.status).toBe(401);
|
expect(response.status).toBe(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
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)
|
||||||
.put(`${INTERNAL_ROOMS_PATH}/${roomId}`)
|
.put(`${ROOMS_PATH}/${roomId}`)
|
||||||
.set('Cookie', adminCookie)
|
.set('Cookie', adminCookie)
|
||||||
.send(roomPreferences);
|
.send(roomPreferences);
|
||||||
expect(response.status).toBe(200);
|
expect(response.status).toBe(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when user is not authenticated', async () => {
|
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);
|
expect(response.status).toBe(401);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user