diff options
Diffstat (limited to 'server/tests/plugins')
-rw-r--r-- | server/tests/plugins/action-hooks.ts | 16 | ||||
-rw-r--r-- | server/tests/plugins/external-auth.ts | 10 | ||||
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 75 | ||||
-rw-r--r-- | server/tests/plugins/html-injection.ts | 2 | ||||
-rw-r--r-- | server/tests/plugins/id-and-pass-auth.ts | 3 | ||||
-rw-r--r-- | server/tests/plugins/plugin-helpers.ts | 73 | ||||
-rw-r--r-- | server/tests/plugins/plugin-router.ts | 2 | ||||
-rw-r--r-- | server/tests/plugins/plugin-storage.ts | 8 | ||||
-rw-r--r-- | server/tests/plugins/plugin-transcoding.ts | 2 | ||||
-rw-r--r-- | server/tests/plugins/plugin-unloading.ts | 2 | ||||
-rw-r--r-- | server/tests/plugins/translations.ts | 2 | ||||
-rw-r--r-- | server/tests/plugins/video-constants.ts | 2 |
12 files changed, 176 insertions, 21 deletions
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts index 4c1bc7d06..8788a9644 100644 --- a/server/tests/plugins/action-hooks.ts +++ b/server/tests/plugins/action-hooks.ts | |||
@@ -9,7 +9,7 @@ import { | |||
9 | PluginsCommand, | 9 | PluginsCommand, |
10 | setAccessTokensToServers, | 10 | setAccessTokensToServers, |
11 | setDefaultVideoChannel | 11 | setDefaultVideoChannel |
12 | } from '@shared/extra-utils' | 12 | } from '@shared/server-commands' |
13 | import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' | 13 | import { ServerHookName, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' |
14 | 14 | ||
15 | describe('Test plugin action hooks', function () { | 15 | describe('Test plugin action hooks', function () { |
@@ -103,6 +103,20 @@ describe('Test plugin action hooks', function () { | |||
103 | }) | 103 | }) |
104 | }) | 104 | }) |
105 | 105 | ||
106 | describe('Captions hooks', function () { | ||
107 | it('Should run action:api.video-caption.created', async function () { | ||
108 | await servers[0].captions.add({ videoId: videoUUID, language: 'en', fixture: 'subtitle-good.srt' }) | ||
109 | |||
110 | await checkHook('action:api.video-caption.created') | ||
111 | }) | ||
112 | |||
113 | it('Should run action:api.video-caption.deleted', async function () { | ||
114 | await servers[0].captions.delete({ videoId: videoUUID, language: 'en' }) | ||
115 | |||
116 | await checkHook('action:api.video-caption.deleted') | ||
117 | }) | ||
118 | }) | ||
119 | |||
106 | describe('Users hooks', function () { | 120 | describe('Users hooks', function () { |
107 | let userId: number | 121 | let userId: number |
108 | 122 | ||
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index f3e018d43..583100671 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts | |||
@@ -2,16 +2,16 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { wait } from '@shared/core-utils' | ||
6 | import { HttpStatusCode, UserRole } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
8 | decodeQueryString, | 10 | decodeQueryString, |
9 | PeerTubeServer, | 11 | PeerTubeServer, |
10 | PluginsCommand, | 12 | PluginsCommand, |
11 | setAccessTokensToServers, | 13 | setAccessTokensToServers |
12 | wait | 14 | } from '@shared/server-commands' |
13 | } from '@shared/extra-utils' | ||
14 | import { HttpStatusCode, UserRole } from '@shared/models' | ||
15 | 15 | ||
16 | async function loginExternal (options: { | 16 | async function loginExternal (options: { |
17 | server: PeerTubeServer | 17 | server: PeerTubeServer |
@@ -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..52ba396e5 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -2,19 +2,19 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
8 | doubleFollow, | 9 | doubleFollow, |
9 | FIXTURE_URLS, | ||
10 | makeRawRequest, | 10 | makeRawRequest, |
11 | PeerTubeServer, | 11 | PeerTubeServer, |
12 | PluginsCommand, | 12 | PluginsCommand, |
13 | setAccessTokensToServers, | 13 | setAccessTokensToServers, |
14 | setDefaultVideoChannel, | 14 | setDefaultVideoChannel, |
15 | waitJobs | 15 | waitJobs |
16 | } from '@shared/extra-utils' | 16 | } from '@shared/server-commands' |
17 | import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' | 17 | import { FIXTURE_URLS } from '../shared' |
18 | 18 | ||
19 | const expect = chai.expect | 19 | const expect = chai.expect |
20 | 20 | ||
@@ -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 | }) |
diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts index 95c0cd687..0a3a9c25f 100644 --- a/server/tests/plugins/html-injection.ts +++ b/server/tests/plugins/html-injection.ts | |||
@@ -9,7 +9,7 @@ import { | |||
9 | PeerTubeServer, | 9 | PeerTubeServer, |
10 | PluginsCommand, | 10 | PluginsCommand, |
11 | setAccessTokensToServers | 11 | setAccessTokensToServers |
12 | } from '../../../shared/extra-utils' | 12 | } from '@shared/server-commands' |
13 | 13 | ||
14 | const expect = chai.expect | 14 | const expect = chai.expect |
15 | 15 | ||
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index fde0166f9..e72046ce2 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts | |||
@@ -2,8 +2,9 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers, wait } from '@shared/extra-utils' | 5 | import { wait } from '@shared/core-utils' |
6 | import { HttpStatusCode, UserRole } from '@shared/models' | 6 | import { HttpStatusCode, UserRole } from '@shared/models' |
7 | import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/server-commands' | ||
7 | 8 | ||
8 | describe('Test id and pass auth plugins', function () { | 9 | describe('Test id and pass auth plugins', function () { |
9 | let server: PeerTubeServer | 10 | let server: PeerTubeServer |
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index 5d16b28a4..167429ef4 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts | |||
@@ -2,19 +2,21 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { pathExists } from 'fs-extra' | ||
6 | import { HttpStatusCode, ThumbnailType } from '@shared/models' | ||
5 | import { | 7 | import { |
6 | checkVideoFilesWereRemoved, | ||
7 | cleanupTests, | 8 | cleanupTests, |
8 | createMultipleServers, | 9 | createMultipleServers, |
9 | doubleFollow, | 10 | doubleFollow, |
10 | makeGetRequest, | 11 | makeGetRequest, |
11 | makePostBodyRequest, | 12 | makePostBodyRequest, |
13 | makeRawRequest, | ||
12 | PeerTubeServer, | 14 | PeerTubeServer, |
13 | PluginsCommand, | 15 | PluginsCommand, |
14 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
15 | waitJobs | 17 | waitJobs |
16 | } from '@shared/extra-utils' | 18 | } from '@shared/server-commands' |
17 | import { HttpStatusCode } from '@shared/models' | 19 | import { checkVideoFilesWereRemoved } from '../shared' |
18 | 20 | ||
19 | function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) { | 21 | function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) { |
20 | const body = { command } | 22 | const body = { command } |
@@ -222,10 +224,75 @@ describe('Test plugin helpers', function () { | |||
222 | 224 | ||
223 | describe('Videos', function () { | 225 | describe('Videos', function () { |
224 | let videoUUID: string | 226 | let videoUUID: string |
227 | let videoPath: string | ||
225 | 228 | ||
226 | before(async () => { | 229 | before(async () => { |
230 | this.timeout(240000) | ||
231 | |||
232 | await servers[0].config.enableTranscoding() | ||
233 | |||
227 | const res = await servers[0].videos.quickUpload({ name: 'video1' }) | 234 | const res = await servers[0].videos.quickUpload({ name: 'video1' }) |
228 | videoUUID = res.uuid | 235 | videoUUID = res.uuid |
236 | |||
237 | await waitJobs(servers) | ||
238 | }) | ||
239 | |||
240 | it('Should get video files', async function () { | ||
241 | const { body } = await makeGetRequest({ | ||
242 | url: servers[0].url, | ||
243 | path: '/plugins/test-four/router/video-files/' + videoUUID, | ||
244 | expectedStatus: HttpStatusCode.OK_200 | ||
245 | }) | ||
246 | |||
247 | // Video files check | ||
248 | { | ||
249 | expect(body.webtorrent.videoFiles).to.be.an('array') | ||
250 | expect(body.hls.videoFiles).to.be.an('array') | ||
251 | |||
252 | for (const resolution of [ 144, 240, 360, 480, 720 ]) { | ||
253 | for (const files of [ body.webtorrent.videoFiles, body.hls.videoFiles ]) { | ||
254 | const file = files.find(f => f.resolution === resolution) | ||
255 | expect(file).to.exist | ||
256 | |||
257 | expect(file.size).to.be.a('number') | ||
258 | expect(file.fps).to.equal(25) | ||
259 | |||
260 | expect(await pathExists(file.path)).to.be.true | ||
261 | await makeRawRequest(file.url, HttpStatusCode.OK_200) | ||
262 | } | ||
263 | } | ||
264 | |||
265 | videoPath = body.webtorrent.videoFiles[0].path | ||
266 | } | ||
267 | |||
268 | // Thumbnails check | ||
269 | { | ||
270 | expect(body.thumbnails).to.be.an('array') | ||
271 | |||
272 | const miniature = body.thumbnails.find(t => t.type === ThumbnailType.MINIATURE) | ||
273 | expect(miniature).to.exist | ||
274 | expect(await pathExists(miniature.path)).to.be.true | ||
275 | await makeRawRequest(miniature.url, HttpStatusCode.OK_200) | ||
276 | |||
277 | const preview = body.thumbnails.find(t => t.type === ThumbnailType.PREVIEW) | ||
278 | expect(preview).to.exist | ||
279 | expect(await pathExists(preview.path)).to.be.true | ||
280 | await makeRawRequest(preview.url, HttpStatusCode.OK_200) | ||
281 | } | ||
282 | }) | ||
283 | |||
284 | it('Should probe a file', async function () { | ||
285 | const { body } = await makeGetRequest({ | ||
286 | url: servers[0].url, | ||
287 | path: '/plugins/test-four/router/ffprobe', | ||
288 | query: { | ||
289 | path: videoPath | ||
290 | }, | ||
291 | expectedStatus: HttpStatusCode.OK_200 | ||
292 | }) | ||
293 | |||
294 | expect(body.streams).to.be.an('array') | ||
295 | expect(body.streams).to.have.lengthOf(2) | ||
229 | }) | 296 | }) |
230 | 297 | ||
231 | it('Should remove a video after a view', async function () { | 298 | it('Should remove a video after a view', async function () { |
diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts index b1ac9e2fe..58629adc7 100644 --- a/server/tests/plugins/plugin-router.ts +++ b/server/tests/plugins/plugin-router.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | PeerTubeServer, | 10 | PeerTubeServer, |
11 | PluginsCommand, | 11 | PluginsCommand, |
12 | setAccessTokensToServers | 12 | setAccessTokensToServers |
13 | } from '@shared/extra-utils' | 13 | } from '@shared/server-commands' |
14 | import { HttpStatusCode } from '@shared/models' | 14 | import { HttpStatusCode } from '@shared/models' |
15 | 15 | ||
16 | describe('Test plugin helpers', function () { | 16 | describe('Test plugin helpers', function () { |
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts index e20c36dba..0bfc4fe28 100644 --- a/server/tests/plugins/plugin-storage.ts +++ b/server/tests/plugins/plugin-storage.ts | |||
@@ -11,7 +11,7 @@ import { | |||
11 | PeerTubeServer, | 11 | PeerTubeServer, |
12 | PluginsCommand, | 12 | PluginsCommand, |
13 | setAccessTokensToServers | 13 | setAccessTokensToServers |
14 | } from '@shared/extra-utils' | 14 | } from '@shared/server-commands' |
15 | import { HttpStatusCode } from '@shared/models' | 15 | import { HttpStatusCode } from '@shared/models' |
16 | 16 | ||
17 | describe('Test plugin storage', function () { | 17 | describe('Test plugin storage', function () { |
@@ -27,10 +27,14 @@ describe('Test plugin storage', function () { | |||
27 | }) | 27 | }) |
28 | 28 | ||
29 | describe('DB storage', function () { | 29 | describe('DB storage', function () { |
30 | |||
31 | it('Should correctly store a subkey', async function () { | 30 | it('Should correctly store a subkey', async function () { |
32 | await server.servers.waitUntilLog('superkey stored value is toto') | 31 | await server.servers.waitUntilLog('superkey stored value is toto') |
33 | }) | 32 | }) |
33 | |||
34 | it('Should correctly retrieve an array as array from the storage.', async function () { | ||
35 | await server.servers.waitUntilLog('storedArrayKey isArray is true') | ||
36 | await server.servers.waitUntilLog('storedArrayKey stored value is toto, toto2') | ||
37 | }) | ||
34 | }) | 38 | }) |
35 | 39 | ||
36 | describe('Disk storage', function () { | 40 | describe('Disk storage', function () { |
diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts index 93637e3ce..5ab686472 100644 --- a/server/tests/plugins/plugin-transcoding.ts +++ b/server/tests/plugins/plugin-transcoding.ts | |||
@@ -12,7 +12,7 @@ import { | |||
12 | setDefaultVideoChannel, | 12 | setDefaultVideoChannel, |
13 | testFfmpegStreamError, | 13 | testFfmpegStreamError, |
14 | waitJobs | 14 | waitJobs |
15 | } from '@shared/extra-utils' | 15 | } from '@shared/server-commands' |
16 | import { VideoPrivacy } from '@shared/models' | 16 | import { VideoPrivacy } from '@shared/models' |
17 | 17 | ||
18 | async function createLiveWrapper (server: PeerTubeServer) { | 18 | async function createLiveWrapper (server: PeerTubeServer) { |
diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index 6bf2fda9b..a94b83695 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts | |||
@@ -9,7 +9,7 @@ import { | |||
9 | PeerTubeServer, | 9 | PeerTubeServer, |
10 | PluginsCommand, | 10 | PluginsCommand, |
11 | setAccessTokensToServers | 11 | setAccessTokensToServers |
12 | } from '@shared/extra-utils' | 12 | } from '@shared/server-commands' |
13 | import { HttpStatusCode } from '@shared/models' | 13 | import { HttpStatusCode } from '@shared/models' |
14 | 14 | ||
15 | describe('Test plugins module unloading', function () { | 15 | describe('Test plugins module unloading', function () { |
diff --git a/server/tests/plugins/translations.ts b/server/tests/plugins/translations.ts index 8b25c6b75..0b6e5793d 100644 --- a/server/tests/plugins/translations.ts +++ b/server/tests/plugins/translations.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/extra-utils' | 5 | import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/server-commands' |
6 | 6 | ||
7 | const expect = chai.expect | 7 | const expect = chai.expect |
8 | 8 | ||
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts index 19cba6c2c..6dce6922f 100644 --- a/server/tests/plugins/video-constants.ts +++ b/server/tests/plugins/video-constants.ts | |||
@@ -9,7 +9,7 @@ import { | |||
9 | PeerTubeServer, | 9 | PeerTubeServer, |
10 | PluginsCommand, | 10 | PluginsCommand, |
11 | setAccessTokensToServers | 11 | setAccessTokensToServers |
12 | } from '@shared/extra-utils' | 12 | } from '@shared/server-commands' |
13 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' | 13 | import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models' |
14 | 14 | ||
15 | const expect = chai.expect | 15 | const expect = chai.expect |