@velocitycareerlabs/server-careerwallet 1.26.0-dev-build.1cce50406 → 1.26.0-dev-build.1a6aed3a4
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 +7 -6
- package/test/accounts-controller.test.js +8 -4
- package/test/accounts-repo.test.js +6 -2
- package/test/careerwallet-config-controller.test.js +6 -2
- package/test/careerwallet-consents-controller.test.js +6 -2
- package/test/create_did_key-controller.test.js +6 -3
- package/test/create_jwk-controller.test.js +6 -3
- package/test/credential-categories-controller.test.js +6 -2
- package/test/credential-icons-controller.test.js +6 -2
- package/test/devices-controller.test.js +11 -7
- package/test/feedback-controller.test.js +25 -18
- package/test/helpers/access-token.js +1 -0
- package/test/id-verification-controller.test.js +6 -2
- package/test/jwt-controller.test.js +7 -3
- package/test/oauth-controller.test.js +6 -2
- package/test/push-controller.test.js +76 -69
- package/test/push-gateway-auth.test.js +4 -0
- package/test/reference-countries-controller.test.js +6 -2
- package/test/reference-personas-controller.test.js +6 -2
- package/test/root.test.js +6 -2
- package/test/swagger.test.js +6 -2
- package/test/verification-controller.test.js +18 -15
- package/jest.config.js +0 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velocitycareerlabs/server-careerwallet",
|
|
3
|
-
"version": "1.26.0-dev-build.
|
|
3
|
+
"version": "1.26.0-dev-build.1a6aed3a4",
|
|
4
4
|
"description": "Career Wallet application",
|
|
5
5
|
"repository": "https://github.com/velocitycareerlabs/packages",
|
|
6
6
|
"engines": {
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"main": "src/index.js",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "
|
|
11
|
+
"test": "cross-env NODE_ENV=test node --test --test-concurrency=1 --experimental-test-module-mocks --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout 'test/**/*.test.js'",
|
|
12
|
+
"test:ci": "NODE_ENV=test node --test --test-concurrency=1 --experimental-test-module-mocks --experimental-test-coverage --test-coverage-include='src/**' --test-reporter=spec --test-reporter=junit --test-reporter-destination=stdout --test-reporter-destination=test-results.junit.xml --test-reporter=lcov --test-reporter-destination=lcov.info 'test/**/*.test.js'",
|
|
12
13
|
"start": "node src/index.js",
|
|
13
14
|
"start:dev": "nodemon src/standalone.js",
|
|
14
15
|
"lint": "eslint . --format json >> eslint.json",
|
|
@@ -33,8 +34,8 @@
|
|
|
33
34
|
"@fastify/swagger-ui": "^5.0.0",
|
|
34
35
|
"@getyoti/sdk-sandbox": "1.7.0",
|
|
35
36
|
"@spencejs/spence-mongo-repos": "^0.10.2",
|
|
36
|
-
"@velocitycareerlabs/migrations": "1.26.0-dev-build.
|
|
37
|
-
"@velocitycareerlabs/yoti-integration-plugin": "1.26.0-dev-build.
|
|
37
|
+
"@velocitycareerlabs/migrations": "1.26.0-dev-build.1a6aed3a4",
|
|
38
|
+
"@velocitycareerlabs/yoti-integration-plugin": "1.26.0-dev-build.1a6aed3a4",
|
|
38
39
|
"@verii/auth": "1.0.0-pre.1757456926",
|
|
39
40
|
"@verii/aws-clients": "1.0.0-pre.1757456926",
|
|
40
41
|
"@verii/common-fetchers": "1.0.0-pre.1757456926",
|
|
@@ -83,10 +84,10 @@
|
|
|
83
84
|
"eslint-plugin-prefer-arrow-functions": "3.6.2",
|
|
84
85
|
"eslint-plugin-prettier": "4.2.5",
|
|
85
86
|
"eslint-watch": "7.0.0",
|
|
86
|
-
"
|
|
87
|
+
"expect": "29.7.0",
|
|
87
88
|
"nock": "14.0.9",
|
|
88
89
|
"nodemon": "3.1.10",
|
|
89
90
|
"prettier": "2.8.8"
|
|
90
91
|
},
|
|
91
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "ff57e717f15ed96719d3d3473902497913ee1cf5"
|
|
92
93
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
2
6
|
const { ObjectId } = require('mongodb');
|
|
3
7
|
const { omit } = require('lodash/fp');
|
|
@@ -63,7 +67,7 @@ describe('Accounts controller Test Suite', () => {
|
|
|
63
67
|
|
|
64
68
|
const deviceId = 'test-device-id';
|
|
65
69
|
|
|
66
|
-
|
|
70
|
+
before(async () => {
|
|
67
71
|
({ publicKey, privateKey } = generateKeyPair({ format: 'jwk' }));
|
|
68
72
|
fastify = buildFastify({
|
|
69
73
|
holderAppServerAccessTokenPublicKey: publicKey,
|
|
@@ -86,7 +90,7 @@ describe('Accounts controller Test Suite', () => {
|
|
|
86
90
|
({ persistPersona } = personaFactory(fastify));
|
|
87
91
|
});
|
|
88
92
|
|
|
89
|
-
|
|
93
|
+
after(async () => {
|
|
90
94
|
await mongoDb().collection('devices').deleteMany({});
|
|
91
95
|
await mongoDb().collection('personas').deleteMany({});
|
|
92
96
|
await mongoDb().collection('accounts').deleteMany({});
|
|
@@ -333,7 +337,7 @@ describe('Accounts controller Test Suite', () => {
|
|
|
333
337
|
.reply(200, jwks);
|
|
334
338
|
});
|
|
335
339
|
|
|
336
|
-
|
|
340
|
+
after(() => {
|
|
337
341
|
nock.cleanAll();
|
|
338
342
|
nock.restore();
|
|
339
343
|
});
|
|
@@ -634,7 +638,7 @@ describe('Accounts controller Test Suite', () => {
|
|
|
634
638
|
describe('GET Account endpoint', () => {
|
|
635
639
|
let serverClientAccessToken;
|
|
636
640
|
|
|
637
|
-
|
|
641
|
+
before(async () => {
|
|
638
642
|
serverClientAccessToken = await createAccessToken(
|
|
639
643
|
adminScopes.adminClient,
|
|
640
644
|
privateKey,
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
2
6
|
const { ObjectId } = require('mongodb');
|
|
3
7
|
const { hashAndEncodeHex } = require('@verii/crypto');
|
|
@@ -28,7 +32,7 @@ describe('test suite for accounts repo', () => {
|
|
|
28
32
|
let fastify;
|
|
29
33
|
let persistAccounts;
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
before(async () => {
|
|
32
36
|
fastify = buildFastify();
|
|
33
37
|
await fastify.ready();
|
|
34
38
|
|
|
@@ -40,7 +44,7 @@ describe('test suite for accounts repo', () => {
|
|
|
40
44
|
({ persistAccounts } = initAccountsFactory(fastify));
|
|
41
45
|
});
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
after(async () => {
|
|
44
48
|
await fastify.close();
|
|
45
49
|
});
|
|
46
50
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
2
6
|
|
|
3
7
|
const initCareerWalletConfigFactory = require('./factories/career-wallet-config-factory');
|
|
@@ -9,7 +13,7 @@ describe('Career Wallet Config Test Suite', () => {
|
|
|
9
13
|
let fastify;
|
|
10
14
|
let persistCareerWalletConfig;
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
before(async () => {
|
|
13
17
|
fastify = buildFastify();
|
|
14
18
|
await fastify.ready();
|
|
15
19
|
|
|
@@ -20,7 +24,7 @@ describe('Career Wallet Config Test Suite', () => {
|
|
|
20
24
|
await mongoDb().collection('careerWalletConfigs').deleteMany({});
|
|
21
25
|
});
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
after(async () => {
|
|
24
28
|
await fastify.close();
|
|
25
29
|
});
|
|
26
30
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
2
6
|
const { hexFromJwk } = require('@verii/jwt');
|
|
3
7
|
const { errorResponseMatcher } = require('@verii/tests-helpers');
|
|
@@ -18,7 +22,7 @@ describe('Consents career wallet controller tests', () => {
|
|
|
18
22
|
let clientAccessToken;
|
|
19
23
|
let serverClientAccessToken;
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
before(async () => {
|
|
22
26
|
({ publicKey, privateKey } = generateKeyPair({ format: 'jwk' }));
|
|
23
27
|
|
|
24
28
|
fastify = buildFastify({
|
|
@@ -53,7 +57,7 @@ describe('Consents career wallet controller tests', () => {
|
|
|
53
57
|
await mongoDb().collection('consentsCareerWallet').deleteMany({});
|
|
54
58
|
});
|
|
55
59
|
|
|
56
|
-
|
|
60
|
+
after(async () => {
|
|
57
61
|
await fastify.close();
|
|
58
62
|
});
|
|
59
63
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const {
|
|
2
6
|
KMSClient,
|
|
3
7
|
CreateKeyCommand,
|
|
@@ -27,7 +31,7 @@ describe('create_did_key controller test suite', () => {
|
|
|
27
31
|
let privateKey;
|
|
28
32
|
let accountId;
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
before(async () => {
|
|
31
35
|
testClient = new KMSClient({
|
|
32
36
|
credentials: {
|
|
33
37
|
accessKeyId: 'tests-key-id',
|
|
@@ -71,7 +75,6 @@ describe('create_did_key controller test suite', () => {
|
|
|
71
75
|
});
|
|
72
76
|
|
|
73
77
|
beforeEach(async () => {
|
|
74
|
-
jest.clearAllMocks();
|
|
75
78
|
await mongoDb().collection('keyPairs').deleteMany({});
|
|
76
79
|
await mongoDb().collection('accounts').deleteMany({});
|
|
77
80
|
const account = await persistAccounts();
|
|
@@ -82,7 +85,7 @@ describe('create_did_key controller test suite', () => {
|
|
|
82
85
|
);
|
|
83
86
|
});
|
|
84
87
|
|
|
85
|
-
|
|
88
|
+
after(async () => {
|
|
86
89
|
await testClient.send(new DeleteAliasCommand({ AliasName: aliasName }));
|
|
87
90
|
|
|
88
91
|
await mongoDb().collection('keyPair').deleteMany({});
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const {
|
|
2
6
|
KMSClient,
|
|
3
7
|
CreateKeyCommand,
|
|
@@ -21,7 +25,7 @@ describe('create_jwk controller test suite', () => {
|
|
|
21
25
|
let jwkRepo;
|
|
22
26
|
let testClient;
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
before(async () => {
|
|
25
29
|
testClient = new KMSClient({
|
|
26
30
|
credentials: {
|
|
27
31
|
accessKeyId: 'tests-key-id',
|
|
@@ -64,11 +68,10 @@ describe('create_jwk controller test suite', () => {
|
|
|
64
68
|
});
|
|
65
69
|
|
|
66
70
|
beforeEach(async () => {
|
|
67
|
-
jest.clearAllMocks();
|
|
68
71
|
await mongoDb().collection('keyPairs').deleteMany({});
|
|
69
72
|
});
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
after(async () => {
|
|
72
75
|
await testClient.send(new DeleteAliasCommand({ AliasName: aliasName }));
|
|
73
76
|
await fastify.close();
|
|
74
77
|
});
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
const { after, before, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
2
6
|
|
|
3
7
|
describe('Credential categories', () => {
|
|
4
8
|
let fastify;
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
before(async () => {
|
|
7
11
|
fastify = buildFastify();
|
|
8
12
|
await fastify.ready();
|
|
9
13
|
});
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
after(async () => {
|
|
12
16
|
await fastify.close();
|
|
13
17
|
});
|
|
14
18
|
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
const { after, before, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
2
6
|
|
|
3
7
|
describe('Credential Icons', () => {
|
|
4
8
|
let fastify;
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
before(async () => {
|
|
7
11
|
fastify = buildFastify();
|
|
8
12
|
await fastify.ready();
|
|
9
13
|
});
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
after(async () => {
|
|
12
16
|
await fastify.close();
|
|
13
17
|
});
|
|
14
18
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
2
6
|
const { ObjectId } = require('mongodb');
|
|
3
7
|
const { omit } = require('lodash/fp');
|
|
@@ -35,7 +39,7 @@ describe('devices endpoints', () => {
|
|
|
35
39
|
let publicKey;
|
|
36
40
|
let privateKey;
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
before(async () => {
|
|
39
43
|
({ publicKey, privateKey } = generateKeyPair({ format: 'jwk' }));
|
|
40
44
|
|
|
41
45
|
fastify = buildFastify({
|
|
@@ -60,7 +64,7 @@ describe('devices endpoints', () => {
|
|
|
60
64
|
});
|
|
61
65
|
});
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
after(async () => {
|
|
64
68
|
await mongoDb().collection('devices').deleteMany({});
|
|
65
69
|
await mongoDb().collection('notifications').deleteMany({});
|
|
66
70
|
await fastify.close();
|
|
@@ -238,7 +242,7 @@ describe('devices endpoints', () => {
|
|
|
238
242
|
});
|
|
239
243
|
|
|
240
244
|
describe('get a device by device id', () => {
|
|
241
|
-
|
|
245
|
+
before(async () => {
|
|
242
246
|
device = await persistDevices();
|
|
243
247
|
await persistDevices({ deviceId: '1223' });
|
|
244
248
|
});
|
|
@@ -285,7 +289,7 @@ describe('devices endpoints', () => {
|
|
|
285
289
|
});
|
|
286
290
|
|
|
287
291
|
describe('remove a device by device id', () => {
|
|
288
|
-
|
|
292
|
+
before(async () => {
|
|
289
293
|
device = await persistDevices();
|
|
290
294
|
notification = await persistNotifications({
|
|
291
295
|
deviceId: device.deviceId,
|
|
@@ -373,7 +377,7 @@ describe('devices endpoints', () => {
|
|
|
373
377
|
const deviceId =
|
|
374
378
|
// eslint-disable-next-line max-len
|
|
375
379
|
'fs9hEl5QeENQmf_fR4xl4k:APA91bGJgbkY03CIcOTm2h1gEXv4jHgY1UuhIavAR9_IiN6p-VBUqfpkNF3UZM_V9pqq1iFckvteao4wjT7Q8gxg7DuC9yH9e0MuxX2U6byM-SAL1J0P-DaWBsPiRyLLkjIcB60nq21J';
|
|
376
|
-
|
|
380
|
+
before(async () => {
|
|
377
381
|
notification = await persistNotifications();
|
|
378
382
|
notifications = [
|
|
379
383
|
await persistNotifications({ deviceId }),
|
|
@@ -562,7 +566,7 @@ describe('devices endpoints', () => {
|
|
|
562
566
|
let credentialRevokedNotification;
|
|
563
567
|
let credentialReplacedNotification;
|
|
564
568
|
|
|
565
|
-
|
|
569
|
+
before(async () => {
|
|
566
570
|
({ deviceId } = await persistDevices());
|
|
567
571
|
|
|
568
572
|
presentationVerifiedNotification = await persistNotifications({
|
|
@@ -743,7 +747,7 @@ describe('devices endpoints', () => {
|
|
|
743
747
|
describe('Access token verification enabled', () => {
|
|
744
748
|
const deviceId = 'test-device-id';
|
|
745
749
|
|
|
746
|
-
|
|
750
|
+
before(async () => {
|
|
747
751
|
fastify.overrides.reqConfig = (config) => ({
|
|
748
752
|
...config,
|
|
749
753
|
oauthVerificationDisabledEndpoints: [], // enabled for all endpoints
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it, mock } = require('node:test');
|
|
2
|
+
const { expect } = require('expect');
|
|
3
|
+
const fp = require('fastify-plugin');
|
|
1
4
|
const { errorResponseMatcher } = require('@verii/tests-helpers');
|
|
2
|
-
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
3
5
|
|
|
4
|
-
const mockSendEmailNotificationNotification =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
...jest.requireActual('@verii/aws-clients'),
|
|
6
|
+
const mockSendEmailNotificationNotification = mock.fn(() => {});
|
|
7
|
+
mock.module('@verii/aws-clients', {
|
|
8
|
+
namedExports: {
|
|
9
|
+
...require('@verii/aws-clients'),
|
|
9
10
|
sendEmailPlugin: fp(async (fastify) => {
|
|
10
11
|
fastify.decorate('sendEmail', mockSendEmailNotificationNotification);
|
|
11
12
|
}),
|
|
12
|
-
initSendEmailNotification:
|
|
13
|
+
initSendEmailNotification: mock.fn(
|
|
13
14
|
() => mockSendEmailNotificationNotification
|
|
14
15
|
),
|
|
15
|
-
}
|
|
16
|
+
},
|
|
16
17
|
});
|
|
17
18
|
|
|
19
|
+
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
20
|
+
|
|
18
21
|
describe('Feedback controller test suite', () => {
|
|
19
22
|
let fastify;
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
before(async () => {
|
|
22
25
|
fastify = buildFastify();
|
|
23
26
|
await fastify.ready();
|
|
24
27
|
});
|
|
25
28
|
|
|
26
29
|
beforeEach(() => {
|
|
27
|
-
|
|
30
|
+
mockSendEmailNotificationNotification.mock.resetCalls();
|
|
28
31
|
});
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
after(async () => {
|
|
31
34
|
await fastify.close();
|
|
32
35
|
});
|
|
33
36
|
|
|
@@ -200,11 +203,14 @@ describe('Feedback controller test suite', () => {
|
|
|
200
203
|
});
|
|
201
204
|
|
|
202
205
|
expect(response.statusCode).toEqual(204);
|
|
203
|
-
expect(mockSendEmailNotificationNotification).
|
|
204
|
-
expect(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
expect(mockSendEmailNotificationNotification.mock.callCount()).toEqual(1);
|
|
207
|
+
expect(
|
|
208
|
+
mockSendEmailNotificationNotification.mock.calls[0].arguments
|
|
209
|
+
).toEqual([
|
|
210
|
+
{
|
|
211
|
+
recipients: ['vcl.devnet@gmail.com'],
|
|
212
|
+
sender: 'no-reply@velocitynetwork.foundation',
|
|
213
|
+
message: `
|
|
208
214
|
Support Request - Account Feedback.
|
|
209
215
|
User Information:
|
|
210
216
|
Account ID: accountId
|
|
@@ -216,7 +222,8 @@ Device Model: deviceModel
|
|
|
216
222
|
Device OS: deviceOS
|
|
217
223
|
IP Address: ip
|
|
218
224
|
`,
|
|
219
|
-
|
|
220
|
-
|
|
225
|
+
subject: 'TEST: Support Request - Account Feedback.',
|
|
226
|
+
},
|
|
227
|
+
]);
|
|
221
228
|
});
|
|
222
229
|
});
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
2
6
|
|
|
3
7
|
const idVerificationUrl = () => '/id-verify';
|
|
@@ -5,12 +9,12 @@ const idVerificationUrl = () => '/id-verify';
|
|
|
5
9
|
describe('Oracle yoti integration plugin test suite', () => {
|
|
6
10
|
let fastify;
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
before(async () => {
|
|
9
13
|
fastify = buildFastify();
|
|
10
14
|
await fastify.ready();
|
|
11
15
|
});
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
after(async () => {
|
|
14
18
|
await fastify.close();
|
|
15
19
|
});
|
|
16
20
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const {
|
|
2
6
|
KMSClient,
|
|
3
7
|
CreateKeyCommand,
|
|
@@ -80,7 +84,7 @@ describe('JWT Controller Test Suite', () => {
|
|
|
80
84
|
let privk;
|
|
81
85
|
let publicKey;
|
|
82
86
|
|
|
83
|
-
|
|
87
|
+
before(async () => {
|
|
84
88
|
testClient = new KMSClient({
|
|
85
89
|
credentials: {
|
|
86
90
|
accessKeyId: 'tests-key-id',
|
|
@@ -134,7 +138,7 @@ describe('JWT Controller Test Suite', () => {
|
|
|
134
138
|
await mongoDb().collection('accounts').deleteMany({});
|
|
135
139
|
});
|
|
136
140
|
|
|
137
|
-
|
|
141
|
+
after(async () => {
|
|
138
142
|
await testClient.send(new DeleteAliasCommand({ AliasName: aliasName }));
|
|
139
143
|
await fastify.close();
|
|
140
144
|
});
|
|
@@ -551,7 +555,7 @@ describe('JWT Controller Test Suite', () => {
|
|
|
551
555
|
});
|
|
552
556
|
|
|
553
557
|
describe('Access Token verification enabled', () => {
|
|
554
|
-
|
|
558
|
+
before(async () => {
|
|
555
559
|
fastify.overrides.reqConfig = (config) => ({
|
|
556
560
|
...config,
|
|
557
561
|
oauthVerificationDisabledEndpoints: [], // enabled for all endpoints
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const { map, slice, size, set } = require('lodash/fp');
|
|
2
6
|
const {
|
|
3
7
|
generateCredentialJwt,
|
|
@@ -131,7 +135,7 @@ describe('oauth test suite', () => {
|
|
|
131
135
|
let persistAccounts;
|
|
132
136
|
let validScopes;
|
|
133
137
|
|
|
134
|
-
|
|
138
|
+
before(async () => {
|
|
135
139
|
fastify = await buildFastify();
|
|
136
140
|
await fastify.ready();
|
|
137
141
|
const {
|
|
@@ -154,7 +158,7 @@ describe('oauth test suite', () => {
|
|
|
154
158
|
await accountsCollection.deleteMany({});
|
|
155
159
|
});
|
|
156
160
|
|
|
157
|
-
|
|
161
|
+
after(async () => {
|
|
158
162
|
await fastify.close();
|
|
159
163
|
});
|
|
160
164
|
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const { ObjectId } = require('mongodb');
|
|
3
|
-
const { nanoid } = require('nanoid');
|
|
4
|
-
const { errorResponseMatcher } = require('@verii/tests-helpers');
|
|
5
|
-
const initDevicesFactory = require('./factories/devices-factory');
|
|
6
|
-
const initAccountsFactory = require('./factories/accounts-factory');
|
|
7
|
-
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
8
|
-
const { accountsRepoPlugin } = require('../src/entities');
|
|
1
|
+
const { after, before, beforeEach, describe, it, mock } = require('node:test');
|
|
9
2
|
|
|
10
|
-
const {
|
|
11
|
-
generateNotification,
|
|
12
|
-
} = require('../src/controllers/api/v0.6/push/notification-types');
|
|
3
|
+
const { expect } = require('expect');
|
|
13
4
|
|
|
14
5
|
const testDID = 'test-did';
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const mockMessaging = jest.fn(() => ({
|
|
6
|
+
const mockSend = mock.fn(() => Promise.resolve(true));
|
|
7
|
+
const mockMessaging = mock.fn(() => ({
|
|
18
8
|
send: mockSend,
|
|
19
9
|
}));
|
|
20
|
-
const mockInitializeApp =
|
|
21
|
-
const mockCredential =
|
|
10
|
+
const mockInitializeApp = mock.fn();
|
|
11
|
+
const mockCredential = mock.fn();
|
|
22
12
|
|
|
23
13
|
const ttlSeconds = 60 * 60 * 24;
|
|
24
14
|
const notificationObj = {
|
|
@@ -57,18 +47,33 @@ const sendPayloadExpectation = (deviceId, notification, data) => ({
|
|
|
57
47
|
},
|
|
58
48
|
});
|
|
59
49
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
mock.module('../src/controllers/api/v0.6/push/push-gateway-auth.js', {
|
|
51
|
+
namedExports: {
|
|
52
|
+
pushGatewayAuth: () => Promise.resolve(),
|
|
53
|
+
},
|
|
54
|
+
});
|
|
63
55
|
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
mock.module('firebase-admin', {
|
|
57
|
+
namedExports: {
|
|
66
58
|
initializeApp: mockInitializeApp,
|
|
67
59
|
credential: { cert: mockCredential },
|
|
68
60
|
messaging: mockMessaging,
|
|
69
|
-
}
|
|
61
|
+
},
|
|
70
62
|
});
|
|
71
63
|
|
|
64
|
+
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
65
|
+
const { ObjectId } = require('mongodb');
|
|
66
|
+
const { nanoid } = require('nanoid');
|
|
67
|
+
const { errorResponseMatcher } = require('@verii/tests-helpers');
|
|
68
|
+
const initDevicesFactory = require('./factories/devices-factory');
|
|
69
|
+
const initAccountsFactory = require('./factories/accounts-factory');
|
|
70
|
+
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
71
|
+
const { accountsRepoPlugin } = require('../src/entities');
|
|
72
|
+
|
|
73
|
+
const {
|
|
74
|
+
generateNotification,
|
|
75
|
+
} = require('../src/controllers/api/v0.6/push/notification-types');
|
|
76
|
+
|
|
72
77
|
describe('push endpoints', () => {
|
|
73
78
|
let fastify;
|
|
74
79
|
let accountsRepo;
|
|
@@ -78,7 +83,7 @@ describe('push endpoints', () => {
|
|
|
78
83
|
let account;
|
|
79
84
|
let pushToken;
|
|
80
85
|
|
|
81
|
-
|
|
86
|
+
before(async () => {
|
|
82
87
|
fastify = buildFastify();
|
|
83
88
|
await fastify.ready();
|
|
84
89
|
accountsRepo = await accountsRepoPlugin(fastify)({
|
|
@@ -89,7 +94,7 @@ describe('push endpoints', () => {
|
|
|
89
94
|
({ persistDevices } = initDevicesFactory(fastify));
|
|
90
95
|
});
|
|
91
96
|
|
|
92
|
-
|
|
97
|
+
after(async () => {
|
|
93
98
|
await mongoDb().collection('devices').deleteMany({});
|
|
94
99
|
await mongoDb().collection('accounts').deleteMany({});
|
|
95
100
|
await mongoDb().collection('notifications').deleteMany({});
|
|
@@ -98,7 +103,9 @@ describe('push endpoints', () => {
|
|
|
98
103
|
});
|
|
99
104
|
|
|
100
105
|
beforeEach(() => {
|
|
101
|
-
|
|
106
|
+
mockMessaging.mock.resetCalls();
|
|
107
|
+
mockSend.mock.resetCalls();
|
|
108
|
+
mockInitializeApp.mock.resetCalls();
|
|
102
109
|
});
|
|
103
110
|
|
|
104
111
|
describe('trigger push on oracle', () => {
|
|
@@ -305,16 +312,16 @@ describe('push endpoints', () => {
|
|
|
305
312
|
},
|
|
306
313
|
});
|
|
307
314
|
expect(response.statusCode).toEqual(204);
|
|
308
|
-
expect(mockMessaging).
|
|
309
|
-
expect(mockSend).
|
|
310
|
-
expect(mockSend).
|
|
315
|
+
expect(mockMessaging.mock.callCount()).toEqual(1);
|
|
316
|
+
expect(mockSend.mock.callCount()).toEqual(1);
|
|
317
|
+
expect(mockSend.mock.calls[0].arguments).toEqual([
|
|
311
318
|
sendPayloadExpectation(device.deviceId, null, {
|
|
312
319
|
count: '0',
|
|
313
320
|
credentialTypes: '[]',
|
|
314
321
|
notificationId: expect.any(String),
|
|
315
322
|
notificationType: 'NewOffersReady',
|
|
316
|
-
})
|
|
317
|
-
);
|
|
323
|
+
}),
|
|
324
|
+
]);
|
|
318
325
|
const accountWithoutUsedPushToken = await accountsRepo.findOne({
|
|
319
326
|
filter,
|
|
320
327
|
});
|
|
@@ -339,16 +346,16 @@ describe('push endpoints', () => {
|
|
|
339
346
|
});
|
|
340
347
|
|
|
341
348
|
expect(response.statusCode).toEqual(204);
|
|
342
|
-
expect(mockMessaging).
|
|
343
|
-
expect(mockSend).
|
|
344
|
-
expect(mockSend).
|
|
349
|
+
expect(mockMessaging.mock.callCount()).toEqual(1);
|
|
350
|
+
expect(mockSend.mock.callCount()).toEqual(1);
|
|
351
|
+
expect(mockSend.mock.calls[0].arguments).toEqual([
|
|
345
352
|
sendPayloadExpectation(device.deviceId, null, {
|
|
346
353
|
count: '2',
|
|
347
354
|
credentialTypes: '["EducationDegree","PastEmploymentPosition"]',
|
|
348
355
|
notificationId: expect.stringMatching(/^[0-9a-fA-F]{24}$/),
|
|
349
356
|
notificationType: 'NewOffersReady',
|
|
350
|
-
})
|
|
351
|
-
);
|
|
357
|
+
}),
|
|
358
|
+
]);
|
|
352
359
|
});
|
|
353
360
|
|
|
354
361
|
it('should have a saved notification on 204 when notification is sent', async () => {
|
|
@@ -374,8 +381,8 @@ describe('push endpoints', () => {
|
|
|
374
381
|
expect(notifications.length).toEqual(1);
|
|
375
382
|
expect(notifications[0].data.notificationType).toEqual('NewOffersReady');
|
|
376
383
|
expect(response.statusCode).toEqual(204);
|
|
377
|
-
expect(mockMessaging).
|
|
378
|
-
expect(mockSend).
|
|
384
|
+
expect(mockMessaging.mock.callCount()).toEqual(1);
|
|
385
|
+
expect(mockSend.mock.callCount()).toEqual(1);
|
|
379
386
|
});
|
|
380
387
|
|
|
381
388
|
it('should have a saved notification on 204 and send notification when there is no pushActivated flag', async () => {
|
|
@@ -400,8 +407,8 @@ describe('push endpoints', () => {
|
|
|
400
407
|
expect(notifications[0].data.notificationType).toEqual('NewOffersReady');
|
|
401
408
|
expect(response.statusCode).toEqual(204);
|
|
402
409
|
|
|
403
|
-
expect(mockMessaging).
|
|
404
|
-
expect(mockSend).
|
|
410
|
+
expect(mockMessaging.mock.callCount()).toEqual(1);
|
|
411
|
+
expect(mockSend.mock.callCount()).toEqual(1);
|
|
405
412
|
});
|
|
406
413
|
|
|
407
414
|
it('should have a saved notification on 204 and send notification when pushActivated flag is true', async () => {
|
|
@@ -439,8 +446,8 @@ describe('push endpoints', () => {
|
|
|
439
446
|
expect(notifications[0].data.notificationType).toEqual('NewOffersReady');
|
|
440
447
|
expect(response.statusCode).toEqual(204);
|
|
441
448
|
|
|
442
|
-
expect(mockMessaging).
|
|
443
|
-
expect(mockSend).
|
|
449
|
+
expect(mockMessaging.mock.callCount()).toEqual(1);
|
|
450
|
+
expect(mockSend.mock.callCount()).toEqual(1);
|
|
444
451
|
});
|
|
445
452
|
|
|
446
453
|
it('should have a saved notification on 204 but not send notification when pushActivated flag is false', async () => {
|
|
@@ -478,8 +485,8 @@ describe('push endpoints', () => {
|
|
|
478
485
|
expect(notifications[0].data.notificationType).toEqual('NewOffersReady');
|
|
479
486
|
expect(response.statusCode).toEqual(204);
|
|
480
487
|
|
|
481
|
-
expect(mockMessaging).
|
|
482
|
-
expect(mockSend).
|
|
488
|
+
expect(mockMessaging.mock.callCount()).toEqual(0);
|
|
489
|
+
expect(mockSend.mock.callCount()).toEqual(0);
|
|
483
490
|
});
|
|
484
491
|
|
|
485
492
|
it('should have a saved notifications on 204 and send notifications when pushActivated flag is true for multiple devices', async () => {
|
|
@@ -538,26 +545,24 @@ describe('push endpoints', () => {
|
|
|
538
545
|
expect(notifications[1].data.notificationType).toEqual('NewOffersReady');
|
|
539
546
|
expect(response.statusCode).toEqual(204);
|
|
540
547
|
|
|
541
|
-
expect(mockMessaging).
|
|
542
|
-
expect(mockSend).
|
|
543
|
-
expect(mockSend).
|
|
544
|
-
1,
|
|
548
|
+
expect(mockMessaging.mock.callCount()).toEqual(2);
|
|
549
|
+
expect(mockSend.mock.callCount()).toEqual(2);
|
|
550
|
+
expect(mockSend.mock.calls[0].arguments).toEqual([
|
|
545
551
|
sendPayloadExpectation(deviceSecond.deviceId, null, {
|
|
546
552
|
count: '0',
|
|
547
553
|
credentialTypes: '[]',
|
|
548
554
|
notificationId: expect.any(String),
|
|
549
555
|
notificationType: 'NewOffersReady',
|
|
550
|
-
})
|
|
551
|
-
);
|
|
552
|
-
expect(mockSend).
|
|
553
|
-
2,
|
|
556
|
+
}),
|
|
557
|
+
]);
|
|
558
|
+
expect(mockSend.mock.calls[1].arguments).toEqual([
|
|
554
559
|
sendPayloadExpectation(deviceFirst.deviceId, null, {
|
|
555
560
|
count: '0',
|
|
556
561
|
credentialTypes: '[]',
|
|
557
562
|
notificationId: expect.any(String),
|
|
558
563
|
notificationType: 'NewOffersReady',
|
|
559
|
-
})
|
|
560
|
-
);
|
|
564
|
+
}),
|
|
565
|
+
]);
|
|
561
566
|
|
|
562
567
|
const firstAccount = await accountsRepo.findOne({
|
|
563
568
|
filter: {
|
|
@@ -610,8 +615,8 @@ describe('push endpoints', () => {
|
|
|
610
615
|
expect(notifications[0].data.notificationType).toEqual('NewOffersReady');
|
|
611
616
|
expect(response.statusCode).toEqual(204);
|
|
612
617
|
|
|
613
|
-
expect(mockMessaging).
|
|
614
|
-
expect(mockSend).
|
|
618
|
+
expect(mockMessaging.mock.callCount()).toEqual(1);
|
|
619
|
+
expect(mockSend.mock.callCount()).toEqual(1);
|
|
615
620
|
});
|
|
616
621
|
|
|
617
622
|
it('should return 404 when device not found', async () => {
|
|
@@ -635,13 +640,15 @@ describe('push endpoints', () => {
|
|
|
635
640
|
statusCode: 404,
|
|
636
641
|
})
|
|
637
642
|
);
|
|
638
|
-
expect(mockInitializeApp).
|
|
639
|
-
expect(mockMessaging).
|
|
640
|
-
expect(mockSend).
|
|
643
|
+
expect(mockInitializeApp.mock.callCount()).toEqual(0);
|
|
644
|
+
expect(mockMessaging.mock.callCount()).toEqual(0);
|
|
645
|
+
expect(mockSend.mock.callCount()).toEqual(0);
|
|
641
646
|
});
|
|
642
647
|
|
|
643
648
|
it('should return 502 when firebase.send throws with an error', async () => {
|
|
644
|
-
mockSend.
|
|
649
|
+
mockSend.mock.mockImplementationOnce(() =>
|
|
650
|
+
Promise.reject(new Error('test sendToDevice error'))
|
|
651
|
+
);
|
|
645
652
|
const response = await fastify.injectJson({
|
|
646
653
|
method: 'POST',
|
|
647
654
|
url: '/api/v0.6/push',
|
|
@@ -677,9 +684,9 @@ describe('push endpoints', () => {
|
|
|
677
684
|
},
|
|
678
685
|
});
|
|
679
686
|
expect(response.statusCode).toEqual(200);
|
|
680
|
-
expect(mockMessaging).
|
|
681
|
-
expect(mockSend).
|
|
682
|
-
expect(mockSend).
|
|
687
|
+
expect(mockMessaging.mock.callCount()).toEqual(1);
|
|
688
|
+
expect(mockSend.mock.callCount()).toEqual(1);
|
|
689
|
+
expect(mockSend.mock.calls[0].arguments).toEqual([
|
|
683
690
|
sendPayloadExpectation(
|
|
684
691
|
device.deviceId,
|
|
685
692
|
{
|
|
@@ -687,8 +694,8 @@ describe('push endpoints', () => {
|
|
|
687
694
|
title: 'notification title',
|
|
688
695
|
},
|
|
689
696
|
null
|
|
690
|
-
)
|
|
691
|
-
);
|
|
697
|
+
),
|
|
698
|
+
]);
|
|
692
699
|
const accountWithoutUsedPushToken = await accountsRepo.findOne({
|
|
693
700
|
filter,
|
|
694
701
|
});
|
|
@@ -716,9 +723,9 @@ describe('push endpoints', () => {
|
|
|
716
723
|
},
|
|
717
724
|
});
|
|
718
725
|
expect(response.statusCode).toEqual(200);
|
|
719
|
-
expect(mockMessaging).
|
|
720
|
-
expect(mockSend).
|
|
721
|
-
expect(mockSend).
|
|
726
|
+
expect(mockMessaging.mock.callCount()).toEqual(1);
|
|
727
|
+
expect(mockSend.mock.callCount()).toEqual(1);
|
|
728
|
+
expect(mockSend.mock.calls[0].arguments).toEqual([
|
|
722
729
|
sendPayloadExpectation(
|
|
723
730
|
newDevice.deviceId,
|
|
724
731
|
{
|
|
@@ -726,8 +733,8 @@ describe('push endpoints', () => {
|
|
|
726
733
|
title: 'notification title',
|
|
727
734
|
},
|
|
728
735
|
null
|
|
729
|
-
)
|
|
730
|
-
);
|
|
736
|
+
),
|
|
737
|
+
]);
|
|
731
738
|
});
|
|
732
739
|
});
|
|
733
740
|
});
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
2
6
|
|
|
3
7
|
const url = '/reference/countries';
|
|
@@ -5,14 +9,14 @@ const url = '/reference/countries';
|
|
|
5
9
|
describe('Reference countries Test Suite', () => {
|
|
6
10
|
let fastify;
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
before(async () => {
|
|
9
13
|
fastify = buildFastify();
|
|
10
14
|
await fastify.ready();
|
|
11
15
|
});
|
|
12
16
|
|
|
13
17
|
beforeEach(async () => {});
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
after(async () => {
|
|
16
20
|
await fastify.close();
|
|
17
21
|
});
|
|
18
22
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const { first, map, omit } = require('lodash/fp');
|
|
2
6
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
3
7
|
const nock = require('nock');
|
|
@@ -10,7 +14,7 @@ describe('Reference personas', () => {
|
|
|
10
14
|
let fastify;
|
|
11
15
|
let persistPersona;
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
before(async () => {
|
|
14
18
|
fastify = buildFastify();
|
|
15
19
|
await fastify.ready();
|
|
16
20
|
({ persistPersona } = initPersonaFactory(fastify));
|
|
@@ -22,7 +26,7 @@ describe('Reference personas', () => {
|
|
|
22
26
|
mongoDb().collection('credentialSchemas').deleteMany({});
|
|
23
27
|
});
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
after(async () => {
|
|
26
30
|
await fastify.close();
|
|
27
31
|
nock.cleanAll();
|
|
28
32
|
nock.restore();
|
package/test/root.test.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
const { after, before, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
2
6
|
|
|
3
7
|
describe('root healthcheck', () => {
|
|
4
8
|
let fastify;
|
|
5
|
-
|
|
9
|
+
before(async () => {
|
|
6
10
|
fastify = buildFastify();
|
|
7
11
|
});
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
after(async () => {
|
|
10
14
|
await fastify.close();
|
|
11
15
|
});
|
|
12
16
|
|
package/test/swagger.test.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
const { after, before, describe, it } = require('node:test');
|
|
2
|
+
|
|
3
|
+
const { expect } = require('expect');
|
|
4
|
+
|
|
1
5
|
const buildFastify = require('./helpers/careerwallet-build-fastify');
|
|
2
6
|
|
|
3
7
|
describe('swagger json', () => {
|
|
4
8
|
let fastify;
|
|
5
|
-
|
|
9
|
+
before(async () => {
|
|
6
10
|
fastify = buildFastify();
|
|
7
11
|
});
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
after(async () => {
|
|
10
14
|
await fastify.close();
|
|
11
15
|
});
|
|
12
16
|
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
const { after, before, beforeEach, describe, it, mock } = require('node:test');
|
|
2
|
+
const { expect } = require('expect');
|
|
3
|
+
const fp = require('fastify-plugin');
|
|
4
|
+
|
|
5
|
+
const mockSendEmailNotification = mock.fn(() => {});
|
|
6
|
+
mock.module('@verii/aws-clients', {
|
|
7
|
+
namedExports: {
|
|
8
|
+
...require('@verii/aws-clients'),
|
|
9
|
+
sendEmailPlugin: fp(async (fastify) => {
|
|
10
|
+
fastify.decorate('sendEmail', mockSendEmailNotification);
|
|
11
|
+
}),
|
|
12
|
+
initSendEmailNotification: mock.fn(() => mockSendEmailNotification),
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
1
16
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
2
17
|
const { wait } = require('@verii/common-functions');
|
|
3
18
|
const { subMinutes, addHours } = require('date-fns/fp');
|
|
@@ -22,18 +37,6 @@ const {
|
|
|
22
37
|
incorrectScopeExpectation,
|
|
23
38
|
} = require('./helpers/access-token');
|
|
24
39
|
|
|
25
|
-
const mockSendEmailNotification = jest.fn(() => {});
|
|
26
|
-
jest.mock('@verii/aws-clients', () => {
|
|
27
|
-
const fp = require('fastify-plugin');
|
|
28
|
-
return {
|
|
29
|
-
...jest.requireActual('@verii/aws-clients'),
|
|
30
|
-
sendEmailPlugin: fp(async (fastify) => {
|
|
31
|
-
fastify.decorate('sendEmail', mockSendEmailNotification);
|
|
32
|
-
}),
|
|
33
|
-
initSendEmailNotification: jest.fn(() => mockSendEmailNotification),
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
|
|
37
40
|
describe('Email & Phone Verification', () => {
|
|
38
41
|
let fastify;
|
|
39
42
|
let persistVerification;
|
|
@@ -42,7 +45,7 @@ describe('Email & Phone Verification', () => {
|
|
|
42
45
|
let publicKey;
|
|
43
46
|
let privateKey;
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
before(async () => {
|
|
46
49
|
({ publicKey, privateKey } = generateKeyPair({ format: 'jwk' }));
|
|
47
50
|
|
|
48
51
|
fastify = buildFastify({
|
|
@@ -68,7 +71,7 @@ describe('Email & Phone Verification', () => {
|
|
|
68
71
|
await mongoDb().collection('verificationCodeAttempts').deleteMany({});
|
|
69
72
|
});
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
after(async () => {
|
|
72
75
|
await fastify.close();
|
|
73
76
|
});
|
|
74
77
|
|
|
@@ -926,7 +929,7 @@ describe('Email & Phone Verification', () => {
|
|
|
926
929
|
});
|
|
927
930
|
});
|
|
928
931
|
describe('Access Token verification enabled', () => {
|
|
929
|
-
|
|
932
|
+
before(async () => {
|
|
930
933
|
fastify.overrides.reqConfig = (config) => ({
|
|
931
934
|
...config,
|
|
932
935
|
oauthVerificationDisabledEndpoints: [], // enabled for all endpoints
|
package/jest.config.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2023 Velocity Team
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
const jestConfig = require('../../jest.config.base');
|
|
18
|
-
const pack = require('./package.json');
|
|
19
|
-
|
|
20
|
-
module.exports = jestConfig(pack.name);
|