Skip to content

Commit

Permalink
Lint and rework SSE condition
Browse files Browse the repository at this point in the history
Issue: CLDSRV-408
  • Loading branch information
KillianG authored Jul 6, 2023
1 parent 646c3e2 commit 4f4762f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
8 changes: 6 additions & 2 deletions lib/api/apiUtils/object/versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,11 +456,15 @@ function restoreMetadatas(objMD, metadataStoreParams) {
if (objMD['x-amz-server-side-encryption']) {
metadataStoreParams.cipherBundle = {
algorithm: objMD['x-amz-server-side-encryption'],
masterKeyId: objMD['x-amz-server-side-encryption-aws-kms-key-id'] || objMD['x-amz-server-side-encryption-customer-algorithm'],
}
masterKeyId: objMD['x-amz-server-side-encryption-aws-kms-key-id'] ||
objMD['x-amz-server-side-encryption-customer-algorithm'],
};
}

if (objMD['x-amz-website-redirect-location']) {
if (!metadataStoreParams.headers) {
metadataStoreParams.headers = {};
}
metadataStoreParams.headers['x-amz-website-redirect-location'] = objMD['x-amz-website-redirect-location'];
}

Expand Down
14 changes: 4 additions & 10 deletions lib/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,10 @@ const services = {
md.setLastModified(lastModifiedDate);
}

if (!cipherBundle && params.cipherBundle) {
cipherBundle = params.cipherBundle;
}

if (cipherBundle) {
md.setAmzServerSideEncryption(cipherBundle.algorithm);
// configuredMasterKeyId takes precedence
if (cipherBundle.configuredMasterKeyId || cipherBundle.masterKeyId) {
md.setAmzEncryptionKeyId(cipherBundle.configuredMasterKeyId || cipherBundle.masterKeyId);
}
if (cipherBundle || params.cipherBundle) {
const bundle = cipherBundle || params.cipherBundle;
md.setAmzServerSideEncryption(bundle.algorithm);
md.setAmzEncryptionKeyId(bundle.configuredMasterKeyId || bundle.masterKeyId);
}
if (headers && headers['x-amz-website-redirect-location']) {
md.setRedirectLocation(headers['x-amz-website-redirect-location']);
Expand Down
1 change: 1 addition & 0 deletions tests/functional/aws-node-sdk/test/object/objectCopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@ describe('Object Copy', () => {
restoreCompletedAt: new Date(10),
restoreWillExpireAt: new Date(10 + (5 * 24 * 60 * 60 * 1000)),
};
originalMetadata['custom-user-md'] = 'custom-md';
fakeMetadataArchive(sourceBucketName, sourceObjName, undefined, archiveCompleted, err => {
assert.ifError(err);
s3.copyObject({
Expand Down
34 changes: 17 additions & 17 deletions tests/functional/aws-node-sdk/test/utils/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,28 @@ function fakeMetadataArchive(bucketName, objectName, versionId, archive, cb) {
objMD.archive = archive;
objMD['x-amz-meta-custom-user-md'] = 'custom-md';
objMD.tags = { tag1: 'value1', tag2: 'value2' };
objMD["x-amz-server-side-encryption"] = "AES256";
objMD["x-amz-server-side-encryption-aws-kms-key-id"] = "very-secret-key";
objMD['x-amz-website-redirect-location'] = 'https://scality.com/'
objMD['x-amz-server-side-encryption'] = 'AES256';
objMD['x-amz-server-side-encryption-aws-kms-key-id'] = 'very-secret-key';
objMD['x-amz-website-redirect-location'] = 'https://scality.com/';
objMD.replicationInfo = {
"status" : "PENDING",
"backends" : [
'status': 'PENDING',
'backends': [
{
"site" : "azure-normal",
"status" : "PENDING",
"dataStoreVersionId" : ""
'site': 'azure-normal',
'status': 'PENDING',
'dataStoreVersionId': ''
}
],
"content" : [
"DATA",
"METADATA"
'content': [
'DATA',
'METADATA'
],
"destination" : "arn:aws:s3:::versioned",
"storageClass" : "azure-normal",
"role" : "arn:aws:iam::root:role/s3-replication-role",
"storageType" : "azure",
"dataStoreVersionId" : "",
"isNFS" : null
'destination': 'arn:aws:s3:::versioned',
'storageClass': 'azure-normal',
'role': 'arn:aws:iam::root:role/s3-replication-role',
'storageType': 'azure',
'dataStoreVersionId': '',
'isNFS': null
};
/* eslint-enable no-param-reassign */
return metadata.putObjectMD(bucketName, objectName, objMD, { versionId: decodeVersionId(versionId) },
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/api/apiUtils/versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ describe('versioning helpers', () => {
'restoreRequestedDays': days,
'restoreRequestedAt': now,
archiveInfo
}
}
},
expectedRes: {
'creationTime': now,
Expand Down

0 comments on commit 4f4762f

Please sign in to comment.