@velocitycareerlabs/data-loader 1.21.0-dev-build.1552eb601 → 1.21.0-dev-build.182271759

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocitycareerlabs/data-loader",
3
- "version": "1.21.0-dev-build.1552eb601",
3
+ "version": "1.21.0-dev-build.182271759",
4
4
  "description": "A tool for uploading data to the different target systems.",
5
5
  "repository": "https://github.com/velocitycareerlabs/packages",
6
6
  "main": "src/index.js",
@@ -40,5 +40,5 @@
40
40
  "lodash": "~4.17.20",
41
41
  "nanoid": "3.3.1"
42
42
  },
43
- "gitHead": "789ae673d98a683a7c515e50d55e9f94be18fb14"
43
+ "gitHead": "dfa6c38caba67a0928995db792fca1114799e0a6"
44
44
  }
@@ -1,3 +1,4 @@
1
+ const { env } = require('node:process');
1
2
  const got = require('got');
2
3
  const { map, isEmpty } = require('lodash/fp');
3
4
  const { printInfo } = require('../helpers/common');
@@ -10,6 +11,11 @@ const setupGot = ({ endpoint, authToken, did }) => {
10
11
  if (authToken != null) {
11
12
  options.headers = { Authorization: `Bearer ${authToken}` };
12
13
  }
14
+ if (env.NODE_TLS_REJECT_UNAUTHORIZED === '0') {
15
+ options.https = {
16
+ rejectUnauthorized: false,
17
+ };
18
+ }
13
19
  return got.extend(options);
14
20
  };
15
21
 
@@ -1,5 +1,9 @@
1
+ const { env } = require('node:process');
1
2
  const path = require('path');
2
3
  const nock = require('nock');
4
+ const got = require('got');
5
+
6
+ const gotExtendSpy = jest.spyOn(got, 'extend');
3
7
  const { nanoid } = require('nanoid');
4
8
  const { runBatchIssuing } = require('../src/batch-issuing/orchestrators');
5
9
 
@@ -15,6 +19,10 @@ describe('batch issuing test', () => {
15
19
  nock.restore();
16
20
  });
17
21
 
22
+ beforeEach(() => {
23
+ jest.clearAllMocks();
24
+ });
25
+
18
26
  it("should fail if options don't have credential type or type doesn't exist", async () => {
19
27
  const options = {
20
28
  csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
@@ -1286,4 +1294,55 @@ describe('batch issuing test', () => {
1286
1294
  });
1287
1295
  });
1288
1296
  });
1297
+
1298
+ describe('https.rejectUnauthorized test suite', () => {
1299
+ beforeEach(() => {
1300
+ env.NODE_TLS_REJECT_UNAUTHORIZED = '';
1301
+ });
1302
+ afterAll(() => {
1303
+ env.NODE_TLS_REJECT_UNAUTHORIZED = '';
1304
+ });
1305
+
1306
+ it('when NODE_TLS_REJECT_UNAUTHORIZED is "0", got client should be setup with https.rejectUnauthorized false', async () => {
1307
+ env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
1308
+ const options = {
1309
+ csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
1310
+ offerTemplateFilename: path.join(
1311
+ __dirname,
1312
+ 'data/email-offer.template.json'
1313
+ ),
1314
+ termsUrl: 'http://example.com/terms.html',
1315
+ did: 'did:ion:sap123',
1316
+ new: true,
1317
+ dryrun: true,
1318
+ };
1319
+ await runBatchIssuing(options);
1320
+ expect(gotExtendSpy.mock.calls).toEqual([
1321
+ [{ https: { rejectUnauthorized: false } }],
1322
+ ]);
1323
+ });
1324
+
1325
+ it('when NODE_TLS_REJECT_UNAUTHORIZED is value other than "0", got client should be setup without https.rejectUnauthorized', async () => {
1326
+ const options = {
1327
+ csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
1328
+ offerTemplateFilename: path.join(
1329
+ __dirname,
1330
+ 'data/email-offer.template.json'
1331
+ ),
1332
+ termsUrl: 'http://example.com/terms.html',
1333
+ did: 'did:ion:sap123',
1334
+ new: true,
1335
+ dryrun: true,
1336
+ };
1337
+ env.NODE_TLS_REJECT_UNAUTHORIZED = 'false';
1338
+ await runBatchIssuing(options);
1339
+ env.NODE_TLS_REJECT_UNAUTHORIZED = '';
1340
+ await runBatchIssuing(options);
1341
+ env.NODE_TLS_REJECT_UNAUTHORIZED = 'undefined';
1342
+ await runBatchIssuing(options);
1343
+ delete env.NODE_TLS_REJECT_UNAUTHORIZED;
1344
+ await runBatchIssuing(options);
1345
+ expect(gotExtendSpy.mock.calls).toEqual([[{}], [{}], [{}], [{}]]);
1346
+ });
1347
+ });
1289
1348
  });