aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-11-07 10:11:51 +0100
committerChocobozzz <me@florianbigard.com>2022-11-07 10:11:51 +0100
commit11ae7e2917ddf6e3c8e53d0855fd786163112d59 (patch)
treea0fb395434fb6003889ffcd8eaa4ac94ac5592ad /server/tests
parent0015924ad67d30bbc2d6966427794f5e1143e70f (diff)
downloadPeerTube-11ae7e2917ddf6e3c8e53d0855fd786163112d59.tar.gz
PeerTube-11ae7e2917ddf6e3c8e53d0855fd786163112d59.tar.zst
PeerTube-11ae7e2917ddf6e3c8e53d0855fd786163112d59.zip
Fix follow constraint check with an account
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/server/follow-constraints.ts88
1 files changed, 87 insertions, 1 deletions
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts
index 5998f58cc..e1ec2b069 100644
--- a/server/tests/api/server/follow-constraints.ts
+++ b/server/tests/api/server/follow-constraints.ts
@@ -1,8 +1,15 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
5import { HttpStatusCode, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' 4import { HttpStatusCode, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models'
5import {
6 cleanupTests,
7 createMultipleServers,
8 doubleFollow,
9 PeerTubeServer,
10 setAccessTokensToServers,
11 waitJobs
12} from '@shared/server-commands'
6 13
7describe('Test follow constraints', function () { 14describe('Test follow constraints', function () {
8 let servers: PeerTubeServer[] = [] 15 let servers: PeerTubeServer[] = []
@@ -189,6 +196,7 @@ describe('Test follow constraints', function () {
189 }) 196 })
190 197
191 describe('With a logged user', function () { 198 describe('With a logged user', function () {
199
192 it('Should get the local video', async function () { 200 it('Should get the local video', async function () {
193 await servers[0].videos.getWithToken({ token: userToken, id: video1UUID }) 201 await servers[0].videos.getWithToken({ token: userToken, id: video1UUID })
194 }) 202 })
@@ -229,6 +237,84 @@ describe('Test follow constraints', function () {
229 }) 237 })
230 }) 238 })
231 239
240 describe('When following a remote account', function () {
241
242 before(async function () {
243 this.timeout(60000)
244
245 await servers[0].follows.follow({ handles: [ 'root@' + servers[1].host ] })
246 await waitJobs(servers)
247 })
248
249 it('Should get the remote video with an unlogged user', async function () {
250 await servers[0].videos.get({ id: video2UUID })
251 })
252
253 it('Should get the remote video with a logged in user', async function () {
254 await servers[0].videos.getWithToken({ token: userToken, id: video2UUID })
255 })
256 })
257
258 describe('When unfollowing a remote account', function () {
259
260 before(async function () {
261 this.timeout(60000)
262
263 await servers[0].follows.unfollow({ target: 'root@' + servers[1].host })
264 await waitJobs(servers)
265 })
266
267 it('Should not get the remote video with an unlogged user', async function () {
268 const body = await servers[0].videos.get({ id: video2UUID, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
269
270 const error = body as unknown as PeerTubeProblemDocument
271 expect(error.code).to.equal(ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS)
272 })
273
274 it('Should get the remote video with a logged in user', async function () {
275 await servers[0].videos.getWithToken({ token: userToken, id: video2UUID })
276 })
277 })
278
279 describe('When following a remote channel', function () {
280
281 before(async function () {
282 this.timeout(60000)
283
284 await servers[0].follows.follow({ handles: [ 'root_channel@' + servers[1].host ] })
285 await waitJobs(servers)
286 })
287
288 it('Should get the remote video with an unlogged user', async function () {
289 await servers[0].videos.get({ id: video2UUID })
290 })
291
292 it('Should get the remote video with a logged in user', async function () {
293 await servers[0].videos.getWithToken({ token: userToken, id: video2UUID })
294 })
295 })
296
297 describe('When unfollowing a remote channel', function () {
298
299 before(async function () {
300 this.timeout(60000)
301
302 await servers[0].follows.unfollow({ target: 'root_channel@' + servers[1].host })
303 await waitJobs(servers)
304 })
305
306 it('Should not get the remote video with an unlogged user', async function () {
307 const body = await servers[0].videos.get({ id: video2UUID, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
308
309 const error = body as unknown as PeerTubeProblemDocument
310 expect(error.code).to.equal(ServerErrorCode.DOES_NOT_RESPECT_FOLLOW_CONSTRAINTS)
311 })
312
313 it('Should get the remote video with a logged in user', async function () {
314 await servers[0].videos.getWithToken({ token: userToken, id: video2UUID })
315 })
316 })
317
232 after(async function () { 318 after(async function () {
233 await cleanupTests(servers) 319 await cleanupTests(servers)
234 }) 320 })