@velocitycareerlabs/data-loader 1.19.0-testnet-build.1b0edb23b → 1.19.0-testnet-build.17f32812c

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.19.0-testnet-build.1b0edb23b",
3
+ "version": "1.19.0-testnet-build.17f32812c",
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",
@@ -26,6 +26,7 @@
26
26
  "eslint-plugin-prettier": "^4.2.1",
27
27
  "eslint-watch": "^7.0.0",
28
28
  "jest": "29.6.2",
29
+ "nock": "13.2.9",
29
30
  "prettier": "^2.2.1"
30
31
  },
31
32
  "dependencies": {
@@ -39,5 +40,5 @@
39
40
  "lodash": "~4.17.20",
40
41
  "nanoid": "3.3.1"
41
42
  },
42
- "gitHead": "458ec57c3a94de18a207c27988688665fe3a6381"
43
+ "gitHead": "771472eee20a9c09596638beb5288244a3932c3b"
43
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,11 +1,30 @@
1
+ const { env } = require('node:process');
1
2
  const path = require('path');
3
+ const nock = require('nock');
4
+ const got = require('got');
5
+
2
6
  const { prepareData } = require('../src/batch-issuing/prepare-data');
3
7
  const { DisclosureType } = require('../src/batch-issuing/constants');
4
8
 
9
+ const gotExtendSpy = jest.spyOn(got, 'extend');
10
+ const { initFetchers } = require('../src/batch-issuing/fetchers');
11
+
5
12
  const ISO_DATETIME_TZ_FORMAT =
6
13
  /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\+\d\d:\d\d|Z)$/;
7
14
 
8
15
  describe('batch issuing test', () => {
16
+ beforeAll(() => {
17
+ nock.cleanAll();
18
+ });
19
+
20
+ afterAll(() => {
21
+ nock.restore();
22
+ });
23
+
24
+ beforeEach(() => {
25
+ jest.clearAllMocks();
26
+ });
27
+
9
28
  it("should fail if options don't have credential type or type doesn't exist", async () => {
10
29
  const options = {
11
30
  csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
@@ -913,4 +932,55 @@ describe('batch issuing test', () => {
913
932
  const updates = await prepareData(DisclosureType.EXISTING, options);
914
933
  expect(updates.newDisclosureRequest).toBeUndefined();
915
934
  });
935
+
936
+ describe('https.rejectUnauthorized test suite', () => {
937
+ beforeEach(() => {
938
+ env.NODE_TLS_REJECT_UNAUTHORIZED = '';
939
+ });
940
+ afterAll(() => {
941
+ env.NODE_TLS_REJECT_UNAUTHORIZED = '';
942
+ });
943
+
944
+ it('when NODE_TLS_REJECT_UNAUTHORIZED is "0", got client should be setup with https.rejectUnauthorized false', async () => {
945
+ env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
946
+ const options = {
947
+ csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
948
+ offerTemplateFilename: path.join(
949
+ __dirname,
950
+ 'data/email-offer.template.json'
951
+ ),
952
+ termsUrl: 'http://example.com/terms.html',
953
+ did: 'did:ion:sap123',
954
+ new: true,
955
+ dryrun: true,
956
+ };
957
+ initFetchers(options);
958
+ expect(gotExtendSpy.mock.calls).toEqual([
959
+ [{ https: { rejectUnauthorized: false } }],
960
+ ]);
961
+ });
962
+
963
+ it('when NODE_TLS_REJECT_UNAUTHORIZED is value other than "0", got client should be setup without https.rejectUnauthorized', async () => {
964
+ const options = {
965
+ csvFilename: path.join(__dirname, 'data/batch-vars-offerids.csv'),
966
+ offerTemplateFilename: path.join(
967
+ __dirname,
968
+ 'data/email-offer.template.json'
969
+ ),
970
+ termsUrl: 'http://example.com/terms.html',
971
+ did: 'did:ion:sap123',
972
+ new: true,
973
+ dryrun: true,
974
+ };
975
+ env.NODE_TLS_REJECT_UNAUTHORIZED = 'false';
976
+ initFetchers(options);
977
+ env.NODE_TLS_REJECT_UNAUTHORIZED = '';
978
+ initFetchers(options);
979
+ env.NODE_TLS_REJECT_UNAUTHORIZED = 'undefined';
980
+ initFetchers(options);
981
+ delete env.NODE_TLS_REJECT_UNAUTHORIZED;
982
+ initFetchers(options);
983
+ expect(gotExtendSpy.mock.calls).toEqual([[{}], [{}], [{}], [{}]]);
984
+ });
985
+ });
916
986
  });