Skip to content

Commit

Permalink
add bistring status with VCv2 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jchartrand committed Aug 31, 2024
1 parent 1ad03a4 commit 9ab02b8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
17 changes: 15 additions & 2 deletions src/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import {
import {
ed25519_2020suiteContext,
getCredentialStatus,
getCredentialStatusBitString,
getUnsignedVC,
getUnsignedVCv2,
getUnsignedVCWithStatus,
getUnsignedVC2WithStatus,
getUnsignedVCWithoutSuiteContext
} from './test-fixtures/vc.js'

Expand Down Expand Up @@ -90,7 +91,7 @@ describe('api', () => {
})

it('returns the submitted vc version 2, signed with test key', async () => {
const sentCred = getUnsignedVCv2()
const sentCred = getUnsignedVC2WithStatus()
const response = await request(app)
.post('/instance/testing/credentials/sign')
.send(sentCred)
Expand Down Expand Up @@ -155,7 +156,19 @@ describe('api', () => {
expect(response.status).to.eql(200)
expect(response.body.credentialStatus).to.eql(statusBeforeSigning)
})

it('leaves an existing bitstring credential status as-is with v2', async () => {
const statusBeforeSigning = getCredentialStatusBitString()
const response = await request(app)
.post('/instance/testing/credentials/sign')
.send(getUnsignedVC2WithStatus())

expect(response.header['content-type']).to.have.string('json')
expect(response.status).to.eql(200)
expect(response.body.credentialStatus).to.eql(statusBeforeSigning)
})
})

describe('DID:web', () => {
const tenantName = 'apptest'

Expand Down
30 changes: 24 additions & 6 deletions src/test-fixtures/vc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const usignedVCv2 = {
'@context': [
'https://www.w3.org/ns/credentials/v2',
'https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json',
'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',
Expand Down Expand Up @@ -41,7 +41,7 @@ const usignedVCv2 = {
const unsignedVC = {
'@context': [
'https://www.w3.org/2018/credentials/v1',
'https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.2.json',
'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'
],
Expand Down Expand Up @@ -89,7 +89,17 @@ const credentialStatus = {
'https://digitalcredentials.github.io/credential-status-jc-test/XA5AAK1PV4'
}

const credentialStatusBitString = {
id: 'https://digitalcredentials.github.io/credential-status-jc-test/XA5AAK1PV4#16',
type: 'BitstringStatusListEntry',
statusPurpose: 'revocation',
statusListIndex: 16,
statusListCredential:
'https://digitalcredentials.github.io/credential-status-jc-test/XA5AAK1PV4'
}

const getUnsignedVC = () => JSON.parse(JSON.stringify(unsignedVC))

const getUnsignedVCv2 = () => JSON.parse(JSON.stringify(usignedVCv2))

const getUnsignedVCWithoutSuiteContext = () => {
Expand All @@ -101,22 +111,30 @@ const getUnsignedVCWithoutSuiteContext = () => {
return vcCopy
}
const getCredentialStatus = () => JSON.parse(JSON.stringify(credentialStatus))
const getCredentialStatusBitString = () =>
JSON.parse(JSON.stringify(credentialStatusBitString))

const getUnsignedVCWithStatus = () => {
const unsignedVCWithStatus = getUnsignedVC()
unsignedVCWithStatus.credentialStatus = getCredentialStatus()
return unsignedVCWithStatus
}

const getUnsignedVC2WithStatus = () => {
const unsignedVC2WithStatus = getUnsignedVCv2()
unsignedVC2WithStatus.credentialStatus = getCredentialStatusBitString()
return unsignedVC2WithStatus
}

const ed25519_2020suiteContext =
'https://w3id.org/security/suites/ed25519-2020/v1'
const statusListContext = 'https://w3id.org/vc/status-list/2021/v1'

export {
getUnsignedVC,
getUnsignedVCv2,
getUnsignedVCWithoutSuiteContext,
getCredentialStatus,
getCredentialStatusBitString,
getUnsignedVCWithStatus,
ed25519_2020suiteContext,
statusListContext
getUnsignedVC2WithStatus,
ed25519_2020suiteContext
}

0 comments on commit 9ab02b8

Please sign in to comment.