diff --git a/audit-resolve.json b/audit-resolve.json index adc96c8..32be228 100644 --- a/audit-resolve.json +++ b/audit-resolve.json @@ -29,6 +29,11 @@ "decision": "ignore", "madeAt": 1635505274932, "expiresAt": 1638097266206 + }, + "1004784|hapi-swagger>swagger-parser>z-schema>validator": { + "decision": "ignore", + "madeAt": 1636105704685, + "expiresAt": 1638697697505 } }, "rules": {}, diff --git a/package-lock.json b/package-lock.json index bf17457..826ca49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1719,9 +1719,9 @@ } }, "@mojaloop/ml-testing-toolkit-shared-lib": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/@mojaloop/ml-testing-toolkit-shared-lib/-/ml-testing-toolkit-shared-lib-12.1.0.tgz", - "integrity": "sha512-ViBWGmY8Gf0qKZm+WgE1R+q8wrsENk1tYE9BOgrNchYG9RK92/fa+PMVq0ZYF+0R0wS1OIj8rU/7w6A8vlBmNw==", + "version": "12.2.0", + "resolved": "https://registry.npmjs.org/@mojaloop/ml-testing-toolkit-shared-lib/-/ml-testing-toolkit-shared-lib-12.2.0.tgz", + "integrity": "sha512-DFAkwKSRvb9M4SSCpHPsjKeaIkAc6fTs8fB6VLs0+JmbJBTx672Mm78NvoGnlfwYH5n2dbwfQeZ/ZWeakEpaUQ==", "dev": true, "requires": { "ajv": "8.5.0", @@ -2516,9 +2516,9 @@ } }, "asn1": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", - "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", + "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==", "dev": true, "requires": { "safer-buffer": "~2.1.0" @@ -6031,9 +6031,9 @@ }, "dependencies": { "ignore": { - "version": "5.1.8", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", - "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", + "version": "5.1.9", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.9.tgz", + "integrity": "sha512-2zeMQpbKz5dhZ9IwL0gbxSW5w0NK/MSAMtNuhgIHEPmaU3vPdKPL0UdvUCXs5SS4JAwsBxysK5sFMW8ocFiVjQ==", "dev": true } } @@ -10037,9 +10037,9 @@ } }, "npm-check-updates": { - "version": "11.8.5", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-11.8.5.tgz", - "integrity": "sha512-IYSHjlWe8UEugDy7X0qjBeJwcni4DlcWdBK4QQEbwgkNlEDlXyd4yQJYWFumKaJzrp/n5/EcvaboXsBD1Er/pw==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-12.0.0.tgz", + "integrity": "sha512-KkUu9W5BWE4JmNeuPEwDz5a5yBOoWSrWl4DbT1/jBm+ytpVzjO9NN2jAD0GydhHZV/Brgh4xgWtBiMZJi5dUxQ==", "dev": true, "requires": { "chalk": "^4.1.2", @@ -10061,12 +10061,13 @@ "pacote": "^11.3.5", "parse-github-url": "^1.0.2", "progress": "^2.0.3", - "prompts": "^2.4.1", + "prompts": "^2.4.2", "rc-config-loader": "^4.0.0", "remote-git-tags": "^3.0.0", "rimraf": "^3.0.2", "semver": "^7.3.5", "semver-utils": "^1.1.4", + "source-map-support": "^0.5.19", "spawn-please": "^1.0.0", "update-notifier": "^5.1.0" }, @@ -12109,13 +12110,13 @@ } }, "sinon": { - "version": "11.1.2", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-11.1.2.tgz", - "integrity": "sha512-59237HChms4kg7/sXhiRcUzdSkKuydDeTiamT/jesUVHshBgL8XAmhgFo0GfK6RruMDM/iRSij1EybmMog9cJw==", + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-12.0.1.tgz", + "integrity": "sha512-iGu29Xhym33ydkAT+aNQFBINakjq69kKO6ByPvTsm3yyIACfyQttRTP03aBP/I8GfhFmLzrnKwNNkr0ORb1udg==", "dev": true, "requires": { "@sinonjs/commons": "^1.8.3", - "@sinonjs/fake-timers": "^7.1.2", + "@sinonjs/fake-timers": "^8.1.0", "@sinonjs/samsam": "^6.0.2", "diff": "^5.0.0", "nise": "^5.1.0", @@ -12123,9 +12124,9 @@ }, "dependencies": { "@sinonjs/fake-timers": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz", - "integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-8.1.0.tgz", + "integrity": "sha512-OAPJUAtgeINhh/TAlUID4QTs53Njm7xzddaVlEs/SXwgtiD1tW22zAB/W1wdqfrpmikgaWQ9Fw6Ws+hsiRm5Vg==", "dev": true, "requires": { "@sinonjs/commons": "^1.7.0" @@ -12171,6 +12172,17 @@ "@sinonjs/text-encoding": "^0.7.1", "just-extend": "^4.0.2", "path-to-regexp": "^1.7.0" + }, + "dependencies": { + "@sinonjs/fake-timers": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz", + "integrity": "sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0" + } + } } }, "path-to-regexp": { diff --git a/package.json b/package.json index c4555af..f9e8320 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,7 @@ "rc": "1.2.8" }, "devDependencies": { - "@mojaloop/ml-testing-toolkit-shared-lib": "12.1.0", + "@mojaloop/ml-testing-toolkit-shared-lib": "12.2.0", "@types/jest": "27.0.2", "eslint": "7.32.0", "eslint-config-standard": "16.0.3", @@ -91,9 +91,9 @@ "jsdoc": "3.6.7", "license-checker": "25.0.1", "npm-audit-resolver": "2.3.1", - "npm-check-updates": "11.8.5", + "npm-check-updates": "12.0.0", "pre-commit": "1.2.2", - "sinon": "11.1.2", + "sinon": "12.0.1", "standard": "16.0.4", "standard-version": "9.3.2" }, diff --git a/test/unit/lib/config.test.js b/test/unit/lib/config.test.js new file mode 100644 index 0000000..8ac10bf --- /dev/null +++ b/test/unit/lib/config.test.js @@ -0,0 +1,81 @@ +/***** + License + -------------- + Copyright © 2017 Bill & Melinda Gates Foundation + The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + Contributors + -------------- + This is the official list of the Mojaloop project contributors for this file. + Names of the original copyright holders (individuals or organizations) + should be listed with a '*' in the first column. People who have + contributed from an organization can be listed under the organization + that actually holds the copyright for their contributions (see the + Gates Foundation organization for an example). Those individuals should have + their names indented and be marked with a '-'. Email address can be added + optionally within square brackets . + * Gates Foundation + - Name Surname + + * Shashikant Hirugade + -------------- + ******/ +'use strict' + +const src = '../../../src/' + +const configImport = `${src}/lib/config` +jest.mock(configImport) + +describe('Config tests', () => { + beforeEach(() => { + jest.resetModules() + }) + + afterEach(() => { + jest.clearAllMocks() + }) + + it('should load successfully', async () => { + // Setup + let Config = null + let isSuccess + // set env var + process.env.ES_ENDPOINT_SECURITY__JWS__JWS_SIGN = false + + // Act + try { + Config = jest.requireActual(configImport) + isSuccess = true + } catch (e) { + isSuccess = false + } + + // Assert + expect(Config != null).toBe(true) + expect(isSuccess).toBe(true) + }) + + it('should parse ENV var ALS_PROTOCOL_VERSIONS__ACCEPT__VALIDATELIST as a string', async () => { + // Setup + let Config = null + let isSuccess + const validateList = ['1'] + // set env var + process.env.ES_PROTOCOL_VERSIONS__ACCEPT__VALIDATELIST = JSON.stringify(validateList) + + // Act + try { + Config = jest.requireActual(configImport) + isSuccess = true + } catch (e) { + isSuccess = false + } + + // Assert + expect(Config != null).toBe(true) + expect(isSuccess).toBe(true) + expect(Config.PROTOCOL_VERSIONS.ACCEPT.VALIDATELIST).toMatchObject(validateList) + }) +})