diff options
Diffstat (limited to 'server/tests/api/check-params/video-blacklist.ts')
-rw-r--r-- | server/tests/api/check-params/video-blacklist.ts | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index 0fda31b29..51609b982 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts | |||
@@ -40,41 +40,41 @@ describe('Test video blacklist API validators', function () { | |||
40 | { | 40 | { |
41 | const username = 'user1' | 41 | const username = 'user1' |
42 | const password = 'my super password' | 42 | const password = 'my super password' |
43 | await servers[0].usersCommand.create({ username: username, password: password }) | 43 | await servers[0].users.create({ username: username, password: password }) |
44 | userAccessToken1 = await servers[0].loginCommand.getAccessToken({ username, password }) | 44 | userAccessToken1 = await servers[0].login.getAccessToken({ username, password }) |
45 | } | 45 | } |
46 | 46 | ||
47 | { | 47 | { |
48 | const username = 'user2' | 48 | const username = 'user2' |
49 | const password = 'my super password' | 49 | const password = 'my super password' |
50 | await servers[0].usersCommand.create({ username: username, password: password }) | 50 | await servers[0].users.create({ username: username, password: password }) |
51 | userAccessToken2 = await servers[0].loginCommand.getAccessToken({ username, password }) | 51 | userAccessToken2 = await servers[0].login.getAccessToken({ username, password }) |
52 | } | 52 | } |
53 | 53 | ||
54 | { | 54 | { |
55 | servers[0].video = await servers[0].videosCommand.upload({ token: userAccessToken1 }) | 55 | servers[0].store.video = await servers[0].videos.upload({ token: userAccessToken1 }) |
56 | } | 56 | } |
57 | 57 | ||
58 | { | 58 | { |
59 | const { uuid } = await servers[0].videosCommand.upload() | 59 | const { uuid } = await servers[0].videos.upload() |
60 | notBlacklistedVideoId = uuid | 60 | notBlacklistedVideoId = uuid |
61 | } | 61 | } |
62 | 62 | ||
63 | { | 63 | { |
64 | const { uuid } = await servers[1].videosCommand.upload() | 64 | const { uuid } = await servers[1].videos.upload() |
65 | remoteVideoUUID = uuid | 65 | remoteVideoUUID = uuid |
66 | } | 66 | } |
67 | 67 | ||
68 | await waitJobs(servers) | 68 | await waitJobs(servers) |
69 | 69 | ||
70 | command = servers[0].blacklistCommand | 70 | command = servers[0].blacklist |
71 | }) | 71 | }) |
72 | 72 | ||
73 | describe('When adding a video in blacklist', function () { | 73 | describe('When adding a video in blacklist', function () { |
74 | const basePath = '/api/v1/videos/' | 74 | const basePath = '/api/v1/videos/' |
75 | 75 | ||
76 | it('Should fail with nothing', async function () { | 76 | it('Should fail with nothing', async function () { |
77 | const path = basePath + servers[0].video + '/blacklist' | 77 | const path = basePath + servers[0].store.video + '/blacklist' |
78 | const fields = {} | 78 | const fields = {} |
79 | await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) | 79 | await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) |
80 | }) | 80 | }) |
@@ -86,13 +86,13 @@ describe('Test video blacklist API validators', function () { | |||
86 | }) | 86 | }) |
87 | 87 | ||
88 | it('Should fail with a non authenticated user', async function () { | 88 | it('Should fail with a non authenticated user', async function () { |
89 | const path = basePath + servers[0].video + '/blacklist' | 89 | const path = basePath + servers[0].store.video + '/blacklist' |
90 | const fields = {} | 90 | const fields = {} |
91 | await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 91 | await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) |
92 | }) | 92 | }) |
93 | 93 | ||
94 | it('Should fail with a non admin user', async function () { | 94 | it('Should fail with a non admin user', async function () { |
95 | const path = basePath + servers[0].video + '/blacklist' | 95 | const path = basePath + servers[0].store.video + '/blacklist' |
96 | const fields = {} | 96 | const fields = {} |
97 | await makePostBodyRequest({ | 97 | await makePostBodyRequest({ |
98 | url: servers[0].url, | 98 | url: servers[0].url, |
@@ -104,7 +104,7 @@ describe('Test video blacklist API validators', function () { | |||
104 | }) | 104 | }) |
105 | 105 | ||
106 | it('Should fail with an invalid reason', async function () { | 106 | it('Should fail with an invalid reason', async function () { |
107 | const path = basePath + servers[0].video.uuid + '/blacklist' | 107 | const path = basePath + servers[0].store.video.uuid + '/blacklist' |
108 | const fields = { reason: 'a'.repeat(305) } | 108 | const fields = { reason: 'a'.repeat(305) } |
109 | 109 | ||
110 | await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) | 110 | await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) |
@@ -124,7 +124,7 @@ describe('Test video blacklist API validators', function () { | |||
124 | }) | 124 | }) |
125 | 125 | ||
126 | it('Should succeed with the correct params', async function () { | 126 | it('Should succeed with the correct params', async function () { |
127 | const path = basePath + servers[0].video.uuid + '/blacklist' | 127 | const path = basePath + servers[0].store.video.uuid + '/blacklist' |
128 | const fields = {} | 128 | const fields = {} |
129 | 129 | ||
130 | await makePostBodyRequest({ | 130 | await makePostBodyRequest({ |
@@ -159,13 +159,13 @@ describe('Test video blacklist API validators', function () { | |||
159 | }) | 159 | }) |
160 | 160 | ||
161 | it('Should fail with a non authenticated user', async function () { | 161 | it('Should fail with a non authenticated user', async function () { |
162 | const path = basePath + servers[0].video + '/blacklist' | 162 | const path = basePath + servers[0].store.video + '/blacklist' |
163 | const fields = {} | 163 | const fields = {} |
164 | await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 164 | await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) |
165 | }) | 165 | }) |
166 | 166 | ||
167 | it('Should fail with a non admin user', async function () { | 167 | it('Should fail with a non admin user', async function () { |
168 | const path = basePath + servers[0].video + '/blacklist' | 168 | const path = basePath + servers[0].store.video + '/blacklist' |
169 | const fields = {} | 169 | const fields = {} |
170 | await makePutBodyRequest({ | 170 | await makePutBodyRequest({ |
171 | url: servers[0].url, | 171 | url: servers[0].url, |
@@ -177,14 +177,14 @@ describe('Test video blacklist API validators', function () { | |||
177 | }) | 177 | }) |
178 | 178 | ||
179 | it('Should fail with an invalid reason', async function () { | 179 | it('Should fail with an invalid reason', async function () { |
180 | const path = basePath + servers[0].video.uuid + '/blacklist' | 180 | const path = basePath + servers[0].store.video.uuid + '/blacklist' |
181 | const fields = { reason: 'a'.repeat(305) } | 181 | const fields = { reason: 'a'.repeat(305) } |
182 | 182 | ||
183 | await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) | 183 | await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) |
184 | }) | 184 | }) |
185 | 185 | ||
186 | it('Should succeed with the correct params', async function () { | 186 | it('Should succeed with the correct params', async function () { |
187 | const path = basePath + servers[0].video.shortUUID + '/blacklist' | 187 | const path = basePath + servers[0].store.video.shortUUID + '/blacklist' |
188 | const fields = { reason: 'hello' } | 188 | const fields = { reason: 'hello' } |
189 | 189 | ||
190 | await makePutBodyRequest({ | 190 | await makePutBodyRequest({ |
@@ -200,27 +200,27 @@ describe('Test video blacklist API validators', function () { | |||
200 | describe('When getting blacklisted video', function () { | 200 | describe('When getting blacklisted video', function () { |
201 | 201 | ||
202 | it('Should fail with a non authenticated user', async function () { | 202 | it('Should fail with a non authenticated user', async function () { |
203 | await servers[0].videosCommand.get({ id: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) | 203 | await servers[0].videos.get({ id: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
204 | }) | 204 | }) |
205 | 205 | ||
206 | it('Should fail with another user', async function () { | 206 | it('Should fail with another user', async function () { |
207 | await servers[0].videosCommand.getWithToken({ | 207 | await servers[0].videos.getWithToken({ |
208 | token: userAccessToken2, | 208 | token: userAccessToken2, |
209 | id: servers[0].video.uuid, | 209 | id: servers[0].store.video.uuid, |
210 | expectedStatus: HttpStatusCode.FORBIDDEN_403 | 210 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
211 | }) | 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 video = await servers[0].videosCommand.getWithToken({ token: userAccessToken1, id: servers[0].video.uuid }) | 215 | const video = await servers[0].videos.getWithToken({ token: userAccessToken1, id: servers[0].store.video.uuid }) |
216 | expect(video.blacklisted).to.be.true | 216 | expect(video.blacklisted).to.be.true |
217 | }) | 217 | }) |
218 | 218 | ||
219 | it('Should succeed with an admin', async function () { | 219 | it('Should succeed with an admin', async function () { |
220 | const video = servers[0].video | 220 | const video = servers[0].store.video |
221 | 221 | ||
222 | for (const id of [ video.id, video.uuid, video.shortUUID ]) { | 222 | for (const id of [ video.id, video.uuid, video.shortUUID ]) { |
223 | const video = await servers[0].videosCommand.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 }) | 223 | const video = await servers[0].videos.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 }) |
224 | expect(video.blacklisted).to.be.true | 224 | expect(video.blacklisted).to.be.true |
225 | } | 225 | } |
226 | }) | 226 | }) |
@@ -229,11 +229,11 @@ describe('Test video blacklist API validators', function () { | |||
229 | describe('When removing a video in blacklist', function () { | 229 | describe('When removing a video in blacklist', function () { |
230 | 230 | ||
231 | it('Should fail with a non authenticated user', async function () { | 231 | it('Should fail with a non authenticated user', async function () { |
232 | await command.remove({ token: 'fake token', videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) | 232 | await command.remove({ token: 'fake token', videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
233 | }) | 233 | }) |
234 | 234 | ||
235 | it('Should fail with a non admin user', async function () { | 235 | it('Should fail with a non admin user', async function () { |
236 | await command.remove({ token: userAccessToken2, videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 236 | await command.remove({ token: userAccessToken2, videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
237 | }) | 237 | }) |
238 | 238 | ||
239 | it('Should fail with an incorrect id', async function () { | 239 | it('Should fail with an incorrect id', async function () { |
@@ -246,7 +246,7 @@ describe('Test video blacklist API validators', function () { | |||
246 | }) | 246 | }) |
247 | 247 | ||
248 | it('Should succeed with the correct params', async function () { | 248 | it('Should succeed with the correct params', async function () { |
249 | await command.remove({ videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) | 249 | await command.remove({ videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) |
250 | }) | 250 | }) |
251 | }) | 251 | }) |
252 | 252 | ||
@@ -254,11 +254,11 @@ describe('Test video blacklist API validators', function () { | |||
254 | const basePath = '/api/v1/videos/blacklist/' | 254 | const basePath = '/api/v1/videos/blacklist/' |
255 | 255 | ||
256 | it('Should fail with a non authenticated user', async function () { | 256 | it('Should fail with a non authenticated user', async function () { |
257 | await servers[0].blacklistCommand.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) | 257 | await servers[0].blacklist.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
258 | }) | 258 | }) |
259 | 259 | ||
260 | it('Should fail with a non admin user', async function () { | 260 | it('Should fail with a non admin user', async function () { |
261 | await servers[0].blacklistCommand.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) | 261 | await servers[0].blacklist.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
262 | }) | 262 | }) |
263 | 263 | ||
264 | it('Should fail with a bad start pagination', async function () { | 264 | it('Should fail with a bad start pagination', async function () { |
@@ -274,11 +274,11 @@ describe('Test video blacklist API validators', function () { | |||
274 | }) | 274 | }) |
275 | 275 | ||
276 | it('Should fail with an invalid type', async function () { | 276 | it('Should fail with an invalid type', async function () { |
277 | await servers[0].blacklistCommand.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) | 277 | await servers[0].blacklist.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
278 | }) | 278 | }) |
279 | 279 | ||
280 | it('Should succeed with the correct parameters', async function () { | 280 | it('Should succeed with the correct parameters', async function () { |
281 | await servers[0].blacklistCommand.list({ type: VideoBlacklistType.MANUAL }) | 281 | await servers[0].blacklist.list({ type: VideoBlacklistType.MANUAL }) |
282 | }) | 282 | }) |
283 | }) | 283 | }) |
284 | 284 | ||