Skip to content

Commit ce5ff7e

Browse files
author
Kerkesni
committed
do not allow crr location as an object locationConstraint
Issue: CLDSRV-653
1 parent 169105b commit ce5ff7e

File tree

6 files changed

+71
-7
lines changed

6 files changed

+71
-7
lines changed

lib/api/objectCopy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function _prepMetadata(request, sourceObjMD, headers, sourceIsDestination,
130130
const backendInfoObjDest = locationConstraintCheck(request,
131131
userMetadata, destBucketMD, log);
132132
if (backendInfoObjDest.err) {
133-
return { error: backendInfoObjSource.err };
133+
return { error: backendInfoObjDest.err };
134134
}
135135
const destLocationConstraintName = backendInfoObjDest.controllingLC;
136136

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"dependencies": {
2222
"@azure/storage-blob": "^12.25.0",
2323
"@hapi/joi": "^17.1.1",
24-
"arsenal": "git+https://github.com/scality/Arsenal#8.2.21",
24+
"arsenal": "git+https://github.com/scality/Arsenal#8.2.22",
2525
"async": "2.6.4",
2626
"aws-sdk": "^2.1692.0",
2727
"bucketclient": "scality/bucketclient#8.2.4",

tests/unit/api/multipartUpload.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,6 +2174,32 @@ describe('Multipart Upload API', () => {
21742174
},
21752175
], done);
21762176
});
2177+
2178+
it('should fail to initiate a multipart upload if location constraint is crr', done => {
2179+
const initiateRequest = {
2180+
socket: {
2181+
remoteAddress: '1.1.1.1',
2182+
},
2183+
bucketName,
2184+
namespace,
2185+
objectKey,
2186+
headers: {
2187+
host: `${bucketName}.s3.amazonaws.com`,
2188+
[constants.objectLocationConstraintHeader]: 'location-crr-v1',
2189+
},
2190+
url: `/${objectKey}?uploads`,
2191+
actionImplicitDenies: false,
2192+
};
2193+
2194+
bucketPut(authInfo, bucketPutRequest, log, err => {
2195+
assert.ifError(err);
2196+
initiateMultipartUpload(authInfo, initiateRequest,
2197+
log, err => {
2198+
assert(err.is.InvalidArgument);
2199+
done();
2200+
});
2201+
});
2202+
});
21772203
});
21782204

21792205
describe('complete mpu with versioning', () => {

tests/unit/api/objectCopy.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ function _createBucketPutRequest(bucketName) {
3939
});
4040
}
4141

42-
function _createObjectCopyRequest(destBucketName) {
42+
function _createObjectCopyRequest(destBucketName, headers = {}) {
4343
const params = {
4444
bucketName: destBucketName,
4545
namespace,
4646
objectKey,
47-
headers: {},
47+
headers,
4848
url: `/${destBucketName}/${objectKey}`,
4949
socket: {},
5050
};
@@ -231,6 +231,7 @@ describe('non-versioned objectCopy', () => {
231231
cleanup();
232232
sinon.stub(metadata, 'putObjectMD')
233233
.callsFake(originalputObjectMD);
234+
234235
async.series([
235236
callback => bucketPut(authInfo, putDestBucketRequest, log,
236237
callback),
@@ -338,6 +339,22 @@ describe('non-versioned objectCopy', () => {
338339
},
339340
], done);
340341
});
342+
343+
it('should fail to copy object when setting a crr location as the locationConstraint', done => {
344+
const testObjectCopyRequest = _createObjectCopyRequest(destBucketName, {
345+
'x-amz-metadata-directive': 'REPLACE', // needed to take the locationConstraint into account
346+
[objectLocationConstraintHeader]: 'location-crr-v1',
347+
});
348+
349+
async.series([
350+
next => objectPut(authInfo, testPutDestObjectRequest, undefined, log, next),
351+
next => objectCopy(authInfo, testObjectCopyRequest, sourceBucketName, objectKey,
352+
undefined, log, next),
353+
], err => {
354+
assert(err.is.InvalidArgument);
355+
done();
356+
});
357+
});
341358
});
342359

343360
describe('objectCopy overheadField', () => {

tests/unit/api/objectPut.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,27 @@ describe('objectPut API', () => {
843843
});
844844
});
845845
});
846+
847+
it('should fail to put object when setting a crr location as the locationConstraint', done => {
848+
const testPutObjectRequest = new DummyRequest({
849+
bucketName,
850+
namespace,
851+
objectKey: objectName,
852+
headers: {
853+
[objectLocationConstraintHeader]: 'location-crr-v1',
854+
},
855+
url: `/${bucketName}/${objectName}`,
856+
calculatedHash: 'vnR+tLdVF79rPPfF+7YvOg==',
857+
}, postBody);
858+
859+
bucketPut(authInfo, testPutBucketRequest, log, () => {
860+
objectPut(authInfo, testPutObjectRequest, undefined, log,
861+
err => {
862+
assert(err.is.InvalidArgument);
863+
done();
864+
});
865+
});
866+
});
846867
});
847868

848869
describe('objectPut API with versioning', () => {

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,9 +1296,9 @@ arraybuffer.prototype.slice@^1.0.4:
12961296
get-intrinsic "^1.2.6"
12971297
is-array-buffer "^3.0.4"
12981298

1299-
"arsenal@git+https://github.com/scality/Arsenal#8.2.21":
1300-
version "8.2.21"
1301-
resolved "git+https://github.com/scality/Arsenal#534e10f48d170b0c4dff9bd818376f796eac8aaa"
1299+
"arsenal@git+https://github.com/scality/Arsenal#8.2.22":
1300+
version "8.2.22"
1301+
resolved "git+https://github.com/scality/Arsenal#034de2bdfa7526111fe21c60205f1e94e5078f46"
13021302
dependencies:
13031303
"@azure/identity" "^4.10.0"
13041304
"@azure/storage-blob" "^12.27.0"

0 commit comments

Comments
 (0)