diff options
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/video-comments.ts | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index c11660d07..9190054da 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts | |||
@@ -3,8 +3,9 @@ | |||
3 | import * as chai from 'chai' | 3 | import * as chai from 'chai' |
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { | 5 | import { |
6 | flushTests, killallServers, makeGetRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers, | 6 | createUser, |
7 | uploadVideo | 7 | flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers, |
8 | uploadVideo, userLogin | ||
8 | } from '../../utils' | 9 | } from '../../utils' |
9 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' | 10 | import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' |
10 | import { addVideoCommentThread } from '../../utils/videos/video-comments' | 11 | import { addVideoCommentThread } from '../../utils/videos/video-comments' |
@@ -16,6 +17,7 @@ describe('Test video comments API validator', function () { | |||
16 | let pathComment: string | 17 | let pathComment: string |
17 | let server: ServerInfo | 18 | let server: ServerInfo |
18 | let videoUUID: string | 19 | let videoUUID: string |
20 | let userAccessToken: string | ||
19 | let commentId: number | 21 | let commentId: number |
20 | 22 | ||
21 | // --------------------------------------------------------------- | 23 | // --------------------------------------------------------------- |
@@ -40,6 +42,15 @@ describe('Test video comments API validator', function () { | |||
40 | commentId = res.body.comment.id | 42 | commentId = res.body.comment.id |
41 | pathComment = '/api/v1/videos/' + videoUUID + '/comments/' + commentId | 43 | pathComment = '/api/v1/videos/' + videoUUID + '/comments/' + commentId |
42 | } | 44 | } |
45 | |||
46 | { | ||
47 | const user = { | ||
48 | username: 'user1', | ||
49 | password: 'my super password' | ||
50 | } | ||
51 | await createUser(server.url, server.accessToken, user.username, user.password) | ||
52 | userAccessToken = await userLogin(server, user) | ||
53 | } | ||
43 | }) | 54 | }) |
44 | 55 | ||
45 | describe('When listing video comment threads', function () { | 56 | describe('When listing video comment threads', function () { |
@@ -185,6 +196,30 @@ describe('Test video comments API validator', function () { | |||
185 | }) | 196 | }) |
186 | }) | 197 | }) |
187 | 198 | ||
199 | describe('When removing video comments', function () { | ||
200 | it('Should fail with a non authenticated user', async function () { | ||
201 | await makeDeleteRequest({ url: server.url, path: pathComment, token: 'none', statusCodeExpected: 401 }) | ||
202 | }) | ||
203 | |||
204 | it('Should fail with another user', async function () { | ||
205 | await makeDeleteRequest({ url: server.url, path: pathComment, token: userAccessToken, statusCodeExpected: 403 }) | ||
206 | }) | ||
207 | |||
208 | it('Should fail with an incorrect video', async function () { | ||
209 | const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comments/' + commentId | ||
210 | await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: 404 }) | ||
211 | }) | ||
212 | |||
213 | it('Should fail with an incorrect comment', async function () { | ||
214 | const path = '/api/v1/videos/' + videoUUID + '/comments/124' | ||
215 | await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: 404 }) | ||
216 | }) | ||
217 | |||
218 | it('Should succeed with the correct parameters', async function () { | ||
219 | await makeDeleteRequest({ url: server.url, path: pathComment, token: server.accessToken, statusCodeExpected: 204 }) | ||
220 | }) | ||
221 | }) | ||
222 | |||
188 | describe('When a video has comments disabled', function () { | 223 | describe('When a video has comments disabled', function () { |
189 | before(async function () { | 224 | before(async function () { |
190 | const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false }) | 225 | const res = await uploadVideo(server.url, server.accessToken, { commentsEnabled: false }) |