update dependencies
[websub-hub] / test-e2e / test-one.js
1 'use strict';
2
3 const assert = require('assert');
4 const uuid = require('uuid');
5 const FakeServersClient = require('./fake-servers-client');
6
7 const subscriberPort = process.env.FAKE_SUBSCRIBER_PORT || 9876;
8 const topicPort = process.env.FAKE_TOPIC_PORT || 9875;
9 const listenAddress = process.env.FAKE_LISTEN_ADDR || '127.0.0.1';
10 const hubAddress = process.env.LISTEN_ADDR || '127.0.0.1';
11 const hubPort = process.env.PORT || 4001;
12 const hubUrl = `http://${hubAddress}:${hubPort}/`;
13
14 const client = new FakeServersClient(listenAddress, subscriberPort, topicPort);
15
16 async function newTopic() {
17 const id = uuid.v4();
18 await client.topicSet(id, { hubUrl });
19 console.log('created fake topic', id);
20 return id;
21 }
22
23 async function newSubscriber() {
24 const id = uuid.v4();
25 await client.subscriberSetVerify(id);
26 console.log('created fake subscriber', id);
27 return id;
28 }
29
30 (async function main() {
31 const topicId = await newTopic();
32 const subscriberId = await newSubscriber();
33
34 const result = await client.subscribe(hubUrl, subscriberId, topicId);
35 console.log('subscribed', { status: result.status, headers: result.headers, data: result.data });
36
37 console.log('done');
38 })().catch((e) => {
39 console.log(e);
40 throw e;
41 });