diff options
Diffstat (limited to 'server/tests/api/check-params/video-blacklist.ts')
-rw-r--r-- | server/tests/api/check-params/video-blacklist.ts | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index 5097f8069..0fda31b29 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts | |||
@@ -11,20 +11,17 @@ import { | |||
11 | cleanupTests, | 11 | cleanupTests, |
12 | doubleFollow, | 12 | doubleFollow, |
13 | flushAndRunMultipleServers, | 13 | flushAndRunMultipleServers, |
14 | getVideo, | ||
15 | getVideoWithToken, | ||
16 | makePostBodyRequest, | 14 | makePostBodyRequest, |
17 | makePutBodyRequest, | 15 | makePutBodyRequest, |
18 | ServerInfo, | 16 | ServerInfo, |
19 | setAccessTokensToServers, | 17 | setAccessTokensToServers, |
20 | uploadVideo, | ||
21 | waitJobs | 18 | waitJobs |
22 | } from '@shared/extra-utils' | 19 | } from '@shared/extra-utils' |
23 | import { VideoBlacklistType, VideoDetails } from '@shared/models' | 20 | import { VideoBlacklistType } from '@shared/models' |
24 | 21 | ||
25 | describe('Test video blacklist API validators', function () { | 22 | describe('Test video blacklist API validators', function () { |
26 | let servers: ServerInfo[] | 23 | let servers: ServerInfo[] |
27 | let notBlacklistedVideoId: number | 24 | let notBlacklistedVideoId: string |
28 | let remoteVideoUUID: string | 25 | let remoteVideoUUID: string |
29 | let userAccessToken1 = '' | 26 | let userAccessToken1 = '' |
30 | let userAccessToken2 = '' | 27 | let userAccessToken2 = '' |
@@ -55,18 +52,17 @@ describe('Test video blacklist API validators', function () { | |||
55 | } | 52 | } |
56 | 53 | ||
57 | { | 54 | { |
58 | const res = await uploadVideo(servers[0].url, userAccessToken1, {}) | 55 | servers[0].video = await servers[0].videosCommand.upload({ token: userAccessToken1 }) |
59 | servers[0].video = res.body.video | ||
60 | } | 56 | } |
61 | 57 | ||
62 | { | 58 | { |
63 | const res = await uploadVideo(servers[0].url, servers[0].accessToken, {}) | 59 | const { uuid } = await servers[0].videosCommand.upload() |
64 | notBlacklistedVideoId = res.body.video.uuid | 60 | notBlacklistedVideoId = uuid |
65 | } | 61 | } |
66 | 62 | ||
67 | { | 63 | { |
68 | const res = await uploadVideo(servers[1].url, servers[1].accessToken, {}) | 64 | const { uuid } = await servers[1].videosCommand.upload() |
69 | remoteVideoUUID = res.body.video.uuid | 65 | remoteVideoUUID = uuid |
70 | } | 66 | } |
71 | 67 | ||
72 | await waitJobs(servers) | 68 | await waitJobs(servers) |
@@ -204,17 +200,19 @@ describe('Test video blacklist API validators', function () { | |||
204 | describe('When getting blacklisted video', function () { | 200 | describe('When getting blacklisted video', function () { |
205 | 201 | ||
206 | it('Should fail with a non authenticated user', async function () { | 202 | it('Should fail with a non authenticated user', async function () { |
207 | await getVideo(servers[0].url, servers[0].video.uuid, HttpStatusCode.UNAUTHORIZED_401) | 203 | await servers[0].videosCommand.get({ id: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
208 | }) | 204 | }) |
209 | 205 | ||
210 | it('Should fail with another user', async function () { | 206 | it('Should fail with another user', async function () { |
211 | await getVideoWithToken(servers[0].url, userAccessToken2, servers[0].video.uuid, HttpStatusCode.FORBIDDEN_403) | 207 | await servers[0].videosCommand.getWithToken({ |
208 | token: userAccessToken2, | ||
209 | id: servers[0].video.uuid, | ||
210 | expectedStatus: HttpStatusCode.FORBIDDEN_403 | ||
211 | }) | ||
212 | }) | 212 | }) |
213 | 213 | ||
214 | it('Should succeed with the owner authenticated user', async function () { | 214 | it('Should succeed with the owner authenticated user', async function () { |
215 | const res = await getVideoWithToken(servers[0].url, userAccessToken1, servers[0].video.uuid, HttpStatusCode.OK_200) | 215 | const video = await servers[0].videosCommand.getWithToken({ token: userAccessToken1, id: servers[0].video.uuid }) |
216 | const video: VideoDetails = res.body | ||
217 | |||
218 | expect(video.blacklisted).to.be.true | 216 | expect(video.blacklisted).to.be.true |
219 | }) | 217 | }) |
220 | 218 | ||
@@ -222,9 +220,7 @@ describe('Test video blacklist API validators', function () { | |||
222 | const video = servers[0].video | 220 | const video = servers[0].video |
223 | 221 | ||
224 | for (const id of [ video.id, video.uuid, video.shortUUID ]) { | 222 | for (const id of [ video.id, video.uuid, video.shortUUID ]) { |
225 | const res = await getVideoWithToken(servers[0].url, servers[0].accessToken, id, HttpStatusCode.OK_200) | 223 | const video = await servers[0].videosCommand.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 }) |
226 | const video: VideoDetails = res.body | ||
227 | |||
228 | expect(video.blacklisted).to.be.true | 224 | expect(video.blacklisted).to.be.true |
229 | } | 225 | } |
230 | }) | 226 | }) |