Skip to content

Commit

Permalink
NSFS | NC | Prevent adding additional properties (bucket schema)
Browse files Browse the repository at this point in the history
Signed-off-by: shirady <57721533+shirady@users.noreply.github.com>
  • Loading branch information
shirady committed Mar 6, 2024
1 parent 29fc24a commit 9377127
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
13 changes: 13 additions & 0 deletions src/manage_nsfs/nsfs_schema_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ schema_utils.strictify(account_schema, {
// NOTE - DO NOT strictify nsfs_config_schema
// we might want to use it in the future for adding additional properties

// objects under schema that using ref (with object underneath) - needs to be strictify as well
schema_utils.strictify(common_api.definitions.bucket_policy, {
additionalProperties: false
});

schema_utils.strictify(common_api.definitions.bucket_encryption, {
additionalProperties: false
});

schema_utils.strictify(common_api.definitions.bucket_website, {
additionalProperties: false
});

/**
* validate_account_schema validates an account object against the NC NSFS account schema
* @param {object} account
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ describe('schema validation NC NSFS bucket', () => {
assert_validation(bucket_data, reason, message);
});

// GAP - this test should have passing
// currently we can properties to s3_policy which are not part of the schema
it.skip('bucket with my_id inside s3_policy', () => {
it('bucket with my_id inside s3_policy', () => {
const bucket_data = get_bucket_data();
bucket_data.s3_policy = bucket_policy1; // added
bucket_data.s3_policy.my_id = '123'; // this is not part of the schema
Expand All @@ -108,9 +106,7 @@ describe('schema validation NC NSFS bucket', () => {
assert_validation(bucket_data, reason, message);
});

// GAP - this test should have passing
// currently we can properties to encryption which are not part of the schema
it.skip('bucket with my_id inside encryption', () => {
it('bucket with my_id inside encryption', () => {
const bucket_data = get_bucket_data();
bucket_data.encryption = encryption1; // added
bucket_data.encryption.my_id = '123'; // this is not part of the schema
Expand All @@ -120,9 +116,7 @@ describe('schema validation NC NSFS bucket', () => {
assert_validation(bucket_data, reason, message);
});

// GAP - this test should have passing
// currently we can properties to website which are not part of the schema
it.skip('bucket with my_id inside website', () => {
it('bucket with my_id inside website', () => {
const bucket_data = get_bucket_data();
bucket_data.website = website1; // added
bucket_data.website.my_id = '123'; // this is not part of the schema
Expand Down

0 comments on commit 9377127

Please sign in to comment.