From d9638c3e8f85b17b73091491f3ad86e94923d1a4 Mon Sep 17 00:00:00 2001 From: Crevil Date: Thu, 25 Mar 2021 21:02:54 +0100 Subject: [PATCH] Allow DELETE /entities/by-uid/:uid in readonly mode Signed-off-by: Crevil --- plugins/catalog-backend/src/service/router.test.ts | 8 +++++--- plugins/catalog-backend/src/service/router.ts | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/catalog-backend/src/service/router.test.ts b/plugins/catalog-backend/src/service/router.test.ts index eb072f04d2..756e17f858 100644 --- a/plugins/catalog-backend/src/service/router.test.ts +++ b/plugins/catalog-backend/src/service/router.test.ts @@ -440,11 +440,13 @@ describe('createRouter readonly enabled', () => { }); describe('DELETE /entities/by-uid/:uid', () => { - it('is not allowed', async () => { + // this delete is allowed as there is no other way to remove entities + it('is allowed', async () => { const response = await request(app).delete('/entities/by-uid/apa'); - expect(response.status).toEqual(403); - expect(response.text).toMatch(/not allowed in readonly/); + expect(entitiesCatalog.removeEntityByUid).toHaveBeenCalledTimes(1); + expect(entitiesCatalog.removeEntityByUid).toHaveBeenCalledWith('apa'); + expect(response.status).toEqual(204); }); }); diff --git a/plugins/catalog-backend/src/service/router.ts b/plugins/catalog-backend/src/service/router.ts index 4c93b27640..ae58255a4e 100644 --- a/plugins/catalog-backend/src/service/router.ts +++ b/plugins/catalog-backend/src/service/router.ts @@ -123,8 +123,6 @@ export async function createRouter( res.status(200).json(entities[0]); }) .delete('/entities/by-uid/:uid', async (req, res) => { - disallowReadonlyMode(readonlyEnabled); - const { uid } = req.params; await entitiesCatalog.removeEntityByUid(uid); res.status(204).end();