Skip to content

Commit

Permalink
add unit test in deleteObject
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Tovar committed Jul 13, 2023
1 parent 2b420a8 commit cd3f68e
Show file tree
Hide file tree
Showing 5 changed files with 888 additions and 185 deletions.
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"runtimeExecutable": null,
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"${workspaceFolder}/tests/functional/aws-node-sdk/test/object/deleteObject.js",
],
"cwd": "${workspaceRoot}",
"internalConsoleOptions": "openOnSessionStart",
// "skipFiles": [
// "<node_internals>/**"
// ]
},
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}/index.js"
}
]
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"homepage": "https://github.com/scality/S3#readme",
"dependencies": {
"@hapi/joi": "^17.1.0",
"ansi-colors": "^4.1.3",
"arsenal": "git+https://github.com/scality/arsenal#7.10.43",
"async": "~2.5.0",
"aws-sdk": "2.905.0",
Expand All @@ -34,6 +35,7 @@
"level-mem": "^5.0.1",
"moment": "^2.26.0",
"npm-run-all": "~4.1.5",
"nyc": "^15.1.0",
"utapi": "git+https://github.com/scality/utapi#7.10.11",
"utf8": "~2.1.1",
"uuid": "^3.0.1",
Expand All @@ -58,6 +60,7 @@
"tv4": "^1.2.7"
},
"scripts": {
"test-object": "cd tests/functional/aws-node-sdk && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json tests/functional/aws-node-sdk/test/object/deleteObject.js",
"ft_awssdk": "cd tests/functional/aws-node-sdk && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json test/",
"ft_awssdk_aws": "cd tests/functional/aws-node-sdk && AWS_ON_AIR=true mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json test/",
"ft_awssdk_buckets": "cd tests/functional/aws-node-sdk && mocha --reporter mocha-multi-reporters --reporter-options configFile=$INIT_CWD/tests/reporter-config.json test/bucket",
Expand Down
57 changes: 57 additions & 0 deletions tests/functional/aws-node-sdk/test/object/deleteObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,62 @@ describe('DELETE object', () => {
}
));
});

describe.only('Try to delete an object version in COMPLIANCE', () => {
const bucketName = 'testdeletelocklegalholdbucket';
const objectName = 'key';
let versionId;
before(() => {
return s3.createBucket({
Bucket: bucketName,
ObjectLockEnabledForBucket: true,
}).promise()
.catch(err => {
process.stdout.write(`Error creating bucket ${err}\n`);
throw err;
}).then(() => {
process.stdout.write('putting object lock configuration\n');
return s3.putObjectLockConfiguration({
Bucket: bucketName,
ObjectLockConfiguration: {
ObjectLockEnabled: 'Enabled',
Rule: {
DefaultRetention: {
Mode: 'COMPLIANCE',
Days: 1,
},
},
},
}).promise();
}).catch(err => {
process.stdout.write('Error putting object lock configuration\n');
throw err;
}).then(() => {
process.stdout.write('putting object\n');
return s3.putObject({
Bucket: bucketName,
Key: objectName,
}).promise();
})
.catch(err => {
process.stdout.write('Error putting object');
throw err;
})
.then(res => {
process.stdout.write('get object versionId\n');
versionId = res.VersionId;
});
});

it('delete object in COMPLIANCE mode', () => {
s3.deleteObject({
Bucket: bucketName,
Key: objectName,
VersionId: versionId,
}, err => {
assert.ifError(err);
});
});
});
});
});
175 changes: 1 addition & 174 deletions tests/locationConfig/locationConfigTests.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,178 +23,5 @@
"type": "mem",
"legacyAwsBehavior": false,
"details": {}
},
"awsbackendencryption": {
"type": "aws_s3",
"legacyAwsBehavior": true,
"details": {
"awsEndpoint": "s3.amazonaws.com",
"bucketName": "multitester555",
"bucketMatch": true,
"credentialsProfile": "default",
"serverSideEncryption": true
}
},
"awsbackend": {
"type": "aws_s3",
"legacyAwsBehavior": true,
"details": {
"awsEndpoint": "s3.amazonaws.com",
"bucketName": "multitester555",
"bucketMatch": true,
"credentialsProfile": "default"
}
},
"awsbackendmismatch": {
"type": "aws_s3",
"legacyAwsBehavior": true,
"details": {
"awsEndpoint": "s3.amazonaws.com",
"bucketName": "multitester555",
"bucketMatch": false,
"credentialsProfile": "default"
}
},
"awsbackend2": {
"type": "aws_s3",
"legacyAwsBehavior": true,
"details": {
"awsEndpoint": "s3.amazonaws.com",
"bucketName": "multitester222",
"bucketMatch": true,
"credentialsProfile": "default_2"
}
},
"azurebackend": {
"type": "azure",
"legacyAwsBehavior": true,
"details": {
"azureStorageEndpoint": "https://fakeaccountname.blob.core.fake.net/",
"azureStorageAccountName": "fakeaccountname",
"azureStorageAccessKey": "Fake00Key001",
"bucketMatch": true,
"azureContainerName": "s3test"
}
},
"azurebackend2": {
"type": "azure",
"legacyAwsBehavior": true,
"details": {
"azureStorageEndpoint": "https://fakeaccountname2.blob.core.fake.net/",
"azureStorageAccountName": "fakeaccountname2",
"azureStorageAccessKey": "Fake00Key002",
"bucketMatch": true,
"azureContainerName": "s3test2"
}
},
"azurebackendmismatch": {
"type": "azure",
"legacyAwsBehavior": true,
"details": {
"azureStorageEndpoint": "https://fakeaccountname.blob.core.fake.net/",
"azureStorageAccountName": "fakeaccountname",
"azureStorageAccessKey": "Fake00Key001",
"bucketMatch": false,
"azureContainerName": "s3test"
}
},
"azurenonexistcontainer": {
"type": "azure",
"legacyAwsBehavior": true,
"details": {
"azureStorageEndpoint": "https://fakeaccountname.blob.core.fake.net/",
"azureStorageAccountName": "fakeaccountname",
"azureStorageAccessKey": "Fake00Key123",
"bucketMatch": true,
"azureContainerName": "s3createbucketonfly"
}
},
"gcpbackend": {
"type": "gcp",
"legacyAwsBehavior": true,
"details": {
"gcpEndpoint": "storage.googleapis.com",
"bucketName": "zenko-gcp-bucket",
"mpuBucketName": "zenko-gcp-mpu",
"overflowBucketName": "zenko-gcp-overflow",
"bucketMatch": true,
"credentialsProfile": "google",
"serviceCredentials": {
"scopes": "https://www.googleapis.com/auth/cloud-platform",
"serviceEmail": "fake001",
"serviceKey": "fake001"
}
}
},
"gcpbackend2": {
"type": "gcp",
"legacyAwsBehavior": true,
"details": {
"gcpEndpoint": "storage.googleapis.com",
"bucketName": "zenko-gcp-bucket-2",
"mpuBucketName": "zenko-gcp-mpu-2",
"overflowBucketName": "zenko-gcp-overflow",
"bucketMatch": true,
"credentialsProfile": "google_2",
"serviceCredentials": {
"scopes": "https://www.googleapis.com/auth/cloud-platform",
"serviceEmail": "fake002",
"serviceKey": "fake002"
}
}
},
"gcpbackendmismatch": {
"type": "gcp",
"legacyAwsBehavior": true,
"details": {
"gcpEndpoint": "storage.googleapis.com",
"bucketName": "zenko-gcp-bucket",
"mpuBucketName": "zenko-gcp-mpu",
"overflowBucketName": "zenko-gcp-overflow",
"bucketMatch": false,
"credentialsProfile": "google",
"serviceCredentials": {
"scopes": "https://www.googleapis.com/auth/cloud-platform",
"serviceEmail": "fake001",
"serviceKey": "fake001"
}
}
},
"gcpbackendproxy": {
"type": "gcp",
"legacyAwsBehavior": true,
"details": {
"proxy": "https://proxy.server",
"https": true,
"gcpEndpoint": "storage.googleapis.com",
"bucketName": "zenko-gcp-bucket",
"mpuBucketName": "zenko-gcp-mpu",
"overflowBucketName": "zenko-gcp-overflow",
"bucketMatch": false,
"credentialsProfile": "google",
"serviceCredentials": {
"scopes": "https://www.googleapis.com/auth/cloud-platform",
"serviceEmail": "fake001",
"serviceKey": "fake001"
}
}
},
"gcpbackendnoproxy": {
"type": "gcp",
"legacyAwsBehavior": true,
"details": {
"https": false,
"gcpEndpoint": "storage.googleapis.com",
"bucketName": "zenko-gcp-bucket",
"mpuBucketName": "zenko-gcp-mpu",
"overflowBucketName": "zenko-gcp-overflow",
"bucketMatch": false,
"credentialsProfile": "google",
"serviceCredentials": {
"scopes": "https://www.googleapis.com/auth/cloud-platform",
"serviceEmail": "fake001",
"serviceKey": "fake001"
}
}
}
}
}
Loading

0 comments on commit cd3f68e

Please sign in to comment.