diff options
author | Chocobozzz <me@florianbigard.com> | 2019-01-10 15:39:51 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-01-10 15:39:51 +0100 |
commit | 5abb9fbbd12e7097e348d6a38622d364b1fa47ed (patch) | |
tree | 8ef483ad15bd76c75876e0e2f34fd3c99b786103 /server/tests/api/videos/video-blacklist-management.ts | |
parent | 93f85e90ffa27453e2c909406b62bef65963b8ad (diff) | |
download | PeerTube-5abb9fbbd12e7097e348d6a38622d364b1fa47ed.tar.gz PeerTube-5abb9fbbd12e7097e348d6a38622d364b1fa47ed.tar.zst PeerTube-5abb9fbbd12e7097e348d6a38622d364b1fa47ed.zip |
Add ability to unfederate a local video (on blacklist)
Diffstat (limited to 'server/tests/api/videos/video-blacklist-management.ts')
-rw-r--r-- | server/tests/api/videos/video-blacklist-management.ts | 192 |
1 files changed, 0 insertions, 192 deletions
diff --git a/server/tests/api/videos/video-blacklist-management.ts b/server/tests/api/videos/video-blacklist-management.ts deleted file mode 100644 index 61411e30d..000000000 --- a/server/tests/api/videos/video-blacklist-management.ts +++ /dev/null | |||
@@ -1,192 +0,0 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as chai from 'chai' | ||
4 | import { orderBy } from 'lodash' | ||
5 | import 'mocha' | ||
6 | import { | ||
7 | addVideoToBlacklist, | ||
8 | flushAndRunMultipleServers, | ||
9 | getBlacklistedVideosList, | ||
10 | getMyVideos, | ||
11 | getSortedBlacklistedVideosList, | ||
12 | getVideosList, | ||
13 | killallServers, | ||
14 | removeVideoFromBlacklist, | ||
15 | ServerInfo, | ||
16 | setAccessTokensToServers, | ||
17 | updateVideoBlacklist, | ||
18 | uploadVideo | ||
19 | } from '../../../../shared/utils/index' | ||
20 | import { doubleFollow } from '../../../../shared/utils/server/follows' | ||
21 | import { waitJobs } from '../../../../shared/utils/server/jobs' | ||
22 | import { VideoAbuse } from '../../../../shared/models/videos' | ||
23 | |||
24 | const expect = chai.expect | ||
25 | |||
26 | describe('Test video blacklist management', function () { | ||
27 | let servers: ServerInfo[] = [] | ||
28 | let videoId: number | ||
29 | |||
30 | async function blacklistVideosOnServer (server: ServerInfo) { | ||
31 | const res = await getVideosList(server.url) | ||
32 | |||
33 | const videos = res.body.data | ||
34 | for (let video of videos) { | ||
35 | await addVideoToBlacklist(server.url, server.accessToken, video.id, 'super reason') | ||
36 | } | ||
37 | } | ||
38 | |||
39 | before(async function () { | ||
40 | this.timeout(50000) | ||
41 | |||
42 | // Run servers | ||
43 | servers = await flushAndRunMultipleServers(2) | ||
44 | |||
45 | // Get the access tokens | ||
46 | await setAccessTokensToServers(servers) | ||
47 | |||
48 | // Server 1 and server 2 follow each other | ||
49 | await doubleFollow(servers[0], servers[1]) | ||
50 | |||
51 | // Upload 2 videos on server 2 | ||
52 | await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 1st video', description: 'A video on server 2' }) | ||
53 | await uploadVideo(servers[1].url, servers[1].accessToken, { name: 'My 2nd video', description: 'A video on server 2' }) | ||
54 | |||
55 | // Wait videos propagation, server 2 has transcoding enabled | ||
56 | await waitJobs(servers) | ||
57 | |||
58 | // Blacklist the two videos on server 1 | ||
59 | await blacklistVideosOnServer(servers[0]) | ||
60 | }) | ||
61 | |||
62 | describe('When listing blacklisted videos', function () { | ||
63 | it('Should display all the blacklisted videos', async function () { | ||
64 | const res = await getBlacklistedVideosList(servers[0].url, servers[0].accessToken) | ||
65 | |||
66 | expect(res.body.total).to.equal(2) | ||
67 | |||
68 | const blacklistedVideos = res.body.data | ||
69 | expect(blacklistedVideos).to.be.an('array') | ||
70 | expect(blacklistedVideos.length).to.equal(2) | ||
71 | |||
72 | for (const blacklistedVideo of blacklistedVideos) { | ||
73 | expect(blacklistedVideo.reason).to.equal('super reason') | ||
74 | videoId = blacklistedVideo.video.id | ||
75 | } | ||
76 | }) | ||
77 | |||
78 | it('Should get the correct sort when sorting by descending id', async function () { | ||
79 | const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-id') | ||
80 | expect(res.body.total).to.equal(2) | ||
81 | |||
82 | const blacklistedVideos = res.body.data | ||
83 | expect(blacklistedVideos).to.be.an('array') | ||
84 | expect(blacklistedVideos.length).to.equal(2) | ||
85 | |||
86 | const result = orderBy(res.body.data, [ 'id' ], [ 'desc' ]) | ||
87 | |||
88 | expect(blacklistedVideos).to.deep.equal(result) | ||
89 | }) | ||
90 | |||
91 | it('Should get the correct sort when sorting by descending video name', async function () { | ||
92 | const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') | ||
93 | expect(res.body.total).to.equal(2) | ||
94 | |||
95 | const blacklistedVideos = res.body.data | ||
96 | expect(blacklistedVideos).to.be.an('array') | ||
97 | expect(blacklistedVideos.length).to.equal(2) | ||
98 | |||
99 | const result = orderBy(res.body.data, [ 'name' ], [ 'desc' ]) | ||
100 | |||
101 | expect(blacklistedVideos).to.deep.equal(result) | ||
102 | }) | ||
103 | |||
104 | it('Should get the correct sort when sorting by ascending creation date', async function () { | ||
105 | const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, 'createdAt') | ||
106 | expect(res.body.total).to.equal(2) | ||
107 | |||
108 | const blacklistedVideos = res.body.data | ||
109 | expect(blacklistedVideos).to.be.an('array') | ||
110 | expect(blacklistedVideos.length).to.equal(2) | ||
111 | |||
112 | const result = orderBy(res.body.data, [ 'createdAt' ]) | ||
113 | |||
114 | expect(blacklistedVideos).to.deep.equal(result) | ||
115 | }) | ||
116 | }) | ||
117 | |||
118 | describe('When updating blacklisted videos', function () { | ||
119 | it('Should change the reason', async function () { | ||
120 | await updateVideoBlacklist(servers[0].url, servers[0].accessToken, videoId, 'my super reason updated') | ||
121 | |||
122 | const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') | ||
123 | const video = res.body.data.find(b => b.video.id === videoId) | ||
124 | |||
125 | expect(video.reason).to.equal('my super reason updated') | ||
126 | }) | ||
127 | }) | ||
128 | |||
129 | describe('When listing my videos', function () { | ||
130 | it('Should display blacklisted videos', async function () { | ||
131 | await blacklistVideosOnServer(servers[1]) | ||
132 | |||
133 | const res = await getMyVideos(servers[1].url, servers[1].accessToken, 0, 5) | ||
134 | |||
135 | expect(res.body.total).to.equal(2) | ||
136 | expect(res.body.data).to.have.lengthOf(2) | ||
137 | |||
138 | for (const video of res.body.data) { | ||
139 | expect(video.blacklisted).to.be.true | ||
140 | expect(video.blacklistedReason).to.equal('super reason') | ||
141 | } | ||
142 | }) | ||
143 | }) | ||
144 | |||
145 | describe('When removing a blacklisted video', function () { | ||
146 | let videoToRemove: VideoAbuse | ||
147 | let blacklist = [] | ||
148 | |||
149 | it('Should not have any video in videos list on server 1', async function () { | ||
150 | const res = await getVideosList(servers[0].url) | ||
151 | expect(res.body.total).to.equal(0) | ||
152 | expect(res.body.data).to.be.an('array') | ||
153 | expect(res.body.data.length).to.equal(0) | ||
154 | }) | ||
155 | |||
156 | it('Should remove a video from the blacklist on server 1', async function () { | ||
157 | // Get one video in the blacklist | ||
158 | const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') | ||
159 | videoToRemove = res.body.data[0] | ||
160 | blacklist = res.body.data.slice(1) | ||
161 | |||
162 | // Remove it | ||
163 | await removeVideoFromBlacklist(servers[0].url, servers[0].accessToken, videoToRemove.video.id) | ||
164 | }) | ||
165 | |||
166 | it('Should have the ex-blacklisted video in videos list on server 1', async function () { | ||
167 | const res = await getVideosList(servers[0].url) | ||
168 | expect(res.body.total).to.equal(1) | ||
169 | |||
170 | const videos = res.body.data | ||
171 | expect(videos).to.be.an('array') | ||
172 | expect(videos.length).to.equal(1) | ||
173 | |||
174 | expect(videos[0].name).to.equal(videoToRemove.video.name) | ||
175 | expect(videos[0].id).to.equal(videoToRemove.video.id) | ||
176 | }) | ||
177 | |||
178 | it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () { | ||
179 | const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') | ||
180 | expect(res.body.total).to.equal(1) | ||
181 | |||
182 | const videos = res.body.data | ||
183 | expect(videos).to.be.an('array') | ||
184 | expect(videos.length).to.equal(1) | ||
185 | expect(videos).to.deep.equal(blacklist) | ||
186 | }) | ||
187 | }) | ||
188 | |||
189 | after(async function () { | ||
190 | killallServers(servers) | ||
191 | }) | ||
192 | }) | ||