Skip to content

Commit 1a2fe7c

Browse files
update update bucket quota tests to test parsing based on content type
ISSUE: CLDSRV-818
1 parent a33d195 commit 1a2fe7c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

tests/functional/aws-node-sdk/test/bucket/updateBucketQuota.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,20 @@ describe('Test update bucket quota', () => {
2525

2626
afterEach(() => s3.send(new DeleteBucketCommand({ Bucket: bucket })));
2727

28-
it('should update the quota', () => sendRequest('PUT',
28+
it('should update the quota, using json parsing by default', () => sendRequest('PUT',
2929
'127.0.0.1:8000', `/${bucket}/?quota=true`, JSON.stringify(quota)));
3030

31+
it('should update quota with explicit JSON content-type', async () => {
32+
await sendRequest('PUT', '127.0.0.1:8000', `/${bucket}/?quota=true`,
33+
JSON.stringify(quota), null, new Date(), { 'Content-Type': 'application/json' });
34+
});
35+
36+
it('should update quota with XML format and explicit XML content-type', async () => {
37+
const xmlQuota = '<QuotaConfiguration><Quota>3000</Quota></QuotaConfiguration>';
38+
await sendRequest('PUT', '127.0.0.1:8000', `/${bucket}/?quota=true`,
39+
xmlQuota, null, new Date(), { 'Content-Type': 'application/xml' });
40+
});
41+
3142
it('should update quota with XML format', async () => {
3243
try {
3344
const xmlQuota = '<QuotaConfiguration><Quota>3000</Quota></QuotaConfiguration>';

tests/functional/aws-node-sdk/test/quota/tooling.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { Sha256 } = require('@aws-crypto/sha256-js');
55
const xml2js = require('xml2js');
66
const { getCredentials } = require('../support/credentials');
77

8-
const sendRequest = async (method, host, path, body = '', config = null, signingDate = new Date()) => {
8+
const sendRequest = async (method, host, path, body = '', config = null, signingDate = new Date(), headers = {}) => {
99
const service = 's3';
1010
const region = 'us-east-1';
1111

@@ -27,6 +27,7 @@ const sendRequest = async (method, host, path, body = '', config = null, signing
2727
headers: {
2828
Host: host, // Explicitly set Host: 127.0.0.1:8000
2929
'X-Amz-Date': signingDate.toISOString().replace(/[:\-]|\.\d{3}/g, ''),
30+
...headers,
3031
},
3132
});
3233

0 commit comments

Comments
 (0)