diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f871b94..ca25bf3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,13 @@ name: Lint and Test -on: [push] +permissions: {} + +on: + push: + branches: ['**'] + schedule: + # check the implementation details on Thursdays; 3 days before test suites + - cron: 0 5 * * 4 jobs: lint: @@ -11,6 +18,8 @@ jobs: node-version: [20.x] steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: @@ -27,6 +36,8 @@ jobs: node-version: [20.x] steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v4 with: diff --git a/lib/main.js b/lib/main.js index 389d1c6..8145269 100644 --- a/lib/main.js +++ b/lib/main.js @@ -7,6 +7,8 @@ import {Implementation} from './Implementation.js'; import {implementerFiles} from '../implementations/index.js'; +export const rawImplementations = implementerFiles; + const keyValues = implementerFiles.map( implementation => [implementation.name, new Implementation(implementation)]); diff --git a/package.json b/package.json index 25756f1..8fa245d 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ }, "devDependencies": { "chai": "^4.3.3", + "chai-datetime": "^1.8.1", "cross-env": "^7.0.3", "eslint": "^8.19.0", "eslint-config-digitalbazaar": "^4.0.1", diff --git a/test/implementations.spec.js b/test/implementations.spec.js index 6ab86d2..f6170af 100644 --- a/test/implementations.spec.js +++ b/test/implementations.spec.js @@ -5,9 +5,11 @@ */ import chai from 'chai'; +import chaiDateTime from 'chai-datetime'; const should = chai.should(); +chai.use(chaiDateTime); -import {allImplementations} from '../lib/main.js'; +import {allImplementations, rawImplementations} from '../lib/main.js'; describe('Loading implementations', () => { it('should result in no errors.', async () => { @@ -31,7 +33,7 @@ describe('Loading implementations', () => { }); }); - verifiers.filter(isDidKeyFilter) + verifiers?.filter(isDidKeyFilter) .map(({settings: {id}}, index) => { describe(`verifier[${index}].id`, () => { it('should not specify a fragment', () => { @@ -42,4 +44,26 @@ describe('Loading implementations', () => { }); }); }); + + describe('Implementations using ZCAPs', () => { + rawImplementations.forEach(implementation => { + Object.keys(implementation) + .filter(key => Array.isArray(implementation[key])) + .forEach(implementationType => { + describe(`${implementation.name} - ${implementationType}`, () => { + implementation[implementationType] + ?.filter(({zcap}) => zcap?.capability) + .forEach(issuer => { + it(`ZCAP should not be expired for ${issuer.id}`, () => { + const expiration = JSON.parse(issuer.zcap.capability).expires; + const today = new Date(); + const nextMonth = new Date( + today.getFullYear(), today.getMonth() + 1, today.getDate()); + chai.expect(new Date(expiration)).to.be.afterDate(nextMonth); + }); + }); + }); + }); + }); + }); });