@velocitycareerlabs/server-webwallet 1.25.0-dev-build.12642c864
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/.localdev.env +57 -0
- package/.standalone.env +22 -0
- package/LICENSE +248 -0
- package/README.md +11 -0
- package/jest.config.js +20 -0
- package/migrate-mongo.config.js +23 -0
- package/package.json +72 -0
- package/src/config/config.js +74 -0
- package/src/controllers/accounts/autohooks.js +28 -0
- package/src/controllers/accounts/controller.js +209 -0
- package/src/controllers/accounts/schemas/index.js +6 -0
- package/src/controllers/accounts/schemas/webwallet-accounts-request.schema.js +25 -0
- package/src/controllers/accounts/schemas/webwallet-accounts-response.schema.js +72 -0
- package/src/controllers/accounts/schemas/webwallet-accounts-update-request.schema.js +23 -0
- package/src/controllers/accounts/schemas/webwallet-test-personas-response.schema.js +110 -0
- package/src/controllers/consent/autohooks.js +14 -0
- package/src/controllers/consent/controller.js +91 -0
- package/src/controllers/consent/schemas/index.js +3 -0
- package/src/controllers/consent/schemas/webwallet-consent-response.schema.js +23 -0
- package/src/controllers/credentials/autohooks.js +36 -0
- package/src/controllers/credentials/controller.js +92 -0
- package/src/controllers/credentials/schemas/index.js +4 -0
- package/src/controllers/credentials/schemas/webwallet-credential-categories-response.schema.js +21 -0
- package/src/controllers/credentials/schemas/webwallet-credentials-response.schema.js +29 -0
- package/src/controllers/disclosures/autohooks.js +21 -0
- package/src/controllers/disclosures/controller.js +168 -0
- package/src/controllers/disclosures/schemas/index.js +7 -0
- package/src/controllers/disclosures/schemas/webwallet-accept-presentation-request-body.schema.js +28 -0
- package/src/controllers/disclosures/schemas/webwallet-accept-presentation-response.schema.js +16 -0
- package/src/controllers/disclosures/schemas/webwallet-get-disclosures-response.schema.js +18 -0
- package/src/controllers/disclosures/schemas/webwallet-get-presentation-request-query.schema.js +21 -0
- package/src/controllers/disclosures/schemas/webwallet-get-presentation-request-response.schema.js +16 -0
- package/src/controllers/feedback/autohooks.js +11 -0
- package/src/controllers/feedback/controller.js +48 -0
- package/src/controllers/issuing/common-schemas/index.js +10 -0
- package/src/controllers/issuing/common-schemas/webwallet-get-credential-manifest-query.schema.js +27 -0
- package/src/controllers/issuing/common-schemas/webwallet-get-credential-manifest-response.schema.js +31 -0
- package/src/controllers/issuing/deep-link/autohooks.js +51 -0
- package/src/controllers/issuing/deep-link/controller.js +192 -0
- package/src/controllers/issuing/deep-link/schemas/index.js +6 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-accept-offers-request.schema.js +30 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-accept-offers-response.schema.js +36 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-offers-request.schema.js +28 -0
- package/src/controllers/issuing/deep-link/schemas/webwallet-deep-link-offers-response.schema.js +48 -0
- package/src/controllers/issuing/identity-credentials/autohooks.js +42 -0
- package/src/controllers/issuing/identity-credentials/controller.js +188 -0
- package/src/controllers/issuing/identity-credentials/schemas/index.js +6 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-confirm-body.schema.js +20 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-confirm-response.schema.js +37 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-request-code-body.schema.js +14 -0
- package/src/controllers/issuing/identity-credentials/schemas/webwallet-identity-credentials-request-code-params.schema.js +19 -0
- package/src/controllers/linkedin/autohooks.js +16 -0
- package/src/controllers/linkedin/controller.js +276 -0
- package/src/controllers/linkedin/schemas/index.js +3 -0
- package/src/controllers/linkedin/schemas/webwallet-linkedin-me-response.schema.js +14 -0
- package/src/controllers/root/controller.js +29 -0
- package/src/entities/.gitkeep +0 -0
- package/src/entities/accounts/constants.js +5 -0
- package/src/entities/accounts/domains/extract-auth0-id-token-or-access-token.js +22 -0
- package/src/entities/accounts/domains/index.js +5 -0
- package/src/entities/accounts/domains/validate-account-permissions.js +36 -0
- package/src/entities/accounts/domains/validate-logo-size.js +25 -0
- package/src/entities/accounts/index.js +5 -0
- package/src/entities/accounts/repos/accounts.repo.js +63 -0
- package/src/entities/credentials/domains/index.js +3 -0
- package/src/entities/credentials/domains/offer-to-credential-mongo-dto.js +43 -0
- package/src/entities/credentials/index.js +6 -0
- package/src/entities/credentials/orchestrators/index.js +3 -0
- package/src/entities/credentials/orchestrators/load-additional-render-info.js +65 -0
- package/src/entities/credentials/repos/credentials.repo.js +132 -0
- package/src/entities/credentials/schemas/index.js +4 -0
- package/src/entities/credentials/schemas/webwallet-credential-response.schema.js +138 -0
- package/src/entities/credentials/schemas/webwallet-credentials-response.schemas.js +95 -0
- package/src/entities/credentials/schemas/webwallet-display-descriptor-response.schema.js +106 -0
- package/src/entities/disclosures/index.js +4 -0
- package/src/entities/disclosures/repos/disclosures.repo.js +31 -0
- package/src/entities/disclosures/schemas/index.js +10 -0
- package/src/entities/disclosures/schemas/webwallet-disclosure.schema.js +39 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-field.schema.js +45 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-filter.schema.js +30 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-format.schema.js +36 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-input-descriptors.schema.js +111 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-schema.schema.js +14 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request-submission-requirements.schema.js +37 -0
- package/src/entities/disclosures/schemas/webwallet-presentation-request.schema.js +79 -0
- package/src/entities/index.js +6 -0
- package/src/entities/issuing/domain/constants.js +8 -0
- package/src/entities/issuing/domain/does-user-have-fresh-pending-verification.js +26 -0
- package/src/entities/issuing/domain/get-credentials-from-offers.js +18 -0
- package/src/entities/issuing/domain/index.js +5 -0
- package/src/entities/issuing/index.js +5 -0
- package/src/entities/issuing/orchestrators/build-issuing-input-credentials.js +35 -0
- package/src/entities/issuing/orchestrators/generate-offers-by-deep-link.js +74 -0
- package/src/entities/issuing/orchestrators/get-identity-issuer.js +35 -0
- package/src/entities/issuing/orchestrators/get-identity-offers-by-deeplink.js +74 -0
- package/src/entities/issuing/orchestrators/index.js +6 -0
- package/src/entities/issuing/schemas/index.js +9 -0
- package/src/entities/issuing/schemas/webwallet-credential-manifest.schema.js +198 -0
- package/src/errors/error-codes.js +12 -0
- package/src/fetchers/career-wallet/create-account-fetcher.js +7 -0
- package/src/fetchers/career-wallet/create-did-fetcher.js +17 -0
- package/src/fetchers/career-wallet/get-app-config.js +11 -0
- package/src/fetchers/career-wallet/get-consents.js +13 -0
- package/src/fetchers/career-wallet/get-credential-categories.js +7 -0
- package/src/fetchers/career-wallet/get-personas.js +7 -0
- package/src/fetchers/career-wallet/index.js +12 -0
- package/src/fetchers/career-wallet/post-consent.js +9 -0
- package/src/fetchers/career-wallet/send-feedback.js +14 -0
- package/src/fetchers/career-wallet/sign-fetcher.js +14 -0
- package/src/fetchers/career-wallet/verify-id-credential-confirm-code.js +19 -0
- package/src/fetchers/career-wallet/verify-id-credential-request-code.js +20 -0
- package/src/fetchers/index.js +4 -0
- package/src/fetchers/lib-api/get-credential-display-schema.js +12 -0
- package/src/fetchers/lib-api/index.js +3 -0
- package/src/fetchers/linkedin/create-linkedin-post.js +45 -0
- package/src/fetchers/linkedin/get-access-token.js +26 -0
- package/src/fetchers/linkedin/get-linkedin-user-email.js +13 -0
- package/src/fetchers/linkedin/get-linkedin-user-id.js +16 -0
- package/src/fetchers/linkedin/index.js +9 -0
- package/src/fetchers/linkedin/register-image-to-upload.js +30 -0
- package/src/fetchers/linkedin/revoke-linkedin-access.js +20 -0
- package/src/fetchers/linkedin/upload-image-to-linkedin.js +16 -0
- package/src/index.js +15 -0
- package/src/init-server.js +108 -0
- package/src/plugins/crypto-services/index.js +5 -0
- package/src/plugins/crypto-services/jwt-sign-service-impl.js +72 -0
- package/src/plugins/crypto-services/jwt-verify-service-impl.js +21 -0
- package/src/plugins/crypto-services/key-service-impl.js +28 -0
- package/src/plugins/fetch-errors-handler-plugin.js +64 -0
- package/src/plugins/index.js +4 -0
- package/src/plugins/vnf-sdk-plugin.js +53 -0
- package/src/standalone.js +8 -0
- package/test/accounts-controller.test.js +618 -0
- package/test/consent-controller.test.js +185 -0
- package/test/credentials-controller.test.js +307 -0
- package/test/crypro-services/jwt-sign-service-impl.test.js +83 -0
- package/test/crypro-services/jwt-verify-service-impl.test.js +27 -0
- package/test/crypro-services/key-service-impl.test.js +76 -0
- package/test/crypro-services/mocks/index.js +4 -0
- package/test/crypro-services/mocks/jwt-mock.js +15 -0
- package/test/crypro-services/mocks/public-jwk.js +14 -0
- package/test/disclosures-controller/disclosure-credentials.test.js +428 -0
- package/test/disclosures-controller/get-disclosures.test.js +169 -0
- package/test/disclosures-controller/mocks/get-credential-manifest.js +20 -0
- package/test/disclosures-controller/mocks/index.js +6 -0
- package/test/disclosures-controller/mocks/presentation-request.js +32 -0
- package/test/disclosures-controller/mocks/presentation-submission.js +21 -0
- package/test/disclosures-controller/mocks/submission-result.js +19 -0
- package/test/factories/accounts.js +25 -0
- package/test/factories/credentials.js +66 -0
- package/test/factories/disclosures.js +106 -0
- package/test/feedback-controller.test.js +125 -0
- package/test/fetch-errors-handler-plugin.test.js +97 -0
- package/test/filter-deleted-credentials-extension.test.js +82 -0
- package/test/helpers/.env.test +10 -0
- package/test/helpers/nock-consent-add.js +16 -0
- package/test/helpers/nock-consents-get.js +15 -0
- package/test/helpers/nock-feedback.js +9 -0
- package/test/helpers/nock-linkedin-access-token.js +9 -0
- package/test/helpers/nock-linkedin-email.js +15 -0
- package/test/helpers/nock-linkedin-image-register.js +28 -0
- package/test/helpers/nock-linkedin-me.js +13 -0
- package/test/helpers/nock-linkedin-post.js +37 -0
- package/test/helpers/nock-linkedin-revoke.js +9 -0
- package/test/helpers/nock-test-personas.js +13 -0
- package/test/helpers/webwallet-build-fastify.js +17 -0
- package/test/issuing-controller/issuing-by-deeplink-empty-offers.test.js +142 -0
- package/test/issuing-controller/issuing-by-deeplink-failed-offers.test.js +142 -0
- package/test/issuing-controller/issuing-by-deeplink.test.js +492 -0
- package/test/issuing-controller/issuing-identity-credentials.test.js +377 -0
- package/test/issuing-controller/mocks/accept-offers-response.js +90 -0
- package/test/issuing-controller/mocks/accepted-credentials.js +47 -0
- package/test/issuing-controller/mocks/credential-manifest-presentation.js +72 -0
- package/test/issuing-controller/mocks/credential-manifest.js +45 -0
- package/test/issuing-controller/mocks/identity-issuing/accept-offers.js +22 -0
- package/test/issuing-controller/mocks/identity-issuing/confirm-verification-code.js +5 -0
- package/test/issuing-controller/mocks/identity-issuing/get-app-config.js +52 -0
- package/test/issuing-controller/mocks/identity-issuing/get-organization.js +118 -0
- package/test/issuing-controller/mocks/identity-issuing/index.js +6 -0
- package/test/issuing-controller/mocks/index.js +6 -0
- package/test/issuing-controller/mocks/issuers.js +126 -0
- package/test/issuing-controller/mocks/offers.js +48 -0
- package/test/issuing-controller/mocks/schema.js +107 -0
- package/test/linkedin-controller.test.js +452 -0
- package/test/mocks/credential-categories.js +115 -0
- package/test/mocks/credentials.js +15 -0
- package/test/mocks/didjwk.js +25 -0
- package/test/mocks/index.js +7 -0
- package/test/mocks/issuers.js +88 -0
- package/test/mocks/jwk.js +53 -0
- package/test/mocks/schema.js +107 -0
- package/test/root.test.js +42 -0
- package/test/vcl-sdk-plugin.test.js +86 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
const mockIssuers = {
|
|
3
|
+
all: [
|
|
4
|
+
{
|
|
5
|
+
payload: {
|
|
6
|
+
name: 'University of Massachusetts Amherst',
|
|
7
|
+
location: {
|
|
8
|
+
countryCode: 'US',
|
|
9
|
+
regionCode: 'MA',
|
|
10
|
+
},
|
|
11
|
+
logo: 'https://upload.wikimedia.org/wikipedia/commons/4/4f/UMass_Seal_Medium_PMS_202.png',
|
|
12
|
+
website: 'https://www.umass.edu/',
|
|
13
|
+
contactEmail: 'test@test.com',
|
|
14
|
+
technicalEmail: 'test@test.com',
|
|
15
|
+
description:
|
|
16
|
+
'Test org, primarily for Issuing Education and Cource credentials',
|
|
17
|
+
founded: '2023-04-04',
|
|
18
|
+
type: 'company',
|
|
19
|
+
physicalAddress: {
|
|
20
|
+
line1: 'xxxx',
|
|
21
|
+
line2: 'xxxx',
|
|
22
|
+
line3: 'xxxx',
|
|
23
|
+
regionCode: 'XX-XX',
|
|
24
|
+
countryCode: 'XX',
|
|
25
|
+
postcode: 'xxxx',
|
|
26
|
+
},
|
|
27
|
+
linkedInProfile: 'https://xxxx.xxx',
|
|
28
|
+
id: 'did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA',
|
|
29
|
+
verifiableCredentialJwt:
|
|
30
|
+
'https://devregistrar.velocitynetwork.foundation/api/v0.6/organizations/did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA/resolve-vc/a78a9c37-0345-4eb4-83da-53ad4322500e',
|
|
31
|
+
service: [
|
|
32
|
+
{
|
|
33
|
+
type: 'VlcCareerIssuer_v1',
|
|
34
|
+
id: '#velocity-issuer-1',
|
|
35
|
+
serviceEndpoint:
|
|
36
|
+
'https://devagent.velocitycareerlabs.io/api/holder/v0.6/org/did:ion:EiApMLdMb4NPb8sae9-hXGHP79W1gisApVSE80USPEbtJA/issue/get-credential-manifest',
|
|
37
|
+
credentialTypes: [
|
|
38
|
+
'EducationDegree',
|
|
39
|
+
'EducationDegreeRegistrationV1.0',
|
|
40
|
+
'EducationDegreeStudyV1.0',
|
|
41
|
+
'EducationDegreeGraduationV1.0',
|
|
42
|
+
'EducationDegreeRegistrationV1.1',
|
|
43
|
+
'EducationDegreeStudyV1.1',
|
|
44
|
+
'EducationDegreeGraduationV1.1',
|
|
45
|
+
'PastEmploymentPosition',
|
|
46
|
+
'CurrentEmploymentPosition',
|
|
47
|
+
'EmploymentCurrentV1.0',
|
|
48
|
+
'EmploymentPastV1.0',
|
|
49
|
+
'EmploymentCurrentV1.1',
|
|
50
|
+
'EmploymentPastV1.1',
|
|
51
|
+
'Certification',
|
|
52
|
+
'CertificationV1.0',
|
|
53
|
+
'LicenseV1.0',
|
|
54
|
+
'CertificationV1.1',
|
|
55
|
+
'LicenseV1.1',
|
|
56
|
+
'Course',
|
|
57
|
+
'CourseRegistrationV1.0',
|
|
58
|
+
'CourseCompletionV1.0',
|
|
59
|
+
'CourseAttendanceV1.0',
|
|
60
|
+
'CourseRegistrationV1.1',
|
|
61
|
+
'CourseCompletionV1.1',
|
|
62
|
+
'CourseAttendanceV1.1',
|
|
63
|
+
'AssessmentDec2020',
|
|
64
|
+
'AssessmentV1.0',
|
|
65
|
+
'AssessmentV1.1',
|
|
66
|
+
'Badge',
|
|
67
|
+
'OpenBadgeV1.0',
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: 'VlcInspector_v1',
|
|
72
|
+
id: '#velocity-inspector-1',
|
|
73
|
+
serviceEndpoint: 'https://devagent.velocitycareerlabs.io',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
permittedVelocityServiceCategory: ['Issuer', 'Inspector'],
|
|
77
|
+
createdAt: '2022-03-01T10:17:38.542Z',
|
|
78
|
+
updatedAt: '2023-06-26T13:36:05.180Z',
|
|
79
|
+
supportsSecureMessages: false,
|
|
80
|
+
},
|
|
81
|
+
TAG: 'VCLOrganization',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
module.exports = {
|
|
87
|
+
mockIssuers,
|
|
88
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Michael Avoyan on 08/08/2024.
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2022 Velocity Career Labs inc.
|
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const Jwk = {
|
|
9
|
+
keys: [
|
|
10
|
+
{
|
|
11
|
+
alg: 'RS512',
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
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
const mockSchema = {
|
|
2
|
+
title: {
|
|
3
|
+
path: [
|
|
4
|
+
'$.hasCredential.issuer.name',
|
|
5
|
+
'$.hasCredential.issuer.id',
|
|
6
|
+
'$.hasCredential.issuer',
|
|
7
|
+
],
|
|
8
|
+
schema: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
},
|
|
11
|
+
fallback: '-',
|
|
12
|
+
},
|
|
13
|
+
subtitle: {
|
|
14
|
+
text: 'Open Badge',
|
|
15
|
+
},
|
|
16
|
+
summary_detail: {
|
|
17
|
+
path: ['$.hasCredential.name'],
|
|
18
|
+
schema: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
},
|
|
21
|
+
fallback: '-',
|
|
22
|
+
},
|
|
23
|
+
description: {
|
|
24
|
+
text: 'Open badge',
|
|
25
|
+
},
|
|
26
|
+
logo: {
|
|
27
|
+
path: ['$.hasCredential.image'],
|
|
28
|
+
schema: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
format: 'uri',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
properties: [
|
|
34
|
+
{
|
|
35
|
+
label: 'Badge name',
|
|
36
|
+
path: ['$.hasCredential.name'],
|
|
37
|
+
schema: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
},
|
|
40
|
+
fallback: '-',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: '',
|
|
44
|
+
path: ['$.hasCredential.image'],
|
|
45
|
+
schema: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: 'Description',
|
|
51
|
+
path: ['$.hasCredential.description'],
|
|
52
|
+
schema: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: 'Type',
|
|
58
|
+
path: ['$.hasCredential.type'],
|
|
59
|
+
schema: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
label: 'Criteria',
|
|
65
|
+
path: ['$.hasCredential.criteria', '$.hasCredential.criteria.narrative'],
|
|
66
|
+
schema: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
label: 'Tags',
|
|
72
|
+
path: ['$.hasCredential.tags'],
|
|
73
|
+
schema: {
|
|
74
|
+
type: 'array',
|
|
75
|
+
items: {
|
|
76
|
+
type: 'string',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
label: 'Alignment',
|
|
82
|
+
path: ['$.hasCredential.alignment[0].targetName'],
|
|
83
|
+
schema: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: 'Alignment URL',
|
|
89
|
+
path: ['$.hasCredential.alignment[0].targetUrl'],
|
|
90
|
+
schema: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
format: 'uri',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: 'Alignment framework',
|
|
97
|
+
path: ['$.hasCredential.alignment[0].targetFramework'],
|
|
98
|
+
schema: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
module.exports = {
|
|
106
|
+
mockSchema,
|
|
107
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const buildFastify = require('./helpers/webwallet-build-fastify');
|
|
2
|
+
|
|
3
|
+
jest.mock('@velocitycareerlabs/vnf-nodejs-wallet-sdk', () => {
|
|
4
|
+
const originalModule = jest.requireActual(
|
|
5
|
+
'@velocitycareerlabs/vnf-nodejs-wallet-sdk'
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
...originalModule,
|
|
10
|
+
VCLProvider: {
|
|
11
|
+
getInstance: jest.fn().mockReturnValue({
|
|
12
|
+
initialize: jest.fn().mockResolvedValue(null),
|
|
13
|
+
}),
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('Root routes', () => {
|
|
19
|
+
let fastify;
|
|
20
|
+
|
|
21
|
+
beforeAll(async () => {
|
|
22
|
+
fastify = buildFastify();
|
|
23
|
+
await fastify.ready();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterAll(async () => {
|
|
27
|
+
await fastify.close();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should respond to /', async () => {
|
|
31
|
+
const response = await fastify.inject({
|
|
32
|
+
method: 'GET',
|
|
33
|
+
url: '/',
|
|
34
|
+
payload: { message: 'Hi' },
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
expect(response.statusCode).toEqual(200);
|
|
38
|
+
expect(response.body).toEqual(
|
|
39
|
+
'Welcome to Webwallet Server\nVersion: 0.5.0-build\n'
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const mockVclSdkInitialize = jest.fn();
|
|
2
|
+
jest.mock('@velocitycareerlabs/vnf-nodejs-wallet-sdk', () => {
|
|
3
|
+
const originalModule = jest.requireActual(
|
|
4
|
+
'@velocitycareerlabs/vnf-nodejs-wallet-sdk'
|
|
5
|
+
);
|
|
6
|
+
return {
|
|
7
|
+
...originalModule,
|
|
8
|
+
VCLProvider: {
|
|
9
|
+
getInstance: jest.fn().mockReturnValue({
|
|
10
|
+
initialize: mockVclSdkInitialize,
|
|
11
|
+
}),
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
const {
|
|
16
|
+
VCLProvider,
|
|
17
|
+
VCLInitializationDescriptor,
|
|
18
|
+
} = require('@velocitycareerlabs/vnf-nodejs-wallet-sdk');
|
|
19
|
+
const { vnfSdkPlugin } = require('../src/plugins/vnf-sdk-plugin');
|
|
20
|
+
|
|
21
|
+
describe('Test vnf-sdk-plugin sdk initialization', () => {
|
|
22
|
+
const fastifyMock = {
|
|
23
|
+
decorate: jest.fn().mockReturnThis(),
|
|
24
|
+
decorateRequest: jest.fn().mockReturnThis(),
|
|
25
|
+
addHook: jest.fn().mockReturnThis(),
|
|
26
|
+
log: { error: jest.fn() },
|
|
27
|
+
sendError: jest.fn().mockReturnThis(),
|
|
28
|
+
config: {},
|
|
29
|
+
close: jest.fn().mockReturnThis(),
|
|
30
|
+
};
|
|
31
|
+
const next = jest.fn();
|
|
32
|
+
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
jest.clearAllMocks();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should initialize vnf sdk successfully', async () => {
|
|
38
|
+
const vclSdk = VCLProvider.getInstance();
|
|
39
|
+
mockVclSdkInitialize.mockResolvedValue(null);
|
|
40
|
+
|
|
41
|
+
await vnfSdkPlugin(fastifyMock, {}, next);
|
|
42
|
+
|
|
43
|
+
expect(VCLProvider.getInstance).toHaveBeenCalled();
|
|
44
|
+
expect(vclSdk.initialize).toHaveBeenCalledWith(
|
|
45
|
+
expect.any(VCLInitializationDescriptor)
|
|
46
|
+
);
|
|
47
|
+
expect(fastifyMock.decorate).toHaveBeenCalledWith('vclSdk', vclSdk);
|
|
48
|
+
expect(fastifyMock.decorateRequest).toHaveBeenCalledWith('vclSdk', null);
|
|
49
|
+
expect(fastifyMock.addHook).toHaveBeenCalledWith(
|
|
50
|
+
'preValidation',
|
|
51
|
+
expect.any(Function)
|
|
52
|
+
);
|
|
53
|
+
expect(next).toHaveBeenCalledTimes(0);
|
|
54
|
+
// catch block:
|
|
55
|
+
expect(fastifyMock.log.error).toHaveBeenCalledTimes(0);
|
|
56
|
+
expect(fastifyMock.sendError).toHaveBeenCalledTimes(0);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should handle vnf sdk initialization error', async () => {
|
|
60
|
+
const expectedError = new Error('VNF SDK initialization error');
|
|
61
|
+
|
|
62
|
+
const vclSdk = VCLProvider.getInstance();
|
|
63
|
+
mockVclSdkInitialize.mockRejectedValueOnce(expectedError);
|
|
64
|
+
|
|
65
|
+
await expect(vnfSdkPlugin(fastifyMock, {}, next)).rejects.toThrow(
|
|
66
|
+
expectedError
|
|
67
|
+
);
|
|
68
|
+
expect(VCLProvider.getInstance).toHaveBeenCalled();
|
|
69
|
+
expect(vclSdk.initialize).toHaveBeenCalledWith(
|
|
70
|
+
expect.any(VCLInitializationDescriptor)
|
|
71
|
+
);
|
|
72
|
+
expect(fastifyMock.decorate).toHaveBeenCalledTimes(0);
|
|
73
|
+
expect(fastifyMock.decorateRequest).toHaveBeenCalledTimes(0);
|
|
74
|
+
expect(fastifyMock.addHook).toHaveBeenCalledTimes(0);
|
|
75
|
+
expect(next).toHaveBeenCalledTimes(0);
|
|
76
|
+
// catch block:
|
|
77
|
+
expect(fastifyMock.log.error).toHaveBeenCalledTimes(1);
|
|
78
|
+
expect(fastifyMock.log.error).toHaveBeenCalledWith(
|
|
79
|
+
expect.objectContaining(expectedError)
|
|
80
|
+
);
|
|
81
|
+
expect(fastifyMock.sendError).toHaveBeenCalledTimes(1);
|
|
82
|
+
expect(fastifyMock.sendError).toHaveBeenCalledWith(
|
|
83
|
+
expect.objectContaining(expectedError)
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
});
|