Skip to content

Commit

Permalink
reorganize test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Jan 9, 2025
1 parent 9798dfb commit e5bafe7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 106 deletions.
130 changes: 27 additions & 103 deletions src/test-fixtures/vc.ts
Original file line number Diff line number Diff line change
@@ -1,106 +1,29 @@
import { expiredV2 } from "./expiredV2"
import { signedUnrevokedVC1 } from "./signedUnrevokedVC1"
import { signedVC1 } from "./signedVC1"
import { v2Expired } from "./verifiableCredentials/v2/v2Expired"

Check failure on line 1 in src/test-fixtures/vc.ts

View workflow job for this annotation

GitHub Actions / test-node (18.x)

Module '"./verifiableCredentials/v2/v2Expired"' has no exported member 'v2Expired'.

Check failure on line 1 in src/test-fixtures/vc.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

Module '"./verifiableCredentials/v2/v2Expired"' has no exported member 'v2Expired'.

Check failure on line 1 in src/test-fixtures/vc.ts

View workflow job for this annotation

GitHub Actions / test-karma (18.x)

Module '"./verifiableCredentials/v2/v2Expired"' has no exported member 'v2Expired'.
import { v1WithValidStatus } from "./verifiableCredentials/v1/v1WithValidStatus"
import { v1NoStatus } from "./verifiableCredentials/v1/v1NoStatus"

const usignedVCv2 = {
'@context': [
'https://www.w3.org/ns/credentials/v2',
'https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json',
'https://w3id.org/security/suites/ed25519-2020/v1'
],
id: 'urn:uuid:2fe53dc9-b2ec-4939-9b2c-0d00f6663b6c',
type: ['VerifiableCredential', 'OpenBadgeCredential'],
name: 'DCC Test Credential',
issuer: {
type: ['Profile'],
id: 'did:key:z6MkhVTX9BF3NGYX6cc7jWpbNnR7cAjH8LUffabZP8Qu4ysC',
name: 'Digital Credentials Consortium Test Issuer',
url: 'https://dcconsortium.org',
image:
'https://user-images.githubusercontent.com/752326/230469660-8f80d264-eccf-4edd-8e50-ea634d407778.png'
},
validFrom: '2023-08-02T17:43:32.903Z',
credentialSubject: {
type: ['AchievementSubject'],
achievement: {
id: 'urn:uuid:bd6d9316-f7ae-4073-a1e5-2f7f5bd22922',
type: ['Achievement'],
achievementType: 'Diploma',
name: 'Badge',
description:
'This is a sample credential issued by the Digital Credentials Consortium to demonstrate the functionality of Verifiable Credentials for wallets and verifiers.',
criteria: {
type: 'Criteria',
narrative:
'This credential was issued to a student that demonstrated proficiency in the Python programming language that occurred from **February 17, 2023** to **June 12, 2023**.'
},
image: {
id: 'https://user-images.githubusercontent.com/752326/214947713-15826a3a-b5ac-4fba-8d4a-884b60cb7157.png',
type: 'Image'
}
},
name: 'Jane Doe'
}
}
const unsignedVCv1 = {
'@context': [
'https://www.w3.org/2018/credentials/v1',
'https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json',
'https://w3id.org/vc/status-list/2021/v1',
'https://w3id.org/security/suites/ed25519-2020/v1'
],
id: 'urn:uuid:951b475e-b795-43bc-ba8f-a2d01efd2eb1',
type: ['VerifiableCredential', 'OpenBadgeCredential'],
issuer: {
id: 'did:key:z6MkhVTX9BF3NGYX6cc7jWpbNnR7cAjH8LUffabZP8Qu4ysC',
type: 'Profile',
name: 'Izzy the Issuer',
description: 'Issue Issue Issue',
url: 'https://izzy.iz/',
image: {
id: 'https://upload.wikimedia.org/wikipedia/commons/a/ad/Blank_2018.png',
type: 'Image'
}
},
issuanceDate: '2020-01-01T00:00:00Z',
name: 'Introduction to Digital Credentialing',
credentialSubject: {
type: 'AchievementSubject',
identifier: {
type: 'IdentityObject',
identityHash: '[email protected]',
hashed: 'false'
},
achievement: {
id: 'http://izzy.iz',
type: 'Achievement',
criteria: {
narrative: 'Completion of a credential.'
},
description: 'Well done you!',
name: 'Introduction to Digital Credentialing'
}
}
const getVCv1 = (): any => {
return JSON.parse(JSON.stringify(v1NoStatus))
}

const getVCv2NoProof = (): any => {
// TODO
}




const getUnsignedVC1 = (): any => JSON.parse(JSON.stringify(unsignedVCv1))
const getUnsignedVCv2 = (): any => JSON.parse(JSON.stringify(usignedVCv2))

const getVCv1NoProof = (): any => {
const v1 = getVCv1()
delete v1.proof
return v1}

const getSignedVC1 = (): any => {
return JSON.parse(JSON.stringify(signedVC1))
return JSON.parse(JSON.stringify(v1NoStatus))
}


const getSignedUnrevokedVC2 = (): any => {
return signedUnrevokedVC1
const getVCv1ValidStatus = (): any => {
return v1WithValidStatus
}

const getTamperedVC1 = (): any => {
const getVCv1Tampered = (): any => {
const signedVC1 = getSignedVC1()
signedVC1.name = 'Introduction to Tampering'
return signedVC1
Expand All @@ -109,21 +32,22 @@ const getTamperedVC1 = (): any => {
const getExpiredVC1 = (): any => {
return null
}
const getExpiredVC2 = (): any => {
return JSON.parse(JSON.stringify(expiredV2))
const getVCv2Expired = (): any => {
return JSON.parse(JSON.stringify(v2Expired))
}

const getExpiredAndTamperedVC2 = (): any => {
const cred = getExpiredVC2()
const getVCv2ExpiredAndTampered = (): any => {
const cred = getVCv2Expired()
cred.name = 'tampered!'
return cred
}

export {
getExpiredVC2,
getExpiredAndTamperedVC2,
getTamperedVC1,
getSignedUnrevokedVC2,
getSignedVC1,
getUnsignedVC1
getVCv2Expired,
getVCv2ExpiredAndTampered,
getVCv1Tampered,
getVCv1ValidStatus,
getVCv1,
getVCv1NoProof,
getVCv2NoProof
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const signedVC1 = {
export const v1NoStatus = {
'@context': [
'https://www.w3.org/2018/credentials/v1',
'https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const signedUnrevokedVC1 = {
export const v1WithValidStatus = {
"type": [
"VerifiableCredential",
"OpenBadgeCredential"
Expand Down Expand Up @@ -50,5 +50,5 @@ export const signedUnrevokedVC1 = {
"proofPurpose": "assertionMethod",
"proofValue": "z38x1N8hFFXEQgfomjv1MvP32qqtqzx4sGQAyqqfDGXqLBcw39jKBQvcwWeiVJrqtxZJmu8RZ5DPUrrAc36ejoPyE"
}
}
}

File renamed without changes.

0 comments on commit e5bafe7

Please sign in to comment.