Skip to content

Commit

Permalink
Add a getSlc helper function.
Browse files Browse the repository at this point in the history
  • Loading branch information
JSAssassin committed May 13, 2022
1 parent f8575d1 commit ee262df
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
41 changes: 17 additions & 24 deletions tests/10-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
'use strict';

const chai = require('chai');
const {createValidVc} = require('./helpers.js');
const documentLoader = require('./documentLoader.js');
const {createValidVc, getSlc} = require('./helpers.js');
const {filterByTag} = require('vc-api-test-suite-implementations');
const sl = require('@digitalbazaar/vc-status-list');
const {testCredential, testSlCredential} = require('./assertions.js');
Expand Down Expand Up @@ -50,29 +49,23 @@ describe('StatusList2021 Credentials (Issue)', function() {
testCredential({credential: issuedVc});
issuedVc.credentialSubject.should.eql(validVc.credentialSubject);
});
describe('Check SLC Properties', function() {
let slc;
before(async function() {
const {credentialStatus: {statusListCredential}} = issuedVc;
const {document} = await documentLoader(statusListCredential);
slc = document;
});
// ensure that issued StatusList Credential contain correct properties
it('MUST have correct properties when dereferencing' +
// ensure that issued StatusList Credential contain correct properties
it('MUST have correct properties when dereferencing' +
'"credentialStatus.statusListCredential"', async function() {
this.test.cell = {columnId: issuerName, rowId: this.test.title};
testSlCredential({slCredential: slc});
});
it('Size of decoded "encodedList" MUST be 16kb', async function() {
const {credentialSubject} = slc;
const {encodedList} = credentialSubject;
// Uncompress encodedList
const decoded = await sl.decodeList({encodedList});
should.exist(decoded);
// decoded size should be 16kb
const decodedSize = (decoded.length / 8) / 1024;
decodedSize.should.equal(16);
});
this.test.cell = {columnId: issuerName, rowId: this.test.title};
const {slc} = await getSlc({issuedVc});
testSlCredential({slCredential: slc});
});
it('Size of decoded "encodedList" MUST be 16kb', async function() {
this.test.cell = {columnId: issuerName, rowId: this.test.title};
const {slc: {credentialSubject}} = await getSlc({issuedVc});
const {encodedList} = credentialSubject;
// Uncompress encodedList
const decoded = await sl.decodeList({encodedList});
should.exist(decoded);
// decoded size should be 16kb
const decodedSize = (decoded.length / 8) / 1024;
decodedSize.should.equal(16);
});
});
}
Expand Down
8 changes: 8 additions & 0 deletions tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'use strict';

const {decodeList} = require('@digitalbazaar/vc-status-list');
const documentLoader = require('./documentLoader.js');
const {httpClient} = require('@digitalbazaar/http-client');
const https = require('https');
const {v4: uuidv4} = require('uuid');
Expand Down Expand Up @@ -50,8 +51,15 @@ const createValidVc = ({issuerId}) => ({
issuer: issuerId
});

const getSlc = async ({issuedVc}) => {
const {credentialStatus: {statusListCredential}} = issuedVc;
const {document} = await documentLoader(statusListCredential);
return {slc: document};
};

module.exports = {
createValidVc,
getCredentialStatus,
getSlc,
ISOTimeStamp
};

0 comments on commit ee262df

Please sign in to comment.