-
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
81a14f8
commit e842826
Showing
4 changed files
with
190 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
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,72 @@ | ||
import type { VerifiableCredential } from '@veramo/core'; | ||
|
||
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 jwtCredential: VerifiableCredential; | ||
|
||
test(' Issue a jwt credential with revocation statuslist', async ({ request }) => { | ||
const credentialData = JSON.parse( | ||
fs.readFileSync(`${PAYLOADS_BASE_PATH}/credential-issue-jwt-revocation.json`, 'utf-8') | ||
); | ||
const response = await request.post(`/credential/issue`, { | ||
data: JSON.stringify(credentialData), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
jwtCredential = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
expect(jwtCredential.proof.type).toBe('JwtProof2020'); | ||
}); | ||
|
||
test(" Verify a credential's revocation status", async ({ request }) => { | ||
const response = await request.post(`/credential/verify?verifyStatus=true`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
}), | ||
headers: { | ||
'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 credential status after revocation', async ({ request }) => { | ||
const response = await request.post(`/credential/revoke?publish=true`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const result = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
expect(result.revoked).toBe(true); | ||
|
||
const verificationResponse = await request.post(`/credential/verify?verifyStatus=true`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const verificationResult = await response.json(); | ||
expect(verificationResponse).toBeOK(); | ||
expect(verificationResponse.status()).toBe(StatusCodes.OK); | ||
expect(verificationResult.verified).toBe(true); | ||
expect(result.revoked).toBe(true); | ||
}); |
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,103 @@ | ||
import type { VerifiableCredential } from '@veramo/core'; | ||
|
||
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 jwtCredential: VerifiableCredential; | ||
|
||
test(' Issue a jwt credential with suspension statuslist', async ({ request }) => { | ||
const credentialData = JSON.parse( | ||
fs.readFileSync(`${PAYLOADS_BASE_PATH}/credential-issue-jwt-revocation.json`, 'utf-8') | ||
); | ||
credentialData.credentialStatus.statusPurpose = 'suspension'; | ||
const response = await request.post(`/credential/issue`, { | ||
data: JSON.stringify(credentialData), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
jwtCredential = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
expect(jwtCredential.proof.type).toBe('JwtProof2020'); | ||
}); | ||
|
||
test(" Verify a credential's suspension status", async ({ request }) => { | ||
const response = await request.post(`/credential/verify`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
verifyStatus: true, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const result = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
Check failure on line 42 in tests/credential/suspension-flow.spec.ts GitHub Actions / Build & Test / Build Node.js[chromium] › credential/suspension-flow.spec.ts:30:1 › Verify a credential's suspension status
Check failure on line 42 in tests/credential/suspension-flow.spec.ts GitHub Actions / Build & Test / Build Node.js[chromium] › credential/suspension-flow.spec.ts:30:1 › Verify a credential's suspension status
|
||
expect(result.verified).toBe(true); | ||
expect(result.suspended).toBe(false); | ||
Check failure on line 44 in tests/credential/suspension-flow.spec.ts GitHub Actions / Build & Test / Build Node.js[chromium] › credential/suspension-flow.spec.ts:30:1 › Verify a credential's suspension status
|
||
}); | ||
|
||
test(' Verify a credential status after suspension', async ({ request }) => { | ||
const response = await request.post(`/credential/suspend?publish=true`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const result = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
expect(result.suspended).toBe(true); | ||
|
||
const verificationResponse = await request.post(`/credential/verify?verifyStatus=true`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const verificationResult = await response.json(); | ||
expect(verificationResponse).toBeOK(); | ||
expect(verificationResponse.status()).toBe(StatusCodes.OK); | ||
expect(verificationResult.verified).toBe(true); | ||
expect(result.suspended).toBe(true); | ||
}); | ||
|
||
test(' Verify a credential status after reinstating', async ({ request }) => { | ||
const response = await request.post(`/credential/reinstate?publish=true`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const result = await response.json(); | ||
expect(response).toBeOK(); | ||
expect(response.status()).toBe(StatusCodes.OK); | ||
expect(result.suspended).toBe(false); | ||
|
||
const verificationResponse = await request.post(`/credential/verify?verifyStatus=true`, { | ||
data: JSON.stringify({ | ||
credential: jwtCredential, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}); | ||
const verificationResult = await response.json(); | ||
expect(verificationResponse).toBeOK(); | ||
expect(verificationResponse.status()).toBe(StatusCodes.OK); | ||
expect(verificationResult.verified).toBe(true); | ||
expect(result.suspended).toBe(false); | ||
}); |
15 changes: 15 additions & 0 deletions
15
tests/payloads/credential/credential-issue-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,15 @@ | ||
{ | ||
"issuerDid": "did:cheqd:testnet:4JdgsZ4A8LegKXdsKE3v6X", | ||
"subjectDid": "did:key:z6MkqJNR1DHxX2qxqDYx9tNDsXoNRVpaVvJkLPeCYqaARz1n", | ||
"attributes": { | ||
"gender": "male", | ||
"name": "Bob" | ||
}, | ||
"@context": ["https://schema.org"], | ||
"type": ["Person"], | ||
"format": "jwt", | ||
"credentialStatus": { | ||
"statusPurpose": "revocation", | ||
"statusListName": "testingstatuslist" | ||
} | ||
} |