Skip to content

Commit

Permalink
feat: Add jsonld tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Dec 11, 2023
1 parent a1ee0aa commit 78139f8
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/credential/issue-verify-flow.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { test, expect } from '@playwright/test';
import { StatusCodes } from 'http-status-codes';
import * as fs from 'fs';

test.use({ storageState: 'playwright/.auth/user.json' });

const PAYLOADS_BASE_PATH = './tests/payloads/credential';

let issuerDid: string;

test(' Issue a jwt credential', async ({ request }) => {
const dids = await (await request.get(`/did/list`)).json();
issuerDid = dids[0];
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_BASE_PATH}/credential-issue-jwt.json`, 'utf-8'));
credentialData.issuerDid = issuerDid;
const response = await request.post(`/credential/issue`, {
data: credentialData,
headers: {
'Content-Type': 'application/json',
},
});
expect(response).toBeOK();
expect(response.status()).toBe(StatusCodes.OK);

Check failure on line 23 in tests/credential/issue-verify-flow.spec.ts

View workflow job for this annotation

GitHub Actions / Build & Test / Build Node.js

[chromium] › credential/issue-verify-flow.spec.ts:11:1 › Issue a jwt credential

2) [chromium] › credential/issue-verify-flow.spec.ts:11:1 › Issue a jwt credential ────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: 200 Received: 403 21 | }); 22 | expect(response).toBeOK(); > 23 | expect(response.status()).toBe(StatusCodes.OK); | ^ 24 | }); 25 | 26 | test(' Issue a jsonLD credential', async ({ request }, testInfo) => { at /home/runner/work/credential-service/credential-service/tests/credential/issue-verify-flow.spec.ts:23:28
});

test(' Issue a jsonLD credential', async ({ request }, testInfo) => {
const credentialData = JSON.parse(fs.readFileSync(`${PAYLOADS_BASE_PATH}/credential-issue-jwt.json`, 'utf-8'));
credentialData.issuerDid = issuerDid;
const response = await request.post(`/credential/issue`, {
data: JSON.parse(fs.readFileSync(`${PAYLOADS_BASE_PATH}/credential-issue-jsonld.json`, 'utf-8')),
headers: {
'Content-Type': 'application/json',
},
});
expect(response).toBeOK();
expect(response.status()).toBe(StatusCodes.OK);

Check failure on line 36 in tests/credential/issue-verify-flow.spec.ts

View workflow job for this annotation

GitHub Actions / Build & Test / Build Node.js

[chromium] › credential/issue-verify-flow.spec.ts:26:1 › Issue a jsonLD credential

1) [chromium] › credential/issue-verify-flow.spec.ts:26:1 › Issue a jsonLD credential ─────────── Error: expect(received).toBe(expected) // Object.is equality Expected: 200 Received: 500 34 | }); 35 | expect(response).toBeOK(); > 36 | expect(response.status()).toBe(StatusCodes.OK); | ^ 37 | }); 38 | at /home/runner/work/credential-service/credential-service/tests/credential/issue-verify-flow.spec.ts:36:28

Check failure on line 36 in tests/credential/issue-verify-flow.spec.ts

View workflow job for this annotation

GitHub Actions / Build & Test / Build Node.js

[chromium] › credential/issue-verify-flow.spec.ts:26:1 › Issue a jsonLD credential

1) [chromium] › credential/issue-verify-flow.spec.ts:26:1 › Issue a jsonLD credential ─────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: 200 Received: 500 34 | }); 35 | expect(response).toBeOK(); > 36 | expect(response.status()).toBe(StatusCodes.OK); | ^ 37 | }); 38 | at /home/runner/work/credential-service/credential-service/tests/credential/issue-verify-flow.spec.ts:36:28

Check failure on line 36 in tests/credential/issue-verify-flow.spec.ts

View workflow job for this annotation

GitHub Actions / Build & Test / Build Node.js

[chromium] › credential/issue-verify-flow.spec.ts:26:1 › Issue a jsonLD credential

1) [chromium] › credential/issue-verify-flow.spec.ts:26:1 › Issue a jsonLD credential ─────────── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: 200 Received: 500 34 | }); 35 | expect(response).toBeOK(); > 36 | expect(response.status()).toBe(StatusCodes.OK); | ^ 37 | }); 38 | at /home/runner/work/credential-service/credential-service/tests/credential/issue-verify-flow.spec.ts:36:28
});
11 changes: 11 additions & 0 deletions tests/payloads/credential/credential-issue-jsonld.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"issuerDid": "did:cheqd:testnet:ae0f3d22-cb16-4515-930c-b9a7c7bdfdc0",
"subjectDid": "did:key:z6MkqJNR1DHxX2qxqDYx9tNDsXoNRVpaVvJkLPeCYqaARz1n",
"attributes": {
"gender": "male",
"name": "Bob"
},
"@context": ["https://schema.org"],
"type": ["Person"],
"format": "lds"
}
11 changes: 11 additions & 0 deletions tests/payloads/credential/credential-issue-jwt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"issuerDid": "did:cheqd:testnet:ae0f3d22-cb16-4515-930c-b9a7c7bdfdc0",
"subjectDid": "did:key:z6MkqJNR1DHxX2qxqDYx9tNDsXoNRVpaVvJkLPeCYqaARz1n",
"attributes": {
"gender": "male",
"name": "Bob"
},
"@context": ["https://schema.org"],
"type": ["Person"],
"format": "jwt"
}

0 comments on commit 78139f8

Please sign in to comment.