Compare commits

...

3 Commits

Author SHA1 Message Date
williamlardier 003aecc09c
CLDSRV-389: bump project version 2023-05-09 14:34:51 +02:00
williamlardier fa5a271b39
CLDSRV-389: add test for bucket creation dates 2023-05-09 14:34:51 +02:00
williamlardier 94eb7d97b3
CLDSRV-389: ensure consistent bucket creation dates 2023-05-09 14:30:10 +02:00
3 changed files with 38 additions and 3 deletions

View File

@ -31,7 +31,7 @@ function addToUsersBucket(canonicalID, bucketName, bucketMD, log, cb) {
constants.splitter : constants.oldSplitter; constants.splitter : constants.oldSplitter;
let key = createKeyForUserBucket(canonicalID, splitter, bucketName); let key = createKeyForUserBucket(canonicalID, splitter, bucketName);
const omVal = { const omVal = {
creationDate: new Date().toJSON(), creationDate: new Date(bucketMD.getCreationDate()).toJSON(),
ingestion: bucketMD.getIngestion(), ingestion: bucketMD.getIngestion(),
}; };
// If the new format usersbucket does not exist, try to put the // If the new format usersbucket does not exist, try to put the
@ -48,7 +48,7 @@ function addToUsersBucket(canonicalID, bucketName, bucketMD, log, cb) {
'creating users bucket'); 'creating users bucket');
key = `${canonicalID}${constants.splitter}` + key = `${canonicalID}${constants.splitter}` +
`${bucketName}`; `${bucketName}`;
const creationDate = new Date().toJSON(); const creationDate = bucketMD.getCreationDate();
const freshBucket = new BucketInfo(usersBucket, const freshBucket = new BucketInfo(usersBucket,
userBucketOwner, userBucketOwner, creationDate, userBucketOwner, userBucketOwner, creationDate,
BucketInfo.currentModelVersion()); BucketInfo.currentModelVersion());

View File

@ -1,6 +1,6 @@
{ {
"name": "@zenko/cloudserver", "name": "@zenko/cloudserver",
"version": "8.7.18", "version": "8.7.11",
"description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol", "description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol",
"main": "index.js", "main": "index.js",
"engines": { "engines": {

View File

@ -4,6 +4,8 @@ const { cleanup, DummyRequestLogger } = require('../helpers');
const { createBucket } = const { createBucket } =
require('../../../lib/api/apiUtils/bucket/bucketCreation'); require('../../../lib/api/apiUtils/bucket/bucketCreation');
const { makeAuthInfo } = require('../helpers'); const { makeAuthInfo } = require('../helpers');
const metadata = require('../../../lib/metadata/wrapper');
const constants = require('../../../constants');
const bucketName = 'creationbucket'; const bucketName = 'creationbucket';
const log = new DummyRequestLogger(); const log = new DummyRequestLogger();
@ -81,3 +83,36 @@ describe('bucket creation with object lock', () => {
}); });
}); });
}); });
describe('bucket creation date consistency', () => {
let creationDate;
beforeEach(done => {
cleanup();
createBucket(authInfo, bucketName, headers, normalBehaviorLocationConstraint, log, err => {
assert.ifError(err);
metadata.getBucket(bucketName, log, (err, bucketInfo) => {
assert.ifError(err);
creationDate = bucketInfo.getCreationDate();
done();
});
});
});
it('should have the same creation date in metadata and users bucket', done => {
// Check creation date in metadata
metadata.getBucket(bucketName, log, (err, bucketMD) => {
assert.ifError(err);
assert.strictEqual(creationDate, bucketMD.getCreationDate());
// Check creation date in users bucket
const canonicalID = authInfo.getCanonicalID();
const usersBucketKey = `${canonicalID}${constants.splitter}${bucketName}`;
metadata.getObjectMD(constants.usersBucket, usersBucketKey, {}, log, (err, usersBucketObjMD) => {
assert.ifError(err);
assert.strictEqual(creationDate, new Date(usersBucketObjMD.creationDate).toJSON());
done();
});
});
});
});