This commit is contained in:
parent
0be180f632
commit
ddde2806d8
@ -11,6 +11,10 @@ class KeyStore {
|
|||||||
return this._keys[key];
|
return this._keys[key];
|
||||||
|
|
||||||
if (valid_for !== 0) {
|
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 ();
|
this._keys[key] = create_salt ();
|
||||||
setTimeout (() => {
|
setTimeout (() => {
|
||||||
delete this._keys[key];
|
delete this._keys[key];
|
||||||
|
@ -79,6 +79,14 @@ describe ('key store', () => {
|
|||||||
.toEqual (keys[1].key);
|
.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 (() => {
|
afterAll (() => {
|
||||||
jasmine.clock ()
|
jasmine.clock ()
|
||||||
.uninstall ();
|
.uninstall ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user