diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-06 17:39:07 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-05-07 08:33:34 +0200 |
commit | feb34f6b6b991046aab6a10df747b48fa4da07a7 (patch) | |
tree | 02bb7277d45be166ba48caef2ee73bf89dbe1258 /server/tests/api/videos | |
parent | d170c5c580abf6f90d7bf144e2417e248ce2ecf4 (diff) | |
download | PeerTube-feb34f6b6b991046aab6a10df747b48fa4da07a7.tar.gz PeerTube-feb34f6b6b991046aab6a10df747b48fa4da07a7.tar.zst PeerTube-feb34f6b6b991046aab6a10df747b48fa4da07a7.zip |
Use video abuse filters on client side
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r-- | server/tests/api/videos/video-abuse.ts | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts index 26bc3783b..a96be97f6 100644 --- a/server/tests/api/videos/video-abuse.ts +++ b/server/tests/api/videos/video-abuse.ts | |||
@@ -71,7 +71,7 @@ describe('Test video abuses', function () { | |||
71 | }) | 71 | }) |
72 | 72 | ||
73 | it('Should not have video abuses', async function () { | 73 | it('Should not have video abuses', async function () { |
74 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 74 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
75 | 75 | ||
76 | expect(res.body.total).to.equal(0) | 76 | expect(res.body.total).to.equal(0) |
77 | expect(res.body.data).to.be.an('array') | 77 | expect(res.body.data).to.be.an('array') |
@@ -89,7 +89,7 @@ describe('Test video abuses', function () { | |||
89 | }) | 89 | }) |
90 | 90 | ||
91 | it('Should have 1 video abuses on server 1 and 0 on server 2', async function () { | 91 | it('Should have 1 video abuses on server 1 and 0 on server 2', async function () { |
92 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 92 | const res1 = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
93 | 93 | ||
94 | expect(res1.body.total).to.equal(1) | 94 | expect(res1.body.total).to.equal(1) |
95 | expect(res1.body.data).to.be.an('array') | 95 | expect(res1.body.data).to.be.an('array') |
@@ -106,7 +106,7 @@ describe('Test video abuses', function () { | |||
106 | expect(abuse.countReportsForReporter).to.equal(1) | 106 | expect(abuse.countReportsForReporter).to.equal(1) |
107 | expect(abuse.countReportsForReportee).to.equal(1) | 107 | expect(abuse.countReportsForReportee).to.equal(1) |
108 | 108 | ||
109 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 109 | const res2 = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
110 | expect(res2.body.total).to.equal(0) | 110 | expect(res2.body.total).to.equal(0) |
111 | expect(res2.body.data).to.be.an('array') | 111 | expect(res2.body.data).to.be.an('array') |
112 | expect(res2.body.data.length).to.equal(0) | 112 | expect(res2.body.data.length).to.equal(0) |
@@ -123,7 +123,7 @@ describe('Test video abuses', function () { | |||
123 | }) | 123 | }) |
124 | 124 | ||
125 | it('Should have 2 video abuses on server 1 and 1 on server 2', async function () { | 125 | it('Should have 2 video abuses on server 1 and 1 on server 2', async function () { |
126 | const res1 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 126 | const res1 = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
127 | expect(res1.body.total).to.equal(2) | 127 | expect(res1.body.total).to.equal(2) |
128 | expect(res1.body.data).to.be.an('array') | 128 | expect(res1.body.data).to.be.an('array') |
129 | expect(res1.body.data.length).to.equal(2) | 129 | expect(res1.body.data.length).to.equal(2) |
@@ -148,7 +148,7 @@ describe('Test video abuses', function () { | |||
148 | expect(abuse2.state.label).to.equal('Pending') | 148 | expect(abuse2.state.label).to.equal('Pending') |
149 | expect(abuse2.moderationComment).to.be.null | 149 | expect(abuse2.moderationComment).to.be.null |
150 | 150 | ||
151 | const res2 = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 151 | const res2 = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
152 | expect(res2.body.total).to.equal(1) | 152 | expect(res2.body.total).to.equal(1) |
153 | expect(res2.body.data).to.be.an('array') | 153 | expect(res2.body.data).to.be.an('array') |
154 | expect(res2.body.data.length).to.equal(1) | 154 | expect(res2.body.data.length).to.equal(1) |
@@ -166,7 +166,7 @@ describe('Test video abuses', function () { | |||
166 | const body = { state: VideoAbuseState.REJECTED } | 166 | const body = { state: VideoAbuseState.REJECTED } |
167 | await updateVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id, body) | 167 | await updateVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id, body) |
168 | 168 | ||
169 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 169 | const res = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
170 | expect(res.body.data[0].state.id).to.equal(VideoAbuseState.REJECTED) | 170 | expect(res.body.data[0].state.id).to.equal(VideoAbuseState.REJECTED) |
171 | }) | 171 | }) |
172 | 172 | ||
@@ -174,7 +174,7 @@ describe('Test video abuses', function () { | |||
174 | const body = { state: VideoAbuseState.ACCEPTED, moderationComment: 'It is valid' } | 174 | const body = { state: VideoAbuseState.ACCEPTED, moderationComment: 'It is valid' } |
175 | await updateVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id, body) | 175 | await updateVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id, body) |
176 | 176 | ||
177 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 177 | const res = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
178 | expect(res.body.data[0].state.id).to.equal(VideoAbuseState.ACCEPTED) | 178 | expect(res.body.data[0].state.id).to.equal(VideoAbuseState.ACCEPTED) |
179 | expect(res.body.data[0].moderationComment).to.equal('It is valid') | 179 | expect(res.body.data[0].moderationComment).to.equal('It is valid') |
180 | }) | 180 | }) |
@@ -186,7 +186,7 @@ describe('Test video abuses', function () { | |||
186 | await reportVideoAbuse(servers[1].url, servers[1].accessToken, servers[0].video.uuid, 'will mute this') | 186 | await reportVideoAbuse(servers[1].url, servers[1].accessToken, servers[0].video.uuid, 'will mute this') |
187 | await waitJobs(servers) | 187 | await waitJobs(servers) |
188 | 188 | ||
189 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 189 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
190 | expect(res.body.total).to.equal(3) | 190 | expect(res.body.total).to.equal(3) |
191 | } | 191 | } |
192 | 192 | ||
@@ -195,7 +195,7 @@ describe('Test video abuses', function () { | |||
195 | { | 195 | { |
196 | await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, accountToBlock) | 196 | await addAccountToServerBlocklist(servers[0].url, servers[0].accessToken, accountToBlock) |
197 | 197 | ||
198 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 198 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
199 | expect(res.body.total).to.equal(2) | 199 | expect(res.body.total).to.equal(2) |
200 | 200 | ||
201 | const abuse = res.body.data.find(a => a.reason === 'will mute this') | 201 | const abuse = res.body.data.find(a => a.reason === 'will mute this') |
@@ -205,7 +205,7 @@ describe('Test video abuses', function () { | |||
205 | { | 205 | { |
206 | await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, accountToBlock) | 206 | await removeAccountFromServerBlocklist(servers[0].url, servers[0].accessToken, accountToBlock) |
207 | 207 | ||
208 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 208 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
209 | expect(res.body.total).to.equal(3) | 209 | expect(res.body.total).to.equal(3) |
210 | } | 210 | } |
211 | }) | 211 | }) |
@@ -216,7 +216,7 @@ describe('Test video abuses', function () { | |||
216 | { | 216 | { |
217 | await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, servers[1].host) | 217 | await addServerToServerBlocklist(servers[0].url, servers[0].accessToken, servers[1].host) |
218 | 218 | ||
219 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 219 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
220 | expect(res.body.total).to.equal(2) | 220 | expect(res.body.total).to.equal(2) |
221 | 221 | ||
222 | const abuse = res.body.data.find(a => a.reason === 'will mute this') | 222 | const abuse = res.body.data.find(a => a.reason === 'will mute this') |
@@ -226,7 +226,7 @@ describe('Test video abuses', function () { | |||
226 | { | 226 | { |
227 | await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, serverToBlock) | 227 | await removeServerFromServerBlocklist(servers[0].url, servers[0].accessToken, serverToBlock) |
228 | 228 | ||
229 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 229 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
230 | expect(res.body.total).to.equal(3) | 230 | expect(res.body.total).to.equal(3) |
231 | } | 231 | } |
232 | }) | 232 | }) |
@@ -238,7 +238,7 @@ describe('Test video abuses', function () { | |||
238 | 238 | ||
239 | await waitJobs(servers) | 239 | await waitJobs(servers) |
240 | 240 | ||
241 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 241 | const res = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
242 | expect(res.body.total).to.equal(2, "wrong number of videos returned") | 242 | expect(res.body.total).to.equal(2, "wrong number of videos returned") |
243 | expect(res.body.data.length).to.equal(2, "wrong number of videos returned") | 243 | expect(res.body.data.length).to.equal(2, "wrong number of videos returned") |
244 | expect(res.body.data[0].id).to.equal(abuseServer2.id, "wrong origin server id for first video") | 244 | expect(res.body.data[0].id).to.equal(abuseServer2.id, "wrong origin server id for first video") |
@@ -274,7 +274,7 @@ describe('Test video abuses', function () { | |||
274 | const reason4 = 'my super bad reason 4' | 274 | const reason4 = 'my super bad reason 4' |
275 | await reportVideoAbuse(servers[0].url, userAccessToken, servers[0].video.id, reason4) | 275 | await reportVideoAbuse(servers[0].url, userAccessToken, servers[0].video.id, reason4) |
276 | 276 | ||
277 | const res2 = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 277 | const res2 = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
278 | 278 | ||
279 | { | 279 | { |
280 | for (const abuse of res2.body.data as VideoAbuse[]) { | 280 | for (const abuse of res2.body.data as VideoAbuse[]) { |
@@ -299,18 +299,56 @@ describe('Test video abuses', function () { | |||
299 | await waitJobs(servers) | 299 | await waitJobs(servers) |
300 | 300 | ||
301 | { | 301 | { |
302 | const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) | 302 | const res = await getVideoAbusesList({ url: servers[1].url, token: servers[1].accessToken }) |
303 | expect(res.body.total).to.equal(1) | 303 | expect(res.body.total).to.equal(1) |
304 | expect(res.body.data.length).to.equal(1) | 304 | expect(res.body.data.length).to.equal(1) |
305 | expect(res.body.data[0].id).to.not.equal(abuseServer2.id) | 305 | expect(res.body.data[0].id).to.not.equal(abuseServer2.id) |
306 | } | 306 | } |
307 | 307 | ||
308 | { | 308 | { |
309 | const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken) | 309 | const res = await getVideoAbusesList({ url: servers[0].url, token: servers[0].accessToken }) |
310 | expect(res.body.total).to.equal(5) | 310 | expect(res.body.total).to.equal(5) |
311 | } | 311 | } |
312 | }) | 312 | }) |
313 | 313 | ||
314 | it('Should list and filter video abuses', async function () { | ||
315 | async function list (query: Omit<Parameters<typeof getVideoAbusesList>[0], 'url' | 'token'>) { | ||
316 | const options = { | ||
317 | url: servers[0].url, | ||
318 | token: servers[0].accessToken | ||
319 | } | ||
320 | |||
321 | Object.assign(options, query) | ||
322 | |||
323 | const res = await getVideoAbusesList(options) | ||
324 | |||
325 | return res.body.data as VideoAbuse[] | ||
326 | } | ||
327 | |||
328 | expect(await list({ id: 56 })).to.have.lengthOf(0) | ||
329 | expect(await list({ id: 1 })).to.have.lengthOf(1) | ||
330 | |||
331 | expect(await list({ search: 'my super name for server 1' })).to.have.lengthOf(3) | ||
332 | expect(await list({ search: 'aaaaaaaaaaaaaaaaaaaaaaaaaa' })).to.have.lengthOf(0) | ||
333 | |||
334 | expect(await list({ searchVideo: 'my second super name for server 1' })).to.have.lengthOf(1) | ||
335 | |||
336 | expect(await list({ searchVideoChannel: 'root' })).to.have.lengthOf(3) | ||
337 | expect(await list({ searchVideoChannel: 'aaaa' })).to.have.lengthOf(0) | ||
338 | |||
339 | expect(await list({ searchReporter: 'user2' })).to.have.lengthOf(1) | ||
340 | expect(await list({ searchReporter: 'root' })).to.have.lengthOf(4) | ||
341 | |||
342 | expect(await list({ searchReportee: 'root' })).to.have.lengthOf(3) | ||
343 | expect(await list({ searchReportee: 'aaaa' })).to.have.lengthOf(0) | ||
344 | |||
345 | expect(await list({ videoIs: 'deleted' })).to.have.lengthOf(1) | ||
346 | expect(await list({ videoIs: 'blacklisted' })).to.have.lengthOf(0) | ||
347 | |||
348 | expect(await list({ state: VideoAbuseState.ACCEPTED })).to.have.lengthOf(0) | ||
349 | expect(await list({ state: VideoAbuseState.PENDING })).to.have.lengthOf(5) | ||
350 | }) | ||
351 | |||
314 | after(async function () { | 352 | after(async function () { |
315 | await cleanupTests(servers) | 353 | await cleanupTests(servers) |
316 | }) | 354 | }) |