aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/video-abuse.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/video-abuse.js')
-rw-r--r--server/tests/api/video-abuse.js193
1 files changed, 0 insertions, 193 deletions
diff --git a/server/tests/api/video-abuse.js b/server/tests/api/video-abuse.js
deleted file mode 100644
index be35a361d..000000000
--- a/server/tests/api/video-abuse.js
+++ /dev/null
@@ -1,193 +0,0 @@
1/* eslint-disable no-unused-expressions */
2
3'use strict'
4
5const chai = require('chai')
6const each = require('async/each')
7const expect = chai.expect
8const series = require('async/series')
9
10const loginUtils = require('../utils/login')
11const podsUtils = require('../utils/pods')
12const serversUtils = require('../utils/servers')
13const videosUtils = require('../utils/videos')
14const videoAbusesUtils = require('../utils/video-abuses')
15
16describe('Test video abuses', function () {
17 let servers = []
18
19 before(function (done) {
20 this.timeout(100000)
21
22 series([
23 // Run servers
24 function (next) {
25 serversUtils.flushAndRunMultipleServers(2, function (serversRun) {
26 servers = serversRun
27 next()
28 })
29 },
30 // Get the access tokens
31 function (next) {
32 each(servers, function (server, callbackEach) {
33 loginUtils.loginAndGetAccessToken(server, function (err, accessToken) {
34 if (err) return callbackEach(err)
35
36 server.accessToken = accessToken
37 callbackEach()
38 })
39 }, next)
40 },
41 // Pod 1 makes friend with pod 2
42 function (next) {
43 const server = servers[0]
44 podsUtils.makeFriends(server.url, server.accessToken, next)
45 },
46 // Upload some videos on each pods
47 function (next) {
48 const videoAttributes = {
49 name: 'my super name for pod 1',
50 description: 'my super description for pod 1'
51 }
52 videosUtils.uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes, next)
53 },
54 function (next) {
55 const videoAttributes = {
56 name: 'my super name for pod 2',
57 description: 'my super description for pod 2'
58 }
59 videosUtils.uploadVideo(servers[1].url, servers[1].accessToken, videoAttributes, next)
60 },
61 // Wait videos propagation
62 function (next) {
63 setTimeout(next, 22000)
64 },
65 function (next) {
66 videosUtils.getVideosList(servers[0].url, function (err, res) {
67 if (err) throw err
68
69 const videos = res.body.data
70
71 expect(videos.length).to.equal(2)
72
73 servers[0].video = videos.find(function (video) { return video.name === 'my super name for pod 1' })
74 servers[1].video = videos.find(function (video) { return video.name === 'my super name for pod 2' })
75
76 next()
77 })
78 }
79 ], done)
80 })
81
82 it('Should not have video abuses', function (done) {
83 videoAbusesUtils.getVideoAbusesList(servers[0].url, servers[0].accessToken, function (err, res) {
84 if (err) throw err
85
86 expect(res.body.total).to.equal(0)
87 expect(res.body.data).to.be.an('array')
88 expect(res.body.data.length).to.equal(0)
89
90 done()
91 })
92 })
93
94 it('Should report abuse on a local video', function (done) {
95 this.timeout(15000)
96
97 const reason = 'my super bad reason'
98 videoAbusesUtils.reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[0].video.id, reason, function (err) {
99 if (err) throw err
100
101 // We wait requests propagation, even if the pod 1 is not supposed to make a request to pod 2
102 setTimeout(done, 11000)
103 })
104 })
105
106 it('Should have 1 video abuses on pod 1 and 0 on pod 2', function (done) {
107 videoAbusesUtils.getVideoAbusesList(servers[0].url, servers[0].accessToken, function (err, res) {
108 if (err) throw err
109
110 expect(res.body.total).to.equal(1)
111 expect(res.body.data).to.be.an('array')
112 expect(res.body.data.length).to.equal(1)
113
114 const abuse = res.body.data[0]
115 expect(abuse.reason).to.equal('my super bad reason')
116 expect(abuse.reporterUsername).to.equal('root')
117 expect(abuse.reporterPodHost).to.equal('localhost:9001')
118 expect(abuse.videoId).to.equal(servers[0].video.id)
119
120 videoAbusesUtils.getVideoAbusesList(servers[1].url, servers[1].accessToken, function (err, res) {
121 if (err) throw err
122
123 expect(res.body.total).to.equal(0)
124 expect(res.body.data).to.be.an('array')
125 expect(res.body.data.length).to.equal(0)
126
127 done()
128 })
129 })
130 })
131
132 it('Should report abuse on a remote video', function (done) {
133 this.timeout(15000)
134
135 const reason = 'my super bad reason 2'
136 videoAbusesUtils.reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[1].video.id, reason, function (err) {
137 if (err) throw err
138
139 // We wait requests propagation
140 setTimeout(done, 11000)
141 })
142 })
143
144 it('Should have 2 video abuse on pod 1 and 1 on pod 2', function (done) {
145 videoAbusesUtils.getVideoAbusesList(servers[0].url, servers[0].accessToken, function (err, res) {
146 if (err) throw err
147
148 expect(res.body.total).to.equal(2)
149 expect(res.body.data).to.be.an('array')
150 expect(res.body.data.length).to.equal(2)
151
152 let abuse = res.body.data[0]
153 expect(abuse.reason).to.equal('my super bad reason')
154 expect(abuse.reporterUsername).to.equal('root')
155 expect(abuse.reporterPodHost).to.equal('localhost:9001')
156 expect(abuse.videoId).to.equal(servers[0].video.id)
157
158 abuse = res.body.data[1]
159 expect(abuse.reason).to.equal('my super bad reason 2')
160 expect(abuse.reporterUsername).to.equal('root')
161 expect(abuse.reporterPodHost).to.equal('localhost:9001')
162 expect(abuse.videoId).to.equal(servers[1].video.id)
163
164 videoAbusesUtils.getVideoAbusesList(servers[1].url, servers[1].accessToken, function (err, res) {
165 if (err) throw err
166
167 expect(res.body.total).to.equal(1)
168 expect(res.body.data).to.be.an('array')
169 expect(res.body.data.length).to.equal(1)
170
171 let abuse = res.body.data[0]
172 expect(abuse.reason).to.equal('my super bad reason 2')
173 expect(abuse.reporterUsername).to.equal('root')
174 expect(abuse.reporterPodHost).to.equal('localhost:9001')
175
176 done()
177 })
178 })
179 })
180
181 after(function (done) {
182 servers.forEach(function (server) {
183 process.kill(-server.app.pid)
184 })
185
186 // Keep the logs if the test failed
187 if (this.ok) {
188 serversUtils.flushTests(done)
189 } else {
190 done()
191 }
192 })
193})