forked from mojaloop/bulk-api-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mojaloop/#2538): fspiop api version negotiation not handled
- fix(mojaloop/#2538): fspiop api version negotiation not handled - mojaloop/project#2538 - added getOptionsForFSPIOPHeaderValidation to the plugin configuration - added new config key for PROTOCOL_VERSIONS to default and integration configs - added DEFAULT_PROTOCOL_VERSION for backward compatibility - updated config and unit tests to FSPIOP v1.1 protocol version - BKAPI_PROTOCOL_VERSIONS__ACCEPT__VALIDATELIST can be set as follows "[ \"1\", \"1.1\"]" and it will be parsed correctly into a object - Added unit tests for config changes BREAKING CHANGE: Forcing a major version change for awareness of the config changes. The `LIB_RESOURCE_VERSIONS` env var is now deprecated, and this is now also controlled by the PROTOCOL_VERSIONS config in the default.json. This has been done for consistency between all API services going forward and unifies the config for both inbound and outbound Protocol API validation/transformation features.
- Loading branch information
Showing
4 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/***** | ||
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> | ||
* Miguel de Barros <miguel.debarros@modusbox.com> | ||
-------------- | ||
******/ | ||
'use strict' | ||
|
||
const src = '../../../src/' | ||
const Test = require('tapes')(require('tape')) | ||
const Util = require('@mojaloop/central-services-shared').Util | ||
const Default = require('../../../config/default.json') | ||
const Proxyquire = require('proxyquire') | ||
|
||
Test('Config tests', configTest => { | ||
let sandbox | ||
const Sinon = require('sinon') | ||
|
||
configTest.beforeEach(t => { | ||
sandbox = Sinon.createSandbox() | ||
t.end() | ||
}) | ||
|
||
configTest.afterEach(t => { | ||
sandbox.restore() | ||
t.end() | ||
}) | ||
|
||
configTest.test('getFileContent should', async getFileContentTest => { | ||
getFileContentTest.test('should not throw', test => { | ||
try { | ||
const DefaultStub = Util.clone(Default) | ||
const Config = Proxyquire(`${src}/lib/config`, { | ||
'../../config/default.json': DefaultStub | ||
}) | ||
test.ok(Config) | ||
test.ok('pass') | ||
} catch (e) { | ||
test.fail('should throw') | ||
} | ||
test.end() | ||
}) | ||
|
||
getFileContentTest.test('should pass ENV var BKAPI_PROTOCOL_VERSIONS__ACCEPT__VALIDATELIST as a string', test => { | ||
try { | ||
const DefaultStub = Util.clone(Default) | ||
// set env var | ||
const validateList = ['1'] | ||
process.env.BKAPI_PROTOCOL_VERSIONS__ACCEPT__VALIDATELIST = JSON.stringify(validateList) | ||
const Config = Proxyquire(`${src}/lib/config`, { | ||
'../../config/default.json': DefaultStub | ||
}) | ||
test.ok(Config) | ||
test.ok('pass') | ||
test.deepEqual(Config.PROTOCOL_VERSIONS.ACCEPT.VALIDATELIST, validateList) | ||
} catch (e) { | ||
test.fail('should throw') | ||
} | ||
test.end() | ||
}) | ||
|
||
getFileContentTest.end() | ||
}) | ||
|
||
configTest.end() | ||
}) |