Add a route to kill tunnel if open with same JWT token

This commit is contained in:
Olivier MICHAUD
2021-05-19 22:28:42 +02:00
parent 1371d03fec
commit 1204fdf99a
5 changed files with 117 additions and 12 deletions
+8 -8
View File
@@ -11,22 +11,22 @@ describe('ClientManager', () => {
it('should create a new client with random id', async () => {
const manager = new ClientManager();
const client = await manager.newClient();
const client = await manager.newClient(null, null);
assert(manager.hasClient(client.id));
manager.removeClient(client.id);
});
it('should create a new client with id', async () => {
const manager = new ClientManager();
const client = await manager.newClient('foobar');
const client = await manager.newClient('foobar', null);
assert(manager.hasClient('foobar'));
manager.removeClient('foobar');
});
it('should create a new client with random id if previous exists', async () => {
const manager = new ClientManager();
const clientA = await manager.newClient('foobar');
const clientB = await manager.newClient('foobar');
const clientA = await manager.newClient('foobar', null);
const clientB = await manager.newClient('foobar', null);
assert(clientA.id, 'foobar');
assert(manager.hasClient(clientB.id));
assert(clientB.id != clientA.id);
@@ -36,7 +36,7 @@ describe('ClientManager', () => {
it('should remove client once it goes offline', async () => {
const manager = new ClientManager();
const client = await manager.newClient('foobar');
const client = await manager.newClient('foobar', null);
const socket = await new Promise((resolve) => {
const netClient = net.createConnection({ port: client.port }, () => {
@@ -57,8 +57,8 @@ describe('ClientManager', () => {
it('should remove correct client once it goes offline', async () => {
const manager = new ClientManager();
const clientFoo = await manager.newClient('foo');
const clientBar = await manager.newClient('bar');
const clientFoo = await manager.newClient('foo', null);
const clientBar = await manager.newClient('bar', null);
const socket = await new Promise((resolve) => {
const netClient = net.createConnection({ port: clientFoo.port }, () => {
@@ -80,7 +80,7 @@ describe('ClientManager', () => {
it('should remove clients if they do not connect within 5 seconds', async () => {
const manager = new ClientManager();
const clientFoo = await manager.newClient('foo');
const clientFoo = await manager.newClient('foo', null);
assert(manager.hasClient('foo'));
// wait past grace period (1s)