aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/activitypub/helpers.ts13
-rw-r--r--server/tests/api/search/search-videos.ts8
-rw-r--r--server/tests/api/videos/video-abuse.ts77
-rw-r--r--server/tests/api/videos/video-change-ownership.ts2
4 files changed, 78 insertions, 22 deletions
diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts
index 365d0e1ae..0d1f154fe 100644
--- a/server/tests/api/activitypub/helpers.ts
+++ b/server/tests/api/activitypub/helpers.ts
@@ -53,19 +53,6 @@ describe('Test activity pub helpers', function () {
53 expect(result).to.be.false 53 expect(result).to.be.false
54 }) 54 })
55 55
56 it('Should fail with an invalid PeerTube URL', async function () {
57 const keys = require('./json/peertube/keys.json')
58 const body = require('./json/peertube/announce-without-context.json')
59
60 const actorSignature = { url: 'http://localhost:9002/accounts/peertube', privateKey: keys.privateKey }
61 const signedBody = await buildSignedActivity(actorSignature as any, body)
62
63 const fromActor = { publicKey: keys.publicKey, url: 'http://localhost:9003/accounts/peertube' }
64 const result = await isJsonLDSignatureVerified(fromActor as any, signedBody)
65
66 expect(result).to.be.false
67 })
68
69 it('Should succeed with a valid PeerTube signature', async function () { 56 it('Should succeed with a valid PeerTube signature', async function () {
70 const keys = require('./json/peertube/keys.json') 57 const keys = require('./json/peertube/keys.json')
71 const body = require('./json/peertube/announce-without-context.json') 58 const body = require('./json/peertube/announce-without-context.json')
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts
index c06200ffe..a3e05156b 100644
--- a/server/tests/api/search/search-videos.ts
+++ b/server/tests/api/search/search-videos.ts
@@ -206,7 +206,7 @@ describe('Test videos search', function () {
206 const query = { 206 const query = {
207 search: '9999', 207 search: '9999',
208 categoryOneOf: [ 1 ], 208 categoryOneOf: [ 1 ],
209 tagsOneOf: [ 'aaaa', 'ffff' ] 209 tagsOneOf: [ 'aAaa', 'ffff' ]
210 } 210 }
211 const res1 = await advancedVideosSearch(server.url, query) 211 const res1 = await advancedVideosSearch(server.url, query)
212 expect(res1.body.total).to.equal(2) 212 expect(res1.body.total).to.equal(2)
@@ -219,15 +219,15 @@ describe('Test videos search', function () {
219 const query = { 219 const query = {
220 search: '9999', 220 search: '9999',
221 categoryOneOf: [ 1 ], 221 categoryOneOf: [ 1 ],
222 tagsAllOf: [ 'cccc' ] 222 tagsAllOf: [ 'CCcc' ]
223 } 223 }
224 const res1 = await advancedVideosSearch(server.url, query) 224 const res1 = await advancedVideosSearch(server.url, query)
225 expect(res1.body.total).to.equal(2) 225 expect(res1.body.total).to.equal(2)
226 226
227 const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'blabla' ] })) 227 const res2 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'blAbla' ] }))
228 expect(res2.body.total).to.equal(0) 228 expect(res2.body.total).to.equal(0)
229 229
230 const res3 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'bbbb', 'cccc' ] })) 230 const res3 = await advancedVideosSearch(server.url, immutableAssign(query, { tagsAllOf: [ 'bbbb', 'CCCC' ] }))
231 expect(res3.body.total).to.equal(1) 231 expect(res3.body.total).to.equal(1)
232 }) 232 })
233 233
diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts
index a2f3ee161..0cd6f22c7 100644
--- a/server/tests/api/videos/video-abuse.ts
+++ b/server/tests/api/videos/video-abuse.ts
@@ -17,6 +17,12 @@ import {
17} from '../../../../shared/extra-utils/index' 17} from '../../../../shared/extra-utils/index'
18import { doubleFollow } from '../../../../shared/extra-utils/server/follows' 18import { doubleFollow } from '../../../../shared/extra-utils/server/follows'
19import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 19import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
20import {
21 addAccountToServerBlocklist,
22 addServerToServerBlocklist,
23 removeAccountFromServerBlocklist,
24 removeServerFromServerBlocklist
25} from '../../../../shared/extra-utils/users/blocklist'
20 26
21const expect = chai.expect 27const expect = chai.expect
22 28
@@ -163,13 +169,76 @@ describe('Test video abuses', function () {
163 expect(res.body.data[0].moderationComment).to.equal('It is valid') 169 expect(res.body.data[0].moderationComment).to.equal('It is valid')
164 }) 170 })
165 171
172 it('Should hide video abuses from blocked accounts', async function () {
173 this.timeout(10000)
174
175 {
176 await reportVideoAbuse(servers[1].url, servers[1].accessToken, servers[0].video.uuid, 'will mute this')
177 await waitJobs(servers)
178
179 const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
180 expect(res.body.total).to.equal(3)
181 }
182
183 const accountToBlock = 'root@localhost:' + servers[1].port
184
185 {
186 await addAccountToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock)
187
188 const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
189 expect(res.body.total).to.equal(2)
190
191 const abuse = res.body.data.find(a => a.reason === 'will mute this')
192 expect(abuse).to.be.undefined
193 }
194
195 {
196 await removeAccountFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, accountToBlock)
197
198 const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
199 expect(res.body.total).to.equal(3)
200 }
201 })
202
203 it('Should hide video abuses from blocked servers', async function () {
204 const serverToBlock = servers[1].host
205
206 {
207 await addServerToServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, servers[1].host)
208
209 const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
210 expect(res.body.total).to.equal(2)
211
212 const abuse = res.body.data.find(a => a.reason === 'will mute this')
213 expect(abuse).to.be.undefined
214 }
215
216 {
217 await removeServerFromServerBlocklist(servers[ 0 ].url, servers[ 0 ].accessToken, serverToBlock)
218
219 const res = await getVideoAbusesList(servers[ 0 ].url, servers[ 0 ].accessToken)
220 expect(res.body.total).to.equal(3)
221 }
222 })
223
166 it('Should delete the video abuse', async function () { 224 it('Should delete the video abuse', async function () {
225 this.timeout(10000)
226
167 await deleteVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id) 227 await deleteVideoAbuse(servers[1].url, servers[1].accessToken, abuseServer2.video.uuid, abuseServer2.id)
168 228
169 const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken) 229 await waitJobs(servers)
170 expect(res.body.total).to.equal(0) 230
171 expect(res.body.data).to.be.an('array') 231 {
172 expect(res.body.data.length).to.equal(0) 232 const res = await getVideoAbusesList(servers[1].url, servers[1].accessToken)
233 expect(res.body.total).to.equal(1)
234 expect(res.body.data.length).to.equal(1)
235 expect(res.body.data[0].id).to.not.equal(abuseServer2.id)
236 }
237
238 {
239 const res = await getVideoAbusesList(servers[0].url, servers[0].accessToken)
240 expect(res.body.total).to.equal(3)
241 }
173 }) 242 })
174 243
175 after(async function () { 244 after(async function () {
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index 3a3add71b..64ee2355a 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -191,7 +191,7 @@ describe('Test video change ownership - nominal', function () {
191 await waitJobs(servers) 191 await waitJobs(servers)
192 }) 192 })
193 193
194 it('Should have video channel updated', async function () { 194 it('Should have the channel of the video updated', async function () {
195 for (const server of servers) { 195 for (const server of servers) {
196 const res = await getVideo(server.url, servers[0].video.uuid) 196 const res = await getVideo(server.url, servers[0].video.uuid)
197 197