diff --git a/lib/api/bucketUpdateQuota.js b/lib/api/bucketUpdateQuota.js index 1b319bc5e3..c70367a103 100644 --- a/lib/api/bucketUpdateQuota.js +++ b/lib/api/bucketUpdateQuota.js @@ -8,7 +8,10 @@ const monitoring = require('../utilities/monitoringHandler'); const { parseString } = require('xml2js'); function validateBucketQuotaProperty(requestBody, next) { - const quota = requestBody.quota; + let quota = requestBody.quota; + if (quota === undefined) { + quota = requestBody.QuotaConfiguration?.Quota; + } const quotaValue = parseInt(quota, 10); if (Number.isNaN(quotaValue)) { return next(errorInstances.InvalidArgument.customizeDescription('Quota Value should be a number')); @@ -27,7 +30,7 @@ function parseRequestBody(requestBody, next) { } return next(null, jsonData); } catch { - return parseString(requestBody, (xmlError, xmlData) => { + return parseString(requestBody, { explicitArray: false }, (xmlError, xmlData) => { if (xmlError) { return next(errorInstances.InvalidArgument.customizeDescription('Request body must be a JSON object')); } diff --git a/package.json b/package.json index 7bfef70498..517dbaad79 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@zenko/cloudserver", - "version": "9.2.14", + "version": "9.3.0-preview.1", "description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol", "main": "index.js", "engines": { diff --git a/tests/functional/aws-node-sdk/test/bucket/updateBucketQuota.js b/tests/functional/aws-node-sdk/test/bucket/updateBucketQuota.js index 3faa522fc5..1126d47362 100644 --- a/tests/functional/aws-node-sdk/test/bucket/updateBucketQuota.js +++ b/tests/functional/aws-node-sdk/test/bucket/updateBucketQuota.js @@ -28,6 +28,16 @@ describe('Test update bucket quota', () => { it('should update the quota', () => sendRequest('PUT', '127.0.0.1:8000', `/${bucket}/?quota=true`, JSON.stringify(quota))); + it('should update quota with XML format', async () => { + try { + const xmlQuota = '3000'; + await sendRequest('PUT', '127.0.0.1:8000', `/${bucket}/?quota=true`, xmlQuota); + assert.ok(true); + } catch (err) { + assert.fail(`Expected no error, but got ${err}`); + } + }); + it('should return no such bucket error', async () => { try { await sendRequest('PUT', '127.0.0.1:8000', `/${nonExistantBucket}/?quota=true`, JSON.stringify(quota));