@velocitycareerlabs/server-webwallet 1.26.0-dev-build.1cce50406 → 1.26.0-dev-build.1d9b69826
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 +18 -17
- package/test/accounts-controller.test.js +44 -40
- package/test/consent-controller.test.js +18 -14
- package/test/credentials-controller.test.js +34 -27
- package/test/crypro-services/jwt-sign-service-impl.test.js +17 -15
- package/test/crypro-services/jwt-verify-service-impl.test.js +5 -1
- package/test/crypro-services/key-service-impl.test.js +17 -14
- package/test/disclosures-controller/disclosure-credentials.test.js +69 -57
- package/test/disclosures-controller/disclosures.test.js +16 -15
- package/test/feedback-controller.test.js +17 -14
- package/test/feeds-controller.test.js +17 -14
- package/test/fetch-errors-handler-plugin.test.js +4 -0
- package/test/filter-deleted-credentials-extension.test.js +17 -15
- package/test/issuing-controller/issuing-by-deeplink-empty-offers.test.js +49 -41
- package/test/issuing-controller/issuing-by-deeplink-failed-offers.test.js +48 -41
- package/test/issuing-controller/issuing-by-deeplink.test.js +74 -57
- package/test/issuing-controller/issuing-identity-credentials.test.js +55 -50
- package/test/issuing-controller/mocks/accept-offers-response.js +2 -0
- package/test/linkedin-controller.test.js +17 -15
- package/test/root.test.js +14 -12
- package/test/vcl-sdk-plugin.test.js +66 -49
- package/jest.config.js +0 -20
|
@@ -5,48 +5,55 @@
|
|
|
5
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
const {
|
|
9
|
+
after,
|
|
10
|
+
afterEach,
|
|
11
|
+
before,
|
|
12
|
+
beforeEach,
|
|
13
|
+
describe,
|
|
14
|
+
it,
|
|
15
|
+
mock,
|
|
16
|
+
} = require('node:test');
|
|
17
|
+
|
|
18
|
+
const { expect } = require('expect');
|
|
19
|
+
|
|
8
20
|
const nock = require('nock');
|
|
9
21
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
22
|
+
const { VCLFinalizeOffersDescriptor } = require('@verii/vnf-nodejs-wallet-sdk');
|
|
23
|
+
const { vclMockCredentialManifest } = require('./mocks');
|
|
24
|
+
const { mockOffers } = require('./mocks/offers');
|
|
25
|
+
const { mockIssuers } = require('./mocks/issuers');
|
|
10
26
|
const {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
...originalModule,
|
|
27
|
+
mockAcceptedFailedCredentials,
|
|
28
|
+
} = require('./mocks/accepted-credentials');
|
|
29
|
+
|
|
30
|
+
const initialize = mock.fn(() => Promise.resolve(null));
|
|
31
|
+
const getCredentialManifest = mock.fn(() =>
|
|
32
|
+
Promise.resolve(vclMockCredentialManifest)
|
|
33
|
+
);
|
|
34
|
+
const generateOffers = mock.fn(() => Promise.resolve(mockOffers));
|
|
35
|
+
const searchForOrganizations = mock.fn(() => Promise.resolve(mockIssuers));
|
|
36
|
+
const finalizeOffers = mock.fn(() =>
|
|
37
|
+
Promise.resolve(mockAcceptedFailedCredentials)
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
mock.module('@verii/vnf-nodejs-wallet-sdk', {
|
|
41
|
+
namedExports: {
|
|
42
|
+
...require('@verii/vnf-nodejs-wallet-sdk'),
|
|
29
43
|
VCLProvider: {
|
|
30
|
-
getInstance:
|
|
31
|
-
initialize
|
|
32
|
-
getCredentialManifest
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
finalizeOffers: jest
|
|
38
|
-
.fn()
|
|
39
|
-
.mockResolvedValue(mockAcceptedFailedCredentials),
|
|
40
|
-
}),
|
|
44
|
+
getInstance: mock.fn(() => ({
|
|
45
|
+
initialize,
|
|
46
|
+
getCredentialManifest,
|
|
47
|
+
generateOffers,
|
|
48
|
+
searchForOrganizations,
|
|
49
|
+
finalizeOffers,
|
|
50
|
+
})),
|
|
41
51
|
},
|
|
42
|
-
}
|
|
52
|
+
},
|
|
43
53
|
});
|
|
44
54
|
|
|
45
|
-
const vclSdk = VCLProvider.getInstance();
|
|
46
55
|
const initAccountsFactory = require('../factories/accounts');
|
|
47
56
|
|
|
48
|
-
const { mockOffers } = require('./mocks');
|
|
49
|
-
|
|
50
57
|
const buildFastify = require('../helpers/webwallet-build-fastify');
|
|
51
58
|
const { mockParsedFailedResponse } = require('./mocks/accept-offers-response');
|
|
52
59
|
const { Jwk } = require('../mocks/jwk');
|
|
@@ -59,7 +66,7 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
59
66
|
let fastify;
|
|
60
67
|
let persistAccounts;
|
|
61
68
|
|
|
62
|
-
|
|
69
|
+
before(async () => {
|
|
63
70
|
fastify = buildFastify();
|
|
64
71
|
|
|
65
72
|
await fastify.ready();
|
|
@@ -78,15 +85,15 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
78
85
|
|
|
79
86
|
afterEach(async () => {
|
|
80
87
|
nock.cleanAll();
|
|
81
|
-
jest.clearAllMocks();
|
|
82
88
|
await mongoDb().collection('credentials').deleteMany();
|
|
83
89
|
await mongoDb().collection('accounts').deleteMany();
|
|
84
90
|
});
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
after(async () => {
|
|
87
93
|
nock.restore();
|
|
88
94
|
await mongoDb().collection('accounts').deleteMany();
|
|
89
95
|
await fastify.close();
|
|
96
|
+
mock.reset();
|
|
90
97
|
});
|
|
91
98
|
|
|
92
99
|
describe('POST /issuing/deep-link/accept-offers', () => {
|
|
@@ -113,10 +120,10 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
113
120
|
expect(response.statusCode).toBe(200);
|
|
114
121
|
expect(response.json).toEqual(mockParsedFailedResponse);
|
|
115
122
|
|
|
116
|
-
expect(
|
|
123
|
+
expect(getCredentialManifest.mock.callCount()).toEqual(0); // important!
|
|
117
124
|
|
|
118
|
-
expect(
|
|
119
|
-
expect(
|
|
125
|
+
expect(finalizeOffers.mock.callCount()).toEqual(1);
|
|
126
|
+
expect(finalizeOffers.mock.calls[0].arguments).toEqual([
|
|
120
127
|
expect.objectContaining(
|
|
121
128
|
new VCLFinalizeOffersDescriptor(
|
|
122
129
|
vclMockCredentialManifest,
|
|
@@ -127,8 +134,8 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
127
134
|
),
|
|
128
135
|
expect.objectContaining({
|
|
129
136
|
value: mockOffers.sessionToken.value,
|
|
130
|
-
})
|
|
131
|
-
);
|
|
137
|
+
}),
|
|
138
|
+
]);
|
|
132
139
|
|
|
133
140
|
const savedCredential = await mongoDb()
|
|
134
141
|
.collection('credentials')
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
const {
|
|
2
|
+
after,
|
|
3
|
+
afterEach,
|
|
4
|
+
before,
|
|
5
|
+
beforeEach,
|
|
6
|
+
describe,
|
|
7
|
+
it,
|
|
8
|
+
mock,
|
|
9
|
+
} = require('node:test');
|
|
10
|
+
|
|
11
|
+
const { expect } = require('expect');
|
|
12
|
+
|
|
1
13
|
const nock = require('nock');
|
|
2
14
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
3
15
|
const { omit } = require('lodash/fp');
|
|
@@ -8,48 +20,48 @@ const {
|
|
|
8
20
|
VCLFilter,
|
|
9
21
|
VCLDeepLink,
|
|
10
22
|
VCLOrganizationsSearchDescriptor,
|
|
11
|
-
VCLProvider,
|
|
12
23
|
VCLGenerateOffersDescriptor,
|
|
13
24
|
VCLVerifiableCredential,
|
|
14
25
|
} = require('@verii/vnf-nodejs-wallet-sdk');
|
|
15
26
|
const { deepLink } = require('./mocks');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
const { vclMockCredentialManifest } = require('./mocks');
|
|
28
|
+
const { mockOffers } = require('./mocks/offers');
|
|
29
|
+
const { mockIssuers } = require('./mocks/issuers');
|
|
30
|
+
const { mockAcceptedCredentials } = require('./mocks/accepted-credentials');
|
|
31
|
+
const { mockCredentialTypes } = require('../mocks');
|
|
32
|
+
|
|
33
|
+
const initialize = mock.fn(() => Promise.resolve(null));
|
|
34
|
+
const getCredentialManifest = mock.fn(() =>
|
|
35
|
+
Promise.resolve(vclMockCredentialManifest)
|
|
36
|
+
);
|
|
37
|
+
const generateOffers = mock.fn(() => Promise.resolve(mockOffers));
|
|
38
|
+
const searchForOrganizations = mock.fn(() => Promise.resolve(mockIssuers));
|
|
39
|
+
const finalizeOffers = mock.fn(() => Promise.resolve(mockAcceptedCredentials));
|
|
40
|
+
|
|
41
|
+
mock.module('@verii/vnf-nodejs-wallet-sdk', {
|
|
42
|
+
namedExports: {
|
|
43
|
+
...require('@verii/vnf-nodejs-wallet-sdk'),
|
|
28
44
|
VCLProvider: {
|
|
29
|
-
getInstance:
|
|
30
|
-
initialize
|
|
31
|
-
getCredentialManifest
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
searchForOrganizations: jest.fn().mockResolvedValue(mockIssuers),
|
|
36
|
-
finalizeOffers: jest.fn().mockResolvedValue(mockAcceptedCredentials),
|
|
45
|
+
getInstance: mock.fn(() => ({
|
|
46
|
+
initialize,
|
|
47
|
+
getCredentialManifest,
|
|
48
|
+
generateOffers,
|
|
49
|
+
searchForOrganizations,
|
|
50
|
+
finalizeOffers,
|
|
37
51
|
credentialTypes: mockCredentialTypes,
|
|
38
|
-
}),
|
|
52
|
+
})),
|
|
39
53
|
},
|
|
40
|
-
}
|
|
54
|
+
},
|
|
41
55
|
});
|
|
42
56
|
|
|
43
|
-
const vclSdk = VCLProvider.getInstance();
|
|
44
57
|
const initAccountsFactory = require('../factories/accounts');
|
|
45
58
|
const initCredentialsFactory = require('../factories/credentials');
|
|
46
59
|
|
|
47
60
|
const { mockDisplayDescriptor } = require('../mocks');
|
|
48
61
|
|
|
49
|
-
const {
|
|
62
|
+
const { mockParsedResponse } = require('./mocks');
|
|
50
63
|
|
|
51
64
|
const buildFastify = require('../helpers/webwallet-build-fastify');
|
|
52
|
-
const { vclMockCredentialManifest } = require('./mocks/credential-manifest');
|
|
53
65
|
const { Jwk } = require('../mocks/jwk');
|
|
54
66
|
const { WebWalletServerError } = require('../../src/errors/error-codes');
|
|
55
67
|
|
|
@@ -62,7 +74,7 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
62
74
|
let persistAccounts;
|
|
63
75
|
let persistCredentials;
|
|
64
76
|
|
|
65
|
-
|
|
77
|
+
before(async () => {
|
|
66
78
|
fastify = buildFastify();
|
|
67
79
|
|
|
68
80
|
await fastify.ready();
|
|
@@ -72,8 +84,11 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
72
84
|
});
|
|
73
85
|
|
|
74
86
|
beforeEach(async () => {
|
|
75
|
-
|
|
87
|
+
getCredentialManifest.mock.resetCalls();
|
|
88
|
+
generateOffers.mock.resetCalls();
|
|
89
|
+
searchForOrganizations.mock.resetCalls();
|
|
76
90
|
|
|
91
|
+
nock('https://localhost/').get('/.well-known/jwks.json').reply(200, Jwk);
|
|
77
92
|
await persistAccounts({
|
|
78
93
|
userId: '1234567890',
|
|
79
94
|
did: 'did:example:123',
|
|
@@ -82,15 +97,15 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
82
97
|
|
|
83
98
|
afterEach(async () => {
|
|
84
99
|
nock.cleanAll();
|
|
85
|
-
jest.clearAllMocks();
|
|
86
100
|
await mongoDb().collection('credentials').deleteMany();
|
|
87
101
|
await mongoDb().collection('accounts').deleteMany();
|
|
88
102
|
});
|
|
89
103
|
|
|
90
|
-
|
|
104
|
+
after(async () => {
|
|
91
105
|
nock.restore();
|
|
92
106
|
await mongoDb().collection('accounts').deleteMany();
|
|
93
107
|
await fastify.close();
|
|
108
|
+
mock.reset();
|
|
94
109
|
});
|
|
95
110
|
|
|
96
111
|
describe('GET /issuing/deep-link/manifest - get manifest by deep link', () => {
|
|
@@ -107,10 +122,12 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
107
122
|
|
|
108
123
|
expect(response.statusCode).toBe(200);
|
|
109
124
|
|
|
110
|
-
expect(
|
|
111
|
-
expect(
|
|
112
|
-
new VCLCredentialManifestDescriptorByDeepLink(
|
|
113
|
-
|
|
125
|
+
expect(getCredentialManifest.mock.callCount()).toEqual(1);
|
|
126
|
+
expect(getCredentialManifest.mock.calls[0].arguments).toEqual([
|
|
127
|
+
new VCLCredentialManifestDescriptorByDeepLink(
|
|
128
|
+
new VCLDeepLink(deepLink)
|
|
129
|
+
),
|
|
130
|
+
]);
|
|
114
131
|
|
|
115
132
|
const { credentialManifest } = response.json;
|
|
116
133
|
expect(credentialManifest).toEqual({
|
|
@@ -155,21 +172,21 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
155
172
|
|
|
156
173
|
expect(response.statusCode).toBe(200);
|
|
157
174
|
|
|
158
|
-
expect(
|
|
175
|
+
expect(getCredentialManifest.mock.callCount()).toEqual(0); // important!
|
|
159
176
|
|
|
160
|
-
expect(
|
|
161
|
-
expect(
|
|
177
|
+
expect(generateOffers.mock.callCount()).toEqual(1);
|
|
178
|
+
expect(generateOffers.mock.calls[0].arguments).toEqual([
|
|
162
179
|
expect.objectContaining(
|
|
163
180
|
new VCLGenerateOffersDescriptor(vclMockCredentialManifest, [], [], [])
|
|
164
|
-
)
|
|
165
|
-
);
|
|
181
|
+
),
|
|
182
|
+
]);
|
|
166
183
|
|
|
167
|
-
expect(
|
|
168
|
-
expect(
|
|
184
|
+
expect(searchForOrganizations.mock.callCount()).toEqual(1);
|
|
185
|
+
expect(searchForOrganizations.mock.calls[0].arguments).toEqual([
|
|
169
186
|
new VCLOrganizationsSearchDescriptor(
|
|
170
187
|
new VCLFilter(mockOffers.all[0].payload.issuer.id)
|
|
171
|
-
)
|
|
172
|
-
);
|
|
188
|
+
),
|
|
189
|
+
]);
|
|
173
190
|
|
|
174
191
|
const { offers, credentialManifest } = response.json;
|
|
175
192
|
expect(credentialManifest.jwt).toBe(
|
|
@@ -204,10 +221,10 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
204
221
|
|
|
205
222
|
expect(response.statusCode).toBe(200);
|
|
206
223
|
|
|
207
|
-
expect(
|
|
224
|
+
expect(getCredentialManifest.mock.callCount()).toEqual(0); // important!
|
|
208
225
|
|
|
209
|
-
expect(
|
|
210
|
-
expect(
|
|
226
|
+
expect(generateOffers.mock.callCount()).toEqual(1);
|
|
227
|
+
expect(generateOffers.mock.calls[0].arguments).toEqual([
|
|
211
228
|
expect.objectContaining(
|
|
212
229
|
new VCLGenerateOffersDescriptor(
|
|
213
230
|
vclMockCredentialManifest,
|
|
@@ -220,15 +237,15 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
220
237
|
),
|
|
221
238
|
]
|
|
222
239
|
)
|
|
223
|
-
)
|
|
224
|
-
);
|
|
240
|
+
),
|
|
241
|
+
]);
|
|
225
242
|
|
|
226
|
-
expect(
|
|
227
|
-
expect(
|
|
243
|
+
expect(searchForOrganizations.mock.callCount()).toEqual(1);
|
|
244
|
+
expect(searchForOrganizations.mock.calls[0].arguments).toEqual([
|
|
228
245
|
new VCLOrganizationsSearchDescriptor(
|
|
229
246
|
new VCLFilter(mockOffers.all[0].payload.issuer.id)
|
|
230
|
-
)
|
|
231
|
-
);
|
|
247
|
+
),
|
|
248
|
+
]);
|
|
232
249
|
|
|
233
250
|
const { offers, credentialManifest } = response.json;
|
|
234
251
|
expect(credentialManifest.jwt).toBe(
|
|
@@ -286,10 +303,10 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
286
303
|
expect(response.statusCode).toBe(200);
|
|
287
304
|
expect(response.json).toEqual(mockParsedResponse);
|
|
288
305
|
|
|
289
|
-
expect(
|
|
306
|
+
expect(getCredentialManifest.mock.callCount()).toEqual(0); // important!
|
|
290
307
|
|
|
291
|
-
expect(
|
|
292
|
-
expect(
|
|
308
|
+
expect(finalizeOffers.mock.callCount()).toEqual(1);
|
|
309
|
+
expect(finalizeOffers.mock.calls[0].arguments).toEqual([
|
|
293
310
|
expect.objectContaining(
|
|
294
311
|
new VCLFinalizeOffersDescriptor(
|
|
295
312
|
vclMockCredentialManifest,
|
|
@@ -300,8 +317,8 @@ describe('Test Deep Link issuing controller', () => {
|
|
|
300
317
|
),
|
|
301
318
|
expect.objectContaining({
|
|
302
319
|
value: mockOffers.sessionToken.value,
|
|
303
|
-
})
|
|
304
|
-
);
|
|
320
|
+
}),
|
|
321
|
+
]);
|
|
305
322
|
|
|
306
323
|
const savedCredential = await mongoDb()
|
|
307
324
|
.collection('credentials')
|
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
const {
|
|
2
|
+
after,
|
|
3
|
+
afterEach,
|
|
4
|
+
before,
|
|
5
|
+
beforeEach,
|
|
6
|
+
describe,
|
|
7
|
+
it,
|
|
8
|
+
mock,
|
|
9
|
+
} = require('node:test');
|
|
10
|
+
const { expect } = require('expect');
|
|
11
|
+
|
|
12
|
+
const initialize = mock.fn(() => Promise.resolve(null));
|
|
13
|
+
const getCredentialManifest = mock.fn(() =>
|
|
14
|
+
Promise.resolve(vclMockCredentialManifest)
|
|
15
|
+
);
|
|
16
|
+
const generateOffers = mock.fn(() => Promise.resolve(mockOffers));
|
|
17
|
+
const searchForOrganizations = mock.fn(() => Promise.resolve(mockIssuers));
|
|
18
|
+
const finalizeOffers = mock.fn(() => Promise.resolve(mockAcceptedCredentials));
|
|
19
|
+
|
|
20
|
+
mock.module('@verii/vnf-nodejs-wallet-sdk', {
|
|
21
|
+
namedExports: {
|
|
22
|
+
...require('@verii/vnf-nodejs-wallet-sdk'),
|
|
23
|
+
VCLProvider: {
|
|
24
|
+
getInstance: mock.fn(() => ({
|
|
25
|
+
initialize,
|
|
26
|
+
getCredentialManifest,
|
|
27
|
+
generateOffers,
|
|
28
|
+
searchForOrganizations,
|
|
29
|
+
finalizeOffers,
|
|
30
|
+
credentialTypes: mockCredentialTypes,
|
|
31
|
+
})),
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
1
36
|
const nock = require('nock');
|
|
2
37
|
const { omit } = require('lodash/fp');
|
|
3
38
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
@@ -8,40 +43,7 @@ const {
|
|
|
8
43
|
VCLIssuingType,
|
|
9
44
|
} = require('@verii/vnf-nodejs-wallet-sdk');
|
|
10
45
|
const { errorResponseMatcher } = require('@verii/tests-helpers');
|
|
11
|
-
|
|
12
|
-
jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
|
|
13
|
-
const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
|
|
14
|
-
|
|
15
|
-
const { vclMockCredentialManifest } = require('./mocks/credential-manifest');
|
|
16
|
-
const { mockOffers } = require('./mocks/offers');
|
|
17
|
-
const {
|
|
18
|
-
getOrganizationMock,
|
|
19
|
-
} = require('./mocks/identity-issuing/get-organization');
|
|
20
|
-
const {
|
|
21
|
-
acceptOffersMock,
|
|
22
|
-
} = require('./mocks/identity-issuing/accept-offers');
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
...originalModule,
|
|
26
|
-
VCLProvider: {
|
|
27
|
-
getInstance: jest.fn().mockReturnValue({
|
|
28
|
-
initialize: jest.fn().mockResolvedValue(null),
|
|
29
|
-
getCredentialManifest: jest
|
|
30
|
-
.fn()
|
|
31
|
-
.mockResolvedValue(vclMockCredentialManifest),
|
|
32
|
-
generateOffers: jest.fn().mockResolvedValue(mockOffers),
|
|
33
|
-
searchForOrganizations: jest
|
|
34
|
-
.fn()
|
|
35
|
-
.mockResolvedValue(getOrganizationMock),
|
|
36
|
-
finalizeOffers: jest.fn().mockResolvedValue(acceptOffersMock),
|
|
37
|
-
}),
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const { VCLProvider } = require('@verii/vnf-nodejs-wallet-sdk');
|
|
43
|
-
|
|
44
|
-
const vclSdk = VCLProvider.getInstance();
|
|
46
|
+
const { vclMockCredentialManifest } = require('./mocks/credential-manifest');
|
|
45
47
|
|
|
46
48
|
const buildFastify = require('../helpers/webwallet-build-fastify');
|
|
47
49
|
|
|
@@ -51,7 +53,10 @@ const {
|
|
|
51
53
|
getAppConfigMock,
|
|
52
54
|
confirmVerificationCodeMock,
|
|
53
55
|
} = require('./mocks/identity-issuing');
|
|
54
|
-
const {
|
|
56
|
+
const { mockOffers } = require('./mocks/offers');
|
|
57
|
+
const { mockIssuers } = require('./mocks/issuers');
|
|
58
|
+
const { mockAcceptedCredentials } = require('./mocks/accepted-credentials');
|
|
59
|
+
const { mockCredentialTypes } = require('../mocks');
|
|
55
60
|
|
|
56
61
|
const auth0Token =
|
|
57
62
|
// eslint-disable-next-line max-len
|
|
@@ -65,7 +70,7 @@ describe('Test Disclosures controller, get disclosures list', () => {
|
|
|
65
70
|
let fastify;
|
|
66
71
|
let persistAccounts;
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
before(async () => {
|
|
69
74
|
fastify = buildFastify();
|
|
70
75
|
|
|
71
76
|
nock('https://localhost/').get('/.well-known/jwks.json').reply(200, jwks);
|
|
@@ -83,14 +88,14 @@ describe('Test Disclosures controller, get disclosures list', () => {
|
|
|
83
88
|
|
|
84
89
|
afterEach(async () => {
|
|
85
90
|
nock.cleanAll();
|
|
86
|
-
jest.clearAllMocks();
|
|
87
91
|
await mongoDb().collection('credentials').deleteMany();
|
|
88
92
|
});
|
|
89
93
|
|
|
90
|
-
|
|
94
|
+
after(async () => {
|
|
91
95
|
nock.restore();
|
|
92
96
|
await mongoDb().collection('accounts').deleteMany();
|
|
93
97
|
await fastify.close();
|
|
98
|
+
mock.reset();
|
|
94
99
|
});
|
|
95
100
|
|
|
96
101
|
describe('POST /issuing/identity-credentials/request-code/email', () => {
|
|
@@ -182,23 +187,23 @@ describe('Test Disclosures controller, get disclosures list', () => {
|
|
|
182
187
|
expect(nockedAppConfig.isDone()).toBe(true);
|
|
183
188
|
expect(nockedConfirmVerification.isDone()).toBe(true);
|
|
184
189
|
|
|
185
|
-
expect(
|
|
186
|
-
expect(
|
|
190
|
+
expect(getCredentialManifest.mock.callCount()).toEqual(1);
|
|
191
|
+
expect(getCredentialManifest.mock.calls[0].arguments).toEqual([
|
|
187
192
|
new VCLCredentialManifestDescriptorByDeepLink(
|
|
188
193
|
new VCLDeepLink(deepLink),
|
|
189
194
|
VCLIssuingType.Identity,
|
|
190
195
|
null,
|
|
191
196
|
null,
|
|
192
197
|
null
|
|
193
|
-
)
|
|
194
|
-
);
|
|
198
|
+
),
|
|
199
|
+
]);
|
|
195
200
|
|
|
196
|
-
expect(
|
|
197
|
-
expect(
|
|
201
|
+
expect(generateOffers.mock.callCount()).toEqual(1);
|
|
202
|
+
expect(generateOffers.mock.calls[0].arguments).toEqual([
|
|
198
203
|
expect.objectContaining({
|
|
199
204
|
credentialManifest: vclMockCredentialManifest,
|
|
200
|
-
})
|
|
201
|
-
);
|
|
205
|
+
}),
|
|
206
|
+
]);
|
|
202
207
|
|
|
203
208
|
const savedCredential = await mongoDb()
|
|
204
209
|
.collection('credentials')
|
|
@@ -234,8 +239,8 @@ describe('Test Disclosures controller, get disclosures list', () => {
|
|
|
234
239
|
nockAppConfig(fastify);
|
|
235
240
|
nockConfirmVerificationCode('123456', fastify);
|
|
236
241
|
|
|
237
|
-
|
|
238
|
-
new VCLOrganizations([])
|
|
242
|
+
searchForOrganizations.mock.mockImplementationOnce(() =>
|
|
243
|
+
Promise.resolve(new VCLOrganizations([]))
|
|
239
244
|
);
|
|
240
245
|
|
|
241
246
|
const response = await fastify.injectJson({
|
|
@@ -266,9 +271,9 @@ describe('Test Disclosures controller, get disclosures list', () => {
|
|
|
266
271
|
nockAppConfig(fastify);
|
|
267
272
|
nockConfirmVerificationCode('123456', fastify);
|
|
268
273
|
|
|
269
|
-
|
|
274
|
+
generateOffers.mock.mockImplementation(() => ({
|
|
270
275
|
all: [],
|
|
271
|
-
});
|
|
276
|
+
}));
|
|
272
277
|
|
|
273
278
|
const response = await fastify.injectJson({
|
|
274
279
|
method: 'POST',
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
const { after, afterEach, before, describe, it, mock } = require('node:test');
|
|
2
|
+
const { expect } = require('expect');
|
|
3
|
+
|
|
4
|
+
mock.module('@verii/vnf-nodejs-wallet-sdk', {
|
|
5
|
+
namedExports: {
|
|
6
|
+
...require('@verii/vnf-nodejs-wallet-sdk'),
|
|
7
|
+
VCLProvider: {
|
|
8
|
+
getInstance: mock.fn(() => ({
|
|
9
|
+
initialize: mock.fn(() => Promise.resolve(null)),
|
|
10
|
+
})),
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
1
15
|
const { mongoDb } = require('@spencejs/spence-mongo-repos');
|
|
2
16
|
|
|
3
17
|
const nock = require('nock');
|
|
@@ -22,24 +36,11 @@ const auth0Token =
|
|
|
22
36
|
const auth0userId = '1234567890';
|
|
23
37
|
const usersDid = 'did:example:123';
|
|
24
38
|
|
|
25
|
-
jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
|
|
26
|
-
const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
...originalModule,
|
|
30
|
-
VCLProvider: {
|
|
31
|
-
getInstance: jest.fn().mockReturnValue({
|
|
32
|
-
initialize: jest.fn().mockResolvedValue(null),
|
|
33
|
-
}),
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
});
|
|
37
|
-
|
|
38
39
|
describe('linkedin-controller', () => {
|
|
39
40
|
let fastify;
|
|
40
41
|
let persistAccounts;
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
before(async () => {
|
|
43
44
|
fastify = buildFastify();
|
|
44
45
|
|
|
45
46
|
nock('https://localhost/')
|
|
@@ -55,9 +56,10 @@ describe('linkedin-controller', () => {
|
|
|
55
56
|
await mongoDb().collection('accounts').deleteMany({});
|
|
56
57
|
});
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
after(async () => {
|
|
59
60
|
nock.restore();
|
|
60
61
|
await fastify.close();
|
|
62
|
+
mock.reset();
|
|
61
63
|
});
|
|
62
64
|
describe('GET /linkedin/me', () => {
|
|
63
65
|
it('should return linkedin user information is exist', async () => {
|
package/test/root.test.js
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
jest.mock('@verii/vnf-nodejs-wallet-sdk', () => {
|
|
4
|
-
const originalModule = jest.requireActual('@verii/vnf-nodejs-wallet-sdk');
|
|
1
|
+
const { after, before, describe, it, mock } = require('node:test');
|
|
2
|
+
const { expect } = require('expect');
|
|
5
3
|
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
mock.module('@verii/vnf-nodejs-wallet-sdk', {
|
|
5
|
+
namedExports: {
|
|
6
|
+
...require('@verii/vnf-nodejs-wallet-sdk'),
|
|
8
7
|
VCLProvider: {
|
|
9
|
-
getInstance:
|
|
10
|
-
initialize:
|
|
11
|
-
}),
|
|
8
|
+
getInstance: mock.fn(() => ({
|
|
9
|
+
initialize: mock.fn(() => Promise.resolve(null)),
|
|
10
|
+
})),
|
|
12
11
|
},
|
|
13
|
-
}
|
|
12
|
+
},
|
|
14
13
|
});
|
|
15
14
|
|
|
15
|
+
const buildFastify = require('./helpers/webwallet-build-fastify');
|
|
16
|
+
|
|
16
17
|
describe('Root routes', () => {
|
|
17
18
|
let fastify;
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
before(async () => {
|
|
20
21
|
fastify = buildFastify();
|
|
21
22
|
await fastify.ready();
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
after(async () => {
|
|
25
26
|
await fastify.close();
|
|
27
|
+
mock.reset();
|
|
26
28
|
});
|
|
27
29
|
|
|
28
30
|
it('should respond to /', async () => {
|