Skip to content

Commit

Permalink
add web5-spec up to main (#851)
Browse files Browse the repository at this point in the history
* add web5-spec up to main

* comment out status list cred vectors

* remove status list cred test vector
  • Loading branch information
nitro-neal authored Aug 23, 2024
1 parent 2d0b423 commit 34590b2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
65 changes: 32 additions & 33 deletions packages/credentials/tests/status-list-credential.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { DidJwk } from '@web5/dids';
import { VerifiableCredential } from '../src/verifiable-credential.js';
import { StatusList2021Entry, StatusListCredential, StatusPurpose } from '../src/status-list-credential.js';

import StatusListCredentialsCreateTestVector from '../../../web5-spec/test-vectors/status_list_credentials/create.json' assert { type: 'json' };

describe('Status List Credential Tests', () => {
let issuerDid: BearerDid;
let holderDid: BearerDid;
Expand Down Expand Up @@ -234,35 +232,36 @@ describe('Status List Credential Tests', () => {
});
});

describe('Web5TestVectorsStatusListCredentials', () => {
it('create', async () => {
const vectors = StatusListCredentialsCreateTestVector.vectors;

for (const vector of vectors) {
const { input, output } = vector;

const vcWithCredStatus = await VerifiableCredential.create({
type : input.credential.type,
issuer : input.credential.issuer,
subject : input.credential.subject,
data : input.credential.credentialSubject,
credentialStatus : input.credential.credentialStatus
});

const statusListCred = StatusListCredential.create({
statusListCredentialId : input.statusListCredential.statusListCredentialId,
issuer : input.statusListCredential.issuer,
statusPurpose : input.statusListCredential.statusPurpose as StatusPurpose,
credentialsToDisable : [vcWithCredStatus]
});

expect(StatusListCredential.validateCredentialInStatusList(vcWithCredStatus, statusListCred)).to.be.true;

const statusListCredSubject = statusListCred.vcDataModel.credentialSubject as any;
expect(statusListCredSubject['type']).to.equal('StatusList2021');
expect(statusListCredSubject['statusPurpose']).to.equal(input.statusListCredential.statusPurpose);
expect(statusListCredSubject['encodedList']).to.equal(output.encodedList);
}
});
});
// TODO: Add tests for validateCredentialInStatusList once we create new vectors - https://github.com/TBD54566975/web5-spec/issues/169
// describe('Web5TestVectorsStatusListCredentials', () => {
// it('create', async () => {
// const vectors = StatusListCredentialsCreateTestVector.vectors;

// for (const vector of vectors) {
// const { input, output } = vector;

// const vcWithCredStatus = await VerifiableCredential.create({
// type : input.credential.type,
// issuer : input.credential.issuer,
// subject : input.credential.subject,
// data : input.credential.credentialSubject,
// credentialStatus : input.credential.credentialStatus
// });

// const statusListCred = StatusListCredential.create({
// statusListCredentialId : input.statusListCredential.statusListCredentialId,
// issuer : input.statusListCredential.issuer,
// statusPurpose : input.statusListCredential.statusPurpose as StatusPurpose,
// credentialsToDisable : [vcWithCredStatus]
// });

// expect(StatusListCredential.validateCredentialInStatusList(vcWithCredStatus, statusListCred)).to.be.true;

// const statusListCredSubject = statusListCred.vcDataModel.credentialSubject as any;
// expect(statusListCredSubject['type']).to.equal('StatusList2021');
// expect(statusListCredSubject['statusPurpose']).to.equal(input.statusListCredential.statusPurpose);
// expect(statusListCredSubject['encodedList']).to.equal(output.encodedList);
// }
// });
// });
});
2 changes: 1 addition & 1 deletion web5-spec

0 comments on commit 34590b2

Please sign in to comment.