From 800ec89532cc83f32290ced2b91f1af4fcccb44a Mon Sep 17 00:00:00 2001 From: Sweta Barman Date: Wed, 25 Sep 2024 10:37:36 -0400 Subject: [PATCH] fix: Add a unit test for imports.write_all_domains scope (#384) ## Related Issues Add a unit test for imports.write_all_domains scope --------- Co-authored-by: bhellema Co-authored-by: Ben Helleman Co-authored-by: semantic-release-bot --- .../test/unit/models/api-key.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/spacecat-shared-data-access/test/unit/models/api-key.test.js b/packages/spacecat-shared-data-access/test/unit/models/api-key.test.js index ab54a004..15e54a1f 100644 --- a/packages/spacecat-shared-data-access/test/unit/models/api-key.test.js +++ b/packages/spacecat-shared-data-access/test/unit/models/api-key.test.js @@ -54,6 +54,16 @@ describe('ApiKey Model tests', () => { expect(apiKey.getCreatedAt()).is.not.empty; }); + it('creates an ApiKey object for a user with scope - imports.write_all_domains', () => { + const apiKey = createApiKey({ ...validApiKey, scopes: [{ name: 'imports.write_all_domains', domains: [] }] }); + expect(apiKey.getScopes()).to.deep.equal([{ name: 'imports.write_all_domains', domains: [] }]); + }); + + it('creates an ApiKey object for a user with scope - imports.write', () => { + const apiKey = createApiKey({ ...validApiKey, scopes: [{ name: 'imports.write', domains: ['https://adobe.com', 'https://test.com'] }] }); + expect(apiKey.getScopes()).to.deep.equal([{ name: 'imports.write', domains: ['https://adobe.com', 'https://test.com'] }]); + }); + it('throws an error if revokedAt is not a valid date', () => { expect(() => createApiKey({ ...validApiKey, revokedAt: 'invalid-date' })).to.throw('revokedAt should be a valid ISO 8601 string: invalid-date'); });