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 bc264e2
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/credential/issue-verify-flow.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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';

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

Check failure on line 17 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:9:1 › Issue a jwt credential

1) [chromium] › credential/issue-verify-flow.spec.ts:9:1 › Issue a jwt credential ─────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: 200 Received: 403 15 | }); 16 | expect(response).toBeOK(); > 17 | expect(response.status()).toBe(StatusCodes.OK); | ^ 18 | }); 19 | 20 | test(' Issue a jsonLD credential', async ({ request }) => { at /home/runner/work/credential-service/credential-service/tests/credential/issue-verify-flow.spec.ts:17:28

Check failure on line 17 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:9:1 › Issue a jwt credential

1) [chromium] › credential/issue-verify-flow.spec.ts:9:1 › Issue a jwt credential ─────────────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: 200 Received: 500 15 | }); 16 | expect(response).toBeOK(); > 17 | expect(response.status()).toBe(StatusCodes.OK); | ^ 18 | }); 19 | 20 | test(' Issue a jsonLD credential', async ({ request }) => { at /home/runner/work/credential-service/credential-service/tests/credential/issue-verify-flow.spec.ts:17:28

Check failure on line 17 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:9:1 › Issue a jwt credential

1) [chromium] › credential/issue-verify-flow.spec.ts:9:1 › Issue a jwt credential ─────────────── Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(received).toBe(expected) // Object.is equality Expected: 200 Received: 500 15 | }); 16 | expect(response).toBeOK(); > 17 | expect(response.status()).toBe(StatusCodes.OK); | ^ 18 | }); 19 | 20 | test(' Issue a jsonLD credential', async ({ request }) => { at /home/runner/work/credential-service/credential-service/tests/credential/issue-verify-flow.spec.ts:17:28
});

test(' Issue a jsonLD credential', async ({ request }) => {
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);
});
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 bc264e2

Please sign in to comment.