diff options
Diffstat (limited to 'server/tests/plugins')
-rw-r--r-- | server/tests/plugins/action-hooks.ts | 5 | ||||
-rw-r--r-- | server/tests/plugins/external-auth.ts | 7 | ||||
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 39 | ||||
-rw-r--r-- | server/tests/plugins/id-and-pass-auth.ts | 13 | ||||
-rw-r--r-- | server/tests/plugins/plugin-helpers.ts | 19 | ||||
-rw-r--r-- | server/tests/plugins/plugin-storage.ts | 17 | ||||
-rw-r--r-- | server/tests/plugins/plugin-transcoding.ts | 3 |
7 files changed, 44 insertions, 59 deletions
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts index bcf773854..cf81e44b7 100644 --- a/server/tests/plugins/action-hooks.ts +++ b/server/tests/plugins/action-hooks.ts | |||
@@ -22,8 +22,7 @@ import { | |||
22 | flushAndRunMultipleServers, | 22 | flushAndRunMultipleServers, |
23 | killallServers, | 23 | killallServers, |
24 | reRunServer, | 24 | reRunServer, |
25 | ServerInfo, | 25 | ServerInfo |
26 | waitUntilLog | ||
27 | } from '../../../shared/extra-utils/server/servers' | 26 | } from '../../../shared/extra-utils/server/servers' |
28 | 27 | ||
29 | describe('Test plugin action hooks', function () { | 28 | describe('Test plugin action hooks', function () { |
@@ -32,7 +31,7 @@ describe('Test plugin action hooks', function () { | |||
32 | let threadId: number | 31 | let threadId: number |
33 | 32 | ||
34 | function checkHook (hook: ServerHookName) { | 33 | function checkHook (hook: ServerHookName) { |
35 | return waitUntilLog(servers[0], 'Run hook ' + hook) | 34 | return servers[0].serversCommand.waitUntilLog('Run hook ' + hook) |
36 | } | 35 | } |
37 | 36 | ||
38 | before(async function () { | 37 | before(async function () { |
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index 09a107ca2..f7cee588a 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts | |||
@@ -17,8 +17,7 @@ import { | |||
17 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
18 | updateMyUser, | 18 | updateMyUser, |
19 | userLogin, | 19 | userLogin, |
20 | wait, | 20 | wait |
21 | waitUntilLog | ||
22 | } from '@shared/extra-utils' | 21 | } from '@shared/extra-utils' |
23 | import { User, UserRole } from '@shared/models' | 22 | import { User, UserRole } from '@shared/models' |
24 | 23 | ||
@@ -127,7 +126,7 @@ describe('Test external auth plugins', function () { | |||
127 | 126 | ||
128 | await loginUsingExternalToken(server, 'cyan', externalAuthToken, HttpStatusCode.BAD_REQUEST_400) | 127 | await loginUsingExternalToken(server, 'cyan', externalAuthToken, HttpStatusCode.BAD_REQUEST_400) |
129 | 128 | ||
130 | await waitUntilLog(server, 'expired external auth token', 2) | 129 | await server.serversCommand.waitUntilLog('expired external auth token', 2) |
131 | }) | 130 | }) |
132 | 131 | ||
133 | it('Should auto login Cyan, create the user and use the token', async function () { | 132 | it('Should auto login Cyan, create the user and use the token', async function () { |
@@ -217,7 +216,7 @@ describe('Test external auth plugins', function () { | |||
217 | }) | 216 | }) |
218 | 217 | ||
219 | it('Should have logged out Cyan', async function () { | 218 | it('Should have logged out Cyan', async function () { |
220 | await waitUntilLog(server, 'On logout cyan') | 219 | await server.serversCommand.waitUntilLog('On logout cyan') |
221 | 220 | ||
222 | await getMyUserInformation(server.url, cyanAccessToken, HttpStatusCode.UNAUTHORIZED_401) | 221 | await getMyUserInformation(server.url, cyanAccessToken, HttpStatusCode.UNAUTHORIZED_401) |
223 | }) | 222 | }) |
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index c235508e8..b5e29d298 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -24,8 +24,7 @@ import { | |||
24 | updateVideo, | 24 | updateVideo, |
25 | uploadVideo, | 25 | uploadVideo, |
26 | uploadVideoAndGetId, | 26 | uploadVideoAndGetId, |
27 | waitJobs, | 27 | waitJobs |
28 | waitUntilLog | ||
29 | } from '@shared/extra-utils' | 28 | } from '@shared/extra-utils' |
30 | import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' | 29 | import { VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' |
31 | 30 | ||
@@ -475,8 +474,8 @@ describe('Test plugin filter hooks', function () { | |||
475 | } | 474 | } |
476 | }) | 475 | }) |
477 | 476 | ||
478 | await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.params', 1) | 477 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1) |
479 | await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.result', 1) | 478 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1) |
480 | }) | 479 | }) |
481 | 480 | ||
482 | it('Should run filter:api.search.videos.index.list.{params,result}', async function () { | 481 | it('Should run filter:api.search.videos.index.list.{params,result}', async function () { |
@@ -487,10 +486,10 @@ describe('Test plugin filter hooks', function () { | |||
487 | } | 486 | } |
488 | }) | 487 | }) |
489 | 488 | ||
490 | await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.params', 1) | 489 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1) |
491 | await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.local.list.result', 1) | 490 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1) |
492 | await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.index.list.params', 1) | 491 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1) |
493 | await waitUntilLog(servers[0], 'Run hook filter:api.search.videos.index.list.result', 1) | 492 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1) |
494 | }) | 493 | }) |
495 | 494 | ||
496 | it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () { | 495 | it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () { |
@@ -500,8 +499,8 @@ describe('Test plugin filter hooks', function () { | |||
500 | } | 499 | } |
501 | }) | 500 | }) |
502 | 501 | ||
503 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.params', 1) | 502 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1) |
504 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.result', 1) | 503 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1) |
505 | }) | 504 | }) |
506 | 505 | ||
507 | it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () { | 506 | it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () { |
@@ -512,10 +511,10 @@ describe('Test plugin filter hooks', function () { | |||
512 | } | 511 | } |
513 | }) | 512 | }) |
514 | 513 | ||
515 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.params', 1) | 514 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1) |
516 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.local.list.result', 1) | 515 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1) |
517 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.params', 1) | 516 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1) |
518 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-channels.index.list.result', 1) | 517 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1) |
519 | }) | 518 | }) |
520 | 519 | ||
521 | it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () { | 520 | it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () { |
@@ -525,8 +524,8 @@ describe('Test plugin filter hooks', function () { | |||
525 | } | 524 | } |
526 | }) | 525 | }) |
527 | 526 | ||
528 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1) | 527 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1) |
529 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.result', 1) | 528 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1) |
530 | }) | 529 | }) |
531 | 530 | ||
532 | it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () { | 531 | it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () { |
@@ -537,10 +536,10 @@ describe('Test plugin filter hooks', function () { | |||
537 | } | 536 | } |
538 | }) | 537 | }) |
539 | 538 | ||
540 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.params', 1) | 539 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1) |
541 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.local.list.result', 1) | 540 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1) |
542 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.index.list.params', 1) | 541 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1) |
543 | await waitUntilLog(servers[0], 'Run hook filter:api.search.video-playlists.index.list.result', 1) | 542 | await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1) |
544 | }) | 543 | }) |
545 | }) | 544 | }) |
546 | 545 | ||
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index 99de28d3f..a0b31bc1f 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts | |||
@@ -15,8 +15,7 @@ import { | |||
15 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
16 | updateMyUser, | 16 | updateMyUser, |
17 | userLogin, | 17 | userLogin, |
18 | wait, | 18 | wait |
19 | waitUntilLog | ||
20 | } from '@shared/extra-utils' | 19 | } from '@shared/extra-utils' |
21 | import { User, UserRole } from '@shared/models' | 20 | import { User, UserRole } from '@shared/models' |
22 | 21 | ||
@@ -137,7 +136,7 @@ describe('Test id and pass auth plugins', function () { | |||
137 | }) | 136 | }) |
138 | 137 | ||
139 | it('Should have logged out Crash', async function () { | 138 | it('Should have logged out Crash', async function () { |
140 | await waitUntilLog(server, 'On logout for auth 1 - 2') | 139 | await server.serversCommand.waitUntilLog('On logout for auth 1 - 2') |
141 | 140 | ||
142 | await getMyUserInformation(server.url, crashAccessToken, 401) | 141 | await getMyUserInformation(server.url, crashAccessToken, 401) |
143 | }) | 142 | }) |
@@ -164,16 +163,16 @@ describe('Test id and pass auth plugins', function () { | |||
164 | 163 | ||
165 | it('Should reject an invalid username, email, role or display name', async function () { | 164 | it('Should reject an invalid username, email, role or display name', async function () { |
166 | await userLogin(server, { username: 'ward', password: 'ward password' }, 400) | 165 | await userLogin(server, { username: 'ward', password: 'ward password' }, 400) |
167 | await waitUntilLog(server, 'valid username') | 166 | await server.serversCommand.waitUntilLog('valid username') |
168 | 167 | ||
169 | await userLogin(server, { username: 'kiros', password: 'kiros password' }, 400) | 168 | await userLogin(server, { username: 'kiros', password: 'kiros password' }, 400) |
170 | await waitUntilLog(server, 'valid display name') | 169 | await server.serversCommand.waitUntilLog('valid display name') |
171 | 170 | ||
172 | await userLogin(server, { username: 'raine', password: 'raine password' }, 400) | 171 | await userLogin(server, { username: 'raine', password: 'raine password' }, 400) |
173 | await waitUntilLog(server, 'valid role') | 172 | await server.serversCommand.waitUntilLog('valid role') |
174 | 173 | ||
175 | await userLogin(server, { username: 'ellone', password: 'elonne password' }, 400) | 174 | await userLogin(server, { username: 'ellone', password: 'elonne password' }, 400) |
176 | await waitUntilLog(server, 'valid email') | 175 | await server.serversCommand.waitUntilLog('valid email') |
177 | }) | 176 | }) |
178 | 177 | ||
179 | it('Should unregister spyro-auth and do not login existing Spyro', async function () { | 178 | it('Should unregister spyro-auth and do not login existing Spyro', async function () { |
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index 0e0f61638..cbb6887eb 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts | |||
@@ -17,8 +17,7 @@ import { | |||
17 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
18 | uploadVideoAndGetId, | 18 | uploadVideoAndGetId, |
19 | viewVideo, | 19 | viewVideo, |
20 | waitJobs, | 20 | waitJobs |
21 | waitUntilLog | ||
22 | } from '@shared/extra-utils' | 21 | } from '@shared/extra-utils' |
23 | 22 | ||
24 | function postCommand (server: ServerInfo, command: string, bodyArg?: object) { | 23 | function postCommand (server: ServerInfo, command: string, bodyArg?: object) { |
@@ -50,22 +49,22 @@ describe('Test plugin helpers', function () { | |||
50 | describe('Logger', function () { | 49 | describe('Logger', function () { |
51 | 50 | ||
52 | it('Should have logged things', async function () { | 51 | it('Should have logged things', async function () { |
53 | await waitUntilLog(servers[0], 'localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false) | 52 | await servers[0].serversCommand.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false) |
54 | await waitUntilLog(servers[0], 'Hello world from plugin four', 1) | 53 | await servers[0].serversCommand.waitUntilLog('Hello world from plugin four', 1) |
55 | }) | 54 | }) |
56 | }) | 55 | }) |
57 | 56 | ||
58 | describe('Database', function () { | 57 | describe('Database', function () { |
59 | 58 | ||
60 | it('Should have made a query', async function () { | 59 | it('Should have made a query', async function () { |
61 | await waitUntilLog(servers[0], `root email is admin${servers[0].internalServerNumber}@example.com`) | 60 | await servers[0].serversCommand.waitUntilLog(`root email is admin${servers[0].internalServerNumber}@example.com`) |
62 | }) | 61 | }) |
63 | }) | 62 | }) |
64 | 63 | ||
65 | describe('Config', function () { | 64 | describe('Config', function () { |
66 | 65 | ||
67 | it('Should have the correct webserver url', async function () { | 66 | it('Should have the correct webserver url', async function () { |
68 | await waitUntilLog(servers[0], `server url is http://localhost:${servers[0].port}`) | 67 | await servers[0].serversCommand.waitUntilLog(`server url is http://localhost:${servers[0].port}`) |
69 | }) | 68 | }) |
70 | 69 | ||
71 | it('Should have the correct config', async function () { | 70 | it('Should have the correct config', async function () { |
@@ -83,7 +82,7 @@ describe('Test plugin helpers', function () { | |||
83 | describe('Server', function () { | 82 | describe('Server', function () { |
84 | 83 | ||
85 | it('Should get the server actor', async function () { | 84 | it('Should get the server actor', async function () { |
86 | await waitUntilLog(servers[0], 'server actor name is peertube') | 85 | await servers[0].serversCommand.waitUntilLog('server actor name is peertube') |
87 | }) | 86 | }) |
88 | }) | 87 | }) |
89 | 88 | ||
@@ -248,7 +247,7 @@ describe('Test plugin helpers', function () { | |||
248 | // Should delete the video | 247 | // Should delete the video |
249 | await viewVideo(servers[0].url, videoUUID) | 248 | await viewVideo(servers[0].url, videoUUID) |
250 | 249 | ||
251 | await waitUntilLog(servers[0], 'Video deleted by plugin four.') | 250 | await servers[0].serversCommand.waitUntilLog('Video deleted by plugin four.') |
252 | 251 | ||
253 | try { | 252 | try { |
254 | // Should throw because the video should have been deleted | 253 | // Should throw because the video should have been deleted |
@@ -258,11 +257,11 @@ describe('Test plugin helpers', function () { | |||
258 | if (err.message.includes('exists')) throw err | 257 | if (err.message.includes('exists')) throw err |
259 | } | 258 | } |
260 | 259 | ||
261 | await checkVideoFilesWereRemoved(videoUUID, servers[0].internalServerNumber) | 260 | await checkVideoFilesWereRemoved(videoUUID, servers[0]) |
262 | }) | 261 | }) |
263 | 262 | ||
264 | it('Should have fetched the video by URL', async function () { | 263 | it('Should have fetched the video by URL', async function () { |
265 | await waitUntilLog(servers[0], `video from DB uuid is ${videoUUID}`) | 264 | await servers[0].serversCommand.waitUntilLog(`video from DB uuid is ${videoUUID}`) |
266 | }) | 265 | }) |
267 | }) | 266 | }) |
268 | 267 | ||
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts index 4c65463f2..9babfc83e 100644 --- a/server/tests/plugins/plugin-storage.ts +++ b/server/tests/plugins/plugin-storage.ts | |||
@@ -5,16 +5,7 @@ import { expect } from 'chai' | |||
5 | import { pathExists, readdir, readFile } from 'fs-extra' | 5 | import { pathExists, readdir, readFile } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/core-utils' |
8 | import { | 8 | import { cleanupTests, flushAndRunServer, makeGetRequest, PluginsCommand, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' |
9 | buildServerDirectory, | ||
10 | cleanupTests, | ||
11 | flushAndRunServer, | ||
12 | makeGetRequest, | ||
13 | PluginsCommand, | ||
14 | ServerInfo, | ||
15 | setAccessTokensToServers, | ||
16 | waitUntilLog | ||
17 | } from '@shared/extra-utils' | ||
18 | 9 | ||
19 | describe('Test plugin storage', function () { | 10 | describe('Test plugin storage', function () { |
20 | let server: ServerInfo | 11 | let server: ServerInfo |
@@ -31,7 +22,7 @@ describe('Test plugin storage', function () { | |||
31 | describe('DB storage', function () { | 22 | describe('DB storage', function () { |
32 | 23 | ||
33 | it('Should correctly store a subkey', async function () { | 24 | it('Should correctly store a subkey', async function () { |
34 | await waitUntilLog(server, 'superkey stored value is toto') | 25 | await server.serversCommand.waitUntilLog('superkey stored value is toto') |
35 | }) | 26 | }) |
36 | }) | 27 | }) |
37 | 28 | ||
@@ -47,12 +38,12 @@ describe('Test plugin storage', function () { | |||
47 | } | 38 | } |
48 | 39 | ||
49 | before(function () { | 40 | before(function () { |
50 | dataPath = buildServerDirectory(server, 'plugins/data') | 41 | dataPath = server.serversCommand.buildDirectory('plugins/data') |
51 | pluginDataPath = join(dataPath, 'peertube-plugin-test-six') | 42 | pluginDataPath = join(dataPath, 'peertube-plugin-test-six') |
52 | }) | 43 | }) |
53 | 44 | ||
54 | it('Should have created the directory on install', async function () { | 45 | it('Should have created the directory on install', async function () { |
55 | const dataPath = buildServerDirectory(server, 'plugins/data') | 46 | const dataPath = server.serversCommand.buildDirectory('plugins/data') |
56 | const pluginDataPath = join(dataPath, 'peertube-plugin-test-six') | 47 | const pluginDataPath = join(dataPath, 'peertube-plugin-test-six') |
57 | 48 | ||
58 | expect(await pathExists(dataPath)).to.be.true | 49 | expect(await pathExists(dataPath)).to.be.true |
diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts index ca4d9f962..4839e8792 100644 --- a/server/tests/plugins/plugin-transcoding.ts +++ b/server/tests/plugins/plugin-transcoding.ts | |||
@@ -5,7 +5,6 @@ import { expect } from 'chai' | |||
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' | 6 | import { getAudioStream, getVideoFileFPS, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' |
7 | import { | 7 | import { |
8 | buildServerDirectory, | ||
9 | cleanupTests, | 8 | cleanupTests, |
10 | flushAndRunServer, | 9 | flushAndRunServer, |
11 | getVideo, | 10 | getVideo, |
@@ -247,7 +246,7 @@ describe('Test transcoding plugins', function () { | |||
247 | const videoUUID = (await uploadVideoAndGetId({ server, videoName: 'video', fixture: 'video_short_240p.mp4' })).uuid | 246 | const videoUUID = (await uploadVideoAndGetId({ server, videoName: 'video', fixture: 'video_short_240p.mp4' })).uuid |
248 | await waitJobs([ server ]) | 247 | await waitJobs([ server ]) |
249 | 248 | ||
250 | const path = buildServerDirectory(server, join('videos', videoUUID + '-240.mp4')) | 249 | const path = server.serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4')) |
251 | const audioProbe = await getAudioStream(path) | 250 | const audioProbe = await getAudioStream(path) |
252 | expect(audioProbe.audioStream.codec_name).to.equal('opus') | 251 | expect(audioProbe.audioStream.codec_name).to.equal('opus') |
253 | 252 | ||