Cleanup reset user password by admin
[oweals/peertube.git] / server / tests / api / check-params / videos.ts
1 /* tslint:disable:no-unused-expression */
2
3 import * as chai from 'chai'
4 import { omit } from 'lodash'
5 import 'mocha'
6 import { join } from 'path'
7 import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enum'
8 import {
9   createUser, flushTests, getMyUserInformation, getVideo, getVideosList, immutableAssign, killallServers, makeDeleteRequest,
10   makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, runServer, ServerInfo, setAccessTokensToServers, userLogin
11 } from '../../../../shared/utils'
12 import {
13   checkBadCountPagination,
14   checkBadSortPagination,
15   checkBadStartPagination
16 } from '../../../../shared/utils/requests/check-api-params'
17 import { getAccountsList } from '../../../../shared/utils/users/accounts'
18
19 const expect = chai.expect
20
21 describe('Test videos API validator', function () {
22   const path = '/api/v1/videos/'
23   let server: ServerInfo
24   let userAccessToken = ''
25   let accountName: string
26   let channelId: number
27   let channelName: string
28   let videoId
29
30   // ---------------------------------------------------------------
31
32   before(async function () {
33     this.timeout(30000)
34
35     await flushTests()
36
37     server = await runServer(1)
38
39     await setAccessTokensToServers([ server ])
40
41     const username = 'user1'
42     const password = 'my super password'
43     await createUser(server.url, server.accessToken, username, password)
44     userAccessToken = await userLogin(server, { username, password })
45
46     {
47       const res = await getMyUserInformation(server.url, server.accessToken)
48       channelId = res.body.videoChannels[ 0 ].id
49       channelName = res.body.videoChannels[ 0 ].name
50       accountName = res.body.account.name + '@' + res.body.account.host
51     }
52   })
53
54   describe('When listing a video', function () {
55     it('Should fail with a bad start pagination', async function () {
56       await checkBadStartPagination(server.url, path)
57     })
58
59     it('Should fail with a bad count pagination', async function () {
60       await checkBadCountPagination(server.url, path)
61     })
62
63     it('Should fail with an incorrect sort', async function () {
64       await checkBadSortPagination(server.url, path)
65     })
66
67     it('Should success with the correct parameters', async function () {
68       await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
69     })
70   })
71
72   describe('When searching a video', function () {
73
74     it('Should fail with nothing', async function () {
75       await makeGetRequest({
76         url: server.url,
77         path: join(path, 'search'),
78         statusCodeExpected: 400
79       })
80     })
81
82     it('Should fail with a bad start pagination', async function () {
83       await checkBadStartPagination(server.url, join(path, 'search', 'test'))
84     })
85
86     it('Should fail with a bad count pagination', async function () {
87       await checkBadCountPagination(server.url, join(path, 'search', 'test'))
88     })
89
90     it('Should fail with an incorrect sort', async function () {
91       await checkBadSortPagination(server.url, join(path, 'search', 'test'))
92     })
93
94     it('Should success with the correct parameters', async function () {
95       await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
96     })
97   })
98
99   describe('When listing my videos', function () {
100     const path = '/api/v1/users/me/videos'
101
102     it('Should fail with a bad start pagination', async function () {
103       await checkBadStartPagination(server.url, path, server.accessToken)
104     })
105
106     it('Should fail with a bad count pagination', async function () {
107       await checkBadCountPagination(server.url, path, server.accessToken)
108     })
109
110     it('Should fail with an incorrect sort', async function () {
111       await checkBadSortPagination(server.url, path, server.accessToken)
112     })
113
114     it('Should success with the correct parameters', async function () {
115       await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: 200 })
116     })
117   })
118
119   describe('When listing account videos', function () {
120     let path: string
121
122     before(async function () {
123       path = '/api/v1/accounts/' + accountName + '/videos'
124     })
125
126     it('Should fail with a bad start pagination', async function () {
127       await checkBadStartPagination(server.url, path, server.accessToken)
128     })
129
130     it('Should fail with a bad count pagination', async function () {
131       await checkBadCountPagination(server.url, path, server.accessToken)
132     })
133
134     it('Should fail with an incorrect sort', async function () {
135       await checkBadSortPagination(server.url, path, server.accessToken)
136     })
137
138     it('Should success with the correct parameters', async function () {
139       await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
140     })
141   })
142
143   describe('When listing video channel videos', function () {
144     let path: string
145
146     before(async function () {
147       path = '/api/v1/video-channels/' + channelName + '/videos'
148     })
149
150     it('Should fail with a bad start pagination', async function () {
151       await checkBadStartPagination(server.url, path, server.accessToken)
152     })
153
154     it('Should fail with a bad count pagination', async function () {
155       await checkBadCountPagination(server.url, path, server.accessToken)
156     })
157
158     it('Should fail with an incorrect sort', async function () {
159       await checkBadSortPagination(server.url, path, server.accessToken)
160     })
161
162     it('Should success with the correct parameters', async function () {
163       await makeGetRequest({ url: server.url, path, statusCodeExpected: 200 })
164     })
165   })
166
167   describe('When adding a video', function () {
168     let baseCorrectParams
169     const baseCorrectAttaches = {
170       'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
171     }
172
173     before(function () {
174       // Put in before to have channelId
175       baseCorrectParams = {
176         name: 'my super name',
177         category: 5,
178         licence: 1,
179         language: 'pt',
180         nsfw: false,
181         commentsEnabled: true,
182         waitTranscoding: true,
183         description: 'my super description',
184         support: 'my super support text',
185         tags: [ 'tag1', 'tag2' ],
186         privacy: VideoPrivacy.PUBLIC,
187         channelId: channelId
188       }
189     })
190
191     it('Should fail with nothing', async function () {
192       const fields = {}
193       const attaches = {}
194       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
195     })
196
197     it('Should fail without name', async function () {
198       const fields = omit(baseCorrectParams, 'name')
199       const attaches = baseCorrectAttaches
200
201       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
202     })
203
204     it('Should fail with a long name', async function () {
205       const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
206       const attaches = baseCorrectAttaches
207
208       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
209     })
210
211     it('Should fail with a bad category', async function () {
212       const fields = immutableAssign(baseCorrectParams, { category: 125 })
213       const attaches = baseCorrectAttaches
214
215       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
216     })
217
218     it('Should fail with a bad licence', async function () {
219       const fields = immutableAssign(baseCorrectParams, { licence: 125 })
220       const attaches = baseCorrectAttaches
221
222       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
223     })
224
225     it('Should fail with a bad language', async function () {
226       const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) })
227       const attaches = baseCorrectAttaches
228
229       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
230     })
231
232     it('Should fail with a long description', async function () {
233       const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
234       const attaches = baseCorrectAttaches
235
236       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
237     })
238
239     it('Should fail with a long support text', async function () {
240       const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
241       const attaches = baseCorrectAttaches
242
243       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
244     })
245
246     it('Should fail without a channel', async function () {
247       const fields = omit(baseCorrectParams, 'channelId')
248       const attaches = baseCorrectAttaches
249
250       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
251     })
252
253     it('Should fail with a bad channel', async function () {
254       const fields = immutableAssign(baseCorrectParams, { channelId: 545454 })
255       const attaches = baseCorrectAttaches
256
257       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
258     })
259
260     it('Should fail with another user channel', async function () {
261       const user = {
262         username: 'fake',
263         password: 'fake_password'
264       }
265       await createUser(server.url, server.accessToken, user.username, user.password)
266
267       const accessTokenUser = await userLogin(server, user)
268       const res = await getMyUserInformation(server.url, accessTokenUser)
269       const customChannelId = res.body.videoChannels[0].id
270
271       const fields = immutableAssign(baseCorrectParams, { channelId: customChannelId })
272       const attaches = baseCorrectAttaches
273
274       await makeUploadRequest({ url: server.url, path: path + '/upload', token: userAccessToken, fields, attaches })
275     })
276
277     it('Should fail with too many tags', async function () {
278       const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
279       const attaches = baseCorrectAttaches
280
281       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
282     })
283
284     it('Should fail with a tag length too low', async function () {
285       const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
286       const attaches = baseCorrectAttaches
287
288       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
289     })
290
291     it('Should fail with a tag length too big', async function () {
292       const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
293       const attaches = baseCorrectAttaches
294
295       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
296     })
297
298     it('Should fail with a bad schedule update (miss updateAt)', async function () {
299       const fields = immutableAssign(baseCorrectParams, { 'scheduleUpdate[privacy]': VideoPrivacy.PUBLIC })
300       const attaches = baseCorrectAttaches
301
302       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
303     })
304
305     it('Should fail with a bad schedule update (wrong updateAt)', async function () {
306       const fields = immutableAssign(baseCorrectParams, {
307         'scheduleUpdate[privacy]': VideoPrivacy.PUBLIC,
308         'scheduleUpdate[updateAt]': 'toto'
309       })
310       const attaches = baseCorrectAttaches
311
312       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
313     })
314
315     it('Should fail without an input file', async function () {
316       const fields = baseCorrectParams
317       const attaches = {}
318       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
319     })
320
321     it('Should fail without an incorrect input file', async function () {
322       const fields = baseCorrectParams
323       let attaches = {
324         'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short_fake.webm')
325       }
326       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
327
328       attaches = {
329         'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mkv')
330       }
331       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
332     })
333
334     it('Should fail with an incorrect thumbnail file', async function () {
335       const fields = baseCorrectParams
336       const attaches = {
337         'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'),
338         'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
339       }
340
341       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
342     })
343
344     it('Should fail with a big thumbnail file', async function () {
345       const fields = baseCorrectParams
346       const attaches = {
347         'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'),
348         'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
349       }
350
351       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
352     })
353
354     it('Should fail with an incorrect preview file', async function () {
355       const fields = baseCorrectParams
356       const attaches = {
357         'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png'),
358         'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
359       }
360
361       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
362     })
363
364     it('Should fail with a big preview file', async function () {
365       const fields = baseCorrectParams
366       const attaches = {
367         'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png'),
368         'videofile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
369       }
370
371       await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches })
372     })
373
374     it('Should succeed with the correct parameters', async function () {
375       this.timeout(10000)
376
377       const fields = baseCorrectParams
378
379       {
380         const attaches = baseCorrectAttaches
381         await makeUploadRequest({
382           url: server.url,
383           path: path + '/upload',
384           token: server.accessToken,
385           fields,
386           attaches,
387           statusCodeExpected: 200
388         })
389       }
390
391       {
392         const attaches = immutableAssign(baseCorrectAttaches, {
393           videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
394         })
395
396         await makeUploadRequest({
397           url: server.url,
398           path: path + '/upload',
399           token: server.accessToken,
400           fields,
401           attaches,
402           statusCodeExpected: 200
403         })
404       }
405
406       {
407         const attaches = immutableAssign(baseCorrectAttaches, {
408           videofile: join(__dirname, '..', '..', 'fixtures', 'video_short.ogv')
409         })
410
411         await makeUploadRequest({
412           url: server.url,
413           path: path + '/upload',
414           token: server.accessToken,
415           fields,
416           attaches,
417           statusCodeExpected: 200
418         })
419       }
420     })
421   })
422
423   describe('When updating a video', function () {
424     const baseCorrectParams = {
425       name: 'my super name',
426       category: 5,
427       licence: 2,
428       language: 'pt',
429       nsfw: false,
430       commentsEnabled: false,
431       description: 'my super description',
432       privacy: VideoPrivacy.PUBLIC,
433       tags: [ 'tag1', 'tag2' ]
434     }
435
436     before(async function () {
437       const res = await getVideosList(server.url)
438       videoId = res.body.data[0].uuid
439     })
440
441     it('Should fail with nothing', async function () {
442       const fields = {}
443       await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields })
444     })
445
446     it('Should fail without a valid uuid', async function () {
447       const fields = baseCorrectParams
448       await makePutBodyRequest({ url: server.url, path: path + 'blabla', token: server.accessToken, fields })
449     })
450
451     it('Should fail with an unknown id', async function () {
452       const fields = baseCorrectParams
453
454       await makePutBodyRequest({
455         url: server.url,
456         path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
457         token: server.accessToken,
458         fields,
459         statusCodeExpected: 404
460       })
461     })
462
463     it('Should fail with a long name', async function () {
464       const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(65) })
465
466       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
467     })
468
469     it('Should fail with a bad category', async function () {
470       const fields = immutableAssign(baseCorrectParams, { category: 125 })
471
472       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
473     })
474
475     it('Should fail with a bad licence', async function () {
476       const fields = immutableAssign(baseCorrectParams, { licence: 125 })
477
478       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
479     })
480
481     it('Should fail with a bad language', async function () {
482       const fields = immutableAssign(baseCorrectParams, { language: 'a'.repeat(15) })
483
484       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
485     })
486
487     it('Should fail with a long description', async function () {
488       const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(2500) })
489
490       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
491     })
492
493     it('Should fail with a long support text', async function () {
494       const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(201) })
495
496       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
497     })
498
499     it('Should fail with a bad channel', async function () {
500       const fields = immutableAssign(baseCorrectParams, { channelId: 545454 })
501
502       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
503     })
504
505     it('Should fail with too many tags', async function () {
506       const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6' ] })
507
508       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
509     })
510
511     it('Should fail with a tag length too low', async function () {
512       const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 't' ] })
513
514       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
515     })
516
517     it('Should fail with a tag length too big', async function () {
518       const fields = immutableAssign(baseCorrectParams, { tags: [ 'tag1', 'my_super_tag_too_long_long_long_long_long_long' ] })
519
520       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
521     })
522
523     it('Should fail with a bad schedule update (miss updateAt)', async function () {
524       const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { privacy: VideoPrivacy.PUBLIC } })
525
526       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
527     })
528
529     it('Should fail with a bad schedule update (wrong updateAt)', async function () {
530       const fields = immutableAssign(baseCorrectParams, { scheduleUpdate: { updateAt: 'toto', privacy: VideoPrivacy.PUBLIC } })
531
532       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields })
533     })
534
535     it('Should fail with an incorrect thumbnail file', async function () {
536       const fields = baseCorrectParams
537       const attaches = {
538         'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
539       }
540
541       await makeUploadRequest({
542         url: server.url,
543         method: 'PUT',
544         path: path + videoId,
545         token: server.accessToken,
546         fields,
547         attaches
548       })
549     })
550
551     it('Should fail with a big thumbnail file', async function () {
552       const fields = baseCorrectParams
553       const attaches = {
554         'thumbnailfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
555       }
556
557       await makeUploadRequest({
558         url: server.url,
559         method: 'PUT',
560         path: path + videoId,
561         token: server.accessToken,
562         fields,
563         attaches
564       })
565     })
566
567     it('Should fail with an incorrect preview file', async function () {
568       const fields = baseCorrectParams
569       const attaches = {
570         'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
571       }
572
573       await makeUploadRequest({
574         url: server.url,
575         method: 'PUT',
576         path: path + videoId,
577         token: server.accessToken,
578         fields,
579         attaches
580       })
581     })
582
583     it('Should fail with a big preview file', async function () {
584       const fields = baseCorrectParams
585       const attaches = {
586         'previewfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
587       }
588
589       await makeUploadRequest({
590         url: server.url,
591         method: 'PUT',
592         path: path + videoId,
593         token: server.accessToken,
594         fields,
595         attaches
596       })
597     })
598
599     it('Should fail with a video of another user without the appropriate right', async function () {
600       const fields = baseCorrectParams
601
602       await makePutBodyRequest({ url: server.url, path: path + videoId, token: userAccessToken, fields, statusCodeExpected: 403 })
603     })
604
605     it('Should fail with a video of another server')
606
607     it('Should succeed with the correct parameters', async function () {
608       const fields = baseCorrectParams
609
610       await makePutBodyRequest({ url: server.url, path: path + videoId, token: server.accessToken, fields, statusCodeExpected: 204 })
611     })
612   })
613
614   describe('When getting a video', function () {
615     it('Should return the list of the videos with nothing', async function () {
616       const res = await makeGetRequest({
617         url: server.url,
618         path,
619         statusCodeExpected: 200
620       })
621
622       expect(res.body.data).to.be.an('array')
623       expect(res.body.data.length).to.equal(3)
624     })
625
626     it('Should fail without a correct uuid', async function () {
627       await getVideo(server.url, 'coucou', 400)
628     })
629
630     it('Should return 404 with an incorrect video', async function () {
631       await getVideo(server.url, '4da6fde3-88f7-4d16-b119-108df5630b06', 404)
632     })
633
634     it('Should succeed with the correct parameters', async function () {
635       await getVideo(server.url, videoId)
636     })
637   })
638
639   describe('When rating a video', function () {
640     let videoId
641
642     before(async function () {
643       const res = await getVideosList(server.url)
644       videoId = res.body.data[0].id
645     })
646
647     it('Should fail without a valid uuid', async function () {
648       const fields = {
649         rating: 'like'
650       }
651       await makePutBodyRequest({ url: server.url, path: path + 'blabla/rate', token: server.accessToken, fields })
652     })
653
654     it('Should fail with an unknown id', async function () {
655       const fields = {
656         rating: 'like'
657       }
658       await makePutBodyRequest({
659         url: server.url,
660         path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
661         token: server.accessToken,
662         fields,
663         statusCodeExpected: 404
664       })
665     })
666
667     it('Should fail with a wrong rating', async function () {
668       const fields = {
669         rating: 'likes'
670       }
671       await makePutBodyRequest({ url: server.url, path: path + videoId + '/rate', token: server.accessToken, fields })
672     })
673
674     it('Should succeed with the correct parameters', async function () {
675       const fields = {
676         rating: 'like'
677       }
678       await makePutBodyRequest({
679         url: server.url,
680         path: path + videoId + '/rate',
681         token: server.accessToken,
682         fields,
683         statusCodeExpected: 204
684       })
685     })
686   })
687
688   describe('When removing a video', function () {
689     it('Should have 404 with nothing', async function () {
690       await makeDeleteRequest({
691         url: server.url,
692         path,
693         statusCodeExpected: 400
694       })
695     })
696
697     it('Should fail without a correct uuid', async function () {
698       await removeVideo(server.url, server.accessToken, 'hello', 400)
699     })
700
701     it('Should fail with a video which does not exist', async function () {
702       await removeVideo(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', 404)
703     })
704
705     it('Should fail with a video of another user without the appropriate right', async function () {
706       await removeVideo(server.url, userAccessToken, videoId, 403)
707     })
708
709     it('Should fail with a video of another server')
710
711     it('Should succeed with the correct parameters', async function () {
712       await removeVideo(server.url, server.accessToken, videoId)
713     })
714   })
715
716   after(async function () {
717     killallServers([ server ])
718
719     // Keep the logs if the test failed
720     if (this['ok']) {
721       await flushTests()
722     }
723   })
724 })