Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTEGRATION [PR#877 > development/8.1] bf: S3C 2276 update bucketinfo policy getter #879

Merged
merged 3 commits into from
Aug 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/models/BucketPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ class BucketPolicy {

/**
* Call resource policy schema validation function
* @param {object} policy - the bucket policy to validate
* @param {object} policy - the bucket policy object to validate
* @return {undefined}
*/
static validatePolicy(policy) {
const validated = validateResourcePolicy(policy);
// only the BucketInfo constructor calls this function
// and BucketInfo will always be passed an object
const validated = validateResourcePolicy(JSON.stringify(policy));
assert.deepStrictEqual(validated, { error: null, valid: true });
}
}
Expand Down
17 changes: 7 additions & 10 deletions tests/unit/models/BucketInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@ Object.keys(acl).forEach(
testCorsConfiguration,
testReplicationConfiguration,
testLifecycleConfiguration,
JSON.stringify(testBucketPolicy),
testUid, undefined, true,
undefined, testAzureInfo);
testBucketPolicy, testUid, undefined,
true, undefined, testAzureInfo);

describe('serialize/deSerialize on BucketInfo class', () => {
const serialized = dummyBucket.serialize();
Expand Down Expand Up @@ -315,8 +314,7 @@ Object.keys(acl).forEach(
});
it('getBucketPolicy should return policy', () => {
assert.deepStrictEqual(
JSON.parse(dummyBucket.getBucketPolicy()),
testBucketPolicy);
dummyBucket.getBucketPolicy(), testBucketPolicy);
});
it('getUid should return unique id of bucket', () => {
assert.deepStrictEqual(dummyBucket.getUid(), testUid);
Expand Down Expand Up @@ -464,10 +462,9 @@ Object.keys(acl).forEach(
},
],
};
dummyBucket.setBucketPolicy(JSON.stringify(newBucketPolicy));
dummyBucket.setBucketPolicy(newBucketPolicy);
assert.deepStrictEqual(
JSON.parse(dummyBucket.getBucketPolicy()),
newBucketPolicy);
dummyBucket.getBucketPolicy(), newBucketPolicy);
});
it('enableIngestion should set ingestion status to enabled', () => {
dummyBucket.enableIngestion();
Expand Down Expand Up @@ -529,7 +526,7 @@ describe('ingest', () => {
testCorsConfiguration,
testReplicationConfiguration,
testLifecycleConfiguration,
JSON.stringify(testBucketPolicy),
testBucketPolicy,
testUid, undefined, true, testIngestionConfiguration);
assert.deepStrictEqual(dummyBucket.getIngestion(),
{ status: 'enabled' });
Expand All @@ -553,7 +550,7 @@ describe('ingest', () => {
testCorsConfiguration,
testReplicationConfiguration,
testLifecycleConfiguration,
JSON.stringify(testBucketPolicy),
testBucketPolicy,
testUid, undefined, true);
assert.deepStrictEqual(dummyBucket.getIngestion(), null);
assert.strictEqual(dummyBucket.isIngestionBucket(), false);
Expand Down