fix
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Timo Hocker 2022-09-09 15:53:38 +02:00
parent 64d4f00629
commit 6eb2009141
No known key found for this signature in database
GPG Key ID: 3B86485AC71C835C
2 changed files with 14 additions and 9 deletions

View File

@ -6,7 +6,7 @@
*/
import blacklist, { Blacklist } from '../../lib/Blacklist';
import { generate_token_id, parse_token_id } from '../../lib/token_id';
import { generate_token_id } from '../../lib/token_id';
import { clock_finalize, clock_setup } from '../Helper';
// eslint-disable-next-line max-lines-per-function

View File

@ -10,6 +10,7 @@
import { blacklist } from '../../lib';
import ks from '../../lib/KeyStore';
import { Redis } from '../../lib/Redis';
import { generate_token_id } from '../../lib/token_id';
import { clock_finalize, clock_setup } from '../Helper';
const frame = 3600;
@ -19,6 +20,10 @@ redis.connect (redis_url);
// eslint-disable-next-line max-lines-per-function
describe ('redis', () => {
const token1 = generate_token_id (new Date (Date.now () + 3600000));
const token2 = generate_token_id (new Date (Date.now () + 3600000));
const token3 = generate_token_id (new Date (Date.now () + 3600000));
beforeAll (async () => {
ks.reset_instance ();
ks.sync_redis (redis_url);
@ -80,26 +85,26 @@ describe ('redis', () => {
});
it ('should add two keys to the blacklist', async () => {
await blacklist.add_signature ('test');
await blacklist.add_signature ('foo');
await blacklist.add_signature (token1);
await blacklist.add_signature (token2);
});
it ('should have two keys in redis blacklist', async () => {
expect ((await redis['_redis']?.sismember ('blacklist', 'test')) === 1)
expect ((await redis['_redis']?.exists (`blacklist_${token1}`)) === 1)
.toBeTrue ();
expect ((await redis['_redis']?.sismember ('blacklist', 'foo')) === 1)
expect ((await redis['_redis']?.exists (`blacklist_${token2}`)) === 1)
.toBeTrue ();
expect ((await redis['_redis']?.sismember ('blacklist', 'bar')) === 1)
expect ((await redis['_redis']?.exists (`blacklist_${token3}`)) === 1)
.toBeFalse ();
});
it ('should read keys from redis', async () => {
blacklist['_signatures'].splice (0, blacklist['_signatures'].length);
expect (await blacklist.is_valid ('test'))
expect (await blacklist.is_valid (token1))
.toBeFalse ();
expect (await blacklist.is_valid ('foo'))
expect (await blacklist.is_valid (token2))
.toBeFalse ();
expect (await blacklist.is_valid ('bar'))
expect (await blacklist.is_valid (token3))
.toBeTrue ();
});
});