test edge case
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Timo Hocker 2020-12-06 21:29:11 +01:00
parent 0be180f632
commit ddde2806d8
2 changed files with 12 additions and 0 deletions

View File

@ -11,6 +11,10 @@ class KeyStore {
return this._keys[key];
if (valid_for !== 0) {
if ((iat + valid_for) * 1000 < (new Date)
.getTime ())
throw new Error ('cannot create already expired keys');
this._keys[key] = create_salt ();
setTimeout (() => {
delete this._keys[key];

View File

@ -79,6 +79,14 @@ describe ('key store', () => {
.toEqual (keys[1].key);
});
it ('should reject key generation of expired keys', () => {
const iat = ((new Date)
.getTime () / 1000) - 10;
const duration = 5;
expect (() => ks.get_key (iat, duration))
.toThrowError ('cannot create already expired keys');
});
afterAll (() => {
jasmine.clock ()
.uninstall ();