function timeout
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-12-13 13:31:48 +01:00
parent 4d6e028fca
commit 142e9ec458
3 changed files with 36 additions and 6 deletions

View File

@ -174,6 +174,14 @@ describe ('crypto helper', () => {
.toEqual (dec);
});
it ('should verify signature using function retrieved timeout 0', () => {
const obj = { foo: 'bar' };
const str = crypto.sign_object (obj, 'baz');
const dec = crypto.verify_signature (str, 'baz', () => 0);
expect (obj)
.toEqual (dec);
});
it ('should reject tampered signatures', () => {
const obj = { foo: 'bar' };
const str = crypto.sign_object (obj, 'baz');
@ -254,6 +262,27 @@ describe ('crypto helper', () => {
.uninstall ();
});
it ('should verify signature using function retrieved timeout', () => {
jasmine.clock ()
.install ();
const base_time = (new Date);
jasmine.clock ()
.mockDate (base_time);
const obj = { foo: 'bar' };
const str = crypto.sign_object (obj, 'baz', { to: 100 });
jasmine.clock ()
.tick (50);
const dec = crypto.verify_signature (str, 'baz', (info) => info.to);
expect (obj)
.toEqual (dec);
jasmine.clock ()
.uninstall ();
});
it ('verify_signature on almost timed out packet', () => {
jasmine.clock ()
.install ();