-
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
b4002fd
commit 8415ff5
Showing
5 changed files
with
138 additions
and
7 deletions.
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
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
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
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
119 changes: 119 additions & 0 deletions
119
tests/e2e/sequential/accreditation/suspension-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,119 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { StatusCodes } from 'http-status-codes'; | ||
import * as fs from 'fs'; | ||
import { CONTENT_TYPE, PAYLOADS_PATH } from '../../constants'; | ||
|
||
test.use({ storageState: 'playwright/.auth/user.json' }); | ||
|
||
const didUrl: string = `did:cheqd:testnet:5RpEg66jhhbmASWPXJRWrA?resourceName=suspensionAccreditation&resourceType=VerifiableAuthorisationForTrustChain`; | ||
const subjectDid: string = 'did:cheqd:testnet:15b74787-6e48-4fd5-8020-eab24e990578'; | ||
|
||
test(' Issue a jwt accreditation with suspension statuslist', async ({ request }) => { | ||
const payload = JSON.parse( | ||
fs.readFileSync(`${PAYLOADS_PATH.ACCREDITATION}/authorize-jwt-revocation.json`, 'utf-8') | ||
); | ||
payload.credentialStatus.statusPurpose = 'suspension'; | ||
payload.accreditationName = 'suspensionAccreditation'; | ||
const issueResponse = await request.post(`/trust-registry/accreditation/issue?accreditationType=authorize`, { | ||
data: JSON.stringify(payload), | ||
headers: { | ||
'Content-Type': CONTENT_TYPE.APPLICATION_JSON, | ||
}, | ||
}); | ||
const { didUrls, accreditation } = await issueResponse.json(); | ||
expect(didUrls).toContain(didUrl); | ||
expect(issueResponse.status()).toBe(StatusCodes.OK); | ||
expect(accreditation.proof.type).toBe('JwtProof2020'); | ||
expect(accreditation.proof).toHaveProperty('jwt'); | ||
expect(typeof accreditation.issuer === 'string' ? accreditation.issuer : accreditation.issuer.id).toBe( | ||
payload.issuerDid | ||
); | ||
expect(accreditation.type).toContain('VerifiableCredential'); | ||
expect(accreditation.credentialSubject.id).toBe(payload.subjectDid); | ||
expect(accreditation.credentialStatus).toMatchObject({ | ||
type: 'StatusList2021Entry', | ||
statusPurpose: 'suspension', | ||
}); | ||
expect(accreditation.credentialStatus).toHaveProperty('statusListIndex'); | ||
expect(accreditation.credentialStatus).toHaveProperty('id'); | ||
}); | ||
|
||
test(" Verify a Accreditation's suspension status", async ({ request }) => { | ||
const response = await request.post(`/trust-registry/accreditation/verify?verifyStatus=true`, { | ||
data: JSON.stringify({ | ||
didUrl, | ||
subjectDid, | ||
}), | ||
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.suspended).toBe(false); | ||
}); | ||
|
||
test(' Verify a credential status after suspension', async ({ request }) => { | ||
const response = await request.post(`/trust-registry/accreditation/suspend?publish=true`, { | ||
data: JSON.stringify({ | ||
didUrl, | ||
subjectDid, | ||
}), | ||
headers: { | ||
'Content-Type': CONTENT_TYPE.APPLICATION_JSON, | ||
}, | ||
}); | ||
const result = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
expect(result.suspended).toBe(true); | ||
expect(result.published).toBe(true); | ||
|
||
const verificationResponse = await request.post(`/trust-registry/accreditation/verify?verifyStatus=true`, { | ||
data: JSON.stringify({ | ||
didUrl, | ||
subjectDid, | ||
}), | ||
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.suspended).toBe(true); | ||
}); | ||
|
||
test(' Verify a accreditation status after reinstating', async ({ request }) => { | ||
const response = await request.post(`/trust-registry/accreditation/reinstate?publish=true`, { | ||
data: JSON.stringify({ | ||
didUrl, | ||
subjectDid, | ||
}), | ||
headers: { | ||
'Content-Type': CONTENT_TYPE.APPLICATION_JSON, | ||
}, | ||
}); | ||
const result = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
expect(result.unsuspended).toBe(true); | ||
|
||
const verificationResponse = await request.post(`/trust-registry/accreditation/verify?verifyStatus=true`, { | ||
data: JSON.stringify({ | ||
didUrl, | ||
subjectDid, | ||
}), | ||
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.suspended).toBe(false); | ||
}); |