aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-14 16:56:15 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-29 09:21:26 +0200
commit444c0a0e017824fb4ce526281a22c4abe0a13c50 (patch)
tree6a3c1ea8c4995361c582176257d1e1315287411d /server/tests/api/check-params
parent99139e7753e20ab0fba8eae5638d3dd3e792fe43 (diff)
downloadPeerTube-444c0a0e017824fb4ce526281a22c4abe0a13c50.tar.gz
PeerTube-444c0a0e017824fb4ce526281a22c4abe0a13c50.tar.zst
PeerTube-444c0a0e017824fb4ce526281a22c4abe0a13c50.zip
Add ability to bulk delete comments
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/bulk.ts88
-rw-r--r--server/tests/api/check-params/index.ts1
2 files changed, 89 insertions, 0 deletions
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts
new file mode 100644
index 000000000..432858b33
--- /dev/null
+++ b/server/tests/api/check-params/bulk.ts
@@ -0,0 +1,88 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import 'mocha'
4import {
5 cleanupTests,
6 createUser,
7 flushAndRunServer,
8 ServerInfo,
9 setAccessTokensToServers,
10 userLogin
11} from '../../../../shared/extra-utils'
12import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests'
13
14describe('Test bulk API validators', function () {
15 let server: ServerInfo
16 let userAccessToken: string
17
18 // ---------------------------------------------------------------
19
20 before(async function () {
21 this.timeout(120000)
22
23 server = await flushAndRunServer(1)
24 await setAccessTokensToServers([ server ])
25
26 const user = { username: 'user1', password: 'password' }
27 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
28
29 userAccessToken = await userLogin(server, user)
30 })
31
32 describe('When removing comments of', function () {
33 const path = '/api/v1/bulk/remove-comments-of'
34
35 it('Should fail with an unauthenticated user', async function () {
36 await makePostBodyRequest({
37 url: server.url,
38 path,
39 fields: { accountName: 'user1', scope: 'my-videos' },
40 statusCodeExpected: 401
41 })
42 })
43
44 it('Should fail with an unknown account', async function () {
45 await makePostBodyRequest({
46 url: server.url,
47 token: server.accessToken,
48 path,
49 fields: { accountName: 'user2', scope: 'my-videos' },
50 statusCodeExpected: 404
51 })
52 })
53
54 it('Should fail with an invalid scope', async function () {
55 await makePostBodyRequest({
56 url: server.url,
57 token: server.accessToken,
58 path,
59 fields: { accountName: 'user1', scope: 'my-videoss' },
60 statusCodeExpected: 400
61 })
62 })
63
64 it('Should fail to delete comments of the instance without the appropriate rights', async function () {
65 await makePostBodyRequest({
66 url: server.url,
67 token: userAccessToken,
68 path,
69 fields: { accountName: 'user1', scope: 'instance' },
70 statusCodeExpected: 403
71 })
72 })
73
74 it('Should succeed with the correct params', async function () {
75 await makePostBodyRequest({
76 url: server.url,
77 token: server.accessToken,
78 path,
79 fields: { accountName: 'user1', scope: 'instance' },
80 statusCodeExpected: 204
81 })
82 })
83 })
84
85 after(async function () {
86 await cleanupTests([ server ])
87 })
88})
diff --git a/server/tests/api/check-params/index.ts b/server/tests/api/check-params/index.ts
index ef152f55c..93ffd98b1 100644
--- a/server/tests/api/check-params/index.ts
+++ b/server/tests/api/check-params/index.ts
@@ -1,5 +1,6 @@
1import './accounts' 1import './accounts'
2import './blocklist' 2import './blocklist'
3import './bulk'
3import './config' 4import './config'
4import './contact-form' 5import './contact-form'
5import './debug' 6import './debug'