Skip to content

Commit

Permalink
better coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed Feb 7, 2025
1 parent d0d91b3 commit 2e1fddb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/unit/policyEvaluator/RequestContext.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,26 @@ describe('RequestContext', () => {
const ssoRC = new RequestContext(...ssoParams);
assert.strictEqual(ssoRC.getResource(), 'arn:scality:sso:::general-resource/specific-resource');
});

it('should return correct ARN for s3 service without specific resource', () => {
const s3Params = [...constructorParams];
s3Params[3] = undefined; // specificResource
const s3RC = new RequestContext(...s3Params);
assert.strictEqual(s3RC.getResource(), 'arn:aws:s3:::general-resource');
});

it('should return correct ARN for s3 service without general and specific resource', () => {
const s3Params = [...constructorParams];
s3Params[2] = undefined; // generalResource
s3Params[3] = undefined; // specificResource
const s3RC = new RequestContext(...s3Params);
assert.strictEqual(s3RC.getResource(), 'arn:aws:s3:::');
});

it('should return undefined for unknown service', () => {
const unknownParams = [...constructorParams];
unknownParams[7] = 'unknown';
const unknownRC = new RequestContext(...unknownParams);
assert.strictEqual(unknownRC.getResource(), undefined);
});
});

0 comments on commit 2e1fddb

Please sign in to comment.