diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/blocklist.ts | 72 | ||||
-rw-r--r-- | server/tests/api/check-params/config.ts | 12 | ||||
-rw-r--r-- | server/tests/api/check-params/plugins.ts | 2 | ||||
-rw-r--r-- | server/tests/api/moderation/blocklist.ts | 107 | ||||
-rw-r--r-- | server/tests/api/notifications/moderation-notifications.ts | 84 | ||||
-rw-r--r-- | server/tests/api/notifications/user-notifications.ts | 2 | ||||
-rw-r--r-- | server/tests/api/redundancy/redundancy.ts | 16 | ||||
-rw-r--r-- | server/tests/api/server/config.ts | 18 | ||||
-rw-r--r-- | server/tests/api/server/email.ts | 2 | ||||
-rw-r--r-- | server/tests/api/videos/video-privacy.ts | 13 | ||||
-rw-r--r-- | server/tests/cli/peertube.ts | 19 | ||||
-rw-r--r-- | server/tests/cli/prune-storage.ts | 49 | ||||
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test/main.js | 22 | ||||
-rw-r--r-- | server/tests/plugins/external-auth.ts | 2 | ||||
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 69 |
15 files changed, 406 insertions, 83 deletions
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts index 7d5fae5cf..f72a892e2 100644 --- a/server/tests/api/check-params/blocklist.ts +++ b/server/tests/api/check-params/blocklist.ts | |||
@@ -481,6 +481,78 @@ describe('Test blocklist API validators', function () { | |||
481 | }) | 481 | }) |
482 | }) | 482 | }) |
483 | 483 | ||
484 | describe('When getting blocklist status', function () { | ||
485 | const path = '/api/v1/blocklist/status' | ||
486 | |||
487 | it('Should fail with a bad token', async function () { | ||
488 | await makeGetRequest({ | ||
489 | url: server.url, | ||
490 | path, | ||
491 | token: 'false', | ||
492 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 | ||
493 | }) | ||
494 | }) | ||
495 | |||
496 | it('Should fail with a bad accounts field', async function () { | ||
497 | await makeGetRequest({ | ||
498 | url: server.url, | ||
499 | path, | ||
500 | query: { | ||
501 | accounts: 1 | ||
502 | }, | ||
503 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
504 | }) | ||
505 | |||
506 | await makeGetRequest({ | ||
507 | url: server.url, | ||
508 | path, | ||
509 | query: { | ||
510 | accounts: [ 1 ] | ||
511 | }, | ||
512 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
513 | }) | ||
514 | }) | ||
515 | |||
516 | it('Should fail with a bad hosts field', async function () { | ||
517 | await makeGetRequest({ | ||
518 | url: server.url, | ||
519 | path, | ||
520 | query: { | ||
521 | hosts: 1 | ||
522 | }, | ||
523 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
524 | }) | ||
525 | |||
526 | await makeGetRequest({ | ||
527 | url: server.url, | ||
528 | path, | ||
529 | query: { | ||
530 | hosts: [ 1 ] | ||
531 | }, | ||
532 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | ||
533 | }) | ||
534 | }) | ||
535 | |||
536 | it('Should succeed with the correct parameters', async function () { | ||
537 | await makeGetRequest({ | ||
538 | url: server.url, | ||
539 | path, | ||
540 | query: {}, | ||
541 | expectedStatus: HttpStatusCode.OK_200 | ||
542 | }) | ||
543 | |||
544 | await makeGetRequest({ | ||
545 | url: server.url, | ||
546 | path, | ||
547 | query: { | ||
548 | hosts: [ 'example.com' ], | ||
549 | accounts: [ 'john@example.com' ] | ||
550 | }, | ||
551 | expectedStatus: HttpStatusCode.OK_200 | ||
552 | }) | ||
553 | }) | ||
554 | }) | ||
555 | |||
484 | after(async function () { | 556 | after(async function () { |
485 | await cleanupTests(servers) | 557 | await cleanupTests(servers) |
486 | }) | 558 | }) |
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index d0cd7722b..a6e87730a 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -54,6 +54,18 @@ describe('Test config API validators', function () { | |||
54 | whitelisted: true | 54 | whitelisted: true |
55 | } | 55 | } |
56 | }, | 56 | }, |
57 | client: { | ||
58 | videos: { | ||
59 | miniature: { | ||
60 | preferAuthorDisplayName: false | ||
61 | } | ||
62 | }, | ||
63 | menu: { | ||
64 | login: { | ||
65 | redirectOnSingleExternalAuth: false | ||
66 | } | ||
67 | } | ||
68 | }, | ||
57 | cache: { | 69 | cache: { |
58 | previews: { | 70 | previews: { |
59 | size: 2 | 71 | size: 2 |
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts index 33f84ecbc..2c436376c 100644 --- a/server/tests/api/check-params/plugins.ts +++ b/server/tests/api/check-params/plugins.ts | |||
@@ -30,7 +30,7 @@ describe('Test server plugins API validators', function () { | |||
30 | // --------------------------------------------------------------- | 30 | // --------------------------------------------------------------- |
31 | 31 | ||
32 | before(async function () { | 32 | before(async function () { |
33 | this.timeout(30000) | 33 | this.timeout(60000) |
34 | 34 | ||
35 | server = await createSingleServer(1) | 35 | server = await createSingleServer(1) |
36 | 36 | ||
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts index 089af8b15..b3fd8ecac 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/server/tests/api/moderation/blocklist.ts | |||
@@ -254,6 +254,45 @@ describe('Test blocklist', function () { | |||
254 | } | 254 | } |
255 | }) | 255 | }) |
256 | 256 | ||
257 | it('Should get blocked status', async function () { | ||
258 | const remoteHandle = 'user2@' + servers[1].host | ||
259 | const localHandle = 'user1@' + servers[0].host | ||
260 | const unknownHandle = 'user5@' + servers[0].host | ||
261 | |||
262 | { | ||
263 | const status = await command.getStatus({ accounts: [ remoteHandle ] }) | ||
264 | expect(Object.keys(status.accounts)).to.have.lengthOf(1) | ||
265 | expect(status.accounts[remoteHandle].blockedByUser).to.be.false | ||
266 | expect(status.accounts[remoteHandle].blockedByServer).to.be.false | ||
267 | |||
268 | expect(Object.keys(status.hosts)).to.have.lengthOf(0) | ||
269 | } | ||
270 | |||
271 | { | ||
272 | const status = await command.getStatus({ token: servers[0].accessToken, accounts: [ remoteHandle ] }) | ||
273 | expect(Object.keys(status.accounts)).to.have.lengthOf(1) | ||
274 | expect(status.accounts[remoteHandle].blockedByUser).to.be.true | ||
275 | expect(status.accounts[remoteHandle].blockedByServer).to.be.false | ||
276 | |||
277 | expect(Object.keys(status.hosts)).to.have.lengthOf(0) | ||
278 | } | ||
279 | |||
280 | { | ||
281 | const status = await command.getStatus({ token: servers[0].accessToken, accounts: [ localHandle, remoteHandle, unknownHandle ] }) | ||
282 | expect(Object.keys(status.accounts)).to.have.lengthOf(3) | ||
283 | |||
284 | for (const handle of [ localHandle, remoteHandle ]) { | ||
285 | expect(status.accounts[handle].blockedByUser).to.be.true | ||
286 | expect(status.accounts[handle].blockedByServer).to.be.false | ||
287 | } | ||
288 | |||
289 | expect(status.accounts[unknownHandle].blockedByUser).to.be.false | ||
290 | expect(status.accounts[unknownHandle].blockedByServer).to.be.false | ||
291 | |||
292 | expect(Object.keys(status.hosts)).to.have.lengthOf(0) | ||
293 | } | ||
294 | }) | ||
295 | |||
257 | it('Should not allow a remote blocked user to comment my videos', async function () { | 296 | it('Should not allow a remote blocked user to comment my videos', async function () { |
258 | this.timeout(60000) | 297 | this.timeout(60000) |
259 | 298 | ||
@@ -434,6 +473,35 @@ describe('Test blocklist', function () { | |||
434 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) | 473 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) |
435 | }) | 474 | }) |
436 | 475 | ||
476 | it('Should get blocklist status', async function () { | ||
477 | const blockedServer = servers[1].host | ||
478 | const notBlockedServer = 'example.com' | ||
479 | |||
480 | { | ||
481 | const status = await command.getStatus({ hosts: [ blockedServer, notBlockedServer ] }) | ||
482 | expect(Object.keys(status.accounts)).to.have.lengthOf(0) | ||
483 | |||
484 | expect(Object.keys(status.hosts)).to.have.lengthOf(2) | ||
485 | expect(status.hosts[blockedServer].blockedByUser).to.be.false | ||
486 | expect(status.hosts[blockedServer].blockedByServer).to.be.false | ||
487 | |||
488 | expect(status.hosts[notBlockedServer].blockedByUser).to.be.false | ||
489 | expect(status.hosts[notBlockedServer].blockedByServer).to.be.false | ||
490 | } | ||
491 | |||
492 | { | ||
493 | const status = await command.getStatus({ token: servers[0].accessToken, hosts: [ blockedServer, notBlockedServer ] }) | ||
494 | expect(Object.keys(status.accounts)).to.have.lengthOf(0) | ||
495 | |||
496 | expect(Object.keys(status.hosts)).to.have.lengthOf(2) | ||
497 | expect(status.hosts[blockedServer].blockedByUser).to.be.true | ||
498 | expect(status.hosts[blockedServer].blockedByServer).to.be.false | ||
499 | |||
500 | expect(status.hosts[notBlockedServer].blockedByUser).to.be.false | ||
501 | expect(status.hosts[notBlockedServer].blockedByServer).to.be.false | ||
502 | } | ||
503 | }) | ||
504 | |||
437 | it('Should unblock the remote server', async function () { | 505 | it('Should unblock the remote server', async function () { |
438 | await command.removeFromMyBlocklist({ server: 'localhost:' + servers[1].port }) | 506 | await command.removeFromMyBlocklist({ server: 'localhost:' + servers[1].port }) |
439 | }) | 507 | }) |
@@ -575,6 +643,27 @@ describe('Test blocklist', function () { | |||
575 | } | 643 | } |
576 | }) | 644 | }) |
577 | 645 | ||
646 | it('Should get blocked status', async function () { | ||
647 | const remoteHandle = 'user2@' + servers[1].host | ||
648 | const localHandle = 'user1@' + servers[0].host | ||
649 | const unknownHandle = 'user5@' + servers[0].host | ||
650 | |||
651 | for (const token of [ undefined, servers[0].accessToken ]) { | ||
652 | const status = await command.getStatus({ token, accounts: [ localHandle, remoteHandle, unknownHandle ] }) | ||
653 | expect(Object.keys(status.accounts)).to.have.lengthOf(3) | ||
654 | |||
655 | for (const handle of [ localHandle, remoteHandle ]) { | ||
656 | expect(status.accounts[handle].blockedByUser).to.be.false | ||
657 | expect(status.accounts[handle].blockedByServer).to.be.true | ||
658 | } | ||
659 | |||
660 | expect(status.accounts[unknownHandle].blockedByUser).to.be.false | ||
661 | expect(status.accounts[unknownHandle].blockedByServer).to.be.false | ||
662 | |||
663 | expect(Object.keys(status.hosts)).to.have.lengthOf(0) | ||
664 | } | ||
665 | }) | ||
666 | |||
578 | it('Should unblock the remote account', async function () { | 667 | it('Should unblock the remote account', async function () { |
579 | await command.removeFromServerBlocklist({ account: 'user2@localhost:' + servers[1].port }) | 668 | await command.removeFromServerBlocklist({ account: 'user2@localhost:' + servers[1].port }) |
580 | }) | 669 | }) |
@@ -620,6 +709,7 @@ describe('Test blocklist', function () { | |||
620 | }) | 709 | }) |
621 | 710 | ||
622 | describe('When managing server blocklist', function () { | 711 | describe('When managing server blocklist', function () { |
712 | |||
623 | it('Should list all videos', async function () { | 713 | it('Should list all videos', async function () { |
624 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { | 714 | for (const token of [ userModeratorToken, servers[0].accessToken ]) { |
625 | await checkAllVideos(servers[0], token) | 715 | await checkAllVideos(servers[0], token) |
@@ -713,6 +803,23 @@ describe('Test blocklist', function () { | |||
713 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) | 803 | expect(block.blockedServer.host).to.equal('localhost:' + servers[1].port) |
714 | }) | 804 | }) |
715 | 805 | ||
806 | it('Should get blocklist status', async function () { | ||
807 | const blockedServer = servers[1].host | ||
808 | const notBlockedServer = 'example.com' | ||
809 | |||
810 | for (const token of [ undefined, servers[0].accessToken ]) { | ||
811 | const status = await command.getStatus({ token, hosts: [ blockedServer, notBlockedServer ] }) | ||
812 | expect(Object.keys(status.accounts)).to.have.lengthOf(0) | ||
813 | |||
814 | expect(Object.keys(status.hosts)).to.have.lengthOf(2) | ||
815 | expect(status.hosts[blockedServer].blockedByUser).to.be.false | ||
816 | expect(status.hosts[blockedServer].blockedByServer).to.be.true | ||
817 | |||
818 | expect(status.hosts[notBlockedServer].blockedByUser).to.be.false | ||
819 | expect(status.hosts[notBlockedServer].blockedByServer).to.be.false | ||
820 | } | ||
821 | }) | ||
822 | |||
716 | it('Should unblock the remote server', async function () { | 823 | it('Should unblock the remote server', async function () { |
717 | await command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port }) | 824 | await command.removeFromServerBlocklist({ server: 'localhost:' + servers[1].port }) |
718 | }) | 825 | }) |
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index f806fed31..81ce8061b 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts | |||
@@ -24,11 +24,13 @@ import { | |||
24 | wait, | 24 | wait, |
25 | waitJobs | 25 | waitJobs |
26 | } from '@shared/extra-utils' | 26 | } from '@shared/extra-utils' |
27 | import { AbuseState, CustomConfig, UserNotification, VideoPrivacy } from '@shared/models' | 27 | import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models' |
28 | 28 | ||
29 | describe('Test moderation notifications', function () { | 29 | describe('Test moderation notifications', function () { |
30 | let servers: PeerTubeServer[] = [] | 30 | let servers: PeerTubeServer[] = [] |
31 | let userAccessToken: string | 31 | let userToken1: string |
32 | let userToken2: string | ||
33 | |||
32 | let userNotifications: UserNotification[] = [] | 34 | let userNotifications: UserNotification[] = [] |
33 | let adminNotifications: UserNotification[] = [] | 35 | let adminNotifications: UserNotification[] = [] |
34 | let adminNotificationsServer2: UserNotification[] = [] | 36 | let adminNotificationsServer2: UserNotification[] = [] |
@@ -39,11 +41,13 @@ describe('Test moderation notifications', function () { | |||
39 | 41 | ||
40 | const res = await prepareNotificationsTest(3) | 42 | const res = await prepareNotificationsTest(3) |
41 | emails = res.emails | 43 | emails = res.emails |
42 | userAccessToken = res.userAccessToken | 44 | userToken1 = res.userAccessToken |
43 | servers = res.servers | 45 | servers = res.servers |
44 | userNotifications = res.userNotifications | 46 | userNotifications = res.userNotifications |
45 | adminNotifications = res.adminNotifications | 47 | adminNotifications = res.adminNotifications |
46 | adminNotificationsServer2 = res.adminNotificationsServer2 | 48 | adminNotificationsServer2 = res.adminNotificationsServer2 |
49 | |||
50 | userToken2 = await servers[1].users.generateUserAndToken('user2', UserRole.USER) | ||
47 | }) | 51 | }) |
48 | 52 | ||
49 | describe('Abuse for moderators notification', function () { | 53 | describe('Abuse for moderators notification', function () { |
@@ -58,15 +62,27 @@ describe('Test moderation notifications', function () { | |||
58 | } | 62 | } |
59 | }) | 63 | }) |
60 | 64 | ||
61 | it('Should send a notification to moderators on local video abuse', async function () { | 65 | it('Should not send a notification to moderators on local abuse reported by an admin', async function () { |
62 | this.timeout(20000) | 66 | this.timeout(20000) |
63 | 67 | ||
64 | const name = 'video for abuse ' + buildUUID() | 68 | const name = 'video for abuse ' + buildUUID() |
65 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 69 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
66 | 70 | ||
67 | await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' }) | 71 | await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' }) |
68 | 72 | ||
69 | await waitJobs(servers) | 73 | await waitJobs(servers) |
74 | await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'absence' }) | ||
75 | }) | ||
76 | |||
77 | it('Should send a notification to moderators on local video abuse', async function () { | ||
78 | this.timeout(20000) | ||
79 | |||
80 | const name = 'video for abuse ' + buildUUID() | ||
81 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) | ||
82 | |||
83 | await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' }) | ||
84 | |||
85 | await waitJobs(servers) | ||
70 | await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) | 86 | await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) |
71 | }) | 87 | }) |
72 | 88 | ||
@@ -74,12 +90,12 @@ describe('Test moderation notifications', function () { | |||
74 | this.timeout(20000) | 90 | this.timeout(20000) |
75 | 91 | ||
76 | const name = 'video for abuse ' + buildUUID() | 92 | const name = 'video for abuse ' + buildUUID() |
77 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 93 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
78 | 94 | ||
79 | await waitJobs(servers) | 95 | await waitJobs(servers) |
80 | 96 | ||
81 | const videoId = await servers[1].videos.getId({ uuid: video.uuid }) | 97 | const videoId = await servers[1].videos.getId({ uuid: video.uuid }) |
82 | await servers[1].abuses.report({ videoId, reason: 'super reason' }) | 98 | await servers[1].abuses.report({ token: userToken2, videoId, reason: 'super reason' }) |
83 | 99 | ||
84 | await waitJobs(servers) | 100 | await waitJobs(servers) |
85 | await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) | 101 | await checkNewVideoAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) |
@@ -89,16 +105,16 @@ describe('Test moderation notifications', function () { | |||
89 | this.timeout(20000) | 105 | this.timeout(20000) |
90 | 106 | ||
91 | const name = 'video for abuse ' + buildUUID() | 107 | const name = 'video for abuse ' + buildUUID() |
92 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 108 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
93 | const comment = await servers[0].comments.createThread({ | 109 | const comment = await servers[0].comments.createThread({ |
94 | token: userAccessToken, | 110 | token: userToken1, |
95 | videoId: video.id, | 111 | videoId: video.id, |
96 | text: 'comment abuse ' + buildUUID() | 112 | text: 'comment abuse ' + buildUUID() |
97 | }) | 113 | }) |
98 | 114 | ||
99 | await waitJobs(servers) | 115 | await waitJobs(servers) |
100 | 116 | ||
101 | await servers[0].abuses.report({ commentId: comment.id, reason: 'super reason' }) | 117 | await servers[0].abuses.report({ token: userToken1, commentId: comment.id, reason: 'super reason' }) |
102 | 118 | ||
103 | await waitJobs(servers) | 119 | await waitJobs(servers) |
104 | await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) | 120 | await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) |
@@ -108,10 +124,10 @@ describe('Test moderation notifications', function () { | |||
108 | this.timeout(20000) | 124 | this.timeout(20000) |
109 | 125 | ||
110 | const name = 'video for abuse ' + buildUUID() | 126 | const name = 'video for abuse ' + buildUUID() |
111 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 127 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
112 | 128 | ||
113 | await servers[0].comments.createThread({ | 129 | await servers[0].comments.createThread({ |
114 | token: userAccessToken, | 130 | token: userToken1, |
115 | videoId: video.id, | 131 | videoId: video.id, |
116 | text: 'comment abuse ' + buildUUID() | 132 | text: 'comment abuse ' + buildUUID() |
117 | }) | 133 | }) |
@@ -120,7 +136,7 @@ describe('Test moderation notifications', function () { | |||
120 | 136 | ||
121 | const { data } = await servers[1].comments.listThreads({ videoId: video.uuid }) | 137 | const { data } = await servers[1].comments.listThreads({ videoId: video.uuid }) |
122 | const commentId = data[0].id | 138 | const commentId = data[0].id |
123 | await servers[1].abuses.report({ commentId, reason: 'super reason' }) | 139 | await servers[1].abuses.report({ token: userToken2, commentId, reason: 'super reason' }) |
124 | 140 | ||
125 | await waitJobs(servers) | 141 | await waitJobs(servers) |
126 | await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) | 142 | await checkNewCommentAbuseForModerators({ ...baseParams, shortUUID: video.shortUUID, videoName: name, checkType: 'presence' }) |
@@ -133,7 +149,7 @@ describe('Test moderation notifications', function () { | |||
133 | const { account } = await servers[0].users.create({ username, password: 'donald' }) | 149 | const { account } = await servers[0].users.create({ username, password: 'donald' }) |
134 | const accountId = account.id | 150 | const accountId = account.id |
135 | 151 | ||
136 | await servers[0].abuses.report({ accountId, reason: 'super reason' }) | 152 | await servers[0].abuses.report({ token: userToken1, accountId, reason: 'super reason' }) |
137 | 153 | ||
138 | await waitJobs(servers) | 154 | await waitJobs(servers) |
139 | await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' }) | 155 | await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' }) |
@@ -149,7 +165,7 @@ describe('Test moderation notifications', function () { | |||
149 | await waitJobs(servers) | 165 | await waitJobs(servers) |
150 | 166 | ||
151 | const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host }) | 167 | const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host }) |
152 | await servers[1].abuses.report({ accountId: account.id, reason: 'super reason' }) | 168 | await servers[1].abuses.report({ token: userToken2, accountId: account.id, reason: 'super reason' }) |
153 | 169 | ||
154 | await waitJobs(servers) | 170 | await waitJobs(servers) |
155 | await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' }) | 171 | await checkNewAccountAbuseForModerators({ ...baseParams, displayName: username, checkType: 'presence' }) |
@@ -165,13 +181,13 @@ describe('Test moderation notifications', function () { | |||
165 | server: servers[0], | 181 | server: servers[0], |
166 | emails, | 182 | emails, |
167 | socketNotifications: userNotifications, | 183 | socketNotifications: userNotifications, |
168 | token: userAccessToken | 184 | token: userToken1 |
169 | } | 185 | } |
170 | 186 | ||
171 | const name = 'abuse ' + buildUUID() | 187 | const name = 'abuse ' + buildUUID() |
172 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 188 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
173 | 189 | ||
174 | const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) | 190 | const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' }) |
175 | abuseId = body.abuse.id | 191 | abuseId = body.abuse.id |
176 | }) | 192 | }) |
177 | 193 | ||
@@ -205,7 +221,7 @@ describe('Test moderation notifications', function () { | |||
205 | server: servers[0], | 221 | server: servers[0], |
206 | emails, | 222 | emails, |
207 | socketNotifications: userNotifications, | 223 | socketNotifications: userNotifications, |
208 | token: userAccessToken | 224 | token: userToken1 |
209 | } | 225 | } |
210 | 226 | ||
211 | baseParamsAdmin = { | 227 | baseParamsAdmin = { |
@@ -216,15 +232,15 @@ describe('Test moderation notifications', function () { | |||
216 | } | 232 | } |
217 | 233 | ||
218 | const name = 'abuse ' + buildUUID() | 234 | const name = 'abuse ' + buildUUID() |
219 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 235 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
220 | 236 | ||
221 | { | 237 | { |
222 | const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) | 238 | const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' }) |
223 | abuseId = body.abuse.id | 239 | abuseId = body.abuse.id |
224 | } | 240 | } |
225 | 241 | ||
226 | { | 242 | { |
227 | const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' }) | 243 | const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason 2' }) |
228 | abuseId2 = body.abuse.id | 244 | abuseId2 = body.abuse.id |
229 | } | 245 | } |
230 | }) | 246 | }) |
@@ -254,7 +270,7 @@ describe('Test moderation notifications', function () { | |||
254 | this.timeout(10000) | 270 | this.timeout(10000) |
255 | 271 | ||
256 | const message = 'my super message to moderators' | 272 | const message = 'my super message to moderators' |
257 | await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) | 273 | await servers[0].abuses.addMessage({ token: userToken1, abuseId: abuseId2, message }) |
258 | await waitJobs(servers) | 274 | await waitJobs(servers) |
259 | 275 | ||
260 | const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com' | 276 | const toEmail = 'admin' + servers[0].internalServerNumber + '@example.com' |
@@ -265,7 +281,7 @@ describe('Test moderation notifications', function () { | |||
265 | this.timeout(10000) | 281 | this.timeout(10000) |
266 | 282 | ||
267 | const message = 'my super message that should not be sent to reporter' | 283 | const message = 'my super message that should not be sent to reporter' |
268 | await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) | 284 | await servers[0].abuses.addMessage({ token: userToken1, abuseId: abuseId2, message }) |
269 | await waitJobs(servers) | 285 | await waitJobs(servers) |
270 | 286 | ||
271 | const toEmail = 'user_1@example.com' | 287 | const toEmail = 'user_1@example.com' |
@@ -281,7 +297,7 @@ describe('Test moderation notifications', function () { | |||
281 | server: servers[0], | 297 | server: servers[0], |
282 | emails, | 298 | emails, |
283 | socketNotifications: userNotifications, | 299 | socketNotifications: userNotifications, |
284 | token: userAccessToken | 300 | token: userToken1 |
285 | } | 301 | } |
286 | }) | 302 | }) |
287 | 303 | ||
@@ -289,7 +305,7 @@ describe('Test moderation notifications', function () { | |||
289 | this.timeout(10000) | 305 | this.timeout(10000) |
290 | 306 | ||
291 | const name = 'video for abuse ' + buildUUID() | 307 | const name = 'video for abuse ' + buildUUID() |
292 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 308 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
293 | 309 | ||
294 | await servers[0].blacklist.add({ videoId: uuid }) | 310 | await servers[0].blacklist.add({ videoId: uuid }) |
295 | 311 | ||
@@ -301,7 +317,7 @@ describe('Test moderation notifications', function () { | |||
301 | this.timeout(10000) | 317 | this.timeout(10000) |
302 | 318 | ||
303 | const name = 'video for abuse ' + buildUUID() | 319 | const name = 'video for abuse ' + buildUUID() |
304 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } }) | 320 | const { uuid, shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes: { name } }) |
305 | 321 | ||
306 | await servers[0].blacklist.add({ videoId: uuid }) | 322 | await servers[0].blacklist.add({ videoId: uuid }) |
307 | 323 | ||
@@ -335,7 +351,7 @@ describe('Test moderation notifications', function () { | |||
335 | 351 | ||
336 | await checkUserRegistered({ ...baseParams, username: 'user_45', checkType: 'presence' }) | 352 | await checkUserRegistered({ ...baseParams, username: 'user_45', checkType: 'presence' }) |
337 | 353 | ||
338 | const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } | 354 | const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } } |
339 | await checkUserRegistered({ ...baseParams, ...userOverride, username: 'user_45', checkType: 'absence' }) | 355 | await checkUserRegistered({ ...baseParams, ...userOverride, username: 'user_45', checkType: 'absence' }) |
340 | }) | 356 | }) |
341 | }) | 357 | }) |
@@ -377,7 +393,7 @@ describe('Test moderation notifications', function () { | |||
377 | 393 | ||
378 | await checkNewInstanceFollower({ ...baseParams, followerHost: 'localhost:' + servers[2].port, checkType: 'presence' }) | 394 | await checkNewInstanceFollower({ ...baseParams, followerHost: 'localhost:' + servers[2].port, checkType: 'presence' }) |
379 | 395 | ||
380 | const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } | 396 | const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } } |
381 | await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: 'localhost:' + servers[2].port, checkType: 'absence' }) | 397 | await checkNewInstanceFollower({ ...baseParams, ...userOverride, followerHost: 'localhost:' + servers[2].port, checkType: 'absence' }) |
382 | }) | 398 | }) |
383 | 399 | ||
@@ -404,7 +420,7 @@ describe('Test moderation notifications', function () { | |||
404 | const followingHost = servers[2].host | 420 | const followingHost = servers[2].host |
405 | await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' }) | 421 | await checkAutoInstanceFollowing({ ...baseParams, followerHost, followingHost, checkType: 'presence' }) |
406 | 422 | ||
407 | const userOverride = { socketNotifications: userNotifications, token: userAccessToken, check: { web: true, mail: false } } | 423 | const userOverride = { socketNotifications: userNotifications, token: userToken1, check: { web: true, mail: false } } |
408 | await checkAutoInstanceFollowing({ ...baseParams, ...userOverride, followerHost, followingHost, checkType: 'absence' }) | 424 | await checkAutoInstanceFollowing({ ...baseParams, ...userOverride, followerHost, followingHost, checkType: 'absence' }) |
409 | 425 | ||
410 | config.followings.instance.autoFollowBack.enabled = false | 426 | config.followings.instance.autoFollowBack.enabled = false |
@@ -461,7 +477,7 @@ describe('Test moderation notifications', function () { | |||
461 | server: servers[0], | 477 | server: servers[0], |
462 | emails, | 478 | emails, |
463 | socketNotifications: userNotifications, | 479 | socketNotifications: userNotifications, |
464 | token: userAccessToken | 480 | token: userToken1 |
465 | } | 481 | } |
466 | 482 | ||
467 | currentCustomConfig = await servers[0].config.getCustomConfig() | 483 | currentCustomConfig = await servers[0].config.getCustomConfig() |
@@ -490,7 +506,7 @@ describe('Test moderation notifications', function () { | |||
490 | this.timeout(120000) | 506 | this.timeout(120000) |
491 | 507 | ||
492 | videoName = 'video with auto-blacklist ' + buildUUID() | 508 | videoName = 'video with auto-blacklist ' + buildUUID() |
493 | const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } }) | 509 | const video = await servers[0].videos.upload({ token: userToken1, attributes: { name: videoName } }) |
494 | shortUUID = video.shortUUID | 510 | shortUUID = video.shortUUID |
495 | uuid = video.uuid | 511 | uuid = video.uuid |
496 | 512 | ||
@@ -547,7 +563,7 @@ describe('Test moderation notifications', function () { | |||
547 | } | 563 | } |
548 | } | 564 | } |
549 | 565 | ||
550 | const { shortUUID, uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes }) | 566 | const { shortUUID, uuid } = await servers[0].videos.upload({ token: userToken1, attributes }) |
551 | 567 | ||
552 | await servers[0].blacklist.remove({ videoId: uuid }) | 568 | await servers[0].blacklist.remove({ videoId: uuid }) |
553 | 569 | ||
@@ -579,7 +595,7 @@ describe('Test moderation notifications', function () { | |||
579 | } | 595 | } |
580 | } | 596 | } |
581 | 597 | ||
582 | const { shortUUID } = await servers[0].videos.upload({ token: userAccessToken, attributes }) | 598 | const { shortUUID } = await servers[0].videos.upload({ token: userToken1, attributes }) |
583 | 599 | ||
584 | await wait(6000) | 600 | await wait(6000) |
585 | await checkVideoIsPublished({ ...userBaseParams, videoName: name, shortUUID, checkType: 'absence' }) | 601 | await checkVideoIsPublished({ ...userBaseParams, videoName: name, shortUUID, checkType: 'absence' }) |
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 468efdf35..9af20843e 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts | |||
@@ -267,7 +267,7 @@ describe('Test user notifications', function () { | |||
267 | }) | 267 | }) |
268 | 268 | ||
269 | it('Should send a notification when an imported video is transcoded', async function () { | 269 | it('Should send a notification when an imported video is transcoded', async function () { |
270 | this.timeout(50000) | 270 | this.timeout(120000) |
271 | 271 | ||
272 | const name = 'video import ' + buildUUID() | 272 | const name = 'video import ' + buildUUID() |
273 | 273 | ||
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 86b40cfe6..b5929129a 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -307,7 +307,7 @@ describe('Test videos redundancy', function () { | |||
307 | const strategy = 'most-views' | 307 | const strategy = 'most-views' |
308 | 308 | ||
309 | before(function () { | 309 | before(function () { |
310 | this.timeout(120000) | 310 | this.timeout(240000) |
311 | 311 | ||
312 | return createServers(strategy) | 312 | return createServers(strategy) |
313 | }) | 313 | }) |
@@ -357,7 +357,7 @@ describe('Test videos redundancy', function () { | |||
357 | const strategy = 'trending' | 357 | const strategy = 'trending' |
358 | 358 | ||
359 | before(function () { | 359 | before(function () { |
360 | this.timeout(120000) | 360 | this.timeout(240000) |
361 | 361 | ||
362 | return createServers(strategy) | 362 | return createServers(strategy) |
363 | }) | 363 | }) |
@@ -420,7 +420,7 @@ describe('Test videos redundancy', function () { | |||
420 | const strategy = 'recently-added' | 420 | const strategy = 'recently-added' |
421 | 421 | ||
422 | before(function () { | 422 | before(function () { |
423 | this.timeout(120000) | 423 | this.timeout(240000) |
424 | 424 | ||
425 | return createServers(strategy, { min_views: 3 }) | 425 | return createServers(strategy, { min_views: 3 }) |
426 | }) | 426 | }) |
@@ -491,7 +491,7 @@ describe('Test videos redundancy', function () { | |||
491 | const strategy = 'recently-added' | 491 | const strategy = 'recently-added' |
492 | 492 | ||
493 | before(async function () { | 493 | before(async function () { |
494 | this.timeout(120000) | 494 | this.timeout(240000) |
495 | 495 | ||
496 | await createServers(strategy, { min_views: 3 }, false) | 496 | await createServers(strategy, { min_views: 3 }, false) |
497 | }) | 497 | }) |
@@ -553,7 +553,7 @@ describe('Test videos redundancy', function () { | |||
553 | 553 | ||
554 | describe('With manual strategy', function () { | 554 | describe('With manual strategy', function () { |
555 | before(function () { | 555 | before(function () { |
556 | this.timeout(120000) | 556 | this.timeout(240000) |
557 | 557 | ||
558 | return createServers(null) | 558 | return createServers(null) |
559 | }) | 559 | }) |
@@ -632,7 +632,7 @@ describe('Test videos redundancy', function () { | |||
632 | } | 632 | } |
633 | 633 | ||
634 | before(async function () { | 634 | before(async function () { |
635 | this.timeout(120000) | 635 | this.timeout(240000) |
636 | 636 | ||
637 | await createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) | 637 | await createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) |
638 | 638 | ||
@@ -674,7 +674,7 @@ describe('Test videos redundancy', function () { | |||
674 | const strategy = 'recently-added' | 674 | const strategy = 'recently-added' |
675 | 675 | ||
676 | before(async function () { | 676 | before(async function () { |
677 | this.timeout(120000) | 677 | this.timeout(240000) |
678 | 678 | ||
679 | await createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) | 679 | await createServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) |
680 | 680 | ||
@@ -698,7 +698,7 @@ describe('Test videos redundancy', function () { | |||
698 | }) | 698 | }) |
699 | 699 | ||
700 | it('Should cache video 2 webseeds on the first video', async function () { | 700 | it('Should cache video 2 webseeds on the first video', async function () { |
701 | this.timeout(120000) | 701 | this.timeout(240000) |
702 | 702 | ||
703 | await waitJobs(servers) | 703 | await waitJobs(servers) |
704 | 704 | ||
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index ea524723c..96ec17b0f 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -43,6 +43,9 @@ function checkInitialConfig (server: PeerTubeServer, data: CustomConfig) { | |||
43 | expect(data.services.twitter.username).to.equal('@Chocobozzz') | 43 | expect(data.services.twitter.username).to.equal('@Chocobozzz') |
44 | expect(data.services.twitter.whitelisted).to.be.false | 44 | expect(data.services.twitter.whitelisted).to.be.false |
45 | 45 | ||
46 | expect(data.client.videos.miniature.preferAuthorDisplayName).to.be.false | ||
47 | expect(data.client.menu.login.redirectOnSingleExternalAuth).to.be.false | ||
48 | |||
46 | expect(data.cache.previews.size).to.equal(1) | 49 | expect(data.cache.previews.size).to.equal(1) |
47 | expect(data.cache.captions.size).to.equal(1) | 50 | expect(data.cache.captions.size).to.equal(1) |
48 | expect(data.cache.torrents.size).to.equal(1) | 51 | expect(data.cache.torrents.size).to.equal(1) |
@@ -138,6 +141,9 @@ function checkUpdatedConfig (data: CustomConfig) { | |||
138 | expect(data.services.twitter.username).to.equal('@Kuja') | 141 | expect(data.services.twitter.username).to.equal('@Kuja') |
139 | expect(data.services.twitter.whitelisted).to.be.true | 142 | expect(data.services.twitter.whitelisted).to.be.true |
140 | 143 | ||
144 | expect(data.client.videos.miniature.preferAuthorDisplayName).to.be.true | ||
145 | expect(data.client.menu.login.redirectOnSingleExternalAuth).to.be.true | ||
146 | |||
141 | expect(data.cache.previews.size).to.equal(2) | 147 | expect(data.cache.previews.size).to.equal(2) |
142 | expect(data.cache.captions.size).to.equal(3) | 148 | expect(data.cache.captions.size).to.equal(3) |
143 | expect(data.cache.torrents.size).to.equal(4) | 149 | expect(data.cache.torrents.size).to.equal(4) |
@@ -246,6 +252,18 @@ const newCustomConfig: CustomConfig = { | |||
246 | whitelisted: true | 252 | whitelisted: true |
247 | } | 253 | } |
248 | }, | 254 | }, |
255 | client: { | ||
256 | videos: { | ||
257 | miniature: { | ||
258 | preferAuthorDisplayName: true | ||
259 | } | ||
260 | }, | ||
261 | menu: { | ||
262 | login: { | ||
263 | redirectOnSingleExternalAuth: true | ||
264 | } | ||
265 | } | ||
266 | }, | ||
249 | cache: { | 267 | cache: { |
250 | previews: { | 268 | previews: { |
251 | size: 2 | 269 | size: 2 |
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index 5f97edbc2..cd8d70341 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts | |||
@@ -185,7 +185,7 @@ describe('Test emails', function () { | |||
185 | this.timeout(10000) | 185 | this.timeout(10000) |
186 | 186 | ||
187 | const reason = 'my super bad reason' | 187 | const reason = 'my super bad reason' |
188 | await server.abuses.report({ videoId, reason }) | 188 | await server.abuses.report({ token: userAccessToken, videoId, reason }) |
189 | 189 | ||
190 | await waitJobs(server) | 190 | await waitJobs(server) |
191 | expect(emails).to.have.lengthOf(3) | 191 | expect(emails).to.have.lengthOf(3) |
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index b51b3bcdd..08b624ff3 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts | |||
@@ -2,7 +2,15 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 5 | import { |
6 | cleanupTests, | ||
7 | createSingleServer, | ||
8 | doubleFollow, | ||
9 | PeerTubeServer, | ||
10 | setAccessTokensToServers, | ||
11 | wait, | ||
12 | waitJobs | ||
13 | } from '@shared/extra-utils' | ||
6 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' | 14 | import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models' |
7 | 15 | ||
8 | const expect = chai.expect | 16 | const expect = chai.expect |
@@ -209,7 +217,7 @@ describe('Test video privacy', function () { | |||
209 | describe('Privacy update', function () { | 217 | describe('Privacy update', function () { |
210 | 218 | ||
211 | it('Should update the private and internal videos to public on server 1', async function () { | 219 | it('Should update the private and internal videos to public on server 1', async function () { |
212 | this.timeout(10000) | 220 | this.timeout(100000) |
213 | 221 | ||
214 | now = Date.now() | 222 | now = Date.now() |
215 | 223 | ||
@@ -230,6 +238,7 @@ describe('Test video privacy', function () { | |||
230 | await servers[0].videos.update({ id: internalVideoId, attributes }) | 238 | await servers[0].videos.update({ id: internalVideoId, attributes }) |
231 | } | 239 | } |
232 | 240 | ||
241 | await wait(10000) | ||
233 | await waitJobs(servers) | 242 | await waitJobs(servers) |
234 | }) | 243 | }) |
235 | 244 | ||
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index f2a984962..3ac440f84 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts | |||
@@ -207,6 +207,25 @@ describe('Test CLI wrapper', function () { | |||
207 | 207 | ||
208 | expect(res).to.not.contain('peertube-plugin-hello-world') | 208 | expect(res).to.not.contain('peertube-plugin-hello-world') |
209 | }) | 209 | }) |
210 | |||
211 | it('Should install a plugin in requested version', async function () { | ||
212 | this.timeout(60000) | ||
213 | |||
214 | await cliCommand.execWithEnv(`${cmd} plugins install --npm-name peertube-plugin-hello-world --plugin-version 0.0.17`) | ||
215 | }) | ||
216 | |||
217 | it('Should list installed plugins, in correct version', async function () { | ||
218 | const res = await cliCommand.execWithEnv(`${cmd} plugins list`) | ||
219 | |||
220 | expect(res).to.contain('peertube-plugin-hello-world') | ||
221 | expect(res).to.contain('0.0.17') | ||
222 | }) | ||
223 | |||
224 | it('Should uninstall the plugin again', async function () { | ||
225 | const res = await cliCommand.execWithEnv(`${cmd} plugins uninstall --npm-name peertube-plugin-hello-world`) | ||
226 | |||
227 | expect(res).to.not.contain('peertube-plugin-hello-world') | ||
228 | }) | ||
210 | }) | 229 | }) |
211 | 230 | ||
212 | describe('Manage video redundancies', function () { | 231 | describe('Manage video redundancies', function () { |
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index 2d4c02da7..1c0282da9 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts | |||
@@ -36,7 +36,7 @@ async function assertNotExists (server: PeerTubeServer, directory: string, subst | |||
36 | } | 36 | } |
37 | } | 37 | } |
38 | 38 | ||
39 | async function assertCountAreOkay (servers: PeerTubeServer[], videoServer2UUID: string) { | 39 | async function assertCountAreOkay (servers: PeerTubeServer[]) { |
40 | for (const server of servers) { | 40 | for (const server of servers) { |
41 | const videosCount = await countFiles(server, 'videos') | 41 | const videosCount = await countFiles(server, 'videos') |
42 | expect(videosCount).to.equal(8) | 42 | expect(videosCount).to.equal(8) |
@@ -52,22 +52,16 @@ async function assertCountAreOkay (servers: PeerTubeServer[], videoServer2UUID: | |||
52 | 52 | ||
53 | const avatarsCount = await countFiles(server, 'avatars') | 53 | const avatarsCount = await countFiles(server, 'avatars') |
54 | expect(avatarsCount).to.equal(2) | 54 | expect(avatarsCount).to.equal(2) |
55 | } | ||
56 | |||
57 | // When we'll prune HLS directories too | ||
58 | // const hlsRootCount = await countFiles(servers[1], 'streaming-playlists/hls/') | ||
59 | // expect(hlsRootCount).to.equal(2) | ||
60 | 55 | ||
61 | // const hlsCount = await countFiles(servers[1], 'streaming-playlists/hls/' + videoServer2UUID) | 56 | const hlsRootCount = await countFiles(server, 'streaming-playlists/hls') |
62 | // expect(hlsCount).to.equal(10) | 57 | expect(hlsRootCount).to.equal(2) |
58 | } | ||
63 | } | 59 | } |
64 | 60 | ||
65 | describe('Test prune storage scripts', function () { | 61 | describe('Test prune storage scripts', function () { |
66 | let servers: PeerTubeServer[] | 62 | let servers: PeerTubeServer[] |
67 | const badNames: { [directory: string]: string[] } = {} | 63 | const badNames: { [directory: string]: string[] } = {} |
68 | 64 | ||
69 | let videoServer2UUID: string | ||
70 | |||
71 | before(async function () { | 65 | before(async function () { |
72 | this.timeout(120000) | 66 | this.timeout(120000) |
73 | 67 | ||
@@ -77,9 +71,7 @@ describe('Test prune storage scripts', function () { | |||
77 | 71 | ||
78 | for (const server of servers) { | 72 | for (const server of servers) { |
79 | await server.videos.upload({ attributes: { name: 'video 1' } }) | 73 | await server.videos.upload({ attributes: { name: 'video 1' } }) |
80 | 74 | await server.videos.upload({ attributes: { name: 'video 2' } }) | |
81 | const { uuid } = await server.videos.upload({ attributes: { name: 'video 2' } }) | ||
82 | if (server.serverNumber === 2) videoServer2UUID = uuid | ||
83 | 75 | ||
84 | await server.users.updateMyAvatar({ fixture: 'avatar.png' }) | 76 | await server.users.updateMyAvatar({ fixture: 'avatar.png' }) |
85 | 77 | ||
@@ -123,7 +115,7 @@ describe('Test prune storage scripts', function () { | |||
123 | }) | 115 | }) |
124 | 116 | ||
125 | it('Should have the files on the disk', async function () { | 117 | it('Should have the files on the disk', async function () { |
126 | await assertCountAreOkay(servers, videoServer2UUID) | 118 | await assertCountAreOkay(servers) |
127 | }) | 119 | }) |
128 | 120 | ||
129 | it('Should create some dirty files', async function () { | 121 | it('Should create some dirty files', async function () { |
@@ -188,27 +180,14 @@ describe('Test prune storage scripts', function () { | |||
188 | badNames['avatars'] = [ n1, n2 ] | 180 | badNames['avatars'] = [ n1, n2 ] |
189 | } | 181 | } |
190 | 182 | ||
191 | // When we'll prune HLS directories too | 183 | { |
192 | // { | 184 | const directory = join('streaming-playlists', 'hls') |
193 | // const directory = join('streaming-playlists', 'hls') | 185 | const base = servers[0].servers.buildDirectory(directory) |
194 | // const base = servers[1].servers.buildDirectory(directory) | ||
195 | |||
196 | // const n1 = buildUUID() | ||
197 | // await createFile(join(base, n1)) | ||
198 | // badNames[directory] = [ n1 ] | ||
199 | // } | ||
200 | |||
201 | // { | ||
202 | // const directory = join('streaming-playlists', 'hls', videoServer2UUID) | ||
203 | // const base = servers[1].servers.buildDirectory(directory) | ||
204 | // const n1 = buildUUID() + '-240-fragmented-.mp4' | ||
205 | // const n2 = buildUUID() + '-master.m3u8' | ||
206 | |||
207 | // await createFile(join(base, n1)) | ||
208 | // await createFile(join(base, n2)) | ||
209 | 186 | ||
210 | // badNames[directory] = [ n1, n2 ] | 187 | const n1 = buildUUID() |
211 | // } | 188 | await createFile(join(base, n1)) |
189 | badNames[directory] = [ n1 ] | ||
190 | } | ||
212 | } | 191 | } |
213 | }) | 192 | }) |
214 | 193 | ||
@@ -220,7 +199,7 @@ describe('Test prune storage scripts', function () { | |||
220 | }) | 199 | }) |
221 | 200 | ||
222 | it('Should have removed files', async function () { | 201 | it('Should have removed files', async function () { |
223 | await assertCountAreOkay(servers, videoServer2UUID) | 202 | await assertCountAreOkay(servers) |
224 | 203 | ||
225 | for (const directory of Object.keys(badNames)) { | 204 | for (const directory of Object.keys(badNames)) { |
226 | for (const name of badNames[directory]) { | 205 | for (const name of badNames[directory]) { |
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js index db405ff31..04e059848 100644 --- a/server/tests/fixtures/peertube-plugin-test/main.js +++ b/server/tests/fixtures/peertube-plugin-test/main.js | |||
@@ -233,6 +233,28 @@ async function register ({ registerHook, registerSetting, settingsManager, stora | |||
233 | } | 233 | } |
234 | }) | 234 | }) |
235 | 235 | ||
236 | registerHook({ | ||
237 | target: 'filter:api.server.stats.get.result', | ||
238 | handler: (result) => { | ||
239 | return { ...result, customStats: 14 } | ||
240 | } | ||
241 | }) | ||
242 | |||
243 | // Upload/import/live attributes | ||
244 | for (const target of [ | ||
245 | 'filter:api.video.upload.video-attribute.result', | ||
246 | 'filter:api.video.import-url.video-attribute.result', | ||
247 | 'filter:api.video.import-torrent.video-attribute.result', | ||
248 | 'filter:api.video.live.video-attribute.result' | ||
249 | ]) { | ||
250 | registerHook({ | ||
251 | target, | ||
252 | handler: (result) => { | ||
253 | return { ...result, description: result.description + ' - ' + target } | ||
254 | } | ||
255 | }) | ||
256 | } | ||
257 | |||
236 | { | 258 | { |
237 | const filterHooks = [ | 259 | const filterHooks = [ |
238 | 'filter:api.search.videos.local.list.params', | 260 | 'filter:api.search.videos.local.list.params', |
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index f3e018d43..25b25bfee 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts | |||
@@ -125,7 +125,7 @@ describe('Test external auth plugins', function () { | |||
125 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 | 125 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
126 | }) | 126 | }) |
127 | 127 | ||
128 | await server.servers.waitUntilLog('expired external auth token', 2) | 128 | await server.servers.waitUntilLog('expired external auth token', 4) |
129 | }) | 129 | }) |
130 | 130 | ||
131 | it('Should auto login Cyan, create the user and use the token', async function () { | 131 | it('Should auto login Cyan, create the user and use the token', async function () { |
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 02915f08c..ff2afc56b 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -537,6 +537,75 @@ describe('Test plugin filter hooks', function () { | |||
537 | }) | 537 | }) |
538 | }) | 538 | }) |
539 | 539 | ||
540 | describe('Upload/import/live attributes filters', function () { | ||
541 | |||
542 | before(async function () { | ||
543 | await servers[0].config.enableLive({ transcoding: false, allowReplay: false }) | ||
544 | await servers[0].config.enableImports() | ||
545 | await servers[0].config.disableTranscoding() | ||
546 | }) | ||
547 | |||
548 | it('Should run filter:api.video.upload.video-attribute.result', async function () { | ||
549 | for (const mode of [ 'legacy' as 'legacy', 'resumable' as 'resumable' ]) { | ||
550 | const { id } = await servers[0].videos.upload({ attributes: { name: 'video', description: 'upload' }, mode }) | ||
551 | |||
552 | const video = await servers[0].videos.get({ id }) | ||
553 | expect(video.description).to.equal('upload - filter:api.video.upload.video-attribute.result') | ||
554 | } | ||
555 | }) | ||
556 | |||
557 | it('Should run filter:api.video.import-url.video-attribute.result', async function () { | ||
558 | const attributes = { | ||
559 | name: 'video', | ||
560 | description: 'import url', | ||
561 | channelId: servers[0].store.channel.id, | ||
562 | targetUrl: FIXTURE_URLS.goodVideo, | ||
563 | privacy: VideoPrivacy.PUBLIC | ||
564 | } | ||
565 | const { video: { id } } = await servers[0].imports.importVideo({ attributes }) | ||
566 | |||
567 | const video = await servers[0].videos.get({ id }) | ||
568 | expect(video.description).to.equal('import url - filter:api.video.import-url.video-attribute.result') | ||
569 | }) | ||
570 | |||
571 | it('Should run filter:api.video.import-torrent.video-attribute.result', async function () { | ||
572 | const attributes = { | ||
573 | name: 'video', | ||
574 | description: 'import torrent', | ||
575 | channelId: servers[0].store.channel.id, | ||
576 | magnetUri: FIXTURE_URLS.magnet, | ||
577 | privacy: VideoPrivacy.PUBLIC | ||
578 | } | ||
579 | const { video: { id } } = await servers[0].imports.importVideo({ attributes }) | ||
580 | |||
581 | const video = await servers[0].videos.get({ id }) | ||
582 | expect(video.description).to.equal('import torrent - filter:api.video.import-torrent.video-attribute.result') | ||
583 | }) | ||
584 | |||
585 | it('Should run filter:api.video.live.video-attribute.result', async function () { | ||
586 | const fields = { | ||
587 | name: 'live', | ||
588 | description: 'live', | ||
589 | channelId: servers[0].store.channel.id, | ||
590 | privacy: VideoPrivacy.PUBLIC | ||
591 | } | ||
592 | const { id } = await servers[0].live.create({ fields }) | ||
593 | |||
594 | const video = await servers[0].videos.get({ id }) | ||
595 | expect(video.description).to.equal('live - filter:api.video.live.video-attribute.result') | ||
596 | }) | ||
597 | }) | ||
598 | |||
599 | describe('Stats filters', function () { | ||
600 | |||
601 | it('Should run filter:api.server.stats.get.result', async function () { | ||
602 | const data = await servers[0].stats.get() | ||
603 | |||
604 | expect((data as any).customStats).to.equal(14) | ||
605 | }) | ||
606 | |||
607 | }) | ||
608 | |||
540 | after(async function () { | 609 | after(async function () { |
541 | await cleanupTests(servers) | 610 | await cleanupTests(servers) |
542 | }) | 611 | }) |