From 1cf7f160db7245decd4fecd2b4f72255c9f71d78 Mon Sep 17 00:00:00 2001 From: Kevin Peraza Date: Thu, 17 Nov 2022 11:35:25 -0600 Subject: [PATCH] feat: add support for expiring applications (#247) * feat: add support for expiring applications * test(application): update mocks * feat(application): make name optional to support expiring apps * feat(tokens): add expiresAt to update token request * test(tokens): add expiresAt to mocks * feat(applications): add conditions to access rules * test(applications): add conditions to access rules mocks * feat(applications): make access rules' conditions optional * feat(applications): make access rule's container optional Co-authored-by: Josue Leon Sarkis --- src/types/models/applications.ts | 13 +++++++++++-- src/types/models/tokens.ts | 1 + test/applications.test.ts | 12 ++++++++++++ test/tokens.test.ts | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/types/models/applications.ts b/src/types/models/applications.ts index 628c0723..34839ada 100644 --- a/src/types/models/applications.ts +++ b/src/types/models/applications.ts @@ -14,21 +14,30 @@ type TransformType = typeof TRANSFORM_TYPES[number]; interface Application extends Auditable { id: string; tenantId: string; - name: string; + name?: string; key?: string; type: ApplicationType; permissions?: string[]; rules?: AccessRule[]; + canCreateExpiringApplications?: boolean; + expiresAt?: string; } interface AccessRule { description: string; priority: number; - container: string; + container?: string; transform: TransformType; permissions: string[]; + conditions?: Condition[]; } +type Condition = { + attribute: string; + operator: string; + value: string; +}; + type CreateApplication = Pick & Partial>; diff --git a/src/types/models/tokens.ts b/src/types/models/tokens.ts index f2fff00a..b5eb62e3 100644 --- a/src/types/models/tokens.ts +++ b/src/types/models/tokens.ts @@ -82,6 +82,7 @@ type UpdateToken = Partial< | 'searchIndexes' | 'fingerprintExpression' | 'mask' + | 'expiresAt' > & { privacy: Omit; deduplicateToken: boolean; diff --git a/test/applications.test.ts b/test/applications.test.ts index 0a7ee7d1..99eb9957 100644 --- a/test/applications.test.ts +++ b/test/applications.test.ts @@ -37,6 +37,8 @@ describe('Applications', () => { name: chance.string(), type: chance.string() as ApplicationType, permissions: [chance.string()], + canCreateExpiringApplications: chance.bool(), + expiresAt: chance.date().toString(), }, updatePayload: { name: chance.string(), @@ -63,8 +65,17 @@ describe('Applications', () => { 'reveal', ]), permissions: [chance.string()], + conditions: [ + { + attribute: chance.string(), + operator: chance.string(), + value: chance.string(), + }, + ], }, ], + canCreateExpiringApplications: chance.bool(), + expiresAt: chance.date().toString(), }, updatePayload: { name: chance.string(), @@ -79,6 +90,7 @@ describe('Applications', () => { 'reveal', ]), permissions: [chance.string()], + conditions: [], }, ], }, diff --git a/test/tokens.test.ts b/test/tokens.test.ts index 96d3114b..323c5420 100644 --- a/test/tokens.test.ts +++ b/test/tokens.test.ts @@ -646,6 +646,7 @@ describe('Tokens', () => { alg: _chance.string(), }, }, + expiresAt: _chance.date().toString(), metadata: { camelCaseParameter: _chance.string(), snake_case_parameter: _chance.string(), @@ -709,6 +710,7 @@ describe('Tokens', () => { }, searchIndexes: [_chance.string(), _chance.string()], fingerprintExpression: _chance.string(), + expiresAt: _chance.date().toString(), }; /* eslint-enable camelcase */