Skip to content

Commit 2dff48c

Browse files
committed
Update jws.test.js
1 parent 9b1ba42 commit 2dff48c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/signature/jws.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ describe('jws', () => {
5454
};
5555

5656
it('reconstructs the full JWS and verifies with allowed algorithm', () => {
57-
const { jws, headerB64 } = buildJws();
57+
const clock = sandbox.useFakeTimers(new Date('2024-01-01T00:00:00Z'));
58+
const currentIat = Math.floor(clock.now / 1000);
59+
const { jws, headerB64 } = buildJws({ iat: currentIat });
5860
const verifyStub = sandbox.stub(KJUR.jws.JWS, 'verify').returns(true);
5961

6062
const result = jwsVerify(jws, payload, publicKey, 60, [algo]);
@@ -64,7 +66,7 @@ describe('jws', () => {
6466
});
6567

6668
it('throws when JWS is malformed', () => {
67-
expect(() => jwsVerify('too.few.parts', payload, publicKey, 60, [algo])).to.throw('Invalid JWS header');
69+
expect(() => jwsVerify('onlytwo.parts', payload, publicKey, 60, [algo])).to.throw('Invalid JWS header');
6870
});
6971

7072
it('throws when algorithm is not permitted', () => {

0 commit comments

Comments
 (0)