Skip to content

Commit

Permalink
fix(mojaloop/#2537): fspiop api version negotiation not handled (#81)
Browse files Browse the repository at this point in the history
- fix(mojaloop/#2537): fspiop api version negotiation not handled - mojaloop/project#2537
    - added unit tests for config changes
    - updated dependencies
    - fixed audit-resolve issues
  • Loading branch information
mdebarros authored Nov 5, 2021
1 parent 31e290b commit 32b899e
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 23 deletions.
5 changes: 5 additions & 0 deletions audit-resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
Expand Down
52 changes: 32 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
81 changes: 81 additions & 0 deletions test/unit/lib/config.test.js
Original file line number Diff line number Diff line change
@@ -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 <email>.
* Gates Foundation
- Name Surname <name.surname@gatesfoundation.com>
* Shashikant Hirugade <shashikant.hirugade@modusbox.com>
--------------
******/
'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)
})
})

0 comments on commit 32b899e

Please sign in to comment.