@mojaloop/sdk-scheme-adapter 24.12.0-snapshot.3 → 24.12.0-snapshot.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarn/cache/{@mojaloop-central-services-shared-npm-18.33.2-ae721deeeb-a80777e9e9.zip → @mojaloop-central-services-shared-npm-18.33.3-676ab2f4ed-bed53621b8.zip} +0 -0
- package/.yarn/install-state.gz +0 -0
- package/modules/api-svc/package.json +2 -2
- package/modules/api-svc/src/InboundServer/handlers.js +2 -1
- package/modules/api-svc/src/InboundServer/index.js +19 -18
- package/modules/api-svc/src/OutboundServer/index.js +4 -22
- package/modules/api-svc/src/index.js +40 -0
- package/modules/api-svc/src/lib/model/InboundTransfersModel.js +12 -3
- package/modules/api-svc/test/unit/InboundServer-iso20022.test.js +2 -1
- package/modules/api-svc/test/unit/InboundServer.test.js +12 -8
- package/modules/api-svc/test/unit/TestServer.test.js +2 -1
- package/modules/api-svc/test/unit/api/utils.js +21 -2
- package/modules/outbound-command-event-handler/package.json +2 -2
- package/modules/outbound-domain-event-handler/package.json +1 -1
- package/modules/private-shared-lib/package.json +2 -2
- package/package.json +1 -1
|
Binary file
|
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/sdk-scheme-adapter-api-svc",
|
|
3
|
-
"version": "21.0.0-snapshot.
|
|
3
|
+
"version": "21.0.0-snapshot.69",
|
|
4
4
|
"description": "An adapter for connecting to Mojaloop API enabled switches.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@mojaloop/central-services-error-handling": "13.1.2",
|
|
69
69
|
"@mojaloop/central-services-logger": "11.10.0",
|
|
70
70
|
"@mojaloop/central-services-metrics": "12.7.1",
|
|
71
|
-
"@mojaloop/central-services-shared": "18.33.
|
|
71
|
+
"@mojaloop/central-services-shared": "18.33.3",
|
|
72
72
|
"@mojaloop/event-sdk": "14.7.0",
|
|
73
73
|
"@mojaloop/logging-bc-client-lib": "0.5.8",
|
|
74
74
|
"@mojaloop/ml-schema-transformer-lib": "2.7.8",
|
|
@@ -76,7 +76,8 @@ const createInboundTransfersModel = (ctx) => new InboundTransfersModel({
|
|
|
76
76
|
logger: ctx.state.logger,
|
|
77
77
|
wso2: ctx.state.wso2,
|
|
78
78
|
resourceVersions: ctx.resourceVersions,
|
|
79
|
-
|
|
79
|
+
backendSharedAgents: ctx.state.backendSharedAgents,
|
|
80
|
+
mojaloopSharedAgents: ctx.state.mojaloopSharedAgents,
|
|
80
81
|
});
|
|
81
82
|
|
|
82
83
|
const prepareResponse = ctx => {
|
|
@@ -48,15 +48,17 @@ const _validator = new Validate({ logExcludePaths });
|
|
|
48
48
|
let _initialize;
|
|
49
49
|
|
|
50
50
|
class InboundApi extends EventEmitter {
|
|
51
|
-
constructor(conf, logger, cache, validator, wso2) {
|
|
51
|
+
constructor(conf, logger, cache, validator, wso2, mojaloopSharedAgents) {
|
|
52
52
|
super({ captureExceptions: true });
|
|
53
53
|
this._conf = conf;
|
|
54
54
|
this._cache = cache;
|
|
55
55
|
this._logger = logger;
|
|
56
56
|
_initialize ||= _validator.initialise(apiSpecs, conf);
|
|
57
57
|
|
|
58
|
-
// Create shared HTTP and HTTPS agents for backend requests
|
|
59
|
-
this.
|
|
58
|
+
// Create shared HTTP and HTTPS agents for backend requests only
|
|
59
|
+
this.backendSharedAgents = this._createBackendSharedAgents();
|
|
60
|
+
// Use provided shared Mojaloop agents
|
|
61
|
+
this.mojaloopSharedAgents = mojaloopSharedAgents;
|
|
60
62
|
|
|
61
63
|
if (conf.validateInboundJws) {
|
|
62
64
|
// peerJWSKey is a special config option specifically for Payment Manager for Mojaloop
|
|
@@ -71,7 +73,8 @@ class InboundApi extends EventEmitter {
|
|
|
71
73
|
cache,
|
|
72
74
|
jwsVerificationKeys: this._jwsVerificationKeys,
|
|
73
75
|
wso2,
|
|
74
|
-
|
|
76
|
+
backendSharedAgents: this.backendSharedAgents,
|
|
77
|
+
mojaloopSharedAgents: this.mojaloopSharedAgents,
|
|
75
78
|
});
|
|
76
79
|
}
|
|
77
80
|
|
|
@@ -118,7 +121,7 @@ class InboundApi extends EventEmitter {
|
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
static _SetupApi({ conf, logger, validator, cache, jwsVerificationKeys, wso2,
|
|
124
|
+
static _SetupApi({ conf, logger, validator, cache, jwsVerificationKeys, wso2, backendSharedAgents, mojaloopSharedAgents }) {
|
|
122
125
|
const api = new Koa();
|
|
123
126
|
|
|
124
127
|
api.use(middlewares.createErrorHandler(logger));
|
|
@@ -130,7 +133,7 @@ class InboundApi extends EventEmitter {
|
|
|
130
133
|
api.use(middlewares.createJwsValidator(logger, jwsVerificationKeys, jwsExclusions));
|
|
131
134
|
}
|
|
132
135
|
|
|
133
|
-
api.use(middlewares.applyState({ conf, cache, wso2, logExcludePaths,
|
|
136
|
+
api.use(middlewares.applyState({ conf, cache, wso2, logExcludePaths, backendSharedAgents, mojaloopSharedAgents }));
|
|
134
137
|
api.use(middlewares.createPingMiddleware(conf, jwsVerificationKeys));
|
|
135
138
|
api.use(middlewares.createRequestValidator(validator));
|
|
136
139
|
api.use(middlewares.assignFspiopIdentifier());
|
|
@@ -160,36 +163,33 @@ class InboundApi extends EventEmitter {
|
|
|
160
163
|
return keys;
|
|
161
164
|
}
|
|
162
165
|
|
|
163
|
-
|
|
166
|
+
_createBackendSharedAgents() {
|
|
164
167
|
const httpAgent = new http.Agent({
|
|
165
168
|
keepAlive: true,
|
|
166
169
|
maxSockets: this._conf.outbound?.maxSockets || 256,
|
|
167
170
|
});
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
const httpsAgentOptions = {
|
|
172
|
+
const httpsAgent = new https.Agent({
|
|
171
173
|
keepAlive: true,
|
|
172
174
|
maxSockets: this._conf.outbound?.maxSockets || 256,
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
// Apply TLS configuration if mTLS is enabled
|
|
176
|
-
if (this._conf.outbound?.tls?.mutualTLS?.enabled && this._conf.outbound?.tls?.creds) {
|
|
177
|
-
Object.assign(httpsAgentOptions, this._conf.outbound.tls.creds);
|
|
178
|
-
}
|
|
175
|
+
});
|
|
179
176
|
|
|
180
|
-
|
|
177
|
+
// Prevent accidental logging of agent internals
|
|
178
|
+
httpAgent.toJSON = () => ({ type: 'BackendHttpAgent', keepAlive: httpAgent.keepAlive });
|
|
179
|
+
httpsAgent.toJSON = () => ({ type: 'BackendHttpsAgent', keepAlive: httpsAgent.keepAlive });
|
|
181
180
|
|
|
182
|
-
this._logger.isInfoEnabled && this._logger.info('Created shared HTTP and HTTPS agents
|
|
181
|
+
this._logger.isInfoEnabled && this._logger.info('Created shared HTTP and HTTPS agents for backend requests');
|
|
183
182
|
|
|
184
183
|
return {
|
|
185
184
|
httpAgent,
|
|
186
185
|
httpsAgent
|
|
187
186
|
};
|
|
188
187
|
}
|
|
188
|
+
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
class InboundServer extends EventEmitter {
|
|
192
|
-
constructor(conf, logger, cache, wso2) {
|
|
192
|
+
constructor(conf, logger, cache, wso2, mojaloopSharedAgents) {
|
|
193
193
|
super({ captureExceptions: true });
|
|
194
194
|
this._conf = conf;
|
|
195
195
|
this._logger = logger.push({ app: this.constructor.name });
|
|
@@ -199,6 +199,7 @@ class InboundServer extends EventEmitter {
|
|
|
199
199
|
cache,
|
|
200
200
|
_validator,
|
|
201
201
|
wso2,
|
|
202
|
+
mojaloopSharedAgents,
|
|
202
203
|
);
|
|
203
204
|
this._api.on('error', (...args) => {
|
|
204
205
|
this.emit('error', ...args);
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
--------------
|
|
26
26
|
******/
|
|
27
27
|
const http = require('http');
|
|
28
|
-
const https = require('https');
|
|
29
28
|
|
|
30
29
|
const Koa = require('koa');
|
|
31
30
|
const koaBody = require('koa-body').default;
|
|
@@ -107,32 +106,15 @@ class OutboundApi extends EventEmitter {
|
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
class OutboundServer extends EventEmitter {
|
|
110
|
-
constructor(conf, logger, cache, metricsClient, wso2) {
|
|
109
|
+
constructor(conf, logger, cache, metricsClient, wso2, mojaloopSharedAgents) {
|
|
111
110
|
super({ captureExceptions: true });
|
|
112
111
|
this._conf = conf;
|
|
113
112
|
this._logger = logger.push({ app: this.constructor.name });
|
|
114
113
|
this._server = null;
|
|
115
114
|
|
|
116
|
-
|
|
117
|
-
this.
|
|
118
|
-
|
|
119
|
-
maxSockets: conf.outbound.maxSockets || 256,
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// Create HTTPS agent based on TLS configuration
|
|
123
|
-
const httpsAgentOptions = {
|
|
124
|
-
keepAlive: true,
|
|
125
|
-
maxSockets: conf.outbound.maxSockets || 256,
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
// Apply TLS configuration if mTLS is enabled
|
|
129
|
-
if (conf.outbound.tls.mutualTLS.enabled && conf.outbound.tls.creds) {
|
|
130
|
-
Object.assign(httpsAgentOptions, conf.outbound.tls.creds);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
this._httpsAgent = new https.Agent(httpsAgentOptions);
|
|
134
|
-
|
|
135
|
-
this._logger.isInfoEnabled && this._logger.info('Created shared HTTP and HTTPS agents with keepAlive enabled');
|
|
115
|
+
this._httpAgent = mojaloopSharedAgents.httpAgent;
|
|
116
|
+
this._httpsAgent = mojaloopSharedAgents.httpsAgent;
|
|
117
|
+
this._logger.isInfoEnabled && this._logger.info('Using shared Mojaloop HTTP and HTTPS agents for OutboundServer');
|
|
136
118
|
if (conf.backendEventHandler.enabled) {
|
|
137
119
|
this._eventLogger = new DefaultLogger(BC_CONFIG.bcName, 'backend-api-handler', '0.0.1', conf.logLevel);
|
|
138
120
|
this._eventProducer = new KafkaDomainEventProducer(conf.backendEventHandler.domainEventProducer, this._eventLogger);
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
'use strict';
|
|
28
28
|
|
|
29
29
|
const EventEmitter = require('node:events');
|
|
30
|
+
const http = require('http');
|
|
31
|
+
const https = require('https');
|
|
30
32
|
const _ = require('lodash');
|
|
31
33
|
const { name, version } = require('../../../package.json');
|
|
32
34
|
|
|
@@ -76,6 +78,9 @@ class Server extends EventEmitter {
|
|
|
76
78
|
logger: this.logger
|
|
77
79
|
});
|
|
78
80
|
|
|
81
|
+
// Create shared Mojaloop agents for switch communication (used by both servers)
|
|
82
|
+
this.mojaloopSharedAgents = this._createMojaloopSharedAgents();
|
|
83
|
+
|
|
79
84
|
this.wso2 = createAuthClient(conf, logger);
|
|
80
85
|
this.wso2.auth.on('error', (msg) => {
|
|
81
86
|
this.emit('error', 'WSO2 auth error in InboundApi', msg);
|
|
@@ -86,6 +91,7 @@ class Server extends EventEmitter {
|
|
|
86
91
|
this.logger,
|
|
87
92
|
this.cache,
|
|
88
93
|
this.wso2,
|
|
94
|
+
this.mojaloopSharedAgents,
|
|
89
95
|
);
|
|
90
96
|
this.inboundServer.on('error', (...args) => {
|
|
91
97
|
this.logger.isErrorEnabled && this.logger.push({ args }).error('Unhandled error in Inbound Server');
|
|
@@ -98,6 +104,7 @@ class Server extends EventEmitter {
|
|
|
98
104
|
this.cache,
|
|
99
105
|
this.metricsClient,
|
|
100
106
|
this.wso2,
|
|
107
|
+
this.mojaloopSharedAgents,
|
|
101
108
|
);
|
|
102
109
|
this.outboundServer.on('error', (...args) => {
|
|
103
110
|
this.logger.isErrorEnabled && this.logger.push({ args }).error('Unhandled error in Outbound Server');
|
|
@@ -292,6 +299,7 @@ class Server extends EventEmitter {
|
|
|
292
299
|
this.logger,
|
|
293
300
|
this.cache,
|
|
294
301
|
this.wso2,
|
|
302
|
+
this.mojaloopSharedAgents,
|
|
295
303
|
);
|
|
296
304
|
this.inboundServer.on('error', (...args) => {
|
|
297
305
|
const errMessage = 'Unhandled error in Inbound Server';
|
|
@@ -317,6 +325,7 @@ class Server extends EventEmitter {
|
|
|
317
325
|
this.cache,
|
|
318
326
|
this.metricsClient,
|
|
319
327
|
this.wso2,
|
|
328
|
+
this.mojaloopSharedAgents,
|
|
320
329
|
);
|
|
321
330
|
this.outboundServer.on('error', (...args) => {
|
|
322
331
|
const errMessage = 'Unhandled error in Outbound Server';
|
|
@@ -447,6 +456,37 @@ class Server extends EventEmitter {
|
|
|
447
456
|
this.fspiopEventHandler?.stop(),
|
|
448
457
|
]);
|
|
449
458
|
}
|
|
459
|
+
|
|
460
|
+
_createMojaloopSharedAgents() {
|
|
461
|
+
const httpAgent = new http.Agent({
|
|
462
|
+
keepAlive: true,
|
|
463
|
+
maxSockets: this.conf.outbound?.maxSockets || 256,
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
// Create HTTPS agent based on TLS configuration for Mojaloop switch communication
|
|
467
|
+
const httpsAgentOptions = {
|
|
468
|
+
keepAlive: true,
|
|
469
|
+
maxSockets: this.conf.outbound?.maxSockets || 256,
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
// Apply TLS configuration if mTLS is enabled for switch communication
|
|
473
|
+
if (this.conf.outbound?.tls?.mutualTLS?.enabled && this.conf.outbound?.tls?.creds) {
|
|
474
|
+
Object.assign(httpsAgentOptions, this.conf.outbound.tls.creds);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const httpsAgent = new https.Agent(httpsAgentOptions);
|
|
478
|
+
|
|
479
|
+
// Prevent accidental logging of agent internals
|
|
480
|
+
httpAgent.toJSON = () => ({ type: 'HttpAgent', keepAlive: httpAgent.keepAlive });
|
|
481
|
+
httpsAgent.toJSON = () => ({ type: 'HttpsAgent', keepAlive: httpsAgent.keepAlive });
|
|
482
|
+
|
|
483
|
+
this.logger.isInfoEnabled && this.logger.info('Created shared HTTP and HTTPS agents for Mojaloop switch communication');
|
|
484
|
+
|
|
485
|
+
return {
|
|
486
|
+
httpAgent,
|
|
487
|
+
httpsAgent
|
|
488
|
+
};
|
|
489
|
+
}
|
|
450
490
|
}
|
|
451
491
|
|
|
452
492
|
/*
|
|
@@ -57,7 +57,7 @@ class InboundTransfersModel {
|
|
|
57
57
|
this._getTransferRequestRetry = config.getTransferRequestRetry;
|
|
58
58
|
this._backendRequestRetry = config.backendRequestRetry;
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
const mojaloopRequestsConfig = {
|
|
61
61
|
logger: this._logger,
|
|
62
62
|
peerEndpoint: config.peerEndpoint,
|
|
63
63
|
alsEndpoint: config.alsEndpoint,
|
|
@@ -78,13 +78,22 @@ class InboundTransfersModel {
|
|
|
78
78
|
wso2: config.wso2,
|
|
79
79
|
resourceVersions: config.resourceVersions,
|
|
80
80
|
apiType: config.apiType,
|
|
81
|
-
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Add shared agents to prevent HTTPS agent recreation per request
|
|
84
|
+
if (config.mojaloopSharedAgents) {
|
|
85
|
+
mojaloopRequestsConfig.httpAgent = config.mojaloopSharedAgents.httpAgent;
|
|
86
|
+
mojaloopRequestsConfig.httpsAgent = config.mojaloopSharedAgents.httpsAgent;
|
|
87
|
+
this._logger.isDebugEnabled && this._logger.debug('Using shared HTTP/HTTPS agents for InboundTransfersModel MojaloopRequests');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this._mojaloopRequests = new MojaloopRequests(mojaloopRequestsConfig);
|
|
82
91
|
|
|
83
92
|
this._backendRequests = new BackendRequests({
|
|
84
93
|
logger: this._logger,
|
|
85
94
|
backendEndpoint: config.backendEndpoint,
|
|
86
95
|
dfspId: config.dfspId,
|
|
87
|
-
sharedAgents: config.
|
|
96
|
+
sharedAgents: config.backendSharedAgents
|
|
88
97
|
});
|
|
89
98
|
|
|
90
99
|
this._checkIlp = config.checkIlp;
|
|
@@ -40,6 +40,7 @@ const supertest = require('supertest');
|
|
|
40
40
|
const InboundServer = require('../../src/InboundServer');
|
|
41
41
|
const Cache = require('../../src/lib/cache');
|
|
42
42
|
const config = require('../../src/config');
|
|
43
|
+
const { createMockSharedAgents } = require('./api/utils');
|
|
43
44
|
const helpers = require('../helpers');
|
|
44
45
|
const { logger } = require('../../src/lib/logger');
|
|
45
46
|
|
|
@@ -56,7 +57,7 @@ describe('Inbound Server ISO-20022 Tests -->', () => {
|
|
|
56
57
|
let server;
|
|
57
58
|
|
|
58
59
|
beforeEach(async () => {
|
|
59
|
-
server = new InboundServer(config, logger, new Cache(config));
|
|
60
|
+
server = new InboundServer(config, logger, new Cache(config), null, createMockSharedAgents());
|
|
60
61
|
await server?.start();
|
|
61
62
|
});
|
|
62
63
|
|
|
@@ -42,6 +42,7 @@ const postQuotesBody = require('./data/postQuotesBody');
|
|
|
42
42
|
const putParticipantsBody = require('./data/putParticipantsBody');
|
|
43
43
|
const commonHttpHeaders = require('./data/commonHttpHeaders');
|
|
44
44
|
const isoBodies = require('./inboundApi/data/isoBodies.json');
|
|
45
|
+
const { createMockSharedAgents } = require('./api/utils');
|
|
45
46
|
|
|
46
47
|
jest.mock('@mojaloop/sdk-standard-components');
|
|
47
48
|
jest.mock('~/lib/cache');
|
|
@@ -51,6 +52,9 @@ const { Jws } = require('@mojaloop/sdk-standard-components');
|
|
|
51
52
|
const { logger } = require('~/lib/logger');
|
|
52
53
|
const InboundServer = require('~/InboundServer');
|
|
53
54
|
const Cache = require('~/lib/cache');
|
|
55
|
+
|
|
56
|
+
// Create shared mock agents for all tests
|
|
57
|
+
const mockSharedAgents = createMockSharedAgents();
|
|
54
58
|
const path = require('path');
|
|
55
59
|
const fs = require('fs');
|
|
56
60
|
const os = require('os');
|
|
@@ -74,7 +78,7 @@ describe('Inbound Server', () => {
|
|
|
74
78
|
logger: logger.push({ component: 'cache' }),
|
|
75
79
|
unsubscribeTimeoutMs: serverConfig.unsubscribeTimeoutMs,
|
|
76
80
|
});
|
|
77
|
-
const svr = new InboundServer(serverConfig, logger, cache);
|
|
81
|
+
const svr = new InboundServer(serverConfig, logger, cache, null, mockSharedAgents);
|
|
78
82
|
await svr.start();
|
|
79
83
|
await supertest(svr._server)
|
|
80
84
|
.put('/parties/MSISDN/123456789')
|
|
@@ -96,7 +100,7 @@ describe('Inbound Server', () => {
|
|
|
96
100
|
const body = contentType.includes(ISO_20022_HEADER_PART)
|
|
97
101
|
? isoBodies.putPartiesRequest
|
|
98
102
|
: putPartiesBody;
|
|
99
|
-
const svr = new InboundServer(serverConfig, logger, cache);
|
|
103
|
+
const svr = new InboundServer(serverConfig, logger, cache, null, mockSharedAgents);
|
|
100
104
|
await svr.start();
|
|
101
105
|
const result = await supertest(svr._server)
|
|
102
106
|
.put('/parties/MSISDN/123456789')
|
|
@@ -179,7 +183,7 @@ describe('Inbound Server', () => {
|
|
|
179
183
|
logger: logger.push({ component: 'cache' }),
|
|
180
184
|
unsubscribeTimeoutMs: serverConfig.unsubscribeTimeoutMs,
|
|
181
185
|
});
|
|
182
|
-
const svr = new InboundServer(serverConfig, logger, cache);
|
|
186
|
+
const svr = new InboundServer(serverConfig, logger, cache, null, mockSharedAgents);
|
|
183
187
|
await svr.start();
|
|
184
188
|
await supertest(svr._server)
|
|
185
189
|
.post('/quotes')
|
|
@@ -199,7 +203,7 @@ describe('Inbound Server', () => {
|
|
|
199
203
|
logger: logger.push({ component: 'cache' }),
|
|
200
204
|
unsubscribeTimeoutMs: serverConfig.unsubscribeTimeoutMs,
|
|
201
205
|
});
|
|
202
|
-
const svr = new InboundServer(serverConfig, logger, cache);
|
|
206
|
+
const svr = new InboundServer(serverConfig, logger, cache, null, mockSharedAgents);
|
|
203
207
|
await svr.start();
|
|
204
208
|
const result = await supertest(svr._server)
|
|
205
209
|
.post('/quotes')
|
|
@@ -276,7 +280,7 @@ describe('Inbound Server', () => {
|
|
|
276
280
|
logger: logger.push({ component: 'cache' }),
|
|
277
281
|
unsubscribeTimeoutMs: serverConfig.unsubscribeTimeoutMs,
|
|
278
282
|
});
|
|
279
|
-
const svr = new InboundServer(serverConfig, logger, cache);
|
|
283
|
+
const svr = new InboundServer(serverConfig, logger, cache, null, mockSharedAgents);
|
|
280
284
|
await svr.start();
|
|
281
285
|
await supertest(svr._server)
|
|
282
286
|
.put('/participants/00000000-0000-1000-a000-000000000002')
|
|
@@ -296,7 +300,7 @@ describe('Inbound Server', () => {
|
|
|
296
300
|
logger: logger.push({ component: 'cache' }),
|
|
297
301
|
unsubscribeTimeoutMs: serverConfig.unsubscribeTimeoutMs,
|
|
298
302
|
});
|
|
299
|
-
const svr = new InboundServer(serverConfig, logger, cache);
|
|
303
|
+
const svr = new InboundServer(serverConfig, logger, cache, null, mockSharedAgents);
|
|
300
304
|
await svr.start();
|
|
301
305
|
const result = await supertest(svr._server)
|
|
302
306
|
.put('/participants/00000000-0000-1000-a000-000000000002')
|
|
@@ -386,7 +390,7 @@ describe('Inbound Server', () => {
|
|
|
386
390
|
logger: logger.push({ component: 'cache' }),
|
|
387
391
|
unsubscribeTimeoutMs: defConfig.unsubscribeTimeoutMs,
|
|
388
392
|
});
|
|
389
|
-
const server = new InboundServer(defConfig, logger, cache);
|
|
393
|
+
const server = new InboundServer(defConfig, logger, cache, null, mockSharedAgents);
|
|
390
394
|
await server.start();
|
|
391
395
|
if (enableTls) {
|
|
392
396
|
expect(httpsServerSpy).toHaveBeenCalled();
|
|
@@ -421,7 +425,7 @@ describe('Inbound Server', () => {
|
|
|
421
425
|
logger: logger.push({ component: 'cache' }),
|
|
422
426
|
unsubscribeTimeoutMs: serverConfig.unsubscribeTimeoutMs,
|
|
423
427
|
});
|
|
424
|
-
svr = new InboundServer(serverConfig, logger, cache);
|
|
428
|
+
svr = new InboundServer(serverConfig, logger, cache, null, mockSharedAgents);
|
|
425
429
|
await svr.start();
|
|
426
430
|
});
|
|
427
431
|
|
|
@@ -43,6 +43,7 @@ const TestServer = require('~/TestServer');
|
|
|
43
43
|
const Cache = require('~/lib/cache');
|
|
44
44
|
const InboundServer = require('~/InboundServer');
|
|
45
45
|
const { logger } = require('~/lib/logger');
|
|
46
|
+
const { createMockSharedAgents } = require('./api/utils');
|
|
46
47
|
|
|
47
48
|
const defaultConfig = require('./data/defaultConfig');
|
|
48
49
|
const putPartiesBody = require('./data/putPartiesBody');
|
|
@@ -83,7 +84,7 @@ describe('Test Server', () => {
|
|
|
83
84
|
expect(testServer._server.listening).toBe(true);
|
|
84
85
|
testReq = supertest.agent(testServer._server);
|
|
85
86
|
|
|
86
|
-
inboundServer = new InboundServer(serverConfig, logger, cache);
|
|
87
|
+
inboundServer = new InboundServer(serverConfig, logger, cache, null, createMockSharedAgents());
|
|
87
88
|
await inboundServer.start();
|
|
88
89
|
inboundReq = supertest(inboundServer._server);
|
|
89
90
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const https = require('https');
|
|
3
5
|
const yaml = require('js-yaml');
|
|
4
6
|
const supertest = require('supertest');
|
|
5
7
|
const { WSO2Auth } = require('@mojaloop/sdk-standard-components');
|
|
@@ -16,6 +18,20 @@ const ServerType = {
|
|
|
16
18
|
Outbound: 'Outbound',
|
|
17
19
|
};
|
|
18
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Create mock shared agents for testing
|
|
23
|
+
*/
|
|
24
|
+
function createMockSharedAgents() {
|
|
25
|
+
const httpAgent = new http.Agent({ keepAlive: true });
|
|
26
|
+
const httpsAgent = new https.Agent({ keepAlive: true });
|
|
27
|
+
|
|
28
|
+
// Prevent logging of agent internals in tests
|
|
29
|
+
httpAgent.toJSON = () => ({ type: 'MockHttpAgent', keepAlive: true });
|
|
30
|
+
httpsAgent.toJSON = () => ({ type: 'MockHttpsAgent', keepAlive: true });
|
|
31
|
+
|
|
32
|
+
return { httpAgent, httpsAgent };
|
|
33
|
+
}
|
|
34
|
+
|
|
19
35
|
/**
|
|
20
36
|
* Get OpenAPI spec and Validator for specified server
|
|
21
37
|
* @param {ServerType} serverType
|
|
@@ -69,11 +85,13 @@ const createTestServers = async (config) => {
|
|
|
69
85
|
}),
|
|
70
86
|
retryWso2AuthFailureTimes: defConfig.wso2.requestAuthFailureRetryTimes,
|
|
71
87
|
};
|
|
72
|
-
const
|
|
88
|
+
const mockSharedAgents = createMockSharedAgents();
|
|
89
|
+
|
|
90
|
+
const serverOutbound = new OutboundServer(defConfig, logger, cache, metricsClient, wso2, mockSharedAgents);
|
|
73
91
|
await serverOutbound.start();
|
|
74
92
|
const reqOutbound = supertest(serverOutbound._server);
|
|
75
93
|
|
|
76
|
-
const serverInbound = new InboundServer(defConfig, logger, cache, wso2);
|
|
94
|
+
const serverInbound = new InboundServer(defConfig, logger, cache, wso2, mockSharedAgents);
|
|
77
95
|
await serverInbound.start();
|
|
78
96
|
const reqInbound = supertest(serverInbound._server);
|
|
79
97
|
|
|
@@ -94,4 +112,5 @@ module.exports = {
|
|
|
94
112
|
createValidators,
|
|
95
113
|
createTestServers,
|
|
96
114
|
destroyTestServers,
|
|
115
|
+
createMockSharedAgents,
|
|
97
116
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/sdk-scheme-adapter-outbound-command-event-handler",
|
|
3
|
-
"version": "0.3.0-snapshot.
|
|
3
|
+
"version": "0.3.0-snapshot.64",
|
|
4
4
|
"description": "Mojaloop sdk scheme adapter command event handler",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/mojaloop/sdk-scheme-adapter/",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@mojaloop/api-snippets": "18.1.1",
|
|
45
|
-
"@mojaloop/central-services-shared": "18.33.
|
|
45
|
+
"@mojaloop/central-services-shared": "18.33.3",
|
|
46
46
|
"@mojaloop/logging-bc-client-lib": "0.5.8",
|
|
47
47
|
"@mojaloop/logging-bc-public-types-lib": "0.5.6",
|
|
48
48
|
"@mojaloop/sdk-scheme-adapter-private-shared-lib": "workspace:^",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/sdk-scheme-adapter-outbound-domain-event-handler",
|
|
3
|
-
"version": "0.3.0-snapshot.
|
|
3
|
+
"version": "0.3.0-snapshot.64",
|
|
4
4
|
"description": "mojaloop sdk scheme adapter outbound domain event handler",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/mojaloop/sdk-scheme-adapter/",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mojaloop/sdk-scheme-adapter-private-shared-lib",
|
|
3
|
-
"version": "0.4.0-snapshot.
|
|
3
|
+
"version": "0.4.0-snapshot.64",
|
|
4
4
|
"description": "SDK Scheme Adapter private shared library.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/mojaloop/accounts-and-balances-bc/tree/main/modules/private-types",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@mojaloop/api-snippets": "18.1.1",
|
|
33
|
-
"@mojaloop/central-services-shared": "18.33.
|
|
33
|
+
"@mojaloop/central-services-shared": "18.33.3",
|
|
34
34
|
"@mojaloop/logging-bc-public-types-lib": "0.5.6",
|
|
35
35
|
"@mojaloop/platform-shared-lib-messaging-types-lib": "0.7.3",
|
|
36
36
|
"@mojaloop/platform-shared-lib-nodejs-kafka-client-lib": "0.5.18",
|
package/package.json
CHANGED