From 4004b67a7f46b63c788f1b5c3674aee35723a833 Mon Sep 17 00:00:00 2001 From: Nestor Carvantes Date: Tue, 8 Mar 2022 07:57:47 -0800 Subject: [PATCH] test: fix subscriptions integ tests (#589) * test: fix subscriptions integ tests - set required ENV API_AWS_REGION - pass scopes arg to client constructor - simplify test allow-list - pass credentials to integ tests * chore: upgrade persistence and routing --- .github/workflows/deploy-smart.yaml | 4 ++++ .../infrastructure/allowList-integTests.ts | 3 ++- integration-tests/subscriptions.test.ts | 6 +++--- package.json | 4 ++-- yarn.lock | 16 ++++++++-------- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy-smart.yaml b/.github/workflows/deploy-smart.yaml index e751fe02..657a0f04 100644 --- a/.github/workflows/deploy-smart.yaml +++ b/.github/workflows/deploy-smart.yaml @@ -210,6 +210,10 @@ jobs: SUBSCRIPTIONS_NOTIFICATIONS_TABLE: ${{ secrets[matrix.subscriptionsNotificationsTableSecretName] }} SUBSCRIPTIONS_ENDPOINT: ${{ secrets[matrix.subscriptionsEndpointSecretName] }} SUBSCRIPTIONS_API_KEY: ${{ secrets[matrix.subscriptionsApiKeySecretName] }} + AWS_ACCESS_KEY_ID: ${{ secrets.SMART_AWS_ACCESS_KEY_ID}} + AWS_SECRET_ACCESS_KEY: ${{ secrets.SMART_AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ matrix.region }} + API_AWS_REGION: ${{ matrix.region }} run: yarn int-test merge-develop-to-mainline: needs: custom-integration-tests diff --git a/integration-tests/infrastructure/allowList-integTests.ts b/integration-tests/infrastructure/allowList-integTests.ts index 39224be7..419a0191 100644 --- a/integration-tests/infrastructure/allowList-integTests.ts +++ b/integration-tests/infrastructure/allowList-integTests.ts @@ -11,7 +11,8 @@ import { SubscriptionEndpoint } from 'fhir-works-on-aws-routing/lib/router/validation/subscriptionValidator'; const getAllowListedSubscriptionEndpoints = async (): Promise => { - const testEndpoint: RegExp = new RegExp(`^${process.env.SUBSCRIPTIONS_ENDPOINT!}`); + // any API Gateway endpoint + const testEndpoint: RegExp = /^https:\/\/\w+\.execute-api\.[\w-]+\.amazonaws.com\/\w+/; return [ { tenantId: 'tenant1', diff --git a/integration-tests/subscriptions.test.ts b/integration-tests/subscriptions.test.ts index e143bc13..5d237512 100644 --- a/integration-tests/subscriptions.test.ts +++ b/integration-tests/subscriptions.test.ts @@ -58,12 +58,12 @@ if (SUBSCRIPTIONS_ENABLED === 'true') { beforeAll(async () => { subscriptionsHelper = new SubscriptionsHelper(SUBSCRIPTIONS_NOTIFICATIONS_TABLE); - client = await getFhirClient(); + client = await getFhirClient('fhirUser user/*.*', true); }); if (MULTI_TENANCY_ENABLED === 'true') { test('tenant isolation', async () => { - const clientAnotherTenant = await getFhirClient({ tenant: 'tenant2' }); + const clientAnotherTenant = await getFhirClient('fhirUser user/*.*', true, { tenant: 'tenant2' }); // tenant 1 creates a subscription const uuid = v4(); const subResource = randomSubscription(uuid); @@ -218,7 +218,7 @@ if (SUBSCRIPTIONS_ENABLED === 'true') { describe('test subscription creation and deletion', () => { beforeAll(async () => { - client = await getFhirClient(); + client = await getFhirClient('fhirUser user/*.*', true); }); test('creation of almost expiring subscription should be deleted by reaper', async () => { diff --git a/package.json b/package.json index 85c1d75a..232710d1 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ "escape-string-regexp": "^4.0.0", "fhir-works-on-aws-authz-smart": "3.1.0", "fhir-works-on-aws-interface": "12.0.0", - "fhir-works-on-aws-persistence-ddb": "3.10.0", - "fhir-works-on-aws-routing": "6.4.0", + "fhir-works-on-aws-persistence-ddb": "3.10.1", + "fhir-works-on-aws-routing": "6.4.1", "fhir-works-on-aws-search-es": "3.11.0", "lodash": "^4.17.21", "p-settle": "^4.1.1", diff --git a/yarn.lock b/yarn.lock index 899ba0d4..2766060e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6270,10 +6270,10 @@ fhir-works-on-aws-interface@^11.1.0: winston "^3.3.3" winston-transport "^4.4.0" -fhir-works-on-aws-persistence-ddb@3.10.0: - version "3.10.0" - resolved "https://registry.yarnpkg.com/fhir-works-on-aws-persistence-ddb/-/fhir-works-on-aws-persistence-ddb-3.10.0.tgz#9625acc1160ae84e7ff574bb0e44405d4adf3e48" - integrity sha512-wgOdG74TA3zhw0ax91MbSm61hlZSVuzBSP2KuYSyKBcFYeLBRfDtx+aNHr2eQEaMEu6DyfJKXktq4/SZ5R9FZg== +fhir-works-on-aws-persistence-ddb@3.10.1: + version "3.10.1" + resolved "https://registry.yarnpkg.com/fhir-works-on-aws-persistence-ddb/-/fhir-works-on-aws-persistence-ddb-3.10.1.tgz#1bcfa13a8ba791e6904b1c8a0a57169254e3b3a9" + integrity sha512-ry0qivUYVXM+0e3xMsRN193+eFkw0fnir1qNhXKwwiOs953pDIzlG6MB7Er5OiHnvOL8KaqM/QRSgUdujsc9dw== dependencies: "@elastic/elasticsearch" "7.13.0" "@types/aws-lambda" "^8.10.83" @@ -6287,10 +6287,10 @@ fhir-works-on-aws-persistence-ddb@3.10.0: promise.allsettled "^1.0.2" uuid "^3.4.0" -fhir-works-on-aws-routing@6.4.0: - version "6.4.0" - resolved "https://registry.yarnpkg.com/fhir-works-on-aws-routing/-/fhir-works-on-aws-routing-6.4.0.tgz#85adf06b19a2223debc4705ba07ea0638338d2a1" - integrity sha512-jQjW7mUvUs0PCBV8IaDD6jwkgNJ28WpDVFpscvBLN19faiPSGFQR0taOLuWU6Eh3WNpVVOjaK8kv6kKvh0PQYQ== +fhir-works-on-aws-routing@6.4.1: + version "6.4.1" + resolved "https://registry.yarnpkg.com/fhir-works-on-aws-routing/-/fhir-works-on-aws-routing-6.4.1.tgz#f2fcdc031015b2fc67f6284995b34c72fc3f030e" + integrity sha512-j4CxZQ7tB11QXqSVClGv2qsAORYlQmNl5OIC1G3m2zUR/XQ877tOBaxvXuJoQowQm86dCMTp2GAZprBU/NBirw== dependencies: "@types/cors" "^2.8.7" "@types/express-serve-static-core" "^4.17.2"