From a0eb9130b6b608f45d71f00ddf32ddfdbb5294b0 Mon Sep 17 00:00:00 2001 From: williamlardier Date: Fri, 29 Nov 2024 13:34:45 +0100 Subject: [PATCH 1/3] Fix missing exlamation mark in route delete route Issue: ARSN-448 --- lib/s3routes/routes/routeDELETE.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/s3routes/routes/routeDELETE.ts b/lib/s3routes/routes/routeDELETE.ts index 484799c10..d6526795d 100644 --- a/lib/s3routes/routes/routeDELETE.ts +++ b/lib/s3routes/routes/routeDELETE.ts @@ -60,7 +60,7 @@ export default function routeDELETE( */ if (err && ( !(err instanceof ArsenalError) || - (!err.is.NoSuchKey && err.is.NoSuchVersion) + (!err.is.NoSuchKey && !err.is.NoSuchVersion) )) { return routesUtils.responseNoBody(err, corsHeaders, response, undefined, log); From 24a87f59fd4959bfebdc94bf0b32fb1d86bd0b27 Mon Sep 17 00:00:00 2001 From: williamlardier Date: Fri, 29 Nov 2024 13:43:47 +0100 Subject: [PATCH 2/3] Split the test It was not testing both cases, but only one Issue: ARSN-448 --- tests/unit/s3routes/routeDELETE.spec.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/unit/s3routes/routeDELETE.spec.js b/tests/unit/s3routes/routeDELETE.spec.js index a78e89ac5..30f84bd34 100644 --- a/tests/unit/s3routes/routeDELETE.spec.js +++ b/tests/unit/s3routes/routeDELETE.spec.js @@ -91,7 +91,7 @@ describe('routeDELETE', () => { ); }); - it('should return 204 when objectDelete encounters NoSuchKey or NoSuchVersion errors', () => { + it('should return 204 when objectDelete encounters NoSuchKey errors', () => { request.objectKey = 'objectKey'; request.query = {}; @@ -107,6 +107,22 @@ describe('routeDELETE', () => { ); }); + it('should return 204 when objectDelete encounters NoSuchVersion errors', () => { + request.objectKey = 'objectKey'; + request.query = {}; + + const noSuchVersionError = new ArsenalError('NoSuchVersion'); + api.callApiMethod = jest.fn((method, req, res, log, callback) => { + callback(noSuchVersionError, {}); + }); + + routeDELETE(request, response, api, log, statsClient); + + expect(routesUtils.responseNoBody).toHaveBeenCalledWith( + null, {}, response, 204, log, + ); + }); + it('should return error code when objectDelete encounters non-arsenal errors', () => { request.objectKey = 'objectKey'; request.query = {}; From 7402f096c9839815db5f03cbc2f4117536f55c28 Mon Sep 17 00:00:00 2001 From: williamlardier Date: Fri, 29 Nov 2024 13:35:09 +0100 Subject: [PATCH 3/3] Bump version Issue: ARSN-448 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c7375bb7c..8d54c9854 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "engines": { "node": ">=16" }, - "version": "8.1.141", + "version": "8.1.142", "description": "Common utilities for the S3 project components", "main": "build/index.js", "repository": {