diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-10 09:23:18 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-10 09:23:18 +0200 |
commit | 31b6ddf86652502e0c96d77fa10861ce4af11aa4 (patch) | |
tree | b94402972945699134b2a504af5d551124f0bf54 /server/tests/api | |
parent | 22834691abb6e74d31654ffd2ebeaaaa8ef3ac7b (diff) | |
download | PeerTube-31b6ddf86652502e0c96d77fa10861ce4af11aa4.tar.gz PeerTube-31b6ddf86652502e0c96d77fa10861ce4af11aa4.tar.zst PeerTube-31b6ddf86652502e0c96d77fa10861ce4af11aa4.zip |
Add ability to disable tracker
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/server/tracker.ts | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts index 25ca00029..41803aef1 100644 --- a/server/tests/api/server/tracker.ts +++ b/server/tests/api/server/tracker.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import * as magnetUtil from 'magnet-uri' | 3 | import * as magnetUtil from 'magnet-uri' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { getVideo, killallServers, runServer, ServerInfo, uploadVideo } from '../../../../shared/utils' | 5 | import { getVideo, killallServers, reRunServer, runServer, ServerInfo, uploadVideo } from '../../../../shared/utils' |
6 | import { flushTests, setAccessTokensToServers } from '../../../../shared/utils/index' | 6 | import { flushTests, setAccessTokensToServers } from '../../../../shared/utils/index' |
7 | import { VideoDetails } from '../../../../shared/models/videos' | 7 | import { VideoDetails } from '../../../../shared/models/videos' |
8 | import * as WebTorrent from 'webtorrent' | 8 | import * as WebTorrent from 'webtorrent' |
@@ -34,7 +34,7 @@ describe('Test tracker', function () { | |||
34 | } | 34 | } |
35 | }) | 35 | }) |
36 | 36 | ||
37 | it('Should return an error when adding an incorrect infohash', done => { | 37 | it('Should return an error when adding an incorrect infohash', function (done) { |
38 | this.timeout(10000) | 38 | this.timeout(10000) |
39 | const webtorrent = new WebTorrent() | 39 | const webtorrent = new WebTorrent() |
40 | 40 | ||
@@ -49,7 +49,7 @@ describe('Test tracker', function () { | |||
49 | torrent.on('done', () => done(new Error('No error on infohash'))) | 49 | torrent.on('done', () => done(new Error('No error on infohash'))) |
50 | }) | 50 | }) |
51 | 51 | ||
52 | it('Should succeed with the correct infohash', done => { | 52 | it('Should succeed with the correct infohash', function (done) { |
53 | this.timeout(10000) | 53 | this.timeout(10000) |
54 | const webtorrent = new WebTorrent() | 54 | const webtorrent = new WebTorrent() |
55 | 55 | ||
@@ -64,6 +64,26 @@ describe('Test tracker', function () { | |||
64 | torrent.on('done', done) | 64 | torrent.on('done', done) |
65 | }) | 65 | }) |
66 | 66 | ||
67 | it('Should disable the tracker', function (done) { | ||
68 | this.timeout(20000) | ||
69 | |||
70 | killallServers([ server ]) | ||
71 | reRunServer(server, { tracker: { enabled: false } }) | ||
72 | .then(() => { | ||
73 | const webtorrent = new WebTorrent() | ||
74 | |||
75 | const torrent = webtorrent.add(goodMagnet) | ||
76 | |||
77 | torrent.on('error', done) | ||
78 | torrent.on('warning', warn => { | ||
79 | const message = typeof warn === 'string' ? warn : warn.message | ||
80 | if (message.indexOf('disabled ') !== -1) return done() | ||
81 | }) | ||
82 | |||
83 | torrent.on('done', () => done(new Error('Tracker is enabled'))) | ||
84 | }) | ||
85 | }) | ||
86 | |||
67 | after(async function () { | 87 | after(async function () { |
68 | killallServers([ server ]) | 88 | killallServers([ server ]) |
69 | }) | 89 | }) |