diff options
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/users/user-subscriptions.ts | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 190a19c38..57cca6ad4 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts | |||
@@ -2,6 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { VideoPrivacy } from '@shared/models' | ||
5 | import { | 6 | import { |
6 | cleanupTests, | 7 | cleanupTests, |
7 | createMultipleServers, | 8 | createMultipleServers, |
@@ -32,20 +33,18 @@ describe('Test users subscriptions', function () { | |||
32 | // Server 1 and server 2 follow each other | 33 | // Server 1 and server 2 follow each other |
33 | await doubleFollow(servers[0], servers[1]) | 34 | await doubleFollow(servers[0], servers[1]) |
34 | 35 | ||
35 | { | 36 | for (const server of servers) { |
36 | for (const server of servers) { | 37 | const user = { username: 'user' + server.serverNumber, password: 'password' } |
37 | const user = { username: 'user' + server.serverNumber, password: 'password' } | 38 | await server.users.create({ username: user.username, password: user.password }) |
38 | await server.users.create({ username: user.username, password: user.password }) | ||
39 | 39 | ||
40 | const accessToken = await server.login.getAccessToken(user) | 40 | const accessToken = await server.login.getAccessToken(user) |
41 | users.push({ accessToken }) | 41 | users.push({ accessToken }) |
42 | 42 | ||
43 | const videoName1 = 'video 1-' + server.serverNumber | 43 | const videoName1 = 'video 1-' + server.serverNumber |
44 | await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } }) | 44 | await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } }) |
45 | 45 | ||
46 | const videoName2 = 'video 2-' + server.serverNumber | 46 | const videoName2 = 'video 2-' + server.serverNumber |
47 | await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }) | 47 | await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } }) |
48 | } | ||
49 | } | 48 | } |
50 | 49 | ||
51 | await waitJobs(servers) | 50 | await waitJobs(servers) |
@@ -540,6 +539,40 @@ describe('Test users subscriptions', function () { | |||
540 | } | 539 | } |
541 | }) | 540 | }) |
542 | 541 | ||
542 | it('Should update video as internal and not see from remote server', async function () { | ||
543 | this.timeout(30000) | ||
544 | |||
545 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'internal', privacy: VideoPrivacy.INTERNAL } }) | ||
546 | await waitJobs(servers) | ||
547 | |||
548 | { | ||
549 | const { data } = await command.listVideos({ token: users[0].accessToken }) | ||
550 | expect(data.find(v => v.name === 'internal')).to.not.exist | ||
551 | } | ||
552 | }) | ||
553 | |||
554 | it('Should see internal from local user', async function () { | ||
555 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) | ||
556 | expect(data.find(v => v.name === 'internal')).to.exist | ||
557 | }) | ||
558 | |||
559 | it('Should update video as private and not see from anyone server', async function () { | ||
560 | this.timeout(30000) | ||
561 | |||
562 | await servers[2].videos.update({ id: video3UUID, attributes: { name: 'private', privacy: VideoPrivacy.PRIVATE } }) | ||
563 | await waitJobs(servers) | ||
564 | |||
565 | { | ||
566 | const { data } = await command.listVideos({ token: users[0].accessToken }) | ||
567 | expect(data.find(v => v.name === 'private')).to.not.exist | ||
568 | } | ||
569 | |||
570 | { | ||
571 | const { data } = await servers[2].subscriptions.listVideos({ token: servers[2].accessToken }) | ||
572 | expect(data.find(v => v.name === 'private')).to.not.exist | ||
573 | } | ||
574 | }) | ||
575 | |||
543 | after(async function () { | 576 | after(async function () { |
544 | await cleanupTests(servers) | 577 | await cleanupTests(servers) |
545 | }) | 578 | }) |