Skip to content

Commit

Permalink
chore: fix v3 test fixture that are not valid v3 credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebulis committed Sep 6, 2021
1 parent b3123d1 commit f2c2022
Show file tree
Hide file tree
Showing 32 changed files with 26,843 additions and 317 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ workflows:
jobs:
- build:
context:
- NPM Deployment
- deployment

jobs:
build:
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ module.exports = {
preset: "ts-jest",
testEnvironment: "node",
watchPlugins: ["jest-watch-typeahead/filename", "jest-watch-typeahead/testname"],
testTimeout: 30000,
};
26,631 changes: 26,581 additions & 50 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@govtechsg/dnsprove": "^2.1.3",
"@govtechsg/document-store": "^2.2.1",
"@govtechsg/open-attestation": "^5.2.3",
"@govtechsg/open-attestation": "^5.4.0",
"@govtechsg/token-registry": "^2.5.2",
"axios": "^0.21.1",
"debug": "^4.3.1",
Expand Down
4 changes: 2 additions & 2 deletions src/did/resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("custom resolver", () => {
createResolver({ ethrResolverConfig: customConfig })
);
expect(did).toEqual(didDoc);
}, 10000);
});

it("should resolve did using verifier", async () => {
const verify = verificationBuilder([openAttestationDidIdentityProof], {
Expand All @@ -106,7 +106,7 @@ describe("custom resolver", () => {
"type": "ISSUER_IDENTITY",
}
`);
}, 10000);
});
});

describe("getProviderConfig", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/getIdentifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe("getIdentifier", () => {
it("should return a DID identity proof if issuer fragment is of type OpenAttestationDidIdentityProof", async () => {
const fragment = await openAttestationDidIdentityProof.verify(v3DidSigned, options);
expect(getIdentifier([verificationFragment1, fragment])).toStrictEqual({
identifier: "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
identifier: "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
type: "DID",
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ jest.mock("../../../did/resolver");

const mockGetPublicKey = getVerificationMethod as jest.Mock;

const whenPublicKeyResolvesSuccessfully = () => {
const whenPublicKeyResolvesSuccessfully = (key = "0xB26B4941941C51a4885E5B7D3A1B861E54405f90") => {
// Private key for signing from this address
// 0x497c85ed89f1874ba37532d1e33519aba15bd533cdcb90774cc497bfe3cde655
// sign using wallet.signMessage(utils.arrayify(merkleRoot))
mockGetPublicKey.mockResolvedValue({
id: "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89#controller",
id: `did:ethr:${key}`,
type: "EcdsaSecp256k1RecoveryMethod2020",
controller: "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
blockchainAccountId: "0xe712878f6e8d5d4f9e87e10da604f9cb564c9a89",
controller: `did:ethr:${key}`,
blockchainAccountId: key.toLowerCase(),
});
};

Expand Down Expand Up @@ -116,7 +116,7 @@ describe("verify", () => {
});
describe("v2", () => {
it("should pass for documents using `DID` and is correctly signed", async () => {
whenPublicKeyResolvesSuccessfully();
whenPublicKeyResolvesSuccessfully("0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89");
const res = await openAttestationDidSignedDocumentStatus.verify(documentDidSigned, options);
expect(res).toMatchInlineSnapshot(`
Object {
Expand Down Expand Up @@ -144,7 +144,7 @@ describe("verify", () => {
`);
});
it("should pass for documents using `DID` and is correctly signed, and is not revoked on a document store (if specified)", async () => {
whenPublicKeyResolvesSuccessfully();
whenPublicKeyResolvesSuccessfully("0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89");
const res = await openAttestationDidSignedDocumentStatus.verify(didSignedRevocationStoreNotRevokedV2, options);
expect(res).toMatchInlineSnapshot(`
Object {
Expand Down Expand Up @@ -173,7 +173,7 @@ describe("verify", () => {
`);
});
it("should pass for documents using `DID-DNS` and is correctly signed", async () => {
whenPublicKeyResolvesSuccessfully();
whenPublicKeyResolvesSuccessfully("0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89");
const res = await openAttestationDidSignedDocumentStatus.verify(documentDnsDidSigned, options);
expect(res).toMatchInlineSnapshot(`
Object {
Expand Down Expand Up @@ -201,7 +201,7 @@ describe("verify", () => {
`);
});
it("should pass for documents using `DID-DNS` and is correctly signed, and is not revoked on a document store (if specified)", async () => {
whenPublicKeyResolvesSuccessfully();
whenPublicKeyResolvesSuccessfully("0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89");
const res = await openAttestationDidSignedDocumentStatus.verify(dnsDidSignedRevocationStoreNotRevokedV2, options);
expect(res).toMatchInlineSnapshot(`
Object {
Expand Down Expand Up @@ -329,7 +329,7 @@ describe("verify", () => {
`);
});
it("should fail when signature is wrong", async () => {
whenPublicKeyResolvesSuccessfully();
whenPublicKeyResolvesSuccessfully("0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89");
const incorrectSignatureDocument = { ...documentDnsDidSigned, proof: documentDidSigned.proof };
const res = await openAttestationDidSignedDocumentStatus.verify(incorrectSignatureDocument, options);
expect(res).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -368,7 +368,7 @@ describe("verify", () => {
`);
});
it("should fail for documents using `DID` and is correctly signed, and is revoked on a document store (if specified)", async () => {
whenPublicKeyResolvesSuccessfully();
whenPublicKeyResolvesSuccessfully("0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89");
const res = await openAttestationDidSignedDocumentStatus.verify(didSignedRevocationStoreButRevokedV2, options);
expect(res).toMatchInlineSnapshot(`
Object {
Expand Down Expand Up @@ -407,7 +407,7 @@ describe("verify", () => {
`);
});
it("should fail for documents using `DID-DNS` and is correctly signed, and is revoked on a document store (if specified)", async () => {
whenPublicKeyResolvesSuccessfully();
whenPublicKeyResolvesSuccessfully("0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89");
const res = await openAttestationDidSignedDocumentStatus.verify(dnsDidSignedRevocationStoreButRevokedV2, options);
expect(res).toMatchInlineSnapshot(`
Object {
Expand Down Expand Up @@ -456,7 +456,7 @@ describe("verify", () => {
"data": Object {
"details": Object {
"issuance": Object {
"did": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"did": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
"issued": true,
},
"revocation": Object {
Expand Down Expand Up @@ -498,11 +498,11 @@ describe("verify", () => {
"data": Object {
"details": Object {
"issuance": Object {
"did": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"did": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
"issued": true,
},
"revocation": Object {
"address": "0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"address": "0xc7dfB2D05ab3Da91e723F2557817165e6acEAc38",
"revoked": false,
},
},
Expand All @@ -524,7 +524,7 @@ describe("verify", () => {
"data": Object {
"details": Object {
"issuance": Object {
"did": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"did": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
"issued": true,
},
"revocation": Object {
Expand All @@ -549,11 +549,11 @@ describe("verify", () => {
"data": Object {
"details": Object {
"issuance": Object {
"did": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"did": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
"issued": true,
},
"revocation": Object {
"address": "0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"address": "0xc7dfB2D05ab3Da91e723F2557817165e6acEAc38",
"revoked": false,
},
},
Expand Down Expand Up @@ -644,15 +644,15 @@ describe("verify", () => {
"data": Object {
"details": Object {
"issuance": Object {
"did": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"did": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
"issued": true,
},
"revocation": Object {
"address": "0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"address": "0xc7dfB2D05ab3Da91e723F2557817165e6acEAc38",
"reason": Object {
"code": 5,
"codeString": "DOCUMENT_REVOKED",
"message": "Document 0xd271155c3fccaf97fd9404b15000399620002c092c047d3cd506cf51ecd522d7 has been revoked under contract 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"message": "Document 0xfdd40a012f38dacedad0d7fbe68726ac47f7836c6019f9824329207b9d7e6bb1 has been revoked under contract 0xc7dfB2D05ab3Da91e723F2557817165e6acEAc38",
},
"revoked": true,
},
Expand All @@ -664,7 +664,7 @@ describe("verify", () => {
"reason": Object {
"code": 5,
"codeString": "DOCUMENT_REVOKED",
"message": "Document 0xd271155c3fccaf97fd9404b15000399620002c092c047d3cd506cf51ecd522d7 has been revoked under contract 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"message": "Document 0xfdd40a012f38dacedad0d7fbe68726ac47f7836c6019f9824329207b9d7e6bb1 has been revoked under contract 0xc7dfB2D05ab3Da91e723F2557817165e6acEAc38",
},
"status": "INVALID",
"type": "DOCUMENT_STATUS",
Expand All @@ -680,15 +680,15 @@ describe("verify", () => {
"data": Object {
"details": Object {
"issuance": Object {
"did": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"did": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
"issued": true,
},
"revocation": Object {
"address": "0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"address": "0xc7dfB2D05ab3Da91e723F2557817165e6acEAc38",
"reason": Object {
"code": 5,
"codeString": "DOCUMENT_REVOKED",
"message": "Document 0x18821b9fb922c38c743bf223cfc08afb8f90c74527d1f9addf3ab766bf1d3eb1 has been revoked under contract 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"message": "Document 0xf2a180a23e7c9917513092d4f315e9aac963388d703d20da2760788032b687b0 has been revoked under contract 0xc7dfB2D05ab3Da91e723F2557817165e6acEAc38",
},
"revoked": true,
},
Expand All @@ -700,7 +700,7 @@ describe("verify", () => {
"reason": Object {
"code": 5,
"codeString": "DOCUMENT_REVOKED",
"message": "Document 0x18821b9fb922c38c743bf223cfc08afb8f90c74527d1f9addf3ab766bf1d3eb1 has been revoked under contract 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"message": "Document 0xf2a180a23e7c9917513092d4f315e9aac963388d703d20da2760788032b687b0 has been revoked under contract 0xc7dfB2D05ab3Da91e723F2557817165e6acEAc38",
},
"status": "INVALID",
"type": "DOCUMENT_STATUS",
Expand All @@ -723,12 +723,12 @@ describe("verify", () => {
"data": Object {
"details": Object {
"issuance": Object {
"did": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"did": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
"issued": false,
"reason": Object {
"code": 7,
"codeString": "WRONG_SIGNATURE",
"message": "merkle root is not signed correctly by 0xe712878f6e8d5d4f9e87e10da604f9cb564c9a89",
"message": "merkle root is not signed correctly by 0xb26b4941941c51a4885e5b7d3a1b861e54405f90",
},
},
"revocation": Object {
Expand All @@ -742,7 +742,7 @@ describe("verify", () => {
"reason": Object {
"code": 7,
"codeString": "WRONG_SIGNATURE",
"message": "merkle root is not signed correctly by 0xe712878f6e8d5d4f9e87e10da604f9cb564c9a89",
"message": "merkle root is not signed correctly by 0xb26b4941941c51a4885e5b7d3a1b861e54405f90",
},
"status": "INVALID",
"type": "DOCUMENT_STATUS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,11 @@ describe("verify", () => {
"data": Object {
"details": Object {
"issuance": Object {
"address": "0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"address": "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
"issued": true,
},
"revocation": Object {
"address": "0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"address": "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
"revoked": false,
},
},
Expand All @@ -405,7 +405,7 @@ describe("verify", () => {
"reason": Object {
"code": 1,
"codeString": "DOCUMENT_NOT_ISSUED",
"message": "Document 0x6e3b3b131db956263d142f42a840962d31359fff61c28937d9d1add0ca04c89e has not been issued under contract 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"message": "Document 0xdaf603bcee04e4489e624aed8d39c5f86674a34d5576031c5c3c9a5766b30885 has not been issued under contract 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
},
},
"revocation": Object {
Expand All @@ -420,7 +420,7 @@ describe("verify", () => {
"reason": Object {
"code": 1,
"codeString": "DOCUMENT_NOT_ISSUED",
"message": "Document 0x6e3b3b131db956263d142f42a840962d31359fff61c28937d9d1add0ca04c89e has not been issued under contract 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"message": "Document 0xdaf603bcee04e4489e624aed8d39c5f86674a34d5576031c5c3c9a5766b30885 has not been issued under contract 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
},
"status": "INVALID",
"type": "DOCUMENT_STATUS",
Expand All @@ -434,15 +434,15 @@ describe("verify", () => {
"data": Object {
"details": Object {
"issuance": Object {
"address": "0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"address": "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
"issued": true,
},
"revocation": Object {
"address": "0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"address": "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
"reason": Object {
"code": 5,
"codeString": "DOCUMENT_REVOKED",
"message": "Document 0xa9e9f0c9adc106908b9ee40325f5ca583912853751cf697f540cf647479a2cd8 has been revoked under contract 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"message": "Document 0x4cefff86bef5079fd0f63a27cf2a849258cf15a6b7c9526bc63d00c7f3d3ebe8 has been revoked under contract 0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
},
"revoked": true,
},
Expand All @@ -454,7 +454,7 @@ describe("verify", () => {
"reason": Object {
"code": 5,
"codeString": "DOCUMENT_REVOKED",
"message": "Document 0xa9e9f0c9adc106908b9ee40325f5ca583912853751cf697f540cf647479a2cd8 has been revoked under contract 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"message": "Document 0x4cefff86bef5079fd0f63a27cf2a849258cf15a6b7c9526bc63d00c7f3d3ebe8 has been revoked under contract 0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
},
"status": "INVALID",
"type": "DOCUMENT_STATUS",
Expand Down
8 changes: 4 additions & 4 deletions src/verifiers/issuerIdentity/did/didIdentityProof.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe("verify", () => {
expect(fragment).toMatchInlineSnapshot(`
Object {
"data": Object {
"did": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"did": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
"verified": true,
},
"name": "OpenAttestationDidIdentityProof",
Expand All @@ -158,19 +158,19 @@ describe("verify", () => {
expect(fragment).toMatchInlineSnapshot(`
Object {
"data": Object {
"did": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"did": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
"reason": Object {
"code": 7,
"codeString": "WRONG_SIGNATURE",
"message": "merkle root is not signed correctly by 0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"message": "merkle root is not signed correctly by 0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
},
"verified": false,
},
"name": "OpenAttestationDidIdentityProof",
"reason": Object {
"code": 7,
"codeString": "WRONG_SIGNATURE",
"message": "merkle root is not signed correctly by 0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89",
"message": "merkle root is not signed correctly by 0xB26B4941941C51a4885E5B7D3A1B861E54405f90",
},
"status": "INVALID",
"type": "ISSUER_IDENTITY",
Expand Down
4 changes: 2 additions & 2 deletions src/verifiers/issuerIdentity/dnsDid/dnsDidProof.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe("verify", () => {
expect(fragment).toMatchInlineSnapshot(`
Object {
"data": Object {
"key": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89#controller",
"key": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90#controller",
"location": "example.tradetrust.io",
"status": "VALID",
},
Expand All @@ -159,7 +159,7 @@ describe("verify", () => {
expect(fragment).toMatchInlineSnapshot(`
Object {
"data": Object {
"key": "did:ethr:0xE712878f6E8d5d4F9e87E10DA604F9cB564C9a89#controller",
"key": "did:ethr:0xB26B4941941C51a4885E5B7D3A1B861E54405f90#controller",
"location": "example.com",
"status": "INVALID",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ describe("verify", () => {
Object {
"data": Object {
"identifier": "example.tradetrust.io",
"value": "0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"value": "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
},
"name": "OpenAttestationDnsTxtIdentityProof",
"status": "VALID",
Expand Down Expand Up @@ -495,13 +495,13 @@ describe("verify", () => {
Object {
"data": Object {
"identifier": "nonexistent.example.com",
"value": "0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"value": "0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
},
"name": "OpenAttestationDnsTxtIdentityProof",
"reason": Object {
"code": 4,
"codeString": "MATCHING_RECORD_NOT_FOUND",
"message": "Matching DNS record not found for 0x8bA63EAB43342AAc3AdBB4B827b68Cf4aAE5Caca",
"message": "Matching DNS record not found for 0x8Fc57204c35fb9317D91285eF52D6b892EC08cD3",
},
"status": "INVALID",
"type": "ISSUER_IDENTITY",
Expand Down
Loading

0 comments on commit f2c2022

Please sign in to comment.