From d2a4114d34c7aa109e6d78ea37da533c110e5fc5 Mon Sep 17 00:00:00 2001 From: Lewis Daly Date: Thu, 16 Sep 2021 15:40:35 +0930 Subject: [PATCH] fix(integration): reenable skipped integration tests (#89) * fix(integration): debugging bad config and mysql issues * fix(integration): debugging bad config and mysql issues * chore: cleanup console.log * chore: appease linting gods * fix(ci): debugging wait4 script * fix(ci): debugging wait4 script --- .circleci/config.yml | 9 +- config/development.json | 2 +- config/integration.json | 2 +- docker-compose.linux.yml | 20 ---- docker-compose.yml | 6 +- package-lock.json | 83 +++++++++------- package.json | 2 +- .../stateMachine/registerConsent.model.ts | 2 +- src/model/consent/consent.ts | 2 + src/model/db.ts | 13 ++- test/integration/domain/consents.test.ts | 99 +++++-------------- .../server/workflows/registerConsent.test.ts | 2 +- test/unit/shared/fido-lib.test.ts | 9 +- 13 files changed, 106 insertions(+), 145 deletions(-) delete mode 100644 docker-compose.linux.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index cabea9ad..41c67e48 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -195,20 +195,25 @@ jobs: [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" docker-compose up -d ./scripts/wait4.js cicd-integration-tests + # use development env since we are connecting to db outside of docker environment: - NODE_ENV: "integration" + NODE_ENV: "development" - run: name: Migrate DB command: | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" npm -s run migrate + # use development env since we are connecting to db outside of docker + environment: + NODE_ENV: "development" - run: name: Execute integration tests command: | [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" npm -s run test:integration + # use development env since we are connecting to db outside of docker environment: - NODE_ENV: "integration" + NODE_ENV: "development" - run: name: Prepare test results command: | diff --git a/config/development.json b/config/development.json index 95b319e2..ffcdce54 100644 --- a/config/development.json +++ b/config/development.json @@ -4,7 +4,7 @@ "PARTICIPANT_ID": "centralAuth", "REDIS": { "PORT": 6379, - "HOST": "redis", + "HOST": "localhost", "TIMEOUT": 100 }, "INSPECT": { diff --git a/config/integration.json b/config/integration.json index f7584fb3..824f50ce 100644 --- a/config/integration.json +++ b/config/integration.json @@ -42,7 +42,7 @@ "client": "mysql", "version": "5.5", "connection": { - "host": "172.17.0.1", + "host": "mysql", "port": 3306, "user": "auth-service", "password": "password", diff --git a/docker-compose.linux.yml b/docker-compose.linux.yml deleted file mode 100644 index f6aab29e..00000000 --- a/docker-compose.linux.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This is an extension docker-compose file that contains `extra_hosts` entries to work arouind networking -# on linux, start docker-local with the following command -# -# docker-compose -f docker-compose.yml -f docker-compose.linux.yml up -d -# -# I suspect that with some of the recent changes to the way containers refer to one another inside the -# docker-local environment, this will no longer be needed. Please delete this file if you are reading this message -# past July and we haven't run into issues... - -version: "3.7" - -services: - auth-service: - extra_hosts: - - "redis:172.17.0.1" - - "ml-testing-toolkit:172.17.0.1" - - ml-testing-toolkit: - extra_hosts: - - "auth-service:172.17.0.1" diff --git a/docker-compose.yml b/docker-compose.yml index eae022cd..e4625420 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ networks: services: auth-service: container_name: as_auth-service - # image: mojaloop/auth-service:local + image: mojaloop/auth-service:local build: context: . cache_from: @@ -22,13 +22,17 @@ services: volumes: - ./scripts/wait4.js:/opt/auth-service/scripts/wait4.js - ./scripts/wait4.config.js:/opt/auth-service/scripts/wait4.config.js + # Mount the config folder for easy config updates + - ./config:/opt/auth-service/config environment: - NODE_ENV=integration + - LOG_LEVEL=debug healthcheck: test: wget -q http://localhost:4004/health -O /dev/null || exit 1 timeout: 20s retries: 30 interval: 15s + user: root mysql: image: mysql/mysql-server diff --git a/package-lock.json b/package-lock.json index 4f788e2e..d61935e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1994,9 +1994,9 @@ } }, "@mojaloop/api-snippets": { - "version": "12.6.2", - "resolved": "https://registry.npmjs.org/@mojaloop/api-snippets/-/api-snippets-12.6.2.tgz", - "integrity": "sha512-Ocmc/DOyHFVI9xBGeHf8QcdkRMpVapItpVjZlwX/FDLOrA+2ocezx5nFOZ5UaDY0Es35pQBLUmkuf8dJRMJqtA==", + "version": "12.6.6", + "resolved": "https://registry.npmjs.org/@mojaloop/api-snippets/-/api-snippets-12.6.6.tgz", + "integrity": "sha512-b8O6P5Z4iCFS1czNAzFOQMapxPS1RaAaqoF7KzxPX2p4IBD3etIlQAXfvo31/0mVObnJIJXCioVUdocDZ/Eqmw==", "requires": { "commander": "^2.19.0", "jest-ts-auto-mock": "^2.0.0", @@ -2021,6 +2021,14 @@ "lru-cache": "^6.0.0" } }, + "is-core-module": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.6.0.tgz", + "integrity": "sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ==", + "requires": { + "has": "^1.0.3" + } + }, "js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", @@ -2055,12 +2063,12 @@ } }, "normalize-package-data": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.2.tgz", - "integrity": "sha512-6CdZocmfGaKnIHPVFhJJZ3GuR8SsLKvDANFp47Jmy51aKIr8akjAWTSxtpI+MBgBFdSMRyo4hMpDlT6dTffgZg==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-3.0.3.tgz", + "integrity": "sha512-p2W1sgqij3zMMyRC067Dg16bfzVH+w7hyegmpIvZ4JNjqtGOVAIvLmjBx3yP7YTe9vKJgkoNOPjwQGogDoMXFA==", "requires": { "hosted-git-info": "^4.0.1", - "resolve": "^1.20.0", + "is-core-module": "^2.5.0", "semver": "^7.3.4", "validate-npm-package-license": "^3.0.1" } @@ -2096,15 +2104,6 @@ } } }, - "resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", - "requires": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" - } - }, "semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", @@ -3919,6 +3918,12 @@ "resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==" }, + "async-limiter": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", + "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", + "dev": true + }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -11466,8 +11471,12 @@ }, "ws": { "version": "5.2.2", - "resolved": "", - "dev": true + "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz", + "integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0" + } }, "y18n": { "version": "4.0.3", @@ -14620,6 +14629,22 @@ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" }, + "micromatch": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", + "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "requires": { + "braces": "^3.0.1", + "picomatch": "^2.2.3" + }, + "dependencies": { + "picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==" + } + } + }, "mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", @@ -20014,29 +20039,13 @@ "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" }, "ts-auto-mock": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/ts-auto-mock/-/ts-auto-mock-3.3.5.tgz", - "integrity": "sha512-V1i2DrEjDHEtjlJi6kaMH/n8NGyX3iat8oIUh1rymhULBboWyBqv6cCogej9S2ZXBd1PM8vaPwS3J6ooM7beTw==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/ts-auto-mock/-/ts-auto-mock-3.5.0.tgz", + "integrity": "sha512-E1XjMO6UWK/e+i4Ri7h8xGFCIHAb+dxgojcmPQZabQXIJatddQvqJOypg7nYCD2lPtb43HVa3bQd6uHDYV5PvQ==", "requires": { "lodash-es": "^4.17.21", "micromatch": "^4.0.4", "winston": "^3.3.3" - }, - "dependencies": { - "micromatch": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", - "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", - "requires": { - "braces": "^3.0.1", - "picomatch": "^2.2.3" - } - }, - "picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==" - } } }, "ts-jest": { diff --git a/package.json b/package.json index 46e43b0e..d3cf0dca 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,7 @@ "@hapi/hapi": "^20.1.5", "@hapi/inert": "^6.0.3", "@hapi/vision": "^6.1.0", - "@mojaloop/api-snippets": "^12.6.2", + "@mojaloop/api-snippets": "^12.6.6", "@mojaloop/central-services-error-handling": "11.3.0", "@mojaloop/central-services-health": "^13.0.0", "@mojaloop/central-services-logger": "10.6.1", diff --git a/src/domain/stateMachine/registerConsent.model.ts b/src/domain/stateMachine/registerConsent.model.ts index 5e3f9bdc..dfd2d535 100644 --- a/src/domain/stateMachine/registerConsent.model.ts +++ b/src/domain/stateMachine/registerConsent.model.ts @@ -256,7 +256,7 @@ export class RegisterConsentModel } const res = await axios.post(alsParticipantURI, payload, axiosConfig) this.logger.push({ res, channel }) - .log('POST /participants/{Type}/{ID} call sent to ALS, listening on response') + .debug('POST /participants/{Type}/{ID} call sent to ALS, listening on response') }) .job(async (message: Message): Promise => { try { diff --git a/src/model/consent/consent.ts b/src/model/consent/consent.ts index 8a26ae98..d07dc00f 100644 --- a/src/model/consent/consent.ts +++ b/src/model/consent/consent.ts @@ -45,6 +45,7 @@ import { NotFoundError, RevokedConsentModificationError } from '../errors' import Knex from 'knex' import { thirdparty as tpAPI } from '@mojaloop/api-snippets' +import { logger } from '~/shared/logger' /* * Interface for Consent resource type as modelled in DB @@ -89,6 +90,7 @@ export class ConsentDB { // Add initial Consent parameters // Error bubbles up in case of primary key violation public async insert(consent: ConsentModel, trx?: Knex.Transaction): Promise { + logger.debug(`ConsentDB.insert - ${JSON.stringify(consent)}`) // optionally insert in transaction const action = this.Db(tableName).insert(consent) if (trx) { diff --git a/src/model/db.ts b/src/model/db.ts index 6a67cc95..2bcc3c4e 100644 --- a/src/model/db.ts +++ b/src/model/db.ts @@ -28,6 +28,7 @@ ******/ import Knex from 'knex' +import { logger } from '~/shared/logger' import Config from '../shared/config' import { ConsentModel, ConsentDB } from './consent' import { ScopeModel, ScopeDB } from './scope' @@ -46,6 +47,7 @@ async function insertConsentWithScopes (consent: ConsentModel, scopes: ScopeMode await scopeDB.insert(scopes, trx) await trx.commit() } catch (err) { + logger.push(err).debug('db.insertConsentWithScopes error') await trx.rollback() throw err } @@ -59,6 +61,12 @@ async function getScopesForConsentId (consentId: string): Promise): Promise { + await Promise.all(consentIds.map(async id => { + return consentDB.delete(id) + })) +} + export { Db, consentDB, @@ -66,5 +74,8 @@ export { closeKnexConnection, insertConsentWithScopes, getConsent, - getScopesForConsentId + getScopesForConsentId, + + // Test utils + testCleanupConsents } diff --git a/test/integration/domain/consents.test.ts b/test/integration/domain/consents.test.ts index 34bc6d1c..794d7649 100644 --- a/test/integration/domain/consents.test.ts +++ b/test/integration/domain/consents.test.ts @@ -28,11 +28,14 @@ -------------- ******/ import { createAndStoreConsent } from '~/domain/consents' -import { closeKnexConnection } from '~/model/db' +import * as DB from '~/model/db' import { thirdparty as tpAPI } from '@mojaloop/api-snippets' import { requestWithPayloadScopes } from 'test/data/data' +import { deriveChallenge } from '~/domain/challenge' describe('server/domain/consents', (): void => { + const consentIdsToCleanup: Array = [] + const consentId = requestWithPayloadScopes.params.ID const participantId = requestWithPayloadScopes.headers['fspiop-destination'] const payload: tpAPI.Schemas.ConsentsPostRequestAUTH = { @@ -51,74 +54,11 @@ describe('server/domain/consents', (): void => { status: 'PENDING', payload: { id: 'X8aQc8WgIOiYzoRIKbTYJdlzMZ_8zo3ZiIL3Rvh_ONfr9kZtudCwYO49tWVkjgJGyJSpoo6anRBVJGda0Lri3Q', - rawId: Buffer.from([ - 95, 198, 144, 115, 197, 160, 32, 232, 152, 206, 132, 72, 41, 180, 216, 37, 217, 115, 49, 159, 252, 206, - 141, 217, 136, 130, 247, 70, 248, 127, 56, 215, 235, 246, 70, 109, 185, 208, 176, 96, 238, 61, 181, - 101, 100, 142, 2, 70, 200, 148, 169, 162, 142, 154, 157, 16, 85, 36, 103, 90, 208, 186, 226, 221] - ).toString('base64'), + rawId: 'X8aQc8WgIOiYzoRIKbTYJdlzMZ/8zo3ZiIL3Rvh/ONfr9kZtudCwYO49tWVkjgJGyJSpoo6anRBVJGda0Lri3Q==', response: { // clientDataJSON needs to be utf-8 not base64 - clientDataJSON: Buffer.from( - [123, 34, 116, 121, 112, 101, 34, 58, 34, 119, 101, 98, - 97, 117, 116, 104, 110, 46, 99, 114, 101, 97, 116, 101, 34, 44, 34, 99, 104, 97, 108, 108, 101, 110, - 103, 101, 34, 58, 34, 77, 103, 65, 51, 65, 68, 103, 65, 78, 81, 66, 106, 65, 68, 73, 65, 90, 65, 65, - 53, 65, 68, 107, 65, 89, 81, 65, 48, 65, 71, 77, 65, 77, 81, 65, 53, 65, 71, 81, 65, 77, 81, 66, 104, - 65, 68, 103, 65, 78, 119, 66, 107, 65, 68, 77, 65, 78, 65, 66, 109, 65, 71, 81, 65, 77, 65, 66, 106, - 65, 68, 69, 65, 77, 65, 66, 104, 65, 71, 81, 65, 77, 65, 66, 105, 65, 68, 85, 65, 77, 103, 65, 51, - 65, 68, 73, 65, 77, 81, 66, 106, 65, 71, 89, 65, 77, 119, 66, 106, 65, 68, 103, 65, 77, 65, 65, 121, - 65, 68, 103, 65, 79, 65, 66, 106, 65, 68, 73, 65, 79, 81, 66, 107, 65, 71, 69, 65, 78, 81, 66, 105, - 65, 68, 65, 65, 90, 81, 66, 105, 65, 71, 85, 65, 90, 103, 65, 50, 65, 68, 99, 65, 79, 65, 65, 122, - 65, 68, 81, 65, 77, 65, 65, 34, 44, 34, 111, 114, 105, 103, 105, 110, 34, 58, 34, 104, 116, 116, 112, - 58, 47, 47, 108, 111, 99, 97, 108, 104, 111, 115, 116, 58, 53, 48, 48, 48, 34, 44, 34, 99, 114, 111, - 115, 115, 79, 114, 105, 103, 105, 110, 34, 58, 102, 97, 108, 115, 101, 125] - ).toString('utf-8'), - attestationObject: Buffer.from( - [163, 99, 102, 109, 116, 102, 112, 97, 99, 107, 101, 100, 103, 97, 116, - 116, 83, 116, 109, 116, 163, 99, 97, 108, 103, 38, 99, 115, 105, 103, 88, 71, 48, 69, 2, 32, 30, 175, - 73, 42, 152, 191, 108, 89, 231, 187, 75, 149, 87, 233, 58, 38, 49, 223, 5, 193, 112, 89, 20, 66, 92, - 149, 165, 122, 56, 51, 36, 181, 2, 33, 0, 246, 136, 227, 141, 25, 119, 155, 56, 44, 106, 223, 181, - 42, 190, 233, 177, 11, 247, 73, 207, 86, 183, 83, 209, 117, 13, 172, 85, 48, 89, 243, 127, 99, 120, - 53, 99, 129, 89, 2, 193, 48, 130, 2, 189, 48, 130, 1, 165, 160, 3, 2, 1, 2, 2, 4, 11, 5, 205, 83, 48, - 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 11, 5, 0, 48, 46, 49, 44, 48, 42, 6, 3, 85, 4, 3, 19, 35, - 89, 117, 98, 105, 99, 111, 32, 85, 50, 70, 32, 82, 111, 111, 116, 32, 67, 65, 32, 83, 101, 114, 105, - 97, 108, 32, 52, 53, 55, 50, 48, 48, 54, 51, 49, 48, 32, 23, 13, 49, 52, 48, 56, 48, 49, 48, 48, 48, - 48, 48, 48, 90, 24, 15, 50, 48, 53, 48, 48, 57, 48, 52, 48, 48, 48, 48, 48, 48, 90, 48, 110, 49, 11, - 48, 9, 6, 3, 85, 4, 6, 19, 2, 83, 69, 49, 18, 48, 16, 6, 3, 85, 4, 10, 12, 9, 89, 117, 98, 105, 99, - 111, 32, 65, 66, 49, 34, 48, 32, 6, 3, 85, 4, 11, 12, 25, 65, 117, 116, 104, 101, 110, 116, 105, 99, - 97, 116, 111, 114, 32, 65, 116, 116, 101, 115, 116, 97, 116, 105, 111, 110, 49, 39, 48, 37, 6, 3, 85, - 4, 3, 12, 30, 89, 117, 98, 105, 99, 111, 32, 85, 50, 70, 32, 69, 69, 32, 83, 101, 114, 105, 97, 108, - 32, 49, 56, 52, 57, 50, 57, 54, 49, 57, 48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, - 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 33, 26, 111, 177, 181, 137, 37, 203, 10, 193, 24, 95, 124, - 42, 227, 168, 180, 136, 16, 20, 121, 177, 30, 255, 245, 85, 224, 125, 151, 81, 189, 43, 23, 106, 37, - 45, 238, 89, 236, 227, 133, 153, 32, 91, 179, 234, 40, 191, 143, 215, 252, 125, 167, 92, 5, 66, 114, - 174, 72, 88, 229, 145, 252, 90, 163, 108, 48, 106, 48, 34, 6, 9, 43, 6, 1, 4, 1, 130, 196, 10, 2, 4, - 21, 49, 46, 51, 46, 54, 46, 49, 46, 52, 46, 49, 46, 52, 49, 52, 56, 50, 46, 49, 46, 49, 48, 19, 6, - 11, 43, 6, 1, 4, 1, 130, 229, 28, 2, 1, 1, 4, 4, 3, 2, 4, 48, 48, 33, 6, 11, 43, 6, 1, 4, 1, 130, - 229, 28, 1, 1, 4, 4, 18, 4, 16, 20, 154, 32, 33, 142, 246, 65, 51, 150, 184, 129, 248, 213, 183, 241, - 245, 48, 12, 6, 3, 85, 29, 19, 1, 1, 255, 4, 2, 48, 0, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, - 11, 5, 0, 3, 130, 1, 1, 0, 62, 254, 163, 223, 61, 42, 224, 114, 87, 143, 126, 4, 208, 221, 90, 75, - 104, 219, 1, 175, 232, 99, 46, 24, 180, 224, 184, 115, 67, 24, 145, 25, 108, 24, 75, 235, 193, 213, - 51, 162, 61, 119, 139, 177, 4, 8, 193, 185, 170, 65, 78, 117, 118, 133, 91, 9, 54, 151, 24, 179, 72, - 175, 92, 239, 108, 176, 48, 134, 114, 214, 31, 184, 189, 155, 134, 161, 10, 166, 130, 206, 140, 45, - 78, 240, 144, 237, 80, 84, 24, 254, 83, 212, 206, 30, 98, 122, 40, 243, 114, 3, 9, 88, 208, 143, 250, - 89, 27, 196, 24, 128, 225, 142, 138, 12, 237, 26, 133, 128, 127, 144, 150, 113, 65, 122, 11, 69, 50, - 21, 179, 141, 193, 71, 42, 36, 73, 118, 64, 180, 232, 107, 254, 196, 241, 84, 99, 155, 133, 184, 232, - 128, 20, 150, 54, 36, 56, 53, 89, 1, 43, 252, 135, 124, 11, 68, 236, 125, 167, 148, 210, 6, 84, 178, - 154, 220, 29, 186, 92, 80, 123, 240, 202, 109, 243, 82, 188, 205, 222, 116, 13, 46, 167, 225, 8, 36, - 162, 206, 57, 79, 144, 77, 29, 153, 65, 94, 58, 124, 69, 181, 254, 40, 122, 155, 203, 220, 105, 142, - 139, 220, 213, 180, 121, 138, 92, 237, 53, 222, 138, 53, 9, 2, 10, 20, 183, 38, 191, 191, 57, 167, - 68, 7, 156, 185, 143, 91, 157, 202, 9, 183, 195, 235, 188, 189, 162, 175, 105, 3, 104, 97, 117, 116, - 104, 68, 97, 116, 97, 88, 196, 73, 150, 13, 229, 136, 14, 140, 104, 116, 52, 23, 15, 100, 118, 96, - 91, 143, 228, 174, 185, 162, 134, 50, 199, 153, 92, 243, 186, 131, 29, 151, 99, 65, 0, 0, 0, 4, 20, - 154, 32, 33, 142, 246, 65, 51, 150, 184, 129, 248, 213, 183, 241, 245, 0, 64, 95, 198, 144, 115, 197, - 160, 32, 232, 152, 206, 132, 72, 41, 180, 216, 37, 217, 115, 49, 159, 252, 206, 141, 217, 136, 130, - 247, 70, 248, 127, 56, 215, 235, 246, 70, 109, 185, 208, 176, 96, 238, 61, 181, 101, 100, 142, 2, 70, - 200, 148, 169, 162, 142, 154, 157, 16, 85, 36, 103, 90, 208, 186, 226, 221, 165, 1, 2, 3, 38, 32, 1, - 33, 88, 32, 116, 102, 143, 113, 2, 62, 213, 231, 68, 238, 236, 120, 252, 23, 149, 168, 208, 13, 192, - 150, 130, 41, 177, 80, 210, 99, 104, 156, 91, 215, 146, 194, 34, 88, 32, 126, 253, 183, 67, 182, 134, - 115, 195, 130, 235, 165, 161, 137, 246, 121, 39, 81, 237, 198, 154, 101, 223, 197, 126, 121, 164, - 226, 252, 142, 1, 54, 155] - ).toString('base64') + clientDataJSON: '{"type":"webauthn.create","challenge":"MgA3ADgANQBjADIAZAA5ADkAYQA0AGMAMQA5AGQAMQBhADgANwBkADMANABmAGQAMABjADEAMABhAGQAMABiADUAMgA3ADIAMQBjAGYAMwBjADgAMAAyADgAOABjADIAOQBkAGEANQBiADAAZQBiAGUAZgA2ADcAOAAzADQAMAA","origin":"http://localhost:5000","crossOrigin":false}', + attestationObject: 'o2NmbXRmcGFja2VkZ2F0dFN0bXSjY2FsZyZjc2lnWEcwRQIgHq9JKpi/bFnnu0uVV+k6JjHfBcFwWRRCXJWlejgzJLUCIQD2iOONGXebOCxq37UqvumxC/dJz1a3U9F1DaxVMFnzf2N4NWOBWQLBMIICvTCCAaWgAwIBAgIECwXNUzANBgkqhkiG9w0BAQsFADAuMSwwKgYDVQQDEyNZdWJpY28gVTJGIFJvb3QgQ0EgU2VyaWFsIDQ1NzIwMDYzMTAgFw0xNDA4MDEwMDAwMDBaGA8yMDUwMDkwNDAwMDAwMFowbjELMAkGA1UEBhMCU0UxEjAQBgNVBAoMCVl1YmljbyBBQjEiMCAGA1UECwwZQXV0aGVudGljYXRvciBBdHRlc3RhdGlvbjEnMCUGA1UEAwweWXViaWNvIFUyRiBFRSBTZXJpYWwgMTg0OTI5NjE5MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEIRpvsbWJJcsKwRhffCrjqLSIEBR5sR7/9VXgfZdRvSsXaiUt7lns44WZIFuz6ii/j9f8fadcBUJyrkhY5ZH8WqNsMGowIgYJKwYBBAGCxAoCBBUxLjMuNi4xLjQuMS40MTQ4Mi4xLjEwEwYLKwYBBAGC5RwCAQEEBAMCBDAwIQYLKwYBBAGC5RwBAQQEEgQQFJogIY72QTOWuIH41bfx9TAMBgNVHRMBAf8EAjAAMA0GCSqGSIb3DQEBCwUAA4IBAQA+/qPfPSrgclePfgTQ3VpLaNsBr+hjLhi04LhzQxiRGWwYS+vB1TOiPXeLsQQIwbmqQU51doVbCTaXGLNIr1zvbLAwhnLWH7i9m4ahCqaCzowtTvCQ7VBUGP5T1M4eYnoo83IDCVjQj/pZG8QYgOGOigztGoWAf5CWcUF6C0UyFbONwUcqJEl2QLToa/7E8VRjm4W46IAUljYkODVZASv8h3wLROx9p5TSBlSymtwdulxQe/DKbfNSvM3edA0up+EIJKLOOU+QTR2ZQV46fEW1/ih6m8vcaY6L3NW0eYpc7TXeijUJAgoUtya/vzmnRAecuY9bncoJt8PrvL2ir2kDaGF1dGhEYXRhWMRJlg3liA6MaHQ0Fw9kdmBbj+SuuaKGMseZXPO6gx2XY0EAAAAEFJogIY72QTOWuIH41bfx9QBAX8aQc8WgIOiYzoRIKbTYJdlzMZ/8zo3ZiIL3Rvh/ONfr9kZtudCwYO49tWVkjgJGyJSpoo6anRBVJGda0Lri3aUBAgMmIAEhWCB0Zo9xAj7V50Tu7Hj8F5Wo0A3AloIpsVDSY2icW9eSwiJYIH79t0O2hnPDguuloYn2eSdR7caaZd/Ffnmk4vyOATab' }, type: 'public-key' } @@ -128,19 +68,30 @@ describe('server/domain/consents', (): void => { const scopesExternal: tpAPI.Schemas.Scope[] = payload.scopes as tpAPI.Schemas.Scope[] afterAll(async (): Promise => { - await closeKnexConnection() + await DB.testCleanupConsents(consentIdsToCleanup) + await DB.closeKnexConnection() }) it('Should resolve successfully', async (): Promise => { - await expect(createAndStoreConsent( + // Arrange + consentIdsToCleanup.push(consentId) + + // Act + const response = await createAndStoreConsent( consentId, participantId, scopesExternal, payload.credential, - 'dwuduwd&e2idjoj0w', - 'xyhdushsoa82w92mzs', - 4 - )).resolves - .toBe(undefined) + '-----BEGIN PUBLIC KEY-----\n' + + 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWM/klen0su2Yxc3Y/klsWjG32sOG\n' + + 'U/sGIApTd7/d5FVks2ONQzS64dY16eCed6gp6uPm/R2F7nf9FBLGarg3lQ==\n' + + '-----END PUBLIC KEY-----\n', + deriveChallenge(payload), + 0 + ) + + // Assert + // We're mainly testing that nothing threw! + expect(response).toBe(undefined) }) }) diff --git a/test/integration/server/workflows/registerConsent.test.ts b/test/integration/server/workflows/registerConsent.test.ts index ba3c65ce..5d87457e 100644 --- a/test/integration/server/workflows/registerConsent.test.ts +++ b/test/integration/server/workflows/registerConsent.test.ts @@ -138,7 +138,7 @@ const consentsPostRequestAUTH: tpAPI.Schemas.ConsentsPostRequestAUTH = { // note to Kevin - I want to get the PR for main implementation and unit tests in // now, so I'll cover the fixes to the integration tests and new integration tests // for tx in the next one! -describe.skip('Inbound POST /consents', (): void => { +describe('Inbound POST /consents', (): void => { const ttkRequestsHistoryUri = `http://localhost:5050/api/history/requests` beforeEach(async(): Promise => { diff --git a/test/unit/shared/fido-lib.test.ts b/test/unit/shared/fido-lib.test.ts index 1e5e0e7c..03e233d9 100644 --- a/test/unit/shared/fido-lib.test.ts +++ b/test/unit/shared/fido-lib.test.ts @@ -161,6 +161,8 @@ import { decodeBase64String } from '~/domain/buffer' } } */ +const atob = require('atob') + const consentsPostRequestAUTH = { headers: { @@ -183,11 +185,8 @@ const consentsPostRequestAUTH = { credentialType: 'FIDO', status: 'PENDING', payload: { - id: 'HskU2gw4np09IUtYNHnxMM696jJHqvccUdBmd0xP6XEWwH0xLei1PUzDJCM19SZ3A2Ex0fNLw0nc2hrIlFnAtw', - rawId: Buffer.from([30, 201, 20, 218, 12, 56, 158, 157, 61, 33, 75, 88, 52, 121, 241, 48, 206, 189, - 234, 50, 71, 170, 247, 28, 81, 208, 102, 119, 76, 79, 233, 113, 22, 192, 125, 49, 45, - 232, 181, 61, 76, 195, 36, 35, 53, 245, 38, 119, 3, 97, 49, 209, 243, 75, 195, 73, 220, - 218, 26, 200, 148, 89, 192, 183]).toString('base64'), + id: atob('HskU2gw4np09IUtYNHnxMM696jJHqvccUdBmd0xP6XEWwH0xLei1PUzDJCM19SZ3A2Ex0fNLw0nc2hrIlFnAtw'), + rawId: atob('HskU2gw4np09IUtYNHnxMM696jJHqvccUdBmd0xP6XEWwH0xLei1PUzDJCM19SZ3A2Ex0fNLw0nc2hrIlFnAtw=='), response: { clientDataJSON: Buffer.from( [123, 34, 116, 121,