Skip to content

Commit

Permalink
Move 2 validFrom & 2 validUntil issuer tests to issuer section.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed Nov 27, 2023
1 parent d9d7ba4 commit 3f5cded
Showing 1 changed file with 58 additions and 56 deletions.
114 changes: 58 additions & 56 deletions test/10-verify.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,64 @@ for(const [version, mockCredential] of versionedCredentials) {
error.message.should
.contain('"suite.verificationMethod" property is required.');
});
if(version === 2.0) {
it('should issue "validUntil" in the future', () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validUntil = '2025-10-31T19:21:25Z';
const now = '2022-06-30T19:21:25Z';
let error;
try {
vc.issue({credential, now});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing "validUntil" in future');
});
it('should issue "validUntil" in the past', () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validUntil = '2025-10-31T19:21:25Z';
const now = '2022-06-30T19:21:25Z';
let error;
try {
vc.issue({credential, now});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing with "validUntil" in past');
});
it('should issue "validFrom" in the past', () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validFrom = '2022-06-30T19:21:25Z';
const now = '2022-10-30T19:21:25Z';
let error;
try {
vc.issue({credential, now});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing "validFrom" in past');
});
it('should issue "validFrom" in the future', () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validFrom = '2022-10-30T19:21:25Z';
const now = '2022-06-30T19:21:25Z';
let error;
try {
vc.issue({credential, now});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing "validFrom" in future');
});
}
});

describe('vc.createPresentation()', () => {
Expand Down Expand Up @@ -649,34 +707,6 @@ for(const [version, mockCredential] of versionedCredentials) {
});
}
if(version === 2.0) {
it('should issue "validFrom" in the past', () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validFrom = '2022-06-30T19:21:25Z';
const now = '2022-10-30T19:21:25Z';
let error;
try {
vc._checkCredential({credential, now});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing "validFrom" in past');
});
it('should issue "validFrom" in the future', () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validFrom = '2022-10-30T19:21:25Z';
const now = '2022-06-30T19:21:25Z';
let error;
try {
vc._checkCredential({credential, now});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing "validFrom" in future');
});
it('should NOT verify "validFrom" in the future', () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
Expand Down Expand Up @@ -705,34 +735,6 @@ for(const [version, mockCredential] of versionedCredentials) {
should.not.exist(error,
'Should not throw error when "validFrom" in past');
});
it('should issue "validUntil" in the future', () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validUntil = '2025-10-31T19:21:25Z';
const now = '2022-06-30T19:21:25Z';
let error;
try {
vc._checkCredential({credential, now});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing "validUntil" in future');
});
it('should issue "validUntil" in the past', () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
credential.validUntil = '2025-10-31T19:21:25Z';
const now = '2022-06-30T19:21:25Z';
let error;
try {
vc._checkCredential({credential, now});
} catch(e) {
error = e;
}
should.not.exist(error,
'Should not throw error when issuing with "validUntil" in past');
});
it('should NOT verify if "validUntil" in the past', () => {
const credential = jsonld.clone(mockCredential);
credential.issuer = 'did:example:12345';
Expand Down

0 comments on commit 3f5cded

Please sign in to comment.