Skip to content

Commit

Permalink
WIP: fix the 'not an Access Grant' test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeswr committed Sep 27, 2023
1 parent 1a2adb7 commit a16ac1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/gConsent/manage/getAccessGrant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { mockAccessApiEndpoint } from "../request/request.mock";
import {
mockAccessGrantObject,
mockAccessGrantVc,
mockConsentRequestObject,
mockConsentRequestVc,
} from "../util/access.mock";
import { getAccessGrant } from "./getAccessGrant";
Expand Down Expand Up @@ -114,7 +115,7 @@ describe("getAccessGrant", () => {
it("throws if the given IRI does not resolve to a access grant Verifiable Credential", async () => {
mockAccessApiEndpoint();
const mockedFetch = jest.fn(global.fetch).mockResolvedValueOnce(
new Response(JSON.stringify(await mockConsentRequestVc()), {
new Response(JSON.stringify(mockConsentRequestObject()), {
headers: new Headers([["content-type", "application/json"]]),
}),
);
Expand Down
12 changes: 12 additions & 0 deletions src/gConsent/util/access.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@ export const mockAccessGrantVc = async (
return accessGrant as unknown as AccessGrant & DatasetCore<Quad, Quad>;
};


export const mockConsentRequestObject = (
options?: RequestVcOptions,
) => {
const requestVc = mockAccessRequestVcObject(options);
requestVc.credentialSubject.hasConsent.forPurpose = ["https://some.purpose"];
requestVc.expirationDate = new Date(2021, 8, 14).toISOString();
requestVc.issuanceDate = new Date(2021, 8, 13).toISOString();
return requestVc;
};


export const mockConsentRequestVc = async (
options?: RequestVcOptions,
framingOptions?: {
Expand Down

0 comments on commit a16ac1c

Please sign in to comment.