Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
AkhtarAmir authored Apr 6, 2023
1 parent d55e8a5 commit 94813b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ module.exports = {

if ( !listCollections.data || listCollections.err) {
helpers.addResult(results, 3,
'Unable to query list OpenSearch collections: ' + helpers.addError(listCollections), region);
'Unable to list OpenSearch collections: ' + helpers.addError(listCollections), region);
return rcb();
}
if (!listCollections.data.length){
helpers.addResult(results, 0, 'No OpenSearch Collection found', region);
helpers.addResult(results, 0, 'No OpenSearch collections found', region);
return rcb();
}
var listSecurityPolicies = helpers.addSource(cache, source,
['opensearchserverless', 'listEncryptionSecurityPolicies', region]);

if (!listSecurityPolicies && listSecurityPolicies.err || !listSecurityPolicies.data) {
helpers.addResult(results, 3,
'Unable to query list OpenSearch security policy: ' + helpers.addError(listSecurityPolicies), region);
'Unable to query list OpenSearch security policies: ' + helpers.addError(listSecurityPolicies), region);
return rcb();
}

if (!listSecurityPolicies.data.length) {
helpers.addResult(results, 2, 'No OpenSearch Security Policy found', region);
helpers.addResult(results, 2, 'No OpenSearch security policies found', region);
return rcb();
}

Expand All @@ -77,7 +77,7 @@ module.exports = {

if (!getSecurityPolicy || !getSecurityPolicy.data || getSecurityPolicy.err){
helpers.addResult(results, 3,
'Unable to query get OpenSearch security policy: ' + helpers.addError(getSecurityPolicy), region, policy.name);
'Unable to query OpenSearch security policy: ' + helpers.addError(getSecurityPolicy), region, policy.name);
return rcb();
}
let securityPolicy;
Expand Down Expand Up @@ -121,10 +121,10 @@ module.exports = {
}
for (let col of listCollections.data){
if (policyMap[col.arn] >= desiredEncryptionLevel){
helpers.addResult(results, 0, `OpenSearch Collection is encrypted with ${helpers.ENCRYPTION_LEVELS[policyMap[col.arn]]} \
helpers.addResult(results, 0, `OpenSearch collection is encrypted with ${helpers.ENCRYPTION_LEVELS[policyMap[col.arn]]} \
which is greater than or equal to the desired encryption level ${config.desiredEncryptionLevelString}`, region, col.arn);
} else {
helpers.addResult(results, 2, `OpenSearch Collection is encrypted with ${helpers.ENCRYPTION_LEVELS[2]} \
helpers.addResult(results, 2, `OpenSearch collection is encrypted with ${helpers.ENCRYPTION_LEVELS[2]} \
which is less than the desired encryption level ${config.desiredEncryptionLevelString}`, region, col.arn);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('collectionCmkEncrypted', function () {
collectionCmkEncrypted.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(3);
expect(results[0].message).to.include('Unable to query list OpenSearch collections');
expect(results[0].message).to.include('Unable to list OpenSearch collections');
done();
});
});
Expand All @@ -145,7 +145,7 @@ describe('collectionCmkEncrypted', function () {
collectionCmkEncrypted.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(0);
expect(results[0].message).to.include('No OpenSearch Collection found');
expect(results[0].message).to.include('No OpenSearch collections found');
done();
});
});
Expand All @@ -155,7 +155,7 @@ describe('collectionCmkEncrypted', function () {
collectionCmkEncrypted.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(3);
expect(results[0].message).to.include('Unable to query list OpenSearch security policy:');
expect(results[0].message).to.include('Unable to query list OpenSearch security policies:');
done();
});
});
Expand All @@ -165,7 +165,7 @@ describe('collectionCmkEncrypted', function () {
collectionCmkEncrypted.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(2);
expect(results[0].message).to.include('No OpenSearch Security Policy found');
expect(results[0].message).to.include('No OpenSearch security policies found');
done();
});
});
Expand All @@ -174,7 +174,7 @@ describe('collectionCmkEncrypted', function () {
collectionCmkEncrypted.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(3);
expect(results[0].message).to.include('Unable to query get OpenSearch security policy:');
expect(results[0].message).to.include('Unable to query OpenSearch security policy:');
done();
});
});
Expand All @@ -183,7 +183,7 @@ describe('collectionCmkEncrypted', function () {
collectionCmkEncrypted.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(0);
expect(results[0].message).to.include('OpenSearch Collection is encrypted with awscmk');
expect(results[0].message).to.include('OpenSearch collection is encrypted with awscmk');
done();
});
});
Expand All @@ -192,7 +192,7 @@ describe('collectionCmkEncrypted', function () {
collectionCmkEncrypted.run(cache, {}, (err, results) => {
expect(results.length).to.equal(1);
expect(results[0].status).to.equal(2);
expect(results[0].message).to.include('OpenSearch Collection is encrypted with awskms');
expect(results[0].message).to.include('OpenSearch collection is encrypted with awskms');
done();
});
});
Expand Down

0 comments on commit 94813b0

Please sign in to comment.