-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a73053
commit e3c63d4
Showing
3 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/e2e/payloads/accreditation/authorize-jwt-revocation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"issuerDid": "did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA", | ||
"subjectDid": "did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578", | ||
"@context": ["https://schema.org"], | ||
"type": ["Person"], | ||
"format": "jwt", | ||
"credentialStatus": { | ||
"statusPurpose": "revocation", | ||
"statusListName": "testingstatuslist" | ||
}, | ||
"schemas": [ | ||
{ | ||
"url": "https://schema.org/Learn", | ||
"type": "Learn" | ||
} | ||
], | ||
"accreditationName": "authorizeAccreditation", | ||
"trustFrameworkId": "https://learn.cheqd.io/governance/start", | ||
"trustFramework": "cheqd Governance Framework" | ||
} |
83 changes: 83 additions & 0 deletions
83
tests/e2e/sequential/accreditation/revocation-flow.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import type { VerifiableCredential } from '@veramo/core'; | ||
import * as fs from 'fs'; | ||
import { test, expect } from '@playwright/test'; | ||
import { StatusCodes } from 'http-status-codes'; | ||
import { CONTENT_TYPE, PAYLOADS_PATH } from '../../constants'; | ||
|
||
test.use({ storageState: 'playwright/.auth/user.json' }); | ||
|
||
let jwtCredential: VerifiableCredential; | ||
|
||
test(' Issue an Accreditation with revocation statuslist', async ({ request }) => { | ||
const payload = JSON.parse( | ||
fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorize-jwt-revocation.json`, 'utf-8') | ||
); | ||
const response = await request.post(`/trust-registry/accreditation/issue`, { | ||
data: JSON.stringify(payload), | ||
headers: { | ||
'Content-Type': CONTENT_TYPE.APPLICATION_JSON, | ||
}, | ||
}); | ||
jwtCredential = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
expect(jwtCredential.proof.type).toBe('JwtProof2020'); | ||
expect(jwtCredential.proof).toHaveProperty('jwt'); | ||
expect(typeof jwtCredential.issuer === 'string' ? jwtCredential.issuer : jwtCredential.issuer.id).toBe( | ||
payload.issuerDid | ||
); | ||
expect(jwtCredential.type).toContain('VerifiableCredential'); | ||
expect(jwtCredential.credentialSubject.id).toBe(payload.subjectDid); | ||
expect(jwtCredential.credentialStatus).toMatchObject({ | ||
type: 'StatusList2021Entry', | ||
statusPurpose: 'revocation', | ||
}); | ||
expect(jwtCredential.credentialStatus).toHaveProperty('statusListIndex'); | ||
expect(jwtCredential.credentialStatus).toHaveProperty('id'); | ||
}); | ||
|
||
test(" Verify a Accreditation's revocation status", async ({ request }) => { | ||
const response = await request.post(`/trust-registry/accreditation/verify?verifyStatus=true`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
}), | ||
headers: { | ||
'Content-Type': CONTENT_TYPE.APPLICATION_JSON, | ||
}, | ||
}); | ||
const result = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
expect(result.verified).toBe(true); | ||
expect(result.revoked).toBe(false); | ||
}); | ||
|
||
test(' Verify a Accreditation status after revocation', async ({ request }) => { | ||
const response = await request.post(`/trust-registry/accreditation/revoke?publish=true`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
}), | ||
headers: { | ||
'Content-Type': CONTENT_TYPE.APPLICATION_JSON, | ||
}, | ||
}); | ||
const result = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
expect(result.revoked).toBe(true); | ||
expect(result.published).toBe(true); | ||
|
||
const verificationResponse = await request.post(`/trust-registry/accreditation/verify?verifyStatus=true`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
}), | ||
headers: { | ||
'Content-Type': CONTENT_TYPE.APPLICATION_JSON, | ||
}, | ||
}); | ||
const verificationResult = await verificationResponse.json(); | ||
expect(verificationResponse).toBeOK(); | ||
expect(verificationResponse.status()).toBe(StatusCodes.OK); | ||
expect(verificationResult.verified).toBe(true); | ||
expect(verificationResult.revoked).toBe(true); | ||
}); |