Skip to content

Commit

Permalink
SDK-3304: Added extra node e2e tests for Problem Details (#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
jholleran authored Aug 16, 2024
1 parent 755d75c commit 68cad54
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 9 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/e2e-node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ jobs:
matrix:
os: [ubuntu-latest]
node-version: ["18.x", "20.x"]
environment-name: ["ESS PodSpaces", "ESS Dev-2-2"]
# PodSpaces doesn't support error descriptions yet.
environment-name: ["ESS Dev-2-3"]
experimental: [false]
include:
- node-version: "20.x"
experimental: true
environment-name: "ESS Dev-2-3"
os: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
85 changes: 82 additions & 3 deletions e2e/node/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ describe("End-to-end verifiable credentials tests for environment", () => {
issuerService,
validSubjectClaims(),
validCredentialClaims,

{
fetch: session.fetch,
},
Expand All @@ -182,7 +181,6 @@ describe("End-to-end verifiable credentials tests for environment", () => {
issuerService,
validSubjectClaims(),
validCredentialClaims,

{
fetch: session.fetch,
returnLegacyJsonld: false,
Expand Down Expand Up @@ -314,8 +312,19 @@ describe("End-to-end verifiable credentials tests for environment", () => {
fetch: session.fetch,
},
);

await expect(vcPromise).rejects.toThrow(
`The VC issuing endpoint [${issuerService}] could not successfully issue a VC`,
expect.objectContaining({
name: "Error",
message: `The VC issuing endpoint [${issuerService}] could not successfully issue a VC`,
// Check that the Error contains Problem Details
problemDetails: expect.objectContaining({
status: 400,
title: "Bad Request",
detail: expect.stringMatching(/.+/),
instance: expect.not.stringMatching(""),
}),
}),
);
});
});
Expand Down Expand Up @@ -549,6 +558,55 @@ describe("End-to-end verifiable credentials tests for environment", () => {
),
);
}, 60_000);

it("throws if error occurred retrieving a VC", async () => {
const vcUrl = `${issuerService}/non-existing-vc`;
const vcPromise = getVerifiableCredential(vcUrl, {
fetch: session.fetch,
returnLegacyJsonld: false,
});

await expect(vcPromise).rejects.toThrow(
expect.objectContaining({
name: "Error",
message: `Fetching the Verifiable Credential [${vcUrl}] failed`,
// Check that the Error contains Problem Details
problemDetails: expect.objectContaining({
status: 404,
title: "Not Found",
detail: expect.stringMatching(/.+/),
instance: expect.not.stringMatching(""),
}),
}),
);
});

it("throws if error occurred querying for a VC", async () => {
const queryPromise = query(
derivationService,
{
// empty query body
} as unknown as VerifiablePresentationRequest,
{
fetch: session.fetch,
returnLegacyJsonld: false,
},
);

await expect(queryPromise).rejects.toThrow(
expect.objectContaining({
name: "Error",
message: `The query endpoint [${derivationService}] returned an error`,
// Check that the Error contains Problem Details
problemDetails: expect.objectContaining({
status: 400,
title: "Bad Request",
detail: expect.stringMatching(/.+/),
instance: expect.not.stringMatching(""),
}),
}),
);
});
});

describe("revoke VCs", () => {
Expand Down Expand Up @@ -578,5 +636,26 @@ describe("End-to-end verifiable credentials tests for environment", () => {
"credentialStatus validation has failed: credential has been revoked",
]);
});

it("throws if error occurred revoking a VC", async () => {
const vcUrl = `${issuerService}/non-existing-vc`;
const vcPromise = revokeVerifiableCredential(statusService, vcUrl, {
fetch: session.fetch,
});

await expect(vcPromise).rejects.toThrow(
expect.objectContaining({
name: "Error",
message: `The issuer [${statusService}] returned an error`,
// Check that the Error contains Problem Details
problemDetails: expect.objectContaining({
status: 404,
title: "Not Found",
detail: expect.stringMatching(/.+/),
instance: expect.not.stringMatching(""),
}),
}),
);
});
});
});

0 comments on commit 68cad54

Please sign in to comment.