ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix server tests
Chocobozzz55e3ae7598cd
diff --git a/packages/tests/src/api/moderation/abuses.ts b/packages/tests/src/api/moderation/abuses.tsindex 37a1fe7e0b..5c2270f4d0 100644--- a/packages/tests/src/api/moderation/abuses.ts+++ b/packages/tests/src/api/moderation/abuses.ts@@ -37,16 +37,21 @@ describe('Test abuses', function () {})describe('Video abuses', function () {+ let video1OwnerToken: string+before(async function () {this.timeout(50000)+ video1OwnerToken = await servers[0].users.generateUserAndToken('video1_owner')+// Upload some videos on each servers+ // Video 1 is not owned by root so root (used as the default reporter in this suite) can report it{const attributes = {name: 'my super name for server 1',description: 'my super description for server 1'}- await servers[0].videos.upload({ attributes })+ await servers[0].videos.upload({ token: video1OwnerToken, attributes })}{@@ -104,7 +109,7 @@ describe('Test abuses', function () {expect(abuse.comment).to.be.null- expect(abuse.flaggedAccount.name).to.equal('root')+ expect(abuse.flaggedAccount.name).to.equal('video1_owner')expect(abuse.flaggedAccount.host).to.equal(servers[0].host)expect(abuse.video.countReports).to.equal(1)@@ -149,7 +154,7 @@ describe('Test abuses', function () {expect(abuse1.comment).to.be.null- expect(abuse1.flaggedAccount.name).to.equal('root')+ expect(abuse1.flaggedAccount.name).to.equal('video1_owner')expect(abuse1.flaggedAccount.host).to.equal(servers[0].host)expect(abuse1.state.id).to.equal(AbuseState.PENDING)@@ -352,13 +357,13 @@ describe('Test abuses', function () {expect(await list({ searchVideo: 'my second super name for server 1' })).to.have.lengthOf(1)- expect(await list({ searchVideoChannel: 'root' })).to.have.lengthOf(4)+ expect(await list({ searchVideoChannel: 'video1_owner' })).to.have.lengthOf(4)expect(await list({ searchVideoChannel: 'aaaa' })).to.have.lengthOf(0)expect(await list({ searchReporter: 'user2' })).to.have.lengthOf(1)expect(await list({ searchReporter: 'root' })).to.have.lengthOf(5)- expect(await list({ searchReportee: 'root' })).to.have.lengthOf(5)+ expect(await list({ searchReportee: 'video1_owner' })).to.have.lengthOf(4)expect(await list({ searchReportee: 'aaaa' })).to.have.lengthOf(0)expect(await list({ videoIs: 'deleted' })).to.have.lengthOf(1)@@ -430,7 +435,8 @@ describe('Test abuses', function () {expect(abuse.comment.video.uuid).to.equal(servers[0].store.videoCreated.uuid)expect(abuse.countReportsForReporter).to.equal(5)- expect(abuse.countReportsForReportee).to.equal(5)+ // root does not own video 1 anymore, so it is only reported here as the comment author+ expect(abuse.countReportsForReportee).to.equal(1)}{@@ -460,7 +466,7 @@ describe('Test abuses', function () {const abuse = body.data[0]expect(abuse.reason).to.equal('it is a bad comment')expect(abuse.countReportsForReporter).to.equal(6)- expect(abuse.countReportsForReportee).to.equal(5)+ expect(abuse.countReportsForReportee).to.equal(1)const abuse2 = body.data[1]diff --git a/packages/tests/src/api/notifications/moderation-notifications.ts b/packages/tests/src/api/notifications/moderation-notifications.tsindex a449dc035a..d3d55c58f0 100644--- a/packages/tests/src/api/notifications/moderation-notifications.ts+++ b/packages/tests/src/api/notifications/moderation-notifications.ts@@ -74,7 +74,8 @@ describe('Test moderation notifications', function () {this.timeout(50000)const name = 'video for abuse ' + buildUUID()- const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } })+ // Uploaded by the admin so userToken1 (a regular user) can report it without owning it+ const video = await servers[0].videos.upload({ attributes: { name } })await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' })@@ -181,7 +182,8 @@ describe('Test moderation notifications', function () {}const name = 'abuse ' + buildUUID()- const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } })+ // Uploaded by the admin so userToken1 (the reporter) does not own the reported video+ const video = await servers[0].videos.upload({ attributes: { name } })const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' })abuseId = body.abuse.id@@ -228,7 +230,8 @@ describe('Test moderation notifications', function () {}const name = 'abuse ' + buildUUID()- const video = await servers[0].videos.upload({ token: userToken1, attributes: { name } })+ // Uploaded by the admin so userToken1 (the reporter) does not own the reported video+ const video = await servers[0].videos.upload({ attributes: { name } }){const body = await servers[0].abuses.report({ token: userToken1, videoId: video.id, reason: 'super reason' })diff --git a/packages/tests/src/api/server/user-rate-limits.ts b/packages/tests/src/api/server/user-rate-limits.tsindex d481ea0f65..f80852c9df 100644--- a/packages/tests/src/api/server/user-rate-limits.ts+++ b/packages/tests/src/api/server/user-rate-limits.ts@@ -29,7 +29,8 @@ describe('Test per-user rate limits', function () {user1Token = await server.users.generateUserAndToken('user1')user2Token = await server.users.generateUserAndToken('user2')- const { id } = await server.videos.upload()+ const videoOwnerToken = await server.users.generateUserAndToken('video-owner')+ const { id } = await server.videos.upload({ token: videoOwnerToken })videoId = id})diff --git a/packages/tests/src/api/users/users.ts b/packages/tests/src/api/users/users.tsindex 2422c4356c..0d45c7cb9e 100644--- a/packages/tests/src/api/users/users.ts+++ b/packages/tests/src/api/users/users.ts@@ -548,11 +548,16 @@ describe('Test users', function () {it('Should report correct abuses counts', async function () {const reason = 'my super bad reason'- await server.abuses.report({ token: user17AccessToken, videoId, reason })+ // root does not own this video (user17 does), so root can report it and it counts as an incrimination against user17+ await server.abuses.report({ videoId, reason })const body1 = await server.abuses.getAdminList()const abuseId = body1.data[0].id+ // user17 reports something it does not own to increase its abusesCreatedCount+ const rootAccount = await server.accounts.get({ accountName: 'root' })+ await server.abuses.report({ token: user17AccessToken, accountId: rootAccount.id, reason: 'another reason' })+const user2 = await server.users.get({ userId: user17Id, withStats: true })expect(user2.abusesCount).to.equal(1) // number of incriminationsexpect(user2.abusesCreatedCount).to.equal(1) // number of reports created