diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/index-fast.ts | 1 | ||||
-rw-r--r-- | server/tests/api/multiple-pods.ts | 6 | ||||
-rw-r--r-- | server/tests/api/request-schedulers.ts | 82 | ||||
-rw-r--r-- | server/tests/api/services.ts | 5 | ||||
-rw-r--r-- | server/tests/api/single-pod.ts | 47 | ||||
-rw-r--r-- | server/tests/api/users.ts | 319 | ||||
-rw-r--r-- | server/tests/api/video-abuse.ts | 60 |
7 files changed, 278 insertions, 242 deletions
diff --git a/server/tests/api/index-fast.ts b/server/tests/api/index-fast.ts index f13d8155d..ced973bc2 100644 --- a/server/tests/api/index-fast.ts +++ b/server/tests/api/index-fast.ts | |||
@@ -10,4 +10,3 @@ import './video-blacklist-management' | |||
10 | import './video-description' | 10 | import './video-description' |
11 | import './video-privacy' | 11 | import './video-privacy' |
12 | import './services' | 12 | import './services' |
13 | import './request-schedulers' | ||
diff --git a/server/tests/api/multiple-pods.ts b/server/tests/api/multiple-pods.ts index 8e89da97a..3c6b3f650 100644 --- a/server/tests/api/multiple-pods.ts +++ b/server/tests/api/multiple-pods.ts | |||
@@ -113,7 +113,7 @@ describe('Test multiple pods', function () { | |||
113 | expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) | 113 | expect(video.tags).to.deep.equal([ 'tag1p1', 'tag2p1' ]) |
114 | expect(dateIsValid(video.createdAt)).to.be.true | 114 | expect(dateIsValid(video.createdAt)).to.be.true |
115 | expect(dateIsValid(video.updatedAt)).to.be.true | 115 | expect(dateIsValid(video.updatedAt)).to.be.true |
116 | expect(video.author).to.equal('root') | 116 | expect(video.account).to.equal('root') |
117 | 117 | ||
118 | const res2 = await getVideo(server.url, video.uuid) | 118 | const res2 = await getVideo(server.url, video.uuid) |
119 | const videoDetails = res2.body | 119 | const videoDetails = res2.body |
@@ -202,7 +202,7 @@ describe('Test multiple pods', function () { | |||
202 | expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) | 202 | expect(video.tags).to.deep.equal([ 'tag1p2', 'tag2p2', 'tag3p2' ]) |
203 | expect(dateIsValid(video.createdAt)).to.be.true | 203 | expect(dateIsValid(video.createdAt)).to.be.true |
204 | expect(dateIsValid(video.updatedAt)).to.be.true | 204 | expect(dateIsValid(video.updatedAt)).to.be.true |
205 | expect(video.author).to.equal('user1') | 205 | expect(video.account).to.equal('user1') |
206 | 206 | ||
207 | if (server.url !== 'http://localhost:9002') { | 207 | if (server.url !== 'http://localhost:9002') { |
208 | expect(video.isLocal).to.be.false | 208 | expect(video.isLocal).to.be.false |
@@ -696,7 +696,7 @@ describe('Test multiple pods', function () { | |||
696 | expect(baseVideo.licence).to.equal(video.licence) | 696 | expect(baseVideo.licence).to.equal(video.licence) |
697 | expect(baseVideo.category).to.equal(video.category) | 697 | expect(baseVideo.category).to.equal(video.category) |
698 | expect(baseVideo.nsfw).to.equal(video.nsfw) | 698 | expect(baseVideo.nsfw).to.equal(video.nsfw) |
699 | expect(baseVideo.author).to.equal(video.author) | 699 | expect(baseVideo.author).to.equal(video.account) |
700 | expect(baseVideo.tags).to.deep.equal(video.tags) | 700 | expect(baseVideo.tags).to.deep.equal(video.tags) |
701 | } | 701 | } |
702 | }) | 702 | }) |
diff --git a/server/tests/api/request-schedulers.ts b/server/tests/api/request-schedulers.ts deleted file mode 100644 index c136d1cea..000000000 --- a/server/tests/api/request-schedulers.ts +++ /dev/null | |||
@@ -1,82 +0,0 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | ||
5 | const expect = chai.expect | ||
6 | |||
7 | import { | ||
8 | ServerInfo, | ||
9 | flushTests, | ||
10 | uploadVideo, | ||
11 | makeFriends, | ||
12 | wait, | ||
13 | setAccessTokensToServers, | ||
14 | flushAndRunMultipleServers, | ||
15 | getRequestsStats, | ||
16 | killallServers | ||
17 | } from '../utils' | ||
18 | |||
19 | describe('Test requests schedulers stats', function () { | ||
20 | const requestSchedulerNames = [ 'requestScheduler', 'requestVideoQaduScheduler', 'requestVideoEventScheduler' ] | ||
21 | let servers: ServerInfo[] = [] | ||
22 | |||
23 | function uploadVideoWrapper (server: ServerInfo) { | ||
24 | const videoAttributes = { | ||
25 | tags: [ 'tag1', 'tag2' ] | ||
26 | } | ||
27 | |||
28 | return uploadVideo(server.url, server.accessToken, videoAttributes) | ||
29 | } | ||
30 | |||
31 | // --------------------------------------------------------------- | ||
32 | |||
33 | before(async function () { | ||
34 | this.timeout(120000) | ||
35 | |||
36 | servers = await flushAndRunMultipleServers(2) | ||
37 | |||
38 | await setAccessTokensToServers(servers) | ||
39 | |||
40 | await makeFriends(servers[0].url, servers[0].accessToken) | ||
41 | }) | ||
42 | |||
43 | it('Should have a correct timer', async function () { | ||
44 | const server = servers[0] | ||
45 | |||
46 | const res = await getRequestsStats(server) | ||
47 | |||
48 | const requestSchedulers = res.body | ||
49 | for (const requestSchedulerName of requestSchedulerNames) { | ||
50 | const requestScheduler = requestSchedulers[requestSchedulerName] | ||
51 | |||
52 | expect(requestScheduler.remainingMilliSeconds).to.be.at.least(0) | ||
53 | expect(requestScheduler.remainingMilliSeconds).to.be.at.most(10000) | ||
54 | } | ||
55 | }) | ||
56 | |||
57 | it('Should have the correct total request', async function () { | ||
58 | this.timeout(15000) | ||
59 | |||
60 | const server = servers[0] | ||
61 | // Ensure the requests of pod 1 won't be made | ||
62 | servers[1].app.kill() | ||
63 | |||
64 | await uploadVideoWrapper(server) | ||
65 | |||
66 | await wait(1000) | ||
67 | |||
68 | const res = await getRequestsStats(server) | ||
69 | const requestSchedulers = res.body | ||
70 | const requestScheduler = requestSchedulers.requestScheduler | ||
71 | expect(requestScheduler.totalRequests).to.equal(3) | ||
72 | }) | ||
73 | |||
74 | after(async function () { | ||
75 | // Server 1 has already been killed | ||
76 | killallServers([ servers[0] ]) | ||
77 | |||
78 | if (this['ok']) { | ||
79 | await flushTests() | ||
80 | } | ||
81 | }) | ||
82 | }) | ||
diff --git a/server/tests/api/services.ts b/server/tests/api/services.ts index 76911fdc5..c34c51f66 100644 --- a/server/tests/api/services.ts +++ b/server/tests/api/services.ts | |||
@@ -14,6 +14,7 @@ import { | |||
14 | getOEmbed | 14 | getOEmbed |
15 | } from '../utils' | 15 | } from '../utils' |
16 | import { runServer } from '../utils/servers' | 16 | import { runServer } from '../utils/servers' |
17 | import { Video } from '../../../client/src/app/videos/shared/video.model' | ||
17 | 18 | ||
18 | describe('Test services', function () { | 19 | describe('Test services', function () { |
19 | let server: ServerInfo = null | 20 | let server: ServerInfo = null |
@@ -46,7 +47,7 @@ describe('Test services', function () { | |||
46 | 47 | ||
47 | expect(res.body.html).to.equal(expectedHtml) | 48 | expect(res.body.html).to.equal(expectedHtml) |
48 | expect(res.body.title).to.equal(server.video.name) | 49 | expect(res.body.title).to.equal(server.video.name) |
49 | expect(res.body.author_name).to.equal(server.video.author) | 50 | expect(res.body.author_name).to.equal(server.video.account) |
50 | expect(res.body.width).to.equal(560) | 51 | expect(res.body.width).to.equal(560) |
51 | expect(res.body.height).to.equal(315) | 52 | expect(res.body.height).to.equal(315) |
52 | expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) | 53 | expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) |
@@ -66,7 +67,7 @@ describe('Test services', function () { | |||
66 | 67 | ||
67 | expect(res.body.html).to.equal(expectedHtml) | 68 | expect(res.body.html).to.equal(expectedHtml) |
68 | expect(res.body.title).to.equal(server.video.name) | 69 | expect(res.body.title).to.equal(server.video.name) |
69 | expect(res.body.author_name).to.equal(server.video.author) | 70 | expect(res.body.author_name).to.equal(server.video.account) |
70 | expect(res.body.height).to.equal(50) | 71 | expect(res.body.height).to.equal(50) |
71 | expect(res.body.width).to.equal(50) | 72 | expect(res.body.width).to.equal(50) |
72 | expect(res.body).to.not.have.property('thumbnail_url') | 73 | expect(res.body).to.not.have.property('thumbnail_url') |
diff --git a/server/tests/api/single-pod.ts b/server/tests/api/single-pod.ts index 3a05d0727..0a917f2ae 100644 --- a/server/tests/api/single-pod.ts +++ b/server/tests/api/single-pod.ts | |||
@@ -125,8 +125,8 @@ describe('Test a single pod', function () { | |||
125 | expect(video.languageLabel).to.equal('Mandarin') | 125 | expect(video.languageLabel).to.equal('Mandarin') |
126 | expect(video.nsfw).to.be.ok | 126 | expect(video.nsfw).to.be.ok |
127 | expect(video.description).to.equal('my super description') | 127 | expect(video.description).to.equal('my super description') |
128 | expect(video.podHost).to.equal('localhost:9001') | 128 | expect(video.serverHost).to.equal('localhost:9001') |
129 | expect(video.author).to.equal('root') | 129 | expect(video.account).to.equal('root') |
130 | expect(video.isLocal).to.be.true | 130 | expect(video.isLocal).to.be.true |
131 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | 131 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) |
132 | expect(dateIsValid(video.createdAt)).to.be.true | 132 | expect(dateIsValid(video.createdAt)).to.be.true |
@@ -174,8 +174,8 @@ describe('Test a single pod', function () { | |||
174 | expect(video.languageLabel).to.equal('Mandarin') | 174 | expect(video.languageLabel).to.equal('Mandarin') |
175 | expect(video.nsfw).to.be.ok | 175 | expect(video.nsfw).to.be.ok |
176 | expect(video.description).to.equal('my super description') | 176 | expect(video.description).to.equal('my super description') |
177 | expect(video.podHost).to.equal('localhost:9001') | 177 | expect(video.serverHost).to.equal('localhost:9001') |
178 | expect(video.author).to.equal('root') | 178 | expect(video.account).to.equal('root') |
179 | expect(video.isLocal).to.be.true | 179 | expect(video.isLocal).to.be.true |
180 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | 180 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) |
181 | expect(dateIsValid(video.createdAt)).to.be.true | 181 | expect(dateIsValid(video.createdAt)).to.be.true |
@@ -237,8 +237,8 @@ describe('Test a single pod', function () { | |||
237 | expect(video.languageLabel).to.equal('Mandarin') | 237 | expect(video.languageLabel).to.equal('Mandarin') |
238 | expect(video.nsfw).to.be.ok | 238 | expect(video.nsfw).to.be.ok |
239 | expect(video.description).to.equal('my super description') | 239 | expect(video.description).to.equal('my super description') |
240 | expect(video.podHost).to.equal('localhost:9001') | 240 | expect(video.serverHost).to.equal('localhost:9001') |
241 | expect(video.author).to.equal('root') | 241 | expect(video.account).to.equal('root') |
242 | expect(video.isLocal).to.be.true | 242 | expect(video.isLocal).to.be.true |
243 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | 243 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) |
244 | expect(dateIsValid(video.createdAt)).to.be.true | 244 | expect(dateIsValid(video.createdAt)).to.be.true |
@@ -249,7 +249,7 @@ describe('Test a single pod', function () { | |||
249 | }) | 249 | }) |
250 | 250 | ||
251 | // Not implemented yet | 251 | // Not implemented yet |
252 | // it('Should search the video by podHost', async function () { | 252 | // it('Should search the video by serverHost', async function () { |
253 | // const res = await videosUtils.searchVideo(server.url, '9001', 'host') | 253 | // const res = await videosUtils.searchVideo(server.url, '9001', 'host') |
254 | 254 | ||
255 | // expect(res.body.total).to.equal(1) | 255 | // expect(res.body.total).to.equal(1) |
@@ -259,7 +259,7 @@ describe('Test a single pod', function () { | |||
259 | // const video = res.body.data[0] | 259 | // const video = res.body.data[0] |
260 | // expect(video.name).to.equal('my super name') | 260 | // expect(video.name).to.equal('my super name') |
261 | // expect(video.description).to.equal('my super description') | 261 | // expect(video.description).to.equal('my super description') |
262 | // expect(video.podHost).to.equal('localhost:9001') | 262 | // expect(video.serverHost).to.equal('localhost:9001') |
263 | // expect(video.author).to.equal('root') | 263 | // expect(video.author).to.equal('root') |
264 | // expect(video.isLocal).to.be.true | 264 | // expect(video.isLocal).to.be.true |
265 | // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | 265 | // expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) |
@@ -291,8 +291,8 @@ describe('Test a single pod', function () { | |||
291 | expect(video.languageLabel).to.equal('Mandarin') | 291 | expect(video.languageLabel).to.equal('Mandarin') |
292 | expect(video.nsfw).to.be.ok | 292 | expect(video.nsfw).to.be.ok |
293 | expect(video.description).to.equal('my super description') | 293 | expect(video.description).to.equal('my super description') |
294 | expect(video.podHost).to.equal('localhost:9001') | 294 | expect(video.serverHost).to.equal('localhost:9001') |
295 | expect(video.author).to.equal('root') | 295 | expect(video.account).to.equal('root') |
296 | expect(video.isLocal).to.be.true | 296 | expect(video.isLocal).to.be.true |
297 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) | 297 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ]) |
298 | expect(dateIsValid(video.createdAt)).to.be.true | 298 | expect(dateIsValid(video.createdAt)).to.be.true |
@@ -311,7 +311,7 @@ describe('Test a single pod', function () { | |||
311 | }) | 311 | }) |
312 | 312 | ||
313 | it('Should not find a search by author', async function () { | 313 | it('Should not find a search by author', async function () { |
314 | const res = await searchVideo(server.url, 'hello', 'author') | 314 | const res = await searchVideo(server.url, 'hello', 'account') |
315 | 315 | ||
316 | expect(res.body.total).to.equal(0) | 316 | expect(res.body.total).to.equal(0) |
317 | expect(res.body.data).to.be.an('array') | 317 | expect(res.body.data).to.be.an('array') |
@@ -352,7 +352,7 @@ describe('Test a single pod', function () { | |||
352 | 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' | 352 | 'video_short1.webm', 'video_short2.webm', 'video_short3.webm' |
353 | ] | 353 | ] |
354 | 354 | ||
355 | const tasks: Promise<any>[] = [] | 355 | // const tasks: Promise<any>[] = [] |
356 | for (const video of videos) { | 356 | for (const video of videos) { |
357 | const videoAttributes = { | 357 | const videoAttributes = { |
358 | name: video + ' name', | 358 | name: video + ' name', |
@@ -366,10 +366,13 @@ describe('Test a single pod', function () { | |||
366 | } | 366 | } |
367 | 367 | ||
368 | const p = uploadVideo(server.url, server.accessToken, videoAttributes) | 368 | const p = uploadVideo(server.url, server.accessToken, videoAttributes) |
369 | tasks.push(p) | 369 | await p |
370 | } | 370 | } |
371 | 371 | // FIXME: concurrent uploads does not work :( | |
372 | await Promise.all(tasks) | 372 | // tasks.push(p) |
373 | // } | ||
374 | // | ||
375 | // await Promise.all(tasks) | ||
373 | }) | 376 | }) |
374 | 377 | ||
375 | it('Should have the correct durations', async function () { | 378 | it('Should have the correct durations', async function () { |
@@ -462,7 +465,7 @@ describe('Test a single pod', function () { | |||
462 | }) | 465 | }) |
463 | 466 | ||
464 | it('Should search all the root author videos', async function () { | 467 | it('Should search all the root author videos', async function () { |
465 | const res = await searchVideoWithPagination(server.url, 'root', 'author', 0, 15) | 468 | const res = await searchVideoWithPagination(server.url, 'root', 'account', 0, 15) |
466 | 469 | ||
467 | const videos = res.body.data | 470 | const videos = res.body.data |
468 | expect(res.body.total).to.equal(6) | 471 | expect(res.body.total).to.equal(6) |
@@ -550,8 +553,8 @@ describe('Test a single pod', function () { | |||
550 | expect(video.languageLabel).to.equal('Arabic') | 553 | expect(video.languageLabel).to.equal('Arabic') |
551 | expect(video.nsfw).to.be.ok | 554 | expect(video.nsfw).to.be.ok |
552 | expect(video.description).to.equal('my super description updated') | 555 | expect(video.description).to.equal('my super description updated') |
553 | expect(video.podHost).to.equal('localhost:9001') | 556 | expect(video.serverHost).to.equal('localhost:9001') |
554 | expect(video.author).to.equal('root') | 557 | expect(video.account).to.equal('root') |
555 | expect(video.isLocal).to.be.true | 558 | expect(video.isLocal).to.be.true |
556 | expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) | 559 | expect(video.tags).to.deep.equal([ 'tagup1', 'tagup2' ]) |
557 | expect(dateIsValid(video.createdAt)).to.be.true | 560 | expect(dateIsValid(video.createdAt)).to.be.true |
@@ -599,8 +602,8 @@ describe('Test a single pod', function () { | |||
599 | expect(video.languageLabel).to.equal('Arabic') | 602 | expect(video.languageLabel).to.equal('Arabic') |
600 | expect(video.nsfw).to.be.ok | 603 | expect(video.nsfw).to.be.ok |
601 | expect(video.description).to.equal('my super description updated') | 604 | expect(video.description).to.equal('my super description updated') |
602 | expect(video.podHost).to.equal('localhost:9001') | 605 | expect(video.serverHost).to.equal('localhost:9001') |
603 | expect(video.author).to.equal('root') | 606 | expect(video.account).to.equal('root') |
604 | expect(video.isLocal).to.be.true | 607 | expect(video.isLocal).to.be.true |
605 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) | 608 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) |
606 | expect(dateIsValid(video.createdAt)).to.be.true | 609 | expect(dateIsValid(video.createdAt)).to.be.true |
@@ -639,8 +642,8 @@ describe('Test a single pod', function () { | |||
639 | expect(video.languageLabel).to.equal('Arabic') | 642 | expect(video.languageLabel).to.equal('Arabic') |
640 | expect(video.nsfw).to.be.ok | 643 | expect(video.nsfw).to.be.ok |
641 | expect(video.description).to.equal('hello everybody') | 644 | expect(video.description).to.equal('hello everybody') |
642 | expect(video.podHost).to.equal('localhost:9001') | 645 | expect(video.serverHost).to.equal('localhost:9001') |
643 | expect(video.author).to.equal('root') | 646 | expect(video.account).to.equal('root') |
644 | expect(video.isLocal).to.be.true | 647 | expect(video.isLocal).to.be.true |
645 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) | 648 | expect(video.tags).to.deep.equal([ 'tag1', 'tag2', 'supertag' ]) |
646 | expect(dateIsValid(video.createdAt)).to.be.true | 649 | expect(dateIsValid(video.createdAt)).to.be.true |
diff --git a/server/tests/api/users.ts b/server/tests/api/users.ts index 6f40ca3c9..055dade04 100644 --- a/server/tests/api/users.ts +++ b/server/tests/api/users.ts | |||
@@ -1,38 +1,36 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* tslint:disable:no-unused-expression */ |
2 | |||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | 2 | import * as chai from 'chai' |
5 | const expect = chai.expect | 3 | import 'mocha' |
6 | 4 | import { UserRole } from '../../../shared' | |
7 | import { | 5 | import { |
8 | ServerInfo, | ||
9 | flushTests, | ||
10 | runServer, | ||
11 | login, | ||
12 | uploadVideo, | ||
13 | makeFriends, | ||
14 | quitFriends, | ||
15 | getVideosList, | ||
16 | rateVideo, | ||
17 | getUserVideoRating, | ||
18 | removeVideo, | ||
19 | makePutBodyRequest, | ||
20 | createUser, | 6 | createUser, |
21 | loginAndGetAccessToken, | 7 | flushTests, |
8 | getBlacklistedVideosList, | ||
22 | getMyUserInformation, | 9 | getMyUserInformation, |
10 | getUserInformation, | ||
23 | getUsersList, | 11 | getUsersList, |
24 | getUsersListPaginationAndSort, | 12 | getUsersListPaginationAndSort, |
25 | updateUser, | 13 | getUserVideoRating, |
26 | updateMyUser, | 14 | getVideosList, |
15 | killallServers, | ||
16 | login, | ||
17 | loginAndGetAccessToken, | ||
18 | makePutBodyRequest, | ||
19 | rateVideo, | ||
27 | registerUser, | 20 | registerUser, |
28 | removeUser, | 21 | removeUser, |
29 | killallServers, | 22 | removeVideo, |
30 | getUserInformation, | 23 | runServer, |
31 | getBlacklistedVideosList | 24 | ServerInfo, |
25 | updateMyUser, | ||
26 | updateUser, | ||
27 | uploadVideo | ||
32 | } from '../utils' | 28 | } from '../utils' |
33 | import { UserRole } from '../../../shared' | 29 | import { follow } from '../utils/follows' |
34 | import { getMyVideos } from '../utils/videos' | 30 | import { getMyVideos } from '../utils/videos' |
35 | 31 | ||
32 | const expect = chai.expect | ||
33 | |||
36 | describe('Test users', function () { | 34 | describe('Test users', function () { |
37 | let server: ServerInfo | 35 | let server: ServerInfo |
38 | let accessToken: string | 36 | let accessToken: string |
@@ -57,28 +55,36 @@ describe('Test users', function () { | |||
57 | const client = { id: 'client', secret: server.client.secret } | 55 | const client = { id: 'client', secret: server.client.secret } |
58 | const res = await login(server.url, client, server.user, 400) | 56 | const res = await login(server.url, client, server.user, 400) |
59 | 57 | ||
60 | expect(res.body.error).to.equal('invalid_client') | 58 | expect(res.body.error) |
59 | .to | ||
60 | .equal('invalid_client') | ||
61 | }) | 61 | }) |
62 | 62 | ||
63 | it('Should not login with an invalid client secret', async function () { | 63 | it('Should not login with an invalid client secret', async function () { |
64 | const client = { id: server.client.id, secret: 'coucou' } | 64 | const client = { id: server.client.id, secret: 'coucou' } |
65 | const res = await login(server.url, client, server.user, 400) | 65 | const res = await login(server.url, client, server.user, 400) |
66 | 66 | ||
67 | expect(res.body.error).to.equal('invalid_client') | 67 | expect(res.body.error) |
68 | .to | ||
69 | .equal('invalid_client') | ||
68 | }) | 70 | }) |
69 | 71 | ||
70 | it('Should not login with an invalid username', async function () { | 72 | it('Should not login with an invalid username', async function () { |
71 | const user = { username: 'captain crochet', password: server.user.password } | 73 | const user = { username: 'captain crochet', password: server.user.password } |
72 | const res = await login(server.url, server.client, user, 400) | 74 | const res = await login(server.url, server.client, user, 400) |
73 | 75 | ||
74 | expect(res.body.error).to.equal('invalid_grant') | 76 | expect(res.body.error) |
77 | .to | ||
78 | .equal('invalid_grant') | ||
75 | }) | 79 | }) |
76 | 80 | ||
77 | it('Should not login with an invalid password', async function () { | 81 | it('Should not login with an invalid password', async function () { |
78 | const user = { username: server.user.username, password: 'mew_three' } | 82 | const user = { username: server.user.username, password: 'mew_three' } |
79 | const res = await login(server.url, server.client, user, 400) | 83 | const res = await login(server.url, server.client, user, 400) |
80 | 84 | ||
81 | expect(res.body.error).to.equal('invalid_grant') | 85 | expect(res.body.error) |
86 | .to | ||
87 | .equal('invalid_grant') | ||
82 | }) | 88 | }) |
83 | 89 | ||
84 | it('Should not be able to upload a video', async function () { | 90 | it('Should not be able to upload a video', async function () { |
@@ -88,15 +94,12 @@ describe('Test users', function () { | |||
88 | await uploadVideo(server.url, accessToken, videoAttributes, 401) | 94 | await uploadVideo(server.url, accessToken, videoAttributes, 401) |
89 | }) | 95 | }) |
90 | 96 | ||
91 | it('Should not be able to make friends', async function () { | 97 | it('Should not be able to follow', async function () { |
92 | accessToken = 'my_super_token' | 98 | accessToken = 'my_super_token' |
93 | await makeFriends(server.url, accessToken, 401) | 99 | await follow(server.url, [ 'http://example.com' ], accessToken, 401) |
94 | }) | 100 | }) |
95 | 101 | ||
96 | it('Should not be able to quit friends', async function () { | 102 | it('Should not be able to unfollow') |
97 | accessToken = 'my_super_token' | ||
98 | await quitFriends(server.url, accessToken, 401) | ||
99 | }) | ||
100 | 103 | ||
101 | it('Should be able to login', async function () { | 104 | it('Should be able to login', async function () { |
102 | const res = await login(server.url, server.client, server.user, 200) | 105 | const res = await login(server.url, server.client, server.user, 200) |
@@ -108,9 +111,11 @@ describe('Test users', function () { | |||
108 | const videoAttributes = {} | 111 | const videoAttributes = {} |
109 | await uploadVideo(server.url, accessToken, videoAttributes, 204) | 112 | await uploadVideo(server.url, accessToken, videoAttributes, 204) |
110 | const res = await getVideosList(server.url) | 113 | const res = await getVideosList(server.url) |
111 | const video = res.body.data[0] | 114 | const video = res.body.data[ 0 ] |
112 | 115 | ||
113 | expect(video.author).to.equal('root') | 116 | expect(video.account) |
117 | .to | ||
118 | .equal('root') | ||
114 | videoId = video.id | 119 | videoId = video.id |
115 | }) | 120 | }) |
116 | 121 | ||
@@ -124,8 +129,12 @@ describe('Test users', function () { | |||
124 | const res = await getUserVideoRating(server.url, accessToken, videoId) | 129 | const res = await getUserVideoRating(server.url, accessToken, videoId) |
125 | const rating = res.body | 130 | const rating = res.body |
126 | 131 | ||
127 | expect(rating.videoId).to.equal(videoId) | 132 | expect(rating.videoId) |
128 | expect(rating.rating).to.equal('like') | 133 | .to |
134 | .equal(videoId) | ||
135 | expect(rating.rating) | ||
136 | .to | ||
137 | .equal('like') | ||
129 | }) | 138 | }) |
130 | 139 | ||
131 | it('Should not be able to remove the video with an incorrect token', async function () { | 140 | it('Should not be able to remove the video with an incorrect token', async function () { |
@@ -187,12 +196,23 @@ describe('Test users', function () { | |||
187 | const res = await getMyUserInformation(server.url, accessTokenUser) | 196 | const res = await getMyUserInformation(server.url, accessTokenUser) |
188 | const user = res.body | 197 | const user = res.body |
189 | 198 | ||
190 | expect(user.username).to.equal('user_1') | 199 | expect(user.username) |
191 | expect(user.email).to.equal('user_1@example.com') | 200 | .to |
201 | .equal('user_1') | ||
202 | expect(user.email) | ||
203 | .to | ||
204 | .equal('user_1@example.com') | ||
192 | expect(user.displayNSFW).to.be.false | 205 | expect(user.displayNSFW).to.be.false |
193 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) | 206 | expect(user.videoQuota) |
194 | expect(user.roleLabel).to.equal('User') | 207 | .to |
195 | expect(user.id).to.be.a('number') | 208 | .equal(2 * 1024 * 1024) |
209 | expect(user.roleLabel) | ||
210 | .to | ||
211 | .equal('User') | ||
212 | expect(user.id) | ||
213 | .to | ||
214 | .be | ||
215 | .a('number') | ||
196 | }) | 216 | }) |
197 | 217 | ||
198 | it('Should be able to upload a video with this user', async function () { | 218 | it('Should be able to upload a video with this user', async function () { |
@@ -206,12 +226,19 @@ describe('Test users', function () { | |||
206 | 226 | ||
207 | it('Should be able to list my videos', async function () { | 227 | it('Should be able to list my videos', async function () { |
208 | const res = await getMyVideos(server.url, accessTokenUser, 0, 5) | 228 | const res = await getMyVideos(server.url, accessTokenUser, 0, 5) |
209 | expect(res.body.total).to.equal(1) | 229 | expect(res.body.total) |
230 | .to | ||
231 | .equal(1) | ||
210 | 232 | ||
211 | const videos = res.body.data | 233 | const videos = res.body.data |
212 | expect(videos).to.have.lengthOf(1) | 234 | expect(videos) |
235 | .to | ||
236 | .have | ||
237 | .lengthOf(1) | ||
213 | 238 | ||
214 | expect(videos[0].name).to.equal('super user video') | 239 | expect(videos[ 0 ].name) |
240 | .to | ||
241 | .equal('super user video') | ||
215 | }) | 242 | }) |
216 | 243 | ||
217 | it('Should list all the users', async function () { | 244 | it('Should list all the users', async function () { |
@@ -220,18 +247,33 @@ describe('Test users', function () { | |||
220 | const total = result.total | 247 | const total = result.total |
221 | const users = result.data | 248 | const users = result.data |
222 | 249 | ||
223 | expect(total).to.equal(2) | 250 | expect(total) |
224 | expect(users).to.be.an('array') | 251 | .to |
225 | expect(users.length).to.equal(2) | 252 | .equal(2) |
226 | 253 | expect(users) | |
227 | const user = users[0] | 254 | .to |
228 | expect(user.username).to.equal('user_1') | 255 | .be |
229 | expect(user.email).to.equal('user_1@example.com') | 256 | .an('array') |
257 | expect(users.length) | ||
258 | .to | ||
259 | .equal(2) | ||
260 | |||
261 | const user = users[ 0 ] | ||
262 | expect(user.username) | ||
263 | .to | ||
264 | .equal('user_1') | ||
265 | expect(user.email) | ||
266 | .to | ||
267 | .equal('user_1@example.com') | ||
230 | expect(user.displayNSFW).to.be.false | 268 | expect(user.displayNSFW).to.be.false |
231 | 269 | ||
232 | const rootUser = users[1] | 270 | const rootUser = users[ 1 ] |
233 | expect(rootUser.username).to.equal('root') | 271 | expect(rootUser.username) |
234 | expect(rootUser.email).to.equal('admin1@example.com') | 272 | .to |
273 | .equal('root') | ||
274 | expect(rootUser.email) | ||
275 | .to | ||
276 | .equal('admin1@example.com') | ||
235 | expect(rootUser.displayNSFW).to.be.false | 277 | expect(rootUser.displayNSFW).to.be.false |
236 | 278 | ||
237 | userId = user.id | 279 | userId = user.id |
@@ -244,13 +286,23 @@ describe('Test users', function () { | |||
244 | const total = result.total | 286 | const total = result.total |
245 | const users = result.data | 287 | const users = result.data |
246 | 288 | ||
247 | expect(total).to.equal(2) | 289 | expect(total) |
248 | expect(users.length).to.equal(1) | 290 | .to |
249 | 291 | .equal(2) | |
250 | const user = users[0] | 292 | expect(users.length) |
251 | expect(user.username).to.equal('root') | 293 | .to |
252 | expect(user.email).to.equal('admin1@example.com') | 294 | .equal(1) |
253 | expect(user.roleLabel).to.equal('Administrator') | 295 | |
296 | const user = users[ 0 ] | ||
297 | expect(user.username) | ||
298 | .to | ||
299 | .equal('root') | ||
300 | expect(user.email) | ||
301 | .to | ||
302 | .equal('admin1@example.com') | ||
303 | expect(user.roleLabel) | ||
304 | .to | ||
305 | .equal('Administrator') | ||
254 | expect(user.displayNSFW).to.be.false | 306 | expect(user.displayNSFW).to.be.false |
255 | }) | 307 | }) |
256 | 308 | ||
@@ -260,12 +312,20 @@ describe('Test users', function () { | |||
260 | const total = result.total | 312 | const total = result.total |
261 | const users = result.data | 313 | const users = result.data |
262 | 314 | ||
263 | expect(total).to.equal(2) | 315 | expect(total) |
264 | expect(users.length).to.equal(1) | 316 | .to |
265 | 317 | .equal(2) | |
266 | const user = users[0] | 318 | expect(users.length) |
267 | expect(user.username).to.equal('user_1') | 319 | .to |
268 | expect(user.email).to.equal('user_1@example.com') | 320 | .equal(1) |
321 | |||
322 | const user = users[ 0 ] | ||
323 | expect(user.username) | ||
324 | .to | ||
325 | .equal('user_1') | ||
326 | expect(user.email) | ||
327 | .to | ||
328 | .equal('user_1@example.com') | ||
269 | expect(user.displayNSFW).to.be.false | 329 | expect(user.displayNSFW).to.be.false |
270 | }) | 330 | }) |
271 | 331 | ||
@@ -275,12 +335,20 @@ describe('Test users', function () { | |||
275 | const total = result.total | 335 | const total = result.total |
276 | const users = result.data | 336 | const users = result.data |
277 | 337 | ||
278 | expect(total).to.equal(2) | 338 | expect(total) |
279 | expect(users.length).to.equal(1) | 339 | .to |
280 | 340 | .equal(2) | |
281 | const user = users[0] | 341 | expect(users.length) |
282 | expect(user.username).to.equal('user_1') | 342 | .to |
283 | expect(user.email).to.equal('user_1@example.com') | 343 | .equal(1) |
344 | |||
345 | const user = users[ 0 ] | ||
346 | expect(user.username) | ||
347 | .to | ||
348 | .equal('user_1') | ||
349 | expect(user.email) | ||
350 | .to | ||
351 | .equal('user_1@example.com') | ||
284 | expect(user.displayNSFW).to.be.false | 352 | expect(user.displayNSFW).to.be.false |
285 | }) | 353 | }) |
286 | 354 | ||
@@ -290,16 +358,28 @@ describe('Test users', function () { | |||
290 | const total = result.total | 358 | const total = result.total |
291 | const users = result.data | 359 | const users = result.data |
292 | 360 | ||
293 | expect(total).to.equal(2) | 361 | expect(total) |
294 | expect(users.length).to.equal(2) | 362 | .to |
295 | 363 | .equal(2) | |
296 | expect(users[0].username).to.equal('root') | 364 | expect(users.length) |
297 | expect(users[0].email).to.equal('admin1@example.com') | 365 | .to |
298 | expect(users[0].displayNSFW).to.be.false | 366 | .equal(2) |
299 | 367 | ||
300 | expect(users[1].username).to.equal('user_1') | 368 | expect(users[ 0 ].username) |
301 | expect(users[1].email).to.equal('user_1@example.com') | 369 | .to |
302 | expect(users[1].displayNSFW).to.be.false | 370 | .equal('root') |
371 | expect(users[ 0 ].email) | ||
372 | .to | ||
373 | .equal('admin1@example.com') | ||
374 | expect(users[ 0 ].displayNSFW).to.be.false | ||
375 | |||
376 | expect(users[ 1 ].username) | ||
377 | .to | ||
378 | .equal('user_1') | ||
379 | expect(users[ 1 ].email) | ||
380 | .to | ||
381 | .equal('user_1@example.com') | ||
382 | expect(users[ 1 ].displayNSFW).to.be.false | ||
303 | }) | 383 | }) |
304 | 384 | ||
305 | it('Should update my password', async function () { | 385 | it('Should update my password', async function () { |
@@ -315,11 +395,20 @@ describe('Test users', function () { | |||
315 | const res = await getMyUserInformation(server.url, accessTokenUser) | 395 | const res = await getMyUserInformation(server.url, accessTokenUser) |
316 | const user = res.body | 396 | const user = res.body |
317 | 397 | ||
318 | expect(user.username).to.equal('user_1') | 398 | expect(user.username) |
319 | expect(user.email).to.equal('user_1@example.com') | 399 | .to |
400 | .equal('user_1') | ||
401 | expect(user.email) | ||
402 | .to | ||
403 | .equal('user_1@example.com') | ||
320 | expect(user.displayNSFW).to.be.ok | 404 | expect(user.displayNSFW).to.be.ok |
321 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) | 405 | expect(user.videoQuota) |
322 | expect(user.id).to.be.a('number') | 406 | .to |
407 | .equal(2 * 1024 * 1024) | ||
408 | expect(user.id) | ||
409 | .to | ||
410 | .be | ||
411 | .a('number') | ||
323 | }) | 412 | }) |
324 | 413 | ||
325 | it('Should be able to change the email display attribute', async function () { | 414 | it('Should be able to change the email display attribute', async function () { |
@@ -328,11 +417,20 @@ describe('Test users', function () { | |||
328 | const res = await getMyUserInformation(server.url, accessTokenUser) | 417 | const res = await getMyUserInformation(server.url, accessTokenUser) |
329 | const user = res.body | 418 | const user = res.body |
330 | 419 | ||
331 | expect(user.username).to.equal('user_1') | 420 | expect(user.username) |
332 | expect(user.email).to.equal('updated@example.com') | 421 | .to |
422 | .equal('user_1') | ||
423 | expect(user.email) | ||
424 | .to | ||
425 | .equal('updated@example.com') | ||
333 | expect(user.displayNSFW).to.be.ok | 426 | expect(user.displayNSFW).to.be.ok |
334 | expect(user.videoQuota).to.equal(2 * 1024 * 1024) | 427 | expect(user.videoQuota) |
335 | expect(user.id).to.be.a('number') | 428 | .to |
429 | .equal(2 * 1024 * 1024) | ||
430 | expect(user.id) | ||
431 | .to | ||
432 | .be | ||
433 | .a('number') | ||
336 | }) | 434 | }) |
337 | 435 | ||
338 | it('Should be able to update another user', async function () { | 436 | it('Should be able to update another user', async function () { |
@@ -341,12 +439,23 @@ describe('Test users', function () { | |||
341 | const res = await getUserInformation(server.url, accessToken, userId) | 439 | const res = await getUserInformation(server.url, accessToken, userId) |
342 | const user = res.body | 440 | const user = res.body |
343 | 441 | ||
344 | expect(user.username).to.equal('user_1') | 442 | expect(user.username) |
345 | expect(user.email).to.equal('updated2@example.com') | 443 | .to |
444 | .equal('user_1') | ||
445 | expect(user.email) | ||
446 | .to | ||
447 | .equal('updated2@example.com') | ||
346 | expect(user.displayNSFW).to.be.ok | 448 | expect(user.displayNSFW).to.be.ok |
347 | expect(user.videoQuota).to.equal(42) | 449 | expect(user.videoQuota) |
348 | expect(user.roleLabel).to.equal('Moderator') | 450 | .to |
349 | expect(user.id).to.be.a('number') | 451 | .equal(42) |
452 | expect(user.roleLabel) | ||
453 | .to | ||
454 | .equal('Moderator') | ||
455 | expect(user.id) | ||
456 | .to | ||
457 | .be | ||
458 | .a('number') | ||
350 | }) | 459 | }) |
351 | 460 | ||
352 | it('Should not be able to delete a user by a moderator', async function () { | 461 | it('Should not be able to delete a user by a moderator', async function () { |
@@ -369,10 +478,14 @@ describe('Test users', function () { | |||
369 | it('Should not have videos of this user', async function () { | 478 | it('Should not have videos of this user', async function () { |
370 | const res = await getVideosList(server.url) | 479 | const res = await getVideosList(server.url) |
371 | 480 | ||
372 | expect(res.body.total).to.equal(1) | 481 | expect(res.body.total) |
482 | .to | ||
483 | .equal(1) | ||
373 | 484 | ||
374 | const video = res.body.data[0] | 485 | const video = res.body.data[ 0 ] |
375 | expect(video.author).to.equal('root') | 486 | expect(video.account) |
487 | .to | ||
488 | .equal('root') | ||
376 | }) | 489 | }) |
377 | 490 | ||
378 | it('Should register a new user', async function () { | 491 | it('Should register a new user', async function () { |
@@ -392,14 +505,16 @@ describe('Test users', function () { | |||
392 | const res = await getMyUserInformation(server.url, accessToken) | 505 | const res = await getMyUserInformation(server.url, accessToken) |
393 | const user = res.body | 506 | const user = res.body |
394 | 507 | ||
395 | expect(user.videoQuota).to.equal(5 * 1024 * 1024) | 508 | expect(user.videoQuota) |
509 | .to | ||
510 | .equal(5 * 1024 * 1024) | ||
396 | }) | 511 | }) |
397 | 512 | ||
398 | after(async function () { | 513 | after(async function () { |
399 | killallServers([ server ]) | 514 | killallServers([ server ]) |
400 | 515 | ||
401 | // Keep the logs if the test failed | 516 | // Keep the logs if the test failed |
402 | if (this['ok']) { | 517 | if (this[ 'ok' ]) { |
403 | await flushTests() | 518 | await flushTests() |
404 | } | 519 | } |
405 | }) | 520 | }) |
diff --git a/server/tests/api/video-abuse.ts b/server/tests/api/video-abuse.ts index f2a2c322a..bc21ee59b 100644 --- a/server/tests/api/video-abuse.ts +++ b/server/tests/api/video-abuse.ts | |||
@@ -1,22 +1,22 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* tslint:disable:no-unused-expression */ |
2 | 2 | ||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
5 | const expect = chai.expect | 4 | import 'mocha' |
6 | |||
7 | import { | 5 | import { |
8 | ServerInfo, | ||
9 | flushAndRunMultipleServers, | 6 | flushAndRunMultipleServers, |
10 | uploadVideo, | 7 | flushTests, |
11 | makeFriends, | ||
12 | getVideosList, | ||
13 | wait, | ||
14 | setAccessTokensToServers, | ||
15 | getVideoAbusesList, | 8 | getVideoAbusesList, |
16 | reportVideoAbuse, | 9 | getVideosList, |
17 | killallServers, | 10 | killallServers, |
18 | flushTests | 11 | reportVideoAbuse, |
12 | ServerInfo, | ||
13 | setAccessTokensToServers, | ||
14 | uploadVideo, | ||
15 | wait | ||
19 | } from '../utils' | 16 | } from '../utils' |
17 | import { doubleFollow } from '../utils/follows' | ||
18 | |||
19 | const expect = chai.expect | ||
20 | 20 | ||
21 | describe('Test video abuses', function () { | 21 | describe('Test video abuses', function () { |
22 | let servers: ServerInfo[] = [] | 22 | let servers: ServerInfo[] = [] |
@@ -30,32 +30,32 @@ describe('Test video abuses', function () { | |||
30 | // Get the access tokens | 30 | // Get the access tokens |
31 | await setAccessTokensToServers(servers) | 31 | await setAccessTokensToServers(servers) |
32 | 32 | ||
33 | // Pod 1 makes friend with pod 2 | 33 | // Server 1 and server 2 follow each other |
34 | await makeFriends(servers[0].url, servers[0].accessToken) | 34 | await doubleFollow(servers[0], servers[1]) |
35 | 35 | ||
36 | // Upload some videos on each pods | 36 | // Upload some videos on each servers |
37 | const video1Attributes = { | 37 | const video1Attributes = { |
38 | name: 'my super name for pod 1', | 38 | name: 'my super name for server 1', |
39 | description: 'my super description for pod 1' | 39 | description: 'my super description for server 1' |
40 | } | 40 | } |
41 | await uploadVideo(servers[0].url, servers[0].accessToken, video1Attributes) | 41 | await uploadVideo(servers[0].url, servers[0].accessToken, video1Attributes) |
42 | 42 | ||
43 | const video2Attributes = { | 43 | const video2Attributes = { |
44 | name: 'my super name for pod 2', | 44 | name: 'my super name for server 2', |
45 | description: 'my super description for pod 2' | 45 | description: 'my super description for server 2' |
46 | } | 46 | } |
47 | await uploadVideo(servers[1].url, servers[1].accessToken, video2Attributes) | 47 | await uploadVideo(servers[1].url, servers[1].accessToken, video2Attributes) |
48 | 48 | ||
49 | // Wait videos propagation | 49 | // Wait videos propagation |
50 | await wait(22000) | 50 | await wait(25000) |
51 | 51 | ||
52 | const res = await getVideosList(servers[0].url) | 52 | const res = await getVideosList(servers[0].url) |
53 | const videos = res.body.data | 53 | const videos = res.body.data |
54 | 54 | ||
55 | expect(videos.length).to.equal(2) | 55 | expect(videos.length).to.equal(2) |
56 | 56 | ||
57 | servers[0].video = videos.find(video => video.name === 'my super name for pod 1') | 57 | servers[0].video = videos.find(video => video.name === 'my super name for server 1') |
58 | servers[1].video = videos.find(video => video.name === 'my super name for pod 2') | 58 | servers[1].video = videos.find(video => video.name === 'my super name for server 2') |
59 | }) | 59 | }) |
60 | 60 | ||
61 | it('Should not have video abuses', async function () { | 61 | it('Should not have video abuses', async function () { |
@@ -72,11 +72,11 @@ describe('Test video abuses', function () { | |||
72 | const reason = 'my super bad reason' | 72 | const reason = 'my super bad reason' |
73 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[0].video.id, reason) | 73 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[0].video.id, reason) |
74 | 74 | ||
75 | // We wait requests propagation, even if the pod 1 is not supposed to make a request to pod 2 | 75 | // We wait requests propagation, even if the server 1 is not supposed to make a request to server 2 |
76 | await wait(11000) | 76 | await wait(11000) |
77 | }) | 77 | }) |
78 | 78 | ||
79 | it('Should have 1 video abuses on pod 1 and 0 on pod 2', async function () { | 79 | it('Should have 1 video abuses on server 1 and 0 on server 2', async function () { |
80 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 80 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) |
81 | 81 | ||
82 | expect(res1.body.total).to.equal(1) | 82 | expect(res1.body.total).to.equal(1) |
@@ -86,7 +86,7 @@ describe('Test video abuses', function () { | |||
86 | const abuse = res1.body.data[0] | 86 | const abuse = res1.body.data[0] |
87 | expect(abuse.reason).to.equal('my super bad reason') | 87 | expect(abuse.reason).to.equal('my super bad reason') |
88 | expect(abuse.reporterUsername).to.equal('root') | 88 | expect(abuse.reporterUsername).to.equal('root') |
89 | expect(abuse.reporterPodHost).to.equal('localhost:9001') | 89 | expect(abuse.reporterServerHost).to.equal('localhost:9001') |
90 | expect(abuse.videoId).to.equal(servers[0].video.id) | 90 | expect(abuse.videoId).to.equal(servers[0].video.id) |
91 | 91 | ||
92 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 92 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) |
@@ -96,16 +96,16 @@ describe('Test video abuses', function () { | |||
96 | }) | 96 | }) |
97 | 97 | ||
98 | it('Should report abuse on a remote video', async function () { | 98 | it('Should report abuse on a remote video', async function () { |
99 | this.timeout(15000) | 99 | this.timeout(25000) |
100 | 100 | ||
101 | const reason = 'my super bad reason 2' | 101 | const reason = 'my super bad reason 2' |
102 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[1].video.id, reason) | 102 | await reportVideoAbuse(servers[0].url, servers[0].accessToken, servers[1].video.id, reason) |
103 | 103 | ||
104 | // We wait requests propagation | 104 | // We wait requests propagation |
105 | await wait(11000) | 105 | await wait(15000) |
106 | }) | 106 | }) |
107 | 107 | ||
108 | it('Should have 2 video abuse on pod 1 and 1 on pod 2', async function () { | 108 | it('Should have 2 video abuse on server 1 and 1 on server 2', async function () { |
109 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 109 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) |
110 | expect(res1.body.total).to.equal(2) | 110 | expect(res1.body.total).to.equal(2) |
111 | expect(res1.body.data).to.be.an('array') | 111 | expect(res1.body.data).to.be.an('array') |
@@ -114,13 +114,13 @@ describe('Test video abuses', function () { | |||
114 | const abuse1 = res1.body.data[0] | 114 | const abuse1 = res1.body.data[0] |
115 | expect(abuse1.reason).to.equal('my super bad reason') | 115 | expect(abuse1.reason).to.equal('my super bad reason') |
116 | expect(abuse1.reporterUsername).to.equal('root') | 116 | expect(abuse1.reporterUsername).to.equal('root') |
117 | expect(abuse1.reporterPodHost).to.equal('localhost:9001') | 117 | expect(abuse1.reporterServerHost).to.equal('localhost:9001') |
118 | expect(abuse1.videoId).to.equal(servers[0].video.id) | 118 | expect(abuse1.videoId).to.equal(servers[0].video.id) |
119 | 119 | ||
120 | const abuse2 = res1.body.data[1] | 120 | const abuse2 = res1.body.data[1] |
121 | expect(abuse2.reason).to.equal('my super bad reason 2') | 121 | expect(abuse2.reason).to.equal('my super bad reason 2') |
122 | expect(abuse2.reporterUsername).to.equal('root') | 122 | expect(abuse2.reporterUsername).to.equal('root') |
123 | expect(abuse2.reporterPodHost).to.equal('localhost:9001') | 123 | expect(abuse2.reporterServerHost).to.equal('localhost:9001') |
124 | expect(abuse2.videoId).to.equal(servers[1].video.id) | 124 | expect(abuse2.videoId).to.equal(servers[1].video.id) |
125 | 125 | ||
126 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 126 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) |
@@ -131,7 +131,7 @@ describe('Test video abuses', function () { | |||
131 | const abuse3 = res2.body.data[0] | 131 | const abuse3 = res2.body.data[0] |
132 | expect(abuse3.reason).to.equal('my super bad reason 2') | 132 | expect(abuse3.reason).to.equal('my super bad reason 2') |
133 | expect(abuse3.reporterUsername).to.equal('root') | 133 | expect(abuse3.reporterUsername).to.equal('root') |
134 | expect(abuse3.reporterPodHost).to.equal('localhost:9001') | 134 | expect(abuse3.reporterServerHost).to.equal('localhost:9001') |
135 | }) | 135 | }) |
136 | 136 | ||
137 | after(async function () { | 137 | after(async function () { |