aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-08 15:18:04 +0200
committerChocobozzz <me@florianbigard.com>2019-04-08 15:18:04 +0200
commit14893eb71cb2d4ca47e07589c81958863603aba4 (patch)
treea6a5c3130058ca57c10ef15b8b6ee00ef78166ea /server/tests/api/check-params
parent5b9c965d5aa747f29b081289f930ee215fdc23c8 (diff)
downloadPeerTube-14893eb71cb2d4ca47e07589c81958863603aba4.tar.gz
PeerTube-14893eb71cb2d4ca47e07589c81958863603aba4.tar.zst
PeerTube-14893eb71cb2d4ca47e07589c81958863603aba4.zip
Add ability to manually approves instance followers in REST API
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/config.ts3
-rw-r--r--server/tests/api/check-params/follows.ts80
2 files changed, 82 insertions, 1 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index d117f26e6..01ab84584 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -90,7 +90,8 @@ describe('Test config API validators', function () {
90 }, 90 },
91 followers: { 91 followers: {
92 instance: { 92 instance: {
93 enabled: false 93 enabled: false,
94 manualApproval: true
94 } 95 }
95 } 96 }
96 } 97 }
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index 67fa43778..ed1d2db59 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -184,6 +184,86 @@ describe('Test server follows API validators', function () {
184 }) 184 })
185 }) 185 })
186 186
187 describe('When accepting a follower', function () {
188 const path = '/api/v1/server/followers'
189
190 it('Should fail with an invalid token', async function () {
191 await makePostBodyRequest({
192 url: server.url,
193 path: path + '/toto@localhost:9002/accept',
194 token: 'fake_token',
195 statusCodeExpected: 401
196 })
197 })
198
199 it('Should fail if the user is not an administrator', async function () {
200 await makePostBodyRequest({
201 url: server.url,
202 path: path + '/toto@localhost:9002/accept',
203 token: userAccessToken,
204 statusCodeExpected: 403
205 })
206 })
207
208 it('Should fail with an invalid follower', async function () {
209 await makePostBodyRequest({
210 url: server.url,
211 path: path + '/toto/accept',
212 token: server.accessToken,
213 statusCodeExpected: 400
214 })
215 })
216
217 it('Should fail with an unknown follower', async function () {
218 await makePostBodyRequest({
219 url: server.url,
220 path: path + '/toto@localhost:9003/accept',
221 token: server.accessToken,
222 statusCodeExpected: 404
223 })
224 })
225 })
226
227 describe('When rejecting a follower', function () {
228 const path = '/api/v1/server/followers'
229
230 it('Should fail with an invalid token', async function () {
231 await makePostBodyRequest({
232 url: server.url,
233 path: path + '/toto@localhost:9002/reject',
234 token: 'fake_token',
235 statusCodeExpected: 401
236 })
237 })
238
239 it('Should fail if the user is not an administrator', async function () {
240 await makePostBodyRequest({
241 url: server.url,
242 path: path + '/toto@localhost:9002/reject',
243 token: userAccessToken,
244 statusCodeExpected: 403
245 })
246 })
247
248 it('Should fail with an invalid follower', async function () {
249 await makePostBodyRequest({
250 url: server.url,
251 path: path + '/toto/reject',
252 token: server.accessToken,
253 statusCodeExpected: 400
254 })
255 })
256
257 it('Should fail with an unknown follower', async function () {
258 await makePostBodyRequest({
259 url: server.url,
260 path: path + '/toto@localhost:9003/reject',
261 token: server.accessToken,
262 statusCodeExpected: 404
263 })
264 })
265 })
266
187 describe('When removing following', function () { 267 describe('When removing following', function () {
188 const path = '/api/v1/server/following' 268 const path = '/api/v1/server/following'
189 269