From 6f2168cce7d5e80399407cbe3b2d2fbc53dbd3d8 Mon Sep 17 00:00:00 2001 From: F-Node-Karlsruhe Date: Wed, 22 Nov 2023 14:31:25 +0100 Subject: [PATCH] add multi status test and example Signed-off-by: F-Node-Karlsruhe --- api/__tests__/credential.test.ts | 65 ++++++++++++++++++++++++++++++++ api/src/routers/verify/index.ts | 53 ++++++++++++++++++++------ 2 files changed, 107 insertions(+), 11 deletions(-) diff --git a/api/__tests__/credential.test.ts b/api/__tests__/credential.test.ts index 4f66f75..e260b81 100644 --- a/api/__tests__/credential.test.ts +++ b/api/__tests__/credential.test.ts @@ -118,6 +118,57 @@ const suspended2021Credential: any = { } } +const multiStatusCredential: any = { + "@context": [ + "https://www.w3.org/2018/credentials/v1", + "https://ref.gs1.org/gs1/vc/licence-context/", + "https://ssi.eecc.de/api/registry/context", + "https://w3id.org/vc/status-list/2021/v1", + "https://w3id.org/security/suites/ed25519-2020/v1" + ], + "id": "https://ssi.eecc.de/api/registry/vc/8ee256f6-9374-4dd4-afc3-8916f4a29573", + "type": [ + "VerifiableCredential", + "GS1PrefixLicenceCredential" + ], + "issuer": { + "id": "did:web:ssi.eecc.de", + "image": "https://id.eecc.de/assets/img/logo_big.png", + "name": "EECC" + }, + "issuanceDate": "2023-11-22T13:20:58Z", + "credentialStatus": [ + { + "id": "https://ssi.eecc.de/api/registry/vc/revocation/did:web:ssi.eecc.de/1#12", + "type": "StatusList2021Entry", + "statusPurpose": "revocation", + "statusListIndex": "12", + "statusListCredential": "https://ssi.eecc.de/api/registry/vc/revocation/did:web:ssi.eecc.de/1" + }, + { + "id": "https://ssi.eecc.de/api/registry/vc/suspension/did:web:ssi.eecc.de/1#5", + "type": "StatusList2021Entry", + "statusPurpose": "suspension", + "statusListIndex": "5", + "statusListCredential": "https://ssi.eecc.de/api/registry/vc/suspension/did:web:ssi.eecc.de/1" + } + ], + "credentialSubject": { + "id": "did:web:eecc.de", + "licenceValue": "040471110", + "alternativeLicenceValue": "040471110", + "organizationName": "European EPC Competence Center", + "partyGLN": "40471110" + }, + "proof": { + "type": "Ed25519Signature2020", + "created": "2023-11-22T13:20:58Z", + "proofPurpose": "assertionMethod", + "verificationMethod": "did:web:ssi.eecc.de#z6MkoHWsmSZnHisAxnVdokYHnXaVqWFZ4H33FnNg13zyymxd", + "proofValue": "z3MmgAE6NWZMXdrk3ncbuBmxWNxNS3ZWF8samxd5mzAiqrR4Ru1TcxB92dQhC9GmgFd1d5Lz2dHM2WoVwoMBxehTF" + } +} + const SDCredential: any = { "@context": [ "https://www.w3.org/2018/credentials/v1", @@ -265,6 +316,20 @@ describe("Verifier API Test for Credentials", () => { expect(res.body[0].statusResult.verified).toBe(false); }); + /** + * Test multi StatusList2021 credential + */ + test("Verify suspended credential", async () => { + const res = await request(server).post("/api/verifier").send([multiStatusCredential]); + expect(res.statusCode).toEqual(200); + expect(res.body[0]).toHaveProperty('verified'); + expect(res.body[0].verified).toBe(true); + expect(res.body[0]).toHaveProperty('statusResult'); + expect(res.body[0].statusResult.verified).toBe(true); + expect(res.body[0].statusResult).toHaveProperty('results'); + expect(res.body[0].statusResult.results.every((r: any) => r.verified)).toBe(true); + }); + test("Falsify single credential", async () => { const res = await request(server).post("/api/verifier").send([manipulatedCredential]); expect(res.statusCode).toEqual(200); diff --git a/api/src/routers/verify/index.ts b/api/src/routers/verify/index.ts index eaf3cac..dbadadf 100644 --- a/api/src/routers/verify/index.ts +++ b/api/src/routers/verify/index.ts @@ -121,22 +121,53 @@ verifyRouter.get('/vc/:vcid', fetchAndVerify); { "@context": [ "https://www.w3.org/2018/credentials/v1", - "https://ssi.eecc.de/api/registry/context/product-passport" + "https://ref.gs1.org/gs1/vc/licence-context/", + "https://ssi.eecc.de/api/registry/context", + "https://w3id.org/vc/status-list/2021/v1", + "https://w3id.org/security/suites/ed25519-2020/v1" + ], + "id": "https://ssi.eecc.de/api/registry/vc/8ee256f6-9374-4dd4-afc3-8916f4a29573", + "type": [ + "VerifiableCredential", + "GS1PrefixLicenceCredential" + ], + "issuer": { + "id": "did:web:ssi.eecc.de", + "image": "https://id.eecc.de/assets/img/logo_big.png", + "name": "EECC" + }, + "issuanceDate": "2023-11-22T13:20:58Z", + "credentialStatus": [ + { + "id": "https://ssi.eecc.de/api/registry/vc/revocation/did:web:ssi.eecc.de/1#12", + "type": "StatusList2021Entry", + "statusPurpose": "revocation", + "statusListIndex": "12", + "statusListCredential": "https://ssi.eecc.de/api/registry/vc/revocation/did:web:ssi.eecc.de/1" + }, + { + "id": "https://ssi.eecc.de/api/registry/vc/suspension/did:web:ssi.eecc.de/1#5", + "type": "StatusList2021Entry", + "statusPurpose": "suspension", + "statusListIndex": "5", + "statusListCredential": "https://ssi.eecc.de/api/registry/vc/suspension/did:web:ssi.eecc.de/1" + } ], - "id": "https://ssi.eecc.de/api/registry/vc/c6e6e206-1538-4da3-b8d6-c7225fc52c5b", - "type": ["VerifiableCredential", "ProductPassportCredential"], "credentialSubject": { - "id": "https://gs1.org/digital-link", - "property": "Example property" + "id": "did:web:eecc.de", + "licenceValue": "040471110", + "alternativeLicenceValue": "040471110", + "organizationName": "European EPC Competence Center", + "partyGLN": "40471110" }, "proof": { - "type": "Ed25519Signature2020", - "created": "2022-09-26T09:01:07.000Z", - "proofPurpose": "assertionMethod", - "verificationMethod": "did:web:ssi.eecc.de#z6Mks681c8vdENF2Qk6cZEvV82YfoqDAkC9KyqnpdgMy2oyv", - "proofValue": "z4wxpr1MJyVrmFEGAuwRy7FhFtcCcPiRb74hFgDyvVCsxUdPDkd6afyEVSe8JEs7Y82XLpAsXfRnaTSzyg2NLGMSm" + "type": "Ed25519Signature2020", + "created": "2023-11-22T13:20:58Z", + "proofPurpose": "assertionMethod", + "verificationMethod": "did:web:ssi.eecc.de#z6MkoHWsmSZnHisAxnVdokYHnXaVqWFZ4H33FnNg13zyymxd", + "proofValue": "z3MmgAE6NWZMXdrk3ncbuBmxWNxNS3ZWF8samxd5mzAiqrR4Ru1TcxB92dQhC9GmgFd1d5Lz2dHM2WoVwoMBxehTF" } - } +} ] * @example request - Presentation request [