diff --git a/tests/credential/issue-verify-flow.spec.ts b/tests/credential/issue-verify-flow.spec.ts new file mode 100644 index 00000000..c82f8c2e --- /dev/null +++ b/tests/credential/issue-verify-flow.spec.ts @@ -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); +}); + +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); +}); diff --git a/tests/payloads/credential/credential-issue-jsonld.json b/tests/payloads/credential/credential-issue-jsonld.json new file mode 100644 index 00000000..0ff172c0 --- /dev/null +++ b/tests/payloads/credential/credential-issue-jsonld.json @@ -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" +} diff --git a/tests/payloads/credential/credential-issue-jwt.json b/tests/payloads/credential/credential-issue-jwt.json new file mode 100644 index 00000000..e4306e12 --- /dev/null +++ b/tests/payloads/credential/credential-issue-jwt.json @@ -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" +}