Compare commits

...

1 Commits

Author SHA1 Message Date
Bennett Buchanan ef4cfa02ba ft: ZENKO-315 Add NFS property to BucketInfo 2018-06-19 14:33:46 -07:00
2 changed files with 31 additions and 4 deletions

View File

@ -53,13 +53,14 @@ class BucketInfo {
* @param {string} [uid] - unique identifier for the bucket, necessary
* @param {string} readLocationConstraint - readLocationConstraint for bucket
* addition for use with lifecycle operations
* @param {boolean} [isNFS] - whether the bucket is on NFS
*/
constructor(name, owner, ownerDisplayName, creationDate,
mdBucketModelVersion, acl, transient, deleted,
serverSideEncryption, versioningConfiguration,
locationConstraint, websiteConfiguration, cors,
replicationConfiguration, lifecycleConfiguration, uid,
readLocationConstraint) {
readLocationConstraint, isNFS) {
assert.strictEqual(typeof name, 'string');
assert.strictEqual(typeof owner, 'string');
assert.strictEqual(typeof ownerDisplayName, 'string');
@ -153,6 +154,7 @@ class BucketInfo {
this._cors = cors || null;
this._lifecycleConfiguration = lifecycleConfiguration || null;
this._uid = uid || uuid();
this._isNFS = isNFS || null;
return this;
}
/**
@ -178,6 +180,7 @@ class BucketInfo {
replicationConfiguration: this._replicationConfiguration,
lifecycleConfiguration: this._lifecycleConfiguration,
uid: this._uid,
isNFS: this._isNFS,
};
if (this._websiteConfiguration) {
bucketInfos.websiteConfiguration =
@ -199,7 +202,7 @@ class BucketInfo {
obj.transient, obj.deleted, obj.serverSideEncryption,
obj.versioningConfiguration, obj.locationConstraint, websiteConfig,
obj.cors, obj.replicationConfiguration, obj.lifecycleConfiguration,
obj.uid, obj.readLocationConstraint);
obj.uid, obj.readLocationConstraint, obj.isNFS);
}
/**
@ -223,7 +226,7 @@ class BucketInfo {
data._versioningConfiguration, data._locationConstraint,
data._websiteConfiguration, data._cors,
data._replicationConfiguration, data._lifecycleConfiguration,
data._uid, data._readLocationConstraint);
data._uid, data._readLocationConstraint, data._isNFS);
}
/**
@ -559,6 +562,22 @@ class BucketInfo {
getUid() {
return this._uid;
}
/**
* Check if the bucket is an NFS bucket.
* @return {boolean} - Wether the bucket is NFS or not
*/
isNFS() {
return this._isNFS;
}
/**
* Set whether the bucket is an NFS bucket.
* @param {boolean} isNFS - Wether the bucket is NFS or not
* @return {BucketInfo} - bucket info instance
*/
setIsNFS(isNFS) {
this._isNFS = isNFS;
return this;
}
}
module.exports = BucketInfo;

View File

@ -136,7 +136,7 @@ Object.keys(acl).forEach(
testCorsConfiguration,
testReplicationConfiguration,
testLifecycleConfiguration,
testUid);
testUid, undefined, true);
describe('serialize/deSerialize on BucketInfo class', () => {
const serialized = dummyBucket.serialize();
@ -164,6 +164,7 @@ Object.keys(acl).forEach(
lifecycleConfiguration:
dummyBucket._lifecycleConfiguration,
uid: dummyBucket._uid,
isNFS: dummyBucket._isNFS,
};
assert.strictEqual(serialized, JSON.stringify(bucketInfos));
done();
@ -279,6 +280,13 @@ Object.keys(acl).forEach(
it('getUid should return unique id of bucket', () => {
assert.deepStrictEqual(dummyBucket.getUid(), testUid);
});
it('get should return whether bucket is on NFS', () => {
assert.deepStrictEqual(dummyBucket.isNFS(), true);
});
it('set should set whether bucket is on NFS', () => {
dummyBucket.setIsNFS(false);
assert.deepStrictEqual(dummyBucket.isNFS(), false);
});
});
describe('setters on BucketInfo class', () => {