diff options
Diffstat (limited to 'server/tests/api/moderation')
-rw-r--r-- | server/tests/api/moderation/abuses.ts | 15 | ||||
-rw-r--r-- | server/tests/api/moderation/blocklist-notification.ts | 9 | ||||
-rw-r--r-- | server/tests/api/moderation/blocklist.ts | 7 | ||||
-rw-r--r-- | server/tests/api/moderation/video-blacklist.ts | 17 |
4 files changed, 17 insertions, 31 deletions
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts index d7462f38f..a7119263c 100644 --- a/server/tests/api/moderation/abuses.ts +++ b/server/tests/api/moderation/abuses.ts | |||
@@ -5,13 +5,10 @@ import * as chai from 'chai' | |||
5 | import { | 5 | import { |
6 | AbusesCommand, | 6 | AbusesCommand, |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createUser, | ||
9 | doubleFollow, | 8 | doubleFollow, |
10 | flushAndRunMultipleServers, | 9 | flushAndRunMultipleServers, |
11 | generateUserAccessToken, | ||
12 | getVideoIdFromUUID, | 10 | getVideoIdFromUUID, |
13 | getVideosList, | 11 | getVideosList, |
14 | removeUser, | ||
15 | removeVideo, | 12 | removeVideo, |
16 | ServerInfo, | 13 | ServerInfo, |
17 | setAccessTokensToServers, | 14 | setAccessTokensToServers, |
@@ -278,7 +275,7 @@ describe('Test abuses', function () { | |||
278 | 275 | ||
279 | // register a second user to have two reporters/reportees | 276 | // register a second user to have two reporters/reportees |
280 | const user = { username: 'user2', password: 'password' } | 277 | const user = { username: 'user2', password: 'password' } |
281 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, ...user }) | 278 | await servers[0].usersCommand.create({ ...user }) |
282 | const userAccessToken = await servers[0].loginCommand.getAccessToken(user) | 279 | const userAccessToken = await servers[0].loginCommand.getAccessToken(user) |
283 | 280 | ||
284 | // upload a third video via this user | 281 | // upload a third video via this user |
@@ -604,9 +601,9 @@ describe('Test abuses', function () { | |||
604 | before(async function () { | 601 | before(async function () { |
605 | this.timeout(50000) | 602 | this.timeout(50000) |
606 | 603 | ||
607 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: 'user_1', password: 'donald' }) | 604 | await servers[0].usersCommand.create({ username: 'user_1', password: 'donald' }) |
608 | 605 | ||
609 | const token = await generateUserAccessToken(servers[1], 'user_2') | 606 | const token = await servers[1].usersCommand.generateUserAndToken('user_2') |
610 | await uploadVideo(servers[1].url, token, { name: 'super video' }) | 607 | await uploadVideo(servers[1].url, token, { name: 'super video' }) |
611 | 608 | ||
612 | await waitJobs(servers) | 609 | await waitJobs(servers) |
@@ -708,7 +705,7 @@ describe('Test abuses', function () { | |||
708 | this.timeout(10000) | 705 | this.timeout(10000) |
709 | 706 | ||
710 | const account = await getAccountFromServer(servers[1], 'user_2', servers[1]) | 707 | const account = await getAccountFromServer(servers[1], 'user_2', servers[1]) |
711 | await removeUser(servers[1].url, account.userId, servers[1].accessToken) | 708 | await servers[1].usersCommand.remove({ userId: account.userId }) |
712 | 709 | ||
713 | await waitJobs(servers) | 710 | await waitJobs(servers) |
714 | 711 | ||
@@ -765,7 +762,7 @@ describe('Test abuses', function () { | |||
765 | let userAccessToken: string | 762 | let userAccessToken: string |
766 | 763 | ||
767 | before(async function () { | 764 | before(async function () { |
768 | userAccessToken = await generateUserAccessToken(servers[0], 'user_42') | 765 | userAccessToken = await servers[0].usersCommand.generateUserAndToken('user_42') |
769 | 766 | ||
770 | await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: 'user reason 1' }) | 767 | await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: 'user reason 1' }) |
771 | 768 | ||
@@ -836,7 +833,7 @@ describe('Test abuses', function () { | |||
836 | let abuseMessageModerationId: number | 833 | let abuseMessageModerationId: number |
837 | 834 | ||
838 | before(async function () { | 835 | before(async function () { |
839 | userToken = await generateUserAccessToken(servers[0], 'user_43') | 836 | userToken = await servers[0].usersCommand.generateUserAndToken('user_43') |
840 | 837 | ||
841 | const body = await commands[0].report({ token: userToken, videoId: servers[0].video.id, reason: 'user 43 reason 1' }) | 838 | const body = await commands[0].report({ token: userToken, videoId: servers[0].video.id, reason: 'user 43 reason 1' }) |
842 | abuseId = body.abuse.id | 839 | abuseId = body.abuse.id |
diff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.ts index 4f2be6198..b44bcb012 100644 --- a/server/tests/api/moderation/blocklist-notification.ts +++ b/server/tests/api/moderation/blocklist-notification.ts | |||
@@ -4,7 +4,6 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { | 5 | import { |
6 | cleanupTests, | 6 | cleanupTests, |
7 | createUser, | ||
8 | doubleFollow, | 7 | doubleFollow, |
9 | flushAndRunMultipleServers, | 8 | flushAndRunMultipleServers, |
10 | ServerInfo, | 9 | ServerInfo, |
@@ -76,9 +75,7 @@ describe('Test blocklist', function () { | |||
76 | 75 | ||
77 | { | 76 | { |
78 | const user = { username: 'user1', password: 'password' } | 77 | const user = { username: 'user1', password: 'password' } |
79 | await createUser({ | 78 | await servers[0].usersCommand.create({ |
80 | url: servers[0].url, | ||
81 | accessToken: servers[0].accessToken, | ||
82 | username: user.username, | 79 | username: user.username, |
83 | password: user.password, | 80 | password: user.password, |
84 | videoQuota: -1, | 81 | videoQuota: -1, |
@@ -91,14 +88,14 @@ describe('Test blocklist', function () { | |||
91 | 88 | ||
92 | { | 89 | { |
93 | const user = { username: 'user2', password: 'password' } | 90 | const user = { username: 'user2', password: 'password' } |
94 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 91 | await servers[0].usersCommand.create({ username: user.username, password: user.password }) |
95 | 92 | ||
96 | userToken2 = await servers[0].loginCommand.getAccessToken(user) | 93 | userToken2 = await servers[0].loginCommand.getAccessToken(user) |
97 | } | 94 | } |
98 | 95 | ||
99 | { | 96 | { |
100 | const user = { username: 'user3', password: 'password' } | 97 | const user = { username: 'user3', password: 'password' } |
101 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) | 98 | await servers[1].usersCommand.create({ username: user.username, password: user.password }) |
102 | 99 | ||
103 | remoteUserToken = await servers[1].loginCommand.getAccessToken(user) | 100 | remoteUserToken = await servers[1].loginCommand.getAccessToken(user) |
104 | } | 101 | } |
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts index c38a7dad4..c253b5c11 100644 --- a/server/tests/api/moderation/blocklist.ts +++ b/server/tests/api/moderation/blocklist.ts | |||
@@ -6,7 +6,6 @@ import { | |||
6 | BlocklistCommand, | 6 | BlocklistCommand, |
7 | cleanupTests, | 7 | cleanupTests, |
8 | CommentsCommand, | 8 | CommentsCommand, |
9 | createUser, | ||
10 | doubleFollow, | 9 | doubleFollow, |
11 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
12 | getVideosList, | 11 | getVideosList, |
@@ -91,7 +90,7 @@ describe('Test blocklist', function () { | |||
91 | 90 | ||
92 | { | 91 | { |
93 | const user = { username: 'user1', password: 'password' } | 92 | const user = { username: 'user1', password: 'password' } |
94 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 93 | await servers[0].usersCommand.create({ username: user.username, password: user.password }) |
95 | 94 | ||
96 | userToken1 = await servers[0].loginCommand.getAccessToken(user) | 95 | userToken1 = await servers[0].loginCommand.getAccessToken(user) |
97 | await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' }) | 96 | await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' }) |
@@ -99,14 +98,14 @@ describe('Test blocklist', function () { | |||
99 | 98 | ||
100 | { | 99 | { |
101 | const user = { username: 'moderator', password: 'password' } | 100 | const user = { username: 'moderator', password: 'password' } |
102 | await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) | 101 | await servers[0].usersCommand.create({ username: user.username, password: user.password }) |
103 | 102 | ||
104 | userModeratorToken = await servers[0].loginCommand.getAccessToken(user) | 103 | userModeratorToken = await servers[0].loginCommand.getAccessToken(user) |
105 | } | 104 | } |
106 | 105 | ||
107 | { | 106 | { |
108 | const user = { username: 'user2', password: 'password' } | 107 | const user = { username: 'user2', password: 'password' } |
109 | await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password }) | 108 | await servers[1].usersCommand.create({ username: user.username, password: user.password }) |
110 | 109 | ||
111 | userToken2 = await servers[1].loginCommand.getAccessToken(user) | 110 | userToken2 = await servers[1].loginCommand.getAccessToken(user) |
112 | await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' }) | 111 | await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' }) |
diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts index b61effc57..ef25cfb8e 100644 --- a/server/tests/api/moderation/video-blacklist.ts +++ b/server/tests/api/moderation/video-blacklist.ts | |||
@@ -6,10 +6,8 @@ import { orderBy } from 'lodash' | |||
6 | import { | 6 | import { |
7 | BlacklistCommand, | 7 | BlacklistCommand, |
8 | cleanupTests, | 8 | cleanupTests, |
9 | createUser, | ||
10 | doubleFollow, | 9 | doubleFollow, |
11 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
12 | getMyUserInformation, | ||
13 | getMyVideos, | 11 | getMyVideos, |
14 | getVideosList, | 12 | getVideosList, |
15 | ImportsCommand, | 13 | ImportsCommand, |
@@ -21,7 +19,7 @@ import { | |||
21 | uploadVideo, | 19 | uploadVideo, |
22 | waitJobs | 20 | waitJobs |
23 | } from '@shared/extra-utils' | 21 | } from '@shared/extra-utils' |
24 | import { User, UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models' | 22 | import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models' |
25 | 23 | ||
26 | const expect = chai.expect | 24 | const expect = chai.expect |
27 | 25 | ||
@@ -356,9 +354,7 @@ describe('Test video blacklist', function () { | |||
356 | 354 | ||
357 | { | 355 | { |
358 | const user = { username: 'user_without_flag', password: 'password' } | 356 | const user = { username: 'user_without_flag', password: 'password' } |
359 | await createUser({ | 357 | await servers[0].usersCommand.create({ |
360 | url: servers[0].url, | ||
361 | accessToken: servers[0].accessToken, | ||
362 | username: user.username, | 358 | username: user.username, |
363 | adminFlags: UserAdminFlag.NONE, | 359 | adminFlags: UserAdminFlag.NONE, |
364 | password: user.password, | 360 | password: user.password, |
@@ -367,16 +363,13 @@ describe('Test video blacklist', function () { | |||
367 | 363 | ||
368 | userWithoutFlag = await servers[0].loginCommand.getAccessToken(user) | 364 | userWithoutFlag = await servers[0].loginCommand.getAccessToken(user) |
369 | 365 | ||
370 | const res = await getMyUserInformation(servers[0].url, userWithoutFlag) | 366 | const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: userWithoutFlag }) |
371 | const body: User = res.body | 367 | channelOfUserWithoutFlag = videoChannels[0].id |
372 | channelOfUserWithoutFlag = body.videoChannels[0].id | ||
373 | } | 368 | } |
374 | 369 | ||
375 | { | 370 | { |
376 | const user = { username: 'user_with_flag', password: 'password' } | 371 | const user = { username: 'user_with_flag', password: 'password' } |
377 | await createUser({ | 372 | await servers[0].usersCommand.create({ |
378 | url: servers[0].url, | ||
379 | accessToken: servers[0].accessToken, | ||
380 | username: user.username, | 373 | username: user.username, |
381 | adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST, | 374 | adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST, |
382 | password: user.password, | 375 | password: user.password, |