aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/activitypub/fetch.ts2
-rw-r--r--server/tests/api/check-params/blocklist.ts2
-rw-r--r--server/tests/api/check-params/config.ts2
-rw-r--r--server/tests/api/check-params/debug.ts2
-rw-r--r--server/tests/api/check-params/follows.ts2
-rw-r--r--server/tests/api/check-params/jobs.ts2
-rw-r--r--server/tests/api/check-params/logs.ts2
-rw-r--r--server/tests/api/check-params/redundancy.ts2
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts2
-rw-r--r--server/tests/api/check-params/users.ts24
-rw-r--r--server/tests/api/check-params/video-abuses.ts2
-rw-r--r--server/tests/api/check-params/video-blacklist.ts13
-rw-r--r--server/tests/api/check-params/video-captions.ts2
-rw-r--r--server/tests/api/check-params/video-channels.ts2
-rw-r--r--server/tests/api/check-params/video-comments.ts2
-rw-r--r--server/tests/api/check-params/video-imports.ts4
-rw-r--r--server/tests/api/check-params/videos-filter.ts18
-rw-r--r--server/tests/api/check-params/videos.ts4
-rw-r--r--server/tests/api/notifications/user-notifications.ts8
-rw-r--r--server/tests/api/search/search-activitypub-video-channels.ts4
-rw-r--r--server/tests/api/server/email.ts2
-rw-r--r--server/tests/api/server/follow-constraints.ts2
-rw-r--r--server/tests/api/server/follows.ts2
-rw-r--r--server/tests/api/server/stats.ts2
-rw-r--r--server/tests/api/users/blocklist.ts6
-rw-r--r--server/tests/api/users/user-subscriptions.ts2
-rw-r--r--server/tests/api/users/users-multiple-servers.ts7
-rw-r--r--server/tests/api/users/users.ts892
-rw-r--r--server/tests/api/videos/multiple-servers.ts2
-rw-r--r--server/tests/api/videos/video-blacklist.ts115
-rw-r--r--server/tests/api/videos/video-change-ownership.ts32
-rw-r--r--server/tests/api/videos/video-channels.ts2
-rw-r--r--server/tests/api/videos/video-nsfw.ts2
-rw-r--r--server/tests/api/videos/video-playlists.ts7
-rw-r--r--server/tests/api/videos/video-privacy.ts2
-rw-r--r--server/tests/api/videos/videos-filter.ts16
-rw-r--r--server/tests/api/videos/videos-history.ts2
-rw-r--r--server/tests/cli/peertube.ts2
-rw-r--r--server/tests/cli/reset-password.ts2
-rw-r--r--server/tests/cli/update-host.ts2
-rw-r--r--server/tests/feeds/feeds.ts2
-rw-r--r--server/tests/misc-endpoints.ts4
-rw-r--r--server/tests/real-world/populate-database.ts2
43 files changed, 710 insertions, 500 deletions
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts
index 5c617de10..9cbc7dd84 100644
--- a/server/tests/api/activitypub/fetch.ts
+++ b/server/tests/api/activitypub/fetch.ts
@@ -38,7 +38,7 @@ describe('Test ActivityPub fetcher', function () {
38 38
39 const user = { username: 'user1', password: 'password' } 39 const user = { username: 'user1', password: 'password' }
40 for (const server of servers) { 40 for (const server of servers) {
41 await createUser(server.url, server.accessToken, user.username, user.password) 41 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
42 } 42 }
43 43
44 const userAccessToken = await userLogin(servers[0], user) 44 const userAccessToken = await userLogin(servers[0], user)
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts
index c20453c16..62a2c2a52 100644
--- a/server/tests/api/check-params/blocklist.ts
+++ b/server/tests/api/check-params/blocklist.ts
@@ -36,7 +36,7 @@ describe('Test blocklist API validators', function () {
36 server = servers[0] 36 server = servers[0]
37 37
38 const user = { username: 'user1', password: 'password' } 38 const user = { username: 'user1', password: 'password' }
39 await createUser(server.url, server.accessToken, user.username, user.password) 39 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
40 40
41 userAccessToken = await userLogin(server, user) 41 userAccessToken = await userLogin(server, user)
42 42
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 01ab84584..3bcb015d9 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -110,7 +110,7 @@ describe('Test config API validators', function () {
110 username: 'user1', 110 username: 'user1',
111 password: 'password' 111 password: 'password'
112 } 112 }
113 await createUser(server.url, server.accessToken, user.username, user.password) 113 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
114 userAccessToken = await userLogin(server, user) 114 userAccessToken = await userLogin(server, user)
115 }) 115 })
116 116
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts
index 9bf664657..da94beffe 100644
--- a/server/tests/api/check-params/debug.ts
+++ b/server/tests/api/check-params/debug.ts
@@ -33,7 +33,7 @@ describe('Test debug API validators', function () {
33 username: 'user1', 33 username: 'user1',
34 password: 'my super password' 34 password: 'my super password'
35 } 35 }
36 await createUser(server.url, server.accessToken, user.username, user.password) 36 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
37 userAccessToken = await userLogin(server, user) 37 userAccessToken = await userLogin(server, user)
38 }) 38 })
39 39
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index ed1d2db59..5bb337682 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -35,7 +35,7 @@ describe('Test server follows API validators', function () {
35 password: 'password' 35 password: 'password'
36 } 36 }
37 37
38 await createUser(server.url, server.accessToken, user.username, user.password) 38 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
39 userAccessToken = await userLogin(server, user) 39 userAccessToken = await userLogin(server, user)
40 }) 40 })
41 41
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index 89760ff98..5fb2b9606 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -38,7 +38,7 @@ describe('Test jobs API validators', function () {
38 username: 'user1', 38 username: 'user1',
39 password: 'my super password' 39 password: 'my super password'
40 } 40 }
41 await createUser(server.url, server.accessToken, user.username, user.password) 41 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
42 userAccessToken = await userLogin(server, user) 42 userAccessToken = await userLogin(server, user)
43 }) 43 })
44 44
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts
index d6a40da61..9bc6ac244 100644
--- a/server/tests/api/check-params/logs.ts
+++ b/server/tests/api/check-params/logs.ts
@@ -33,7 +33,7 @@ describe('Test logs API validators', function () {
33 username: 'user1', 33 username: 'user1',
34 password: 'my super password' 34 password: 'my super password'
35 } 35 }
36 await createUser(server.url, server.accessToken, user.username, user.password) 36 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
37 userAccessToken = await userLogin(server, user) 37 userAccessToken = await userLogin(server, user)
38 }) 38 })
39 39
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index ff4726ceb..d14e35cf2 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -34,7 +34,7 @@ describe('Test server redundancy API validators', function () {
34 password: 'password' 34 password: 'password'
35 } 35 }
36 36
37 await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) 37 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
38 userAccessToken = await userLogin(servers[0], user) 38 userAccessToken = await userLogin(servers[0], user)
39 }) 39 })
40 40
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 04a3eb97c..a18e1a43b 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -42,7 +42,7 @@ describe('Test user subscriptions API validators', function () {
42 username: 'user1', 42 username: 'user1',
43 password: 'my super password' 43 password: 'my super password'
44 } 44 }
45 await createUser(server.url, server.accessToken, user.username, user.password) 45 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
46 userAccessToken = await userLogin(server, user) 46 userAccessToken = await userLogin(server, user)
47 }) 47 })
48 48
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index f3ee99e85..b5c812e8f 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -19,6 +19,7 @@ import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from
19import { VideoPrivacy } from '../../../../shared/models/videos' 19import { VideoPrivacy } from '../../../../shared/models/videos'
20import { waitJobs } from '../../../../shared/utils/server/jobs' 20import { waitJobs } from '../../../../shared/utils/server/jobs'
21import { expect } from 'chai' 21import { expect } from 'chai'
22import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
22 23
23describe('Test users API validators', function () { 24describe('Test users API validators', function () {
24 const path = '/api/v1/users/' 25 const path = '/api/v1/users/'
@@ -47,7 +48,13 @@ describe('Test users API validators', function () {
47 await setAccessTokensToServers([ server ]) 48 await setAccessTokensToServers([ server ])
48 49
49 const videoQuota = 42000000 50 const videoQuota = 42000000
50 await createUser(server.url, server.accessToken, user.username, user.password, videoQuota) 51 await createUser({
52 url: server.url,
53 accessToken: server.accessToken,
54 username: user.username,
55 password: user.password,
56 videoQuota: videoQuota
57 })
51 userAccessToken = await userLogin(server, user) 58 userAccessToken = await userLogin(server, user)
52 59
53 { 60 {
@@ -99,7 +106,8 @@ describe('Test users API validators', function () {
99 password: 'my super password', 106 password: 'my super password',
100 videoQuota: -1, 107 videoQuota: -1,
101 videoQuotaDaily: -1, 108 videoQuotaDaily: -1,
102 role: UserRole.USER 109 role: UserRole.USER,
110 adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST
103 } 111 }
104 112
105 it('Should fail with a too small username', async function () { 113 it('Should fail with a too small username', async function () {
@@ -150,6 +158,12 @@ describe('Test users API validators', function () {
150 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 158 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
151 }) 159 })
152 160
161 it('Should fail with invalid admin flags', async function () {
162 const fields = immutableAssign(baseCorrectParams, { adminFlags: 'toto' })
163
164 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
165 })
166
153 it('Should fail with an non authenticated user', async function () { 167 it('Should fail with an non authenticated user', async function () {
154 await makePostBodyRequest({ 168 await makePostBodyRequest({
155 url: server.url, 169 url: server.url,
@@ -498,6 +512,12 @@ describe('Test users API validators', function () {
498 await makePutBodyRequest({ url: server.url, path: path + rootId, token: server.accessToken, fields }) 512 await makePutBodyRequest({ url: server.url, path: path + rootId, token: server.accessToken, fields })
499 }) 513 })
500 514
515 it('Should fail with invalid admin flags', async function () {
516 const fields = { adminFlags: 'toto' }
517
518 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
519 })
520
501 it('Should succeed with the correct params', async function () { 521 it('Should succeed with the correct params', async function () {
502 const fields = { 522 const fields = {
503 email: 'email@example.com', 523 email: 'email@example.com',
diff --git a/server/tests/api/check-params/video-abuses.ts b/server/tests/api/check-params/video-abuses.ts
index 3b8f5f14d..7edc8e39d 100644
--- a/server/tests/api/check-params/video-abuses.ts
+++ b/server/tests/api/check-params/video-abuses.ts
@@ -41,7 +41,7 @@ describe('Test video abuses API validators', function () {
41 41
42 const username = 'user1' 42 const username = 'user1'
43 const password = 'my super password' 43 const password = 'my super password'
44 await createUser(server.url, server.accessToken, username, password) 44 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
45 userAccessToken = await userLogin(server, { username, password }) 45 userAccessToken = await userLogin(server, { username, password })
46 46
47 const res = await uploadVideo(server.url, server.accessToken, {}) 47 const res = await uploadVideo(server.url, server.accessToken, {})
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index fc039e847..81423aee9 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -8,7 +8,6 @@ import {
8 flushAndRunMultipleServers, 8 flushAndRunMultipleServers,
9 flushTests, 9 flushTests,
10 getBlacklistedVideosList, 10 getBlacklistedVideosList,
11 getBlacklistedVideosListWithTypeFilter,
12 getVideo, 11 getVideo,
13 getVideoWithToken, 12 getVideoWithToken,
14 killallServers, 13 killallServers,
@@ -49,14 +48,14 @@ describe('Test video blacklist API validators', function () {
49 { 48 {
50 const username = 'user1' 49 const username = 'user1'
51 const password = 'my super password' 50 const password = 'my super password'
52 await createUser(servers[0].url, servers[0].accessToken, username, password) 51 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: username, password: password })
53 userAccessToken1 = await userLogin(servers[0], { username, password }) 52 userAccessToken1 = await userLogin(servers[0], { username, password })
54 } 53 }
55 54
56 { 55 {
57 const username = 'user2' 56 const username = 'user2'
58 const password = 'my super password' 57 const password = 'my super password'
59 await createUser(servers[0].url, servers[0].accessToken, username, password) 58 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: username, password: password })
60 userAccessToken2 = await userLogin(servers[0], { username, password }) 59 userAccessToken2 = await userLogin(servers[0], { username, password })
61 } 60 }
62 61
@@ -221,11 +220,11 @@ describe('Test video blacklist API validators', function () {
221 const basePath = '/api/v1/videos/blacklist/' 220 const basePath = '/api/v1/videos/blacklist/'
222 221
223 it('Should fail with a non authenticated user', async function () { 222 it('Should fail with a non authenticated user', async function () {
224 await getBlacklistedVideosList(servers[0].url, 'fake token', 401) 223 await getBlacklistedVideosList({ url: servers[0].url, token: 'fake token', specialStatus: 401 })
225 }) 224 })
226 225
227 it('Should fail with a non admin user', async function () { 226 it('Should fail with a non admin user', async function () {
228 await getBlacklistedVideosList(servers[0].url, userAccessToken2, 403) 227 await getBlacklistedVideosList({ url: servers[0].url, token: userAccessToken2, specialStatus: 403 })
229 }) 228 })
230 229
231 it('Should fail with a bad start pagination', async function () { 230 it('Should fail with a bad start pagination', async function () {
@@ -241,11 +240,11 @@ describe('Test video blacklist API validators', function () {
241 }) 240 })
242 241
243 it('Should fail with an invalid type', async function () { 242 it('Should fail with an invalid type', async function () {
244 await getBlacklistedVideosListWithTypeFilter(servers[0].url, servers[0].accessToken, 0, 400) 243 await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, type: 0, specialStatus: 400 })
245 }) 244 })
246 245
247 it('Should succeed with the correct parameters', async function () { 246 it('Should succeed with the correct parameters', async function () {
248 await getBlacklistedVideosListWithTypeFilter(servers[0].url, servers[0].accessToken, VideoBlacklistType.MANUAL) 247 await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken, type: VideoBlacklistType.MANUAL })
249 }) 248 })
250 }) 249 })
251 250
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index e4d36fd4f..de2ca8cd1 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -45,7 +45,7 @@ describe('Test video captions API validator', function () {
45 username: 'user1', 45 username: 'user1',
46 password: 'my super password' 46 password: 'my super password'
47 } 47 }
48 await createUser(server.url, server.accessToken, user.username, user.password) 48 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
49 userAccessToken = await userLogin(server, user) 49 userAccessToken = await userLogin(server, user)
50 } 50 }
51 }) 51 })
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 14e4deaf7..b72fc4220 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -53,7 +53,7 @@ describe('Test video channels API validator', function () {
53 } 53 }
54 54
55 { 55 {
56 await createUser(server.url, server.accessToken, user.username, user.password) 56 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
57 accessTokenUser = await userLogin(server, user) 57 accessTokenUser = await userLogin(server, user)
58 } 58 }
59 }) 59 })
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index 5981780ed..5f70998ef 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -52,7 +52,7 @@ describe('Test video comments API validator', function () {
52 username: 'user1', 52 username: 'user1',
53 password: 'my super password' 53 password: 'my super password'
54 } 54 }
55 await createUser(server.url, server.accessToken, user.username, user.password) 55 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
56 userAccessToken = await userLogin(server, user) 56 userAccessToken = await userLogin(server, user)
57 } 57 }
58 }) 58 })
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 6dd9f15f7..4d2bf2e8d 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -46,7 +46,7 @@ describe('Test video imports API validator', function () {
46 46
47 const username = 'user1' 47 const username = 'user1'
48 const password = 'my super password' 48 const password = 'my super password'
49 await createUser(server.url, server.accessToken, username, password) 49 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
50 userAccessToken = await userLogin(server, { username, password }) 50 userAccessToken = await userLogin(server, { username, password })
51 51
52 { 52 {
@@ -167,7 +167,7 @@ describe('Test video imports API validator', function () {
167 username: 'fake', 167 username: 'fake',
168 password: 'fake_password' 168 password: 'fake_password'
169 } 169 }
170 await createUser(server.url, server.accessToken, user.username, user.password) 170 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
171 171
172 const accessTokenUser = await userLogin(server, user) 172 const accessTokenUser = await userLogin(server, user)
173 const res = await getMyUserInformation(server.url, accessTokenUser) 173 const res = await getMyUserInformation(server.url, accessTokenUser)
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts
index d5557cd07..7c487ae81 100644
--- a/server/tests/api/check-params/videos-filter.ts
+++ b/server/tests/api/check-params/videos-filter.ts
@@ -56,18 +56,20 @@ describe('Test videos filters', function () {
56 await setDefaultVideoChannel([ server ]) 56 await setDefaultVideoChannel([ server ])
57 57
58 const user = { username: 'user1', password: 'my super password' } 58 const user = { username: 'user1', password: 'my super password' }
59 await createUser(server.url, server.accessToken, user.username, user.password) 59 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
60 userAccessToken = await userLogin(server, user) 60 userAccessToken = await userLogin(server, user)
61 61
62 const moderator = { username: 'moderator', password: 'my super password' } 62 const moderator = { username: 'moderator', password: 'my super password' }
63 await createUser( 63 await createUser(
64 server.url, 64 {
65 server.accessToken, 65 url: server.url,
66 moderator.username, 66 accessToken: server.accessToken,
67 moderator.password, 67 username: moderator.username,
68 undefined, 68 password: moderator.password,
69 undefined, 69 videoQuota: undefined,
70 UserRole.MODERATOR 70 videoQuotaDaily: undefined,
71 role: UserRole.MODERATOR
72 }
71 ) 73 )
72 moderatorAccessToken = await userLogin(server, moderator) 74 moderatorAccessToken = await userLogin(server, moderator)
73 75
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index 5a013b890..3f0e0d646 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -41,7 +41,7 @@ describe('Test videos API validator', function () {
41 41
42 const username = 'user1' 42 const username = 'user1'
43 const password = 'my super password' 43 const password = 'my super password'
44 await createUser(server.url, server.accessToken, username, password) 44 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
45 userAccessToken = await userLogin(server, { username, password }) 45 userAccessToken = await userLogin(server, { username, password })
46 46
47 { 47 {
@@ -265,7 +265,7 @@ describe('Test videos API validator', function () {
265 username: 'fake', 265 username: 'fake',
266 password: 'fake_password' 266 password: 'fake_password'
267 } 267 }
268 await createUser(server.url, server.accessToken, user.username, user.password) 268 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
269 269
270 const accessTokenUser = await userLogin(server, user) 270 const accessTokenUser = await userLogin(server, user)
271 const res = await getMyUserInformation(server.url, accessTokenUser) 271 const res = await getMyUserInformation(server.url, accessTokenUser)
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index 7bff52796..d1d6f3c35 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -133,7 +133,13 @@ describe('Test users notifications', function () {
133 username: 'user_1', 133 username: 'user_1',
134 password: 'super password' 134 password: 'super password'
135 } 135 }
136 await createUser(servers[0].url, servers[0].accessToken, user.username, user.password, 10 * 1000 * 1000) 136 await createUser({
137 url: servers[ 0 ].url,
138 accessToken: servers[ 0 ].accessToken,
139 username: user.username,
140 password: user.password,
141 videoQuota: 10 * 1000 * 1000
142 })
137 userAccessToken = await userLogin(servers[0], user) 143 userAccessToken = await userLogin(servers[0], user)
138 144
139 await updateMyNotificationSettings(servers[0].url, userAccessToken, allNotificationSettings) 145 await updateMyNotificationSettings(servers[0].url, userAccessToken, allNotificationSettings)
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts
index a411e973b..682bd262a 100644
--- a/server/tests/api/search/search-activitypub-video-channels.ts
+++ b/server/tests/api/search/search-activitypub-video-channels.ts
@@ -40,7 +40,7 @@ describe('Test a ActivityPub video channels search', function () {
40 await setAccessTokensToServers(servers) 40 await setAccessTokensToServers(servers)
41 41
42 { 42 {
43 await createUser(servers[0].url, servers[0].accessToken, 'user1_server1', 'password') 43 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: 'user1_server1', password: 'password' })
44 const channel = { 44 const channel = {
45 name: 'channel1_server1', 45 name: 'channel1_server1',
46 displayName: 'Channel 1 server 1' 46 displayName: 'Channel 1 server 1'
@@ -50,7 +50,7 @@ describe('Test a ActivityPub video channels search', function () {
50 50
51 { 51 {
52 const user = { username: 'user1_server2', password: 'password' } 52 const user = { username: 'user1_server2', password: 'password' }
53 await createUser(servers[1].url, servers[1].accessToken, user.username, user.password) 53 await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
54 userServer2Token = await userLogin(servers[1], user) 54 userServer2Token = await userLogin(servers[1], user)
55 55
56 const channel = { 56 const channel = {
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index 164905651..bc45102d2 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -54,7 +54,7 @@ describe('Test emails', function () {
54 await setAccessTokensToServers([ server ]) 54 await setAccessTokensToServers([ server ])
55 55
56 { 56 {
57 const res = await createUser(server.url, server.accessToken, user.username, user.password) 57 const res = await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
58 userId = res.body.user.id 58 userId = res.body.user.id
59 59
60 userAccessToken = await userLogin(server, user) 60 userAccessToken = await userLogin(server, user)
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts
index 8bb073c41..28862a1c6 100644
--- a/server/tests/api/server/follow-constraints.ts
+++ b/server/tests/api/server/follow-constraints.ts
@@ -47,7 +47,7 @@ describe('Test follow constraints', function () {
47 username: 'user1', 47 username: 'user1',
48 password: 'super_password' 48 password: 'super_password'
49 } 49 }
50 await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) 50 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
51 userAccessToken = await userLogin(servers[0], user) 51 userAccessToken = await userLogin(servers[0], user)
52 52
53 await doubleFollow(servers[0], servers[1]) 53 await doubleFollow(servers[0], servers[1])
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index 80f54b7ad..a5e6c3c1e 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -263,7 +263,7 @@ describe('Test follows', function () {
263 263
264 { 264 {
265 const user = { username: 'captain', password: 'password' } 265 const user = { username: 'captain', password: 'password' }
266 await createUser(servers[ 2 ].url, servers[ 2 ].accessToken, user.username, user.password) 266 await createUser({ url: servers[ 2 ].url, accessToken: servers[ 2 ].accessToken, username: user.username, password: user.password })
267 const userAccessToken = await userLogin(servers[ 2 ], user) 267 const userAccessToken = await userLogin(servers[ 2 ], user)
268 268
269 const resVideos = await getVideosList(servers[ 2 ].url) 269 const resVideos = await getVideosList(servers[ 2 ].url)
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts
index aaa6c62f7..eadbcaf83 100644
--- a/server/tests/api/server/stats.ts
+++ b/server/tests/api/server/stats.ts
@@ -37,7 +37,7 @@ describe('Test stats (excluding redundancy)', function () {
37 username: 'user1', 37 username: 'user1',
38 password: 'super_password' 38 password: 'super_password'
39 } 39 }
40 await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) 40 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
41 41
42 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { fixture: 'video_short.webm' }) 42 const resVideo = await uploadVideo(servers[0].url, servers[0].accessToken, { fixture: 'video_short.webm' })
43 const videoUUID = resVideo.body.video.uuid 43 const videoUUID = resVideo.body.video.uuid
diff --git a/server/tests/api/users/blocklist.ts b/server/tests/api/users/blocklist.ts
index 4bca27a94..638a443ba 100644
--- a/server/tests/api/users/blocklist.ts
+++ b/server/tests/api/users/blocklist.ts
@@ -86,7 +86,7 @@ describe('Test blocklist', function () {
86 86
87 { 87 {
88 const user = { username: 'user1', password: 'password' } 88 const user = { username: 'user1', password: 'password' }
89 await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) 89 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
90 90
91 userToken1 = await userLogin(servers[0], user) 91 userToken1 = await userLogin(servers[0], user)
92 await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' }) 92 await uploadVideo(servers[0].url, userToken1, { name: 'video user 1' })
@@ -94,14 +94,14 @@ describe('Test blocklist', function () {
94 94
95 { 95 {
96 const user = { username: 'moderator', password: 'password' } 96 const user = { username: 'moderator', password: 'password' }
97 await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) 97 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
98 98
99 userModeratorToken = await userLogin(servers[0], user) 99 userModeratorToken = await userLogin(servers[0], user)
100 } 100 }
101 101
102 { 102 {
103 const user = { username: 'user2', password: 'password' } 103 const user = { username: 'user2', password: 'password' }
104 await createUser(servers[1].url, servers[1].accessToken, user.username, user.password) 104 await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
105 105
106 userToken2 = await userLogin(servers[1], user) 106 userToken2 = await userLogin(servers[1], user)
107 await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' }) 107 await uploadVideo(servers[1].url, userToken2, { name: 'video user 2' })
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts
index 88a7187d6..037a79a76 100644
--- a/server/tests/api/users/user-subscriptions.ts
+++ b/server/tests/api/users/user-subscriptions.ts
@@ -45,7 +45,7 @@ describe('Test users subscriptions', function () {
45 { 45 {
46 for (const server of servers) { 46 for (const server of servers) {
47 const user = { username: 'user' + server.serverNumber, password: 'password' } 47 const user = { username: 'user' + server.serverNumber, password: 'password' }
48 await createUser(server.url, server.accessToken, user.username, user.password) 48 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
49 49
50 const accessToken = await userLogin(server, user) 50 const accessToken = await userLogin(server, user)
51 users.push({ accessToken }) 51 users.push({ accessToken })
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index c46c2b7d7..0510b2de9 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -57,7 +57,12 @@ describe('Test users with multiple servers', function () {
57 username: 'user1', 57 username: 'user1',
58 password: 'password' 58 password: 'password'
59 } 59 }
60 const res = await createUser(servers[ 0 ].url, servers[ 0 ].accessToken, user.username, user.password) 60 const res = await createUser({
61 url: servers[ 0 ].url,
62 accessToken: servers[ 0 ].accessToken,
63 username: user.username,
64 password: user.password
65 })
61 userId = res.body.user.id 66 userId = res.body.user.id
62 userAccessToken = await userLogin(servers[ 0 ], user) 67 userAccessToken = await userLogin(servers[ 0 ], user)
63 } 68 }
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 6e7de9c38..13511e070 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -37,6 +37,7 @@ import {
37import { follow } from '../../../../shared/utils/server/follows' 37import { follow } from '../../../../shared/utils/server/follows'
38import { setAccessTokensToServers } from '../../../../shared/utils/users/login' 38import { setAccessTokensToServers } from '../../../../shared/utils/users/login'
39import { getMyVideos } from '../../../../shared/utils/videos/videos' 39import { getMyVideos } from '../../../../shared/utils/videos/videos'
40import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
40 41
41const expect = chai.expect 42const expect = chai.expect
42 43
@@ -60,563 +61,622 @@ describe('Test users', function () {
60 await setAccessTokensToServers([ server ]) 61 await setAccessTokensToServers([ server ])
61 }) 62 })
62 63
63 it('Should create a new client') 64 describe('OAuth client', function () {
65 it('Should create a new client')
64 66
65 it('Should return the first client') 67 it('Should return the first client')
66 68
67 it('Should remove the last client') 69 it('Should remove the last client')
68 70
69 it('Should not login with an invalid client id', async function () { 71 it('Should not login with an invalid client id', async function () {
70 const client = { id: 'client', secret: server.client.secret } 72 const client = { id: 'client', secret: server.client.secret }
71 const res = await login(server.url, client, server.user, 400) 73 const res = await login(server.url, client, server.user, 400)
72 74
73 expect(res.body.error).to.contain('client is invalid') 75 expect(res.body.error).to.contain('client is invalid')
74 }) 76 })
75 77
76 it('Should not login with an invalid client secret', async function () { 78 it('Should not login with an invalid client secret', async function () {
77 const client = { id: server.client.id, secret: 'coucou' } 79 const client = { id: server.client.id, secret: 'coucou' }
78 const res = await login(server.url, client, server.user, 400) 80 const res = await login(server.url, client, server.user, 400)
79 81
80 expect(res.body.error).to.contain('client is invalid') 82 expect(res.body.error).to.contain('client is invalid')
83 })
81 }) 84 })
82 85
83 it('Should not login with an invalid username', async function () { 86 describe('Login', function () {
84 const user = { username: 'captain crochet', password: server.user.password }
85 const res = await login(server.url, server.client, user, 400)
86
87 expect(res.body.error).to.contain('credentials are invalid')
88 })
89 87
90 it('Should not login with an invalid password', async function () { 88 it('Should not login with an invalid username', async function () {
91 const user = { username: server.user.username, password: 'mew_three' } 89 const user = { username: 'captain crochet', password: server.user.password }
92 const res = await login(server.url, server.client, user, 400) 90 const res = await login(server.url, server.client, user, 400)
93 91
94 expect(res.body.error).to.contain('credentials are invalid') 92 expect(res.body.error).to.contain('credentials are invalid')
95 }) 93 })
96 94
97 it('Should not be able to upload a video', async function () { 95 it('Should not login with an invalid password', async function () {
98 accessToken = 'my_super_token' 96 const user = { username: server.user.username, password: 'mew_three' }
97 const res = await login(server.url, server.client, user, 400)
99 98
100 const videoAttributes = {} 99 expect(res.body.error).to.contain('credentials are invalid')
101 await uploadVideo(server.url, accessToken, videoAttributes, 401) 100 })
102 })
103 101
104 it('Should not be able to follow', async function () { 102 it('Should not be able to upload a video', async function () {
105 accessToken = 'my_super_token' 103 accessToken = 'my_super_token'
106 await follow(server.url, [ 'http://example.com' ], accessToken, 401)
107 })
108 104
109 it('Should not be able to unfollow') 105 const videoAttributes = {}
106 await uploadVideo(server.url, accessToken, videoAttributes, 401)
107 })
110 108
111 it('Should be able to login', async function () { 109 it('Should not be able to follow', async function () {
112 const res = await login(server.url, server.client, server.user, 200) 110 accessToken = 'my_super_token'
111 await follow(server.url, [ 'http://example.com' ], accessToken, 401)
112 })
113 113
114 accessToken = res.body.access_token 114 it('Should not be able to unfollow')
115 })
116 115
117 it('Should upload the video with the correct token', async function () { 116 it('Should be able to login', async function () {
118 const videoAttributes = {} 117 const res = await login(server.url, server.client, server.user, 200)
119 await uploadVideo(server.url, accessToken, videoAttributes)
120 const res = await getVideosList(server.url)
121 const video = res.body.data[ 0 ]
122 118
123 expect(video.account.name).to.equal('root') 119 accessToken = res.body.access_token
124 videoId = video.id 120 })
125 }) 121 })
126 122
127 it('Should upload the video again with the correct token', async function () { 123 describe('Upload', function () {
128 const videoAttributes = {}
129 await uploadVideo(server.url, accessToken, videoAttributes)
130 })
131 124
132 it('Should retrieve a video rating', async function () { 125 it('Should upload the video with the correct token', async function () {
133 await rateVideo(server.url, accessToken, videoId, 'like') 126 const videoAttributes = {}
134 const res = await getMyUserVideoRating(server.url, accessToken, videoId) 127 await uploadVideo(server.url, accessToken, videoAttributes)
135 const rating = res.body 128 const res = await getVideosList(server.url)
129 const video = res.body.data[ 0 ]
136 130
137 expect(rating.videoId).to.equal(videoId) 131 expect(video.account.name).to.equal('root')
138 expect(rating.rating).to.equal('like') 132 videoId = video.id
133 })
134
135 it('Should upload the video again with the correct token', async function () {
136 const videoAttributes = {}
137 await uploadVideo(server.url, accessToken, videoAttributes)
138 })
139 }) 139 })
140 140
141 it('Should retrieve ratings list', async function () { 141 describe('Ratings', function () {
142 await rateVideo(server.url, accessToken, videoId, 'like')
143 142
144 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, null, 200) 143 it('Should retrieve a video rating', async function () {
145 const ratings = res.body 144 await rateVideo(server.url, accessToken, videoId, 'like')
145 const res = await getMyUserVideoRating(server.url, accessToken, videoId)
146 const rating = res.body
146 147
147 expect(ratings.total).to.equal(1) 148 expect(rating.videoId).to.equal(videoId)
148 expect(ratings.data[0].video.id).to.equal(videoId) 149 expect(rating.rating).to.equal('like')
149 expect(ratings.data[0].rating).to.equal('like') 150 })
150 })
151 151
152 it('Should retrieve ratings list by rating type', async function () { 152 it('Should retrieve ratings list', async function () {
153 { 153 await rateVideo(server.url, accessToken, videoId, 'like')
154 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'like')
155 const ratings = res.body
156 expect(ratings.data.length).to.equal(1)
157 }
158 154
159 { 155 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, null, 200)
160 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'dislike')
161 const ratings = res.body 156 const ratings = res.body
162 expect(ratings.data.length).to.equal(0)
163 }
164 })
165
166 it('Should not be able to remove the video with an incorrect token', async function () {
167 await removeVideo(server.url, 'bad_token', videoId, 401)
168 })
169 157
170 it('Should not be able to remove the video with the token of another account') 158 expect(ratings.total).to.equal(1)
159 expect(ratings.data[ 0 ].video.id).to.equal(videoId)
160 expect(ratings.data[ 0 ].rating).to.equal('like')
161 })
171 162
172 it('Should be able to remove the video with the correct token', async function () { 163 it('Should retrieve ratings list by rating type', async function () {
173 await removeVideo(server.url, accessToken, videoId) 164 {
165 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'like')
166 const ratings = res.body
167 expect(ratings.data.length).to.equal(1)
168 }
169
170 {
171 const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'dislike')
172 const ratings = res.body
173 expect(ratings.data.length).to.equal(0)
174 }
175 })
174 }) 176 })
175 177
176 it('Should logout (revoke token)') 178 describe('Remove video', function () {
177 179 it('Should not be able to remove the video with an incorrect token', async function () {
178 it('Should not be able to get the user information') 180 await removeVideo(server.url, 'bad_token', videoId, 401)
179 181 })
180 it('Should not be able to upload a video')
181
182 it('Should not be able to remove a video')
183 182
184 it('Should not be able to rate a video', async function () { 183 it('Should not be able to remove the video with the token of another account')
185 const path = '/api/v1/videos/'
186 const data = {
187 rating: 'likes'
188 }
189 184
190 const options = { 185 it('Should be able to remove the video with the correct token', async function () {
191 url: server.url, 186 await removeVideo(server.url, accessToken, videoId)
192 path: path + videoId, 187 })
193 token: 'wrong token',
194 fields: data,
195 statusCodeExpected: 401
196 }
197 await makePutBodyRequest(options)
198 }) 188 })
199 189
200 it('Should be able to login again') 190 describe('Logout', function () {
191 it('Should logout (revoke token)')
201 192
202 it('Should have an expired access token') 193 it('Should not be able to get the user information')
203 194
204 it('Should refresh the token') 195 it('Should not be able to upload a video')
205 196
206 it('Should be able to upload a video again') 197 it('Should not be able to remove a video')
207 198
208 it('Should be able to create a new user', async function () { 199 it('Should not be able to rate a video', async function () {
209 await createUser(server.url, accessToken, user.username, user.password, 2 * 1024 * 1024) 200 const path = '/api/v1/videos/'
210 }) 201 const data = {
202 rating: 'likes'
203 }
211 204
212 it('Should be able to login with this user', async function () { 205 const options = {
213 accessTokenUser = await userLogin(server, user) 206 url: server.url,
214 }) 207 path: path + videoId,
208 token: 'wrong token',
209 fields: data,
210 statusCodeExpected: 401
211 }
212 await makePutBodyRequest(options)
213 })
215 214
216 it('Should be able to get the user information', async function () { 215 it('Should be able to login again')
217 const res = await getMyUserInformation(server.url, accessTokenUser)
218 const user = res.body
219
220 expect(user.username).to.equal('user_1')
221 expect(user.email).to.equal('user_1@example.com')
222 expect(user.nsfwPolicy).to.equal('display')
223 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
224 expect(user.roleLabel).to.equal('User')
225 expect(user.id).to.be.a('number')
226 expect(user.account.displayName).to.equal('user_1')
227 expect(user.account.description).to.be.null
228 })
229 216
230 it('Should be able to upload a video with this user', async function () { 217 it('Should have an expired access token')
231 this.timeout(5000)
232 218
233 const videoAttributes = { 219 it('Should refresh the token')
234 name: 'super user video', 220
235 fixture: 'video_short.webm' 221 it('Should be able to upload a video again')
236 }
237 await uploadVideo(server.url, accessTokenUser, videoAttributes)
238 }) 222 })
239 223
240 it('Should have video quota updated', async function () { 224 describe('Creating a user', function () {
241 const res = await getMyUserVideoQuotaUsed(server.url, accessTokenUser)
242 const data = res.body
243 225
244 expect(data.videoQuotaUsed).to.equal(218910) 226 it('Should be able to create a new user', async function () {
227 await createUser({
228 url: server.url,
229 accessToken: accessToken,
230 username: user.username,
231 password: user.password,
232 videoQuota: 2 * 1024 * 1024,
233 adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST
234 })
235 })
245 236
246 const resUsers = await getUsersList(server.url, server.accessToken) 237 it('Should be able to login with this user', async function () {
238 accessTokenUser = await userLogin(server, user)
239 })
247 240
248 const users: User[] = resUsers.body.data 241 it('Should be able to get user information', async function () {
249 const tmpUser = users.find(u => u.username === user.username) 242 const res1 = await getMyUserInformation(server.url, accessTokenUser)
250 expect(tmpUser.videoQuotaUsed).to.equal(218910) 243 const userMe: User = res1.body
244
245 const res2 = await getUserInformation(server.url, server.accessToken, userMe.id)
246 const userGet: User = res2.body
247
248 for (const user of [ userMe, userGet ]) {
249 expect(user.username).to.equal('user_1')
250 expect(user.email).to.equal('user_1@example.com')
251 expect(user.nsfwPolicy).to.equal('display')
252 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
253 expect(user.roleLabel).to.equal('User')
254 expect(user.id).to.be.a('number')
255 expect(user.account.displayName).to.equal('user_1')
256 expect(user.account.description).to.be.null
257 }
258
259 expect(userMe.adminFlags).to.be.undefined
260 expect(userGet.adminFlags).to.equal(UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST)
261 })
251 }) 262 })
252 263
253 it('Should be able to list my videos', async function () { 264 describe('My videos & quotas', function () {
254 const res = await getMyVideos(server.url, accessTokenUser, 0, 5)
255 expect(res.body.total).to.equal(1)
256
257 const videos = res.body.data
258 expect(videos).to.have.lengthOf(1)
259 265
260 expect(videos[ 0 ].name).to.equal('super user video') 266 it('Should be able to upload a video with this user', async function () {
261 }) 267 this.timeout(5000)
262
263 it('Should list all the users', async function () {
264 const res = await getUsersList(server.url, server.accessToken)
265 const result = res.body
266 const total = result.total
267 const users = result.data
268 268
269 expect(total).to.equal(2) 269 const videoAttributes = {
270 expect(users).to.be.an('array') 270 name: 'super user video',
271 expect(users.length).to.equal(2) 271 fixture: 'video_short.webm'
272 }
273 await uploadVideo(server.url, accessTokenUser, videoAttributes)
274 })
272 275
273 const user = users[ 0 ] 276 it('Should have video quota updated', async function () {
274 expect(user.username).to.equal('user_1') 277 const res = await getMyUserVideoQuotaUsed(server.url, accessTokenUser)
275 expect(user.email).to.equal('user_1@example.com') 278 const data = res.body
276 expect(user.nsfwPolicy).to.equal('display')
277 279
278 const rootUser = users[ 1 ] 280 expect(data.videoQuotaUsed).to.equal(218910)
279 expect(rootUser.username).to.equal('root')
280 expect(rootUser.email).to.equal('admin1@example.com')
281 expect(user.nsfwPolicy).to.equal('display')
282 281
283 userId = user.id 282 const resUsers = await getUsersList(server.url, server.accessToken)
284 })
285 283
286 it('Should list only the first user by username asc', async function () { 284 const users: User[] = resUsers.body.data
287 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, 'username') 285 const tmpUser = users.find(u => u.username === user.username)
286 expect(tmpUser.videoQuotaUsed).to.equal(218910)
287 })
288 288
289 const result = res.body 289 it('Should be able to list my videos', async function () {
290 const total = result.total 290 const res = await getMyVideos(server.url, accessTokenUser, 0, 5)
291 const users = result.data 291 expect(res.body.total).to.equal(1)
292 292
293 expect(total).to.equal(2) 293 const videos = res.body.data
294 expect(users.length).to.equal(1) 294 expect(videos).to.have.lengthOf(1)
295 295
296 const user = users[ 0 ] 296 expect(videos[ 0 ].name).to.equal('super user video')
297 expect(user.username).to.equal('root') 297 })
298 expect(user.email).to.equal('admin1@example.com')
299 expect(user.roleLabel).to.equal('Administrator')
300 expect(user.nsfwPolicy).to.equal('display')
301 }) 298 })
302 299
303 it('Should list only the first user by username desc', async function () { 300 describe('Users listing', function () {
304 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, '-username')
305 const result = res.body
306 const total = result.total
307 const users = result.data
308 301
309 expect(total).to.equal(2) 302 it('Should list all the users', async function () {
310 expect(users.length).to.equal(1) 303 const res = await getUsersList(server.url, server.accessToken)
304 const result = res.body
305 const total = result.total
306 const users = result.data
311 307
312 const user = users[ 0 ] 308 expect(total).to.equal(2)
313 expect(user.username).to.equal('user_1') 309 expect(users).to.be.an('array')
314 expect(user.email).to.equal('user_1@example.com') 310 expect(users.length).to.equal(2)
315 expect(user.nsfwPolicy).to.equal('display')
316 })
317 311
318 it('Should list only the second user by createdAt desc', async function () { 312 const user = users[ 0 ]
319 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, '-createdAt') 313 expect(user.username).to.equal('user_1')
320 const result = res.body 314 expect(user.email).to.equal('user_1@example.com')
321 const total = result.total 315 expect(user.nsfwPolicy).to.equal('display')
322 const users = result.data
323 316
324 expect(total).to.equal(2) 317 const rootUser = users[ 1 ]
325 expect(users.length).to.equal(1) 318 expect(rootUser.username).to.equal('root')
319 expect(rootUser.email).to.equal('admin1@example.com')
320 expect(user.nsfwPolicy).to.equal('display')
326 321
327 const user = users[ 0 ] 322 userId = user.id
328 expect(user.username).to.equal('user_1') 323 })
329 expect(user.email).to.equal('user_1@example.com')
330 expect(user.nsfwPolicy).to.equal('display')
331 })
332 324
333 it('Should list all the users by createdAt asc', async function () { 325 it('Should list only the first user by username asc', async function () {
334 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt') 326 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, 'username')
335 const result = res.body
336 const total = result.total
337 const users = result.data
338 327
339 expect(total).to.equal(2) 328 const result = res.body
340 expect(users.length).to.equal(2) 329 const total = result.total
330 const users = result.data
341 331
342 expect(users[ 0 ].username).to.equal('root') 332 expect(total).to.equal(2)
343 expect(users[ 0 ].email).to.equal('admin1@example.com') 333 expect(users.length).to.equal(1)
344 expect(users[ 0 ].nsfwPolicy).to.equal('display')
345 334
346 expect(users[ 1 ].username).to.equal('user_1') 335 const user = users[ 0 ]
347 expect(users[ 1 ].email).to.equal('user_1@example.com') 336 expect(user.username).to.equal('root')
348 expect(users[ 1 ].nsfwPolicy).to.equal('display') 337 expect(user.email).to.equal('admin1@example.com')
349 }) 338 expect(user.roleLabel).to.equal('Administrator')
339 expect(user.nsfwPolicy).to.equal('display')
340 })
350 341
351 it('Should search user by username', async function () { 342 it('Should list only the first user by username desc', async function () {
352 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', 'oot') 343 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, '-username')
353 const users = res.body.data as User[] 344 const result = res.body
345 const total = result.total
346 const users = result.data
354 347
355 expect(res.body.total).to.equal(1) 348 expect(total).to.equal(2)
356 expect(users.length).to.equal(1) 349 expect(users.length).to.equal(1)
357 350
358 expect(users[ 0 ].username).to.equal('root') 351 const user = users[ 0 ]
359 }) 352 expect(user.username).to.equal('user_1')
353 expect(user.email).to.equal('user_1@example.com')
354 expect(user.nsfwPolicy).to.equal('display')
355 })
360 356
361 it('Should search user by email', async function () { 357 it('Should list only the second user by createdAt desc', async function () {
362 { 358 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 1, '-createdAt')
363 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', 'r_1@exam') 359 const result = res.body
364 const users = res.body.data as User[] 360 const total = result.total
361 const users = result.data
365 362
366 expect(res.body.total).to.equal(1) 363 expect(total).to.equal(2)
367 expect(users.length).to.equal(1) 364 expect(users.length).to.equal(1)
368 365
369 expect(users[ 0 ].username).to.equal('user_1') 366 const user = users[ 0 ]
370 expect(users[ 0 ].email).to.equal('user_1@example.com') 367 expect(user.username).to.equal('user_1')
371 } 368 expect(user.email).to.equal('user_1@example.com')
369 expect(user.nsfwPolicy).to.equal('display')
370 })
372 371
373 { 372 it('Should list all the users by createdAt asc', async function () {
374 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', 'example') 373 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt')
375 const users = res.body.data as User[] 374 const result = res.body
375 const total = result.total
376 const users = result.data
376 377
377 expect(res.body.total).to.equal(2) 378 expect(total).to.equal(2)
378 expect(users.length).to.equal(2) 379 expect(users.length).to.equal(2)
379 380
380 expect(users[ 0 ].username).to.equal('root') 381 expect(users[ 0 ].username).to.equal('root')
381 expect(users[ 1 ].username).to.equal('user_1') 382 expect(users[ 0 ].email).to.equal('admin1@example.com')
382 } 383 expect(users[ 0 ].nsfwPolicy).to.equal('display')
383 })
384 384
385 it('Should update my password', async function () { 385 expect(users[ 1 ].username).to.equal('user_1')
386 await updateMyUser({ 386 expect(users[ 1 ].email).to.equal('user_1@example.com')
387 url: server.url, 387 expect(users[ 1 ].nsfwPolicy).to.equal('display')
388 accessToken: accessTokenUser,
389 currentPassword: 'super password',
390 newPassword: 'new password'
391 }) 388 })
392 user.password = 'new password'
393 389
394 await userLogin(server, user, 200) 390 it('Should search user by username', async function () {
395 }) 391 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', 'oot')
392 const users = res.body.data as User[]
393
394 expect(res.body.total).to.equal(1)
395 expect(users.length).to.equal(1)
396 396
397 it('Should be able to change the NSFW display attribute', async function () { 397 expect(users[ 0 ].username).to.equal('root')
398 await updateMyUser({
399 url: server.url,
400 accessToken: accessTokenUser,
401 nsfwPolicy: 'do_not_list'
402 }) 398 })
403 399
404 const res = await getMyUserInformation(server.url, accessTokenUser) 400 it('Should search user by email', async function () {
405 const user = res.body 401 {
402 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', 'r_1@exam')
403 const users = res.body.data as User[]
406 404
407 expect(user.username).to.equal('user_1') 405 expect(res.body.total).to.equal(1)
408 expect(user.email).to.equal('user_1@example.com') 406 expect(users.length).to.equal(1)
409 expect(user.nsfwPolicy).to.equal('do_not_list')
410 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
411 expect(user.id).to.be.a('number')
412 expect(user.account.displayName).to.equal('user_1')
413 expect(user.account.description).to.be.null
414 })
415 407
416 it('Should be able to change the autoPlayVideo attribute', async function () { 408 expect(users[ 0 ].username).to.equal('user_1')
417 await updateMyUser({ 409 expect(users[ 0 ].email).to.equal('user_1@example.com')
418 url: server.url, 410 }
419 accessToken: accessTokenUser,
420 autoPlayVideo: false
421 })
422 411
423 const res = await getMyUserInformation(server.url, accessTokenUser) 412 {
424 const user = res.body 413 const res = await getUsersListPaginationAndSort(server.url, server.accessToken, 0, 2, 'createdAt', 'example')
414 const users = res.body.data as User[]
425 415
426 expect(user.autoPlayVideo).to.be.false 416 expect(res.body.total).to.equal(2)
427 }) 417 expect(users.length).to.equal(2)
428 418
429 it('Should be able to change the email display attribute', async function () { 419 expect(users[ 0 ].username).to.equal('root')
430 await updateMyUser({ 420 expect(users[ 1 ].username).to.equal('user_1')
431 url: server.url, 421 }
432 accessToken: accessTokenUser,
433 email: 'updated@example.com'
434 }) 422 })
435
436 const res = await getMyUserInformation(server.url, accessTokenUser)
437 const user = res.body
438
439 expect(user.username).to.equal('user_1')
440 expect(user.email).to.equal('updated@example.com')
441 expect(user.nsfwPolicy).to.equal('do_not_list')
442 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
443 expect(user.id).to.be.a('number')
444 expect(user.account.displayName).to.equal('user_1')
445 expect(user.account.description).to.be.null
446 }) 423 })
447 424
448 it('Should be able to update my avatar', async function () { 425 describe('Update my account', function () {
449 const fixture = 'avatar.png' 426 it('Should update my password', async function () {
427 await updateMyUser({
428 url: server.url,
429 accessToken: accessTokenUser,
430 currentPassword: 'super password',
431 newPassword: 'new password'
432 })
433 user.password = 'new password'
450 434
451 await updateMyAvatar({ 435 await userLogin(server, user, 200)
452 url: server.url,
453 accessToken: accessTokenUser,
454 fixture
455 }) 436 })
456 437
457 const res = await getMyUserInformation(server.url, accessTokenUser) 438 it('Should be able to change the NSFW display attribute', async function () {
458 const user = res.body 439 await updateMyUser({
440 url: server.url,
441 accessToken: accessTokenUser,
442 nsfwPolicy: 'do_not_list'
443 })
444
445 const res = await getMyUserInformation(server.url, accessTokenUser)
446 const user = res.body
447
448 expect(user.username).to.equal('user_1')
449 expect(user.email).to.equal('user_1@example.com')
450 expect(user.nsfwPolicy).to.equal('do_not_list')
451 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
452 expect(user.id).to.be.a('number')
453 expect(user.account.displayName).to.equal('user_1')
454 expect(user.account.description).to.be.null
455 })
459 456
460 await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png') 457 it('Should be able to change the autoPlayVideo attribute', async function () {
461 }) 458 await updateMyUser({
459 url: server.url,
460 accessToken: accessTokenUser,
461 autoPlayVideo: false
462 })
462 463
463 it('Should be able to update my display name', async function () { 464 const res = await getMyUserInformation(server.url, accessTokenUser)
464 await updateMyUser({ 465 const user = res.body
465 url: server.url, 466
466 accessToken: accessTokenUser, 467 expect(user.autoPlayVideo).to.be.false
467 displayName: 'new display name'
468 }) 468 })
469 469
470 const res = await getMyUserInformation(server.url, accessTokenUser) 470 it('Should be able to change the email display attribute', async function () {
471 const user = res.body 471 await updateMyUser({
472 url: server.url,
473 accessToken: accessTokenUser,
474 email: 'updated@example.com'
475 })
476
477 const res = await getMyUserInformation(server.url, accessTokenUser)
478 const user = res.body
479
480 expect(user.username).to.equal('user_1')
481 expect(user.email).to.equal('updated@example.com')
482 expect(user.nsfwPolicy).to.equal('do_not_list')
483 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
484 expect(user.id).to.be.a('number')
485 expect(user.account.displayName).to.equal('user_1')
486 expect(user.account.description).to.be.null
487 })
472 488
473 expect(user.username).to.equal('user_1') 489 it('Should be able to update my avatar', async function () {
474 expect(user.email).to.equal('updated@example.com') 490 const fixture = 'avatar.png'
475 expect(user.nsfwPolicy).to.equal('do_not_list')
476 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
477 expect(user.id).to.be.a('number')
478 expect(user.account.displayName).to.equal('new display name')
479 expect(user.account.description).to.be.null
480 })
481 491
482 it('Should be able to update my description', async function () { 492 await updateMyAvatar({
483 await updateMyUser({ 493 url: server.url,
484 url: server.url, 494 accessToken: accessTokenUser,
485 accessToken: accessTokenUser, 495 fixture
486 description: 'my super description updated' 496 })
487 })
488 497
489 const res = await getMyUserInformation(server.url, accessTokenUser) 498 const res = await getMyUserInformation(server.url, accessTokenUser)
490 const user = res.body 499 const user = res.body
491 500
492 expect(user.username).to.equal('user_1') 501 await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.png')
493 expect(user.email).to.equal('updated@example.com') 502 })
494 expect(user.nsfwPolicy).to.equal('do_not_list') 503
495 expect(user.videoQuota).to.equal(2 * 1024 * 1024) 504 it('Should be able to update my display name', async function () {
496 expect(user.id).to.be.a('number') 505 await updateMyUser({
497 expect(user.account.displayName).to.equal('new display name') 506 url: server.url,
498 expect(user.account.description).to.equal('my super description updated') 507 accessToken: accessTokenUser,
499 }) 508 displayName: 'new display name'
509 })
510
511 const res = await getMyUserInformation(server.url, accessTokenUser)
512 const user = res.body
513
514 expect(user.username).to.equal('user_1')
515 expect(user.email).to.equal('updated@example.com')
516 expect(user.nsfwPolicy).to.equal('do_not_list')
517 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
518 expect(user.id).to.be.a('number')
519 expect(user.account.displayName).to.equal('new display name')
520 expect(user.account.description).to.be.null
521 })
500 522
501 it('Should be able to update another user', async function () { 523 it('Should be able to update my description', async function () {
502 await updateUser({ 524 await updateMyUser({
503 url: server.url, 525 url: server.url,
504 userId, 526 accessToken: accessTokenUser,
505 accessToken, 527 description: 'my super description updated'
506 email: 'updated2@example.com', 528 })
507 emailVerified: true, 529
508 videoQuota: 42, 530 const res = await getMyUserInformation(server.url, accessTokenUser)
509 role: UserRole.MODERATOR 531 const user = res.body
510 }) 532
511 533 expect(user.username).to.equal('user_1')
512 const res = await getUserInformation(server.url, accessToken, userId) 534 expect(user.email).to.equal('updated@example.com')
513 const user = res.body 535 expect(user.nsfwPolicy).to.equal('do_not_list')
514 536 expect(user.videoQuota).to.equal(2 * 1024 * 1024)
515 expect(user.username).to.equal('user_1') 537 expect(user.id).to.be.a('number')
516 expect(user.email).to.equal('updated2@example.com') 538 expect(user.account.displayName).to.equal('new display name')
517 expect(user.emailVerified).to.be.true 539 expect(user.account.description).to.equal('my super description updated')
518 expect(user.nsfwPolicy).to.equal('do_not_list') 540 })
519 expect(user.videoQuota).to.equal(42)
520 expect(user.roleLabel).to.equal('Moderator')
521 expect(user.id).to.be.a('number')
522 }) 541 })
523 542
524 it('Should have removed the user token', async function () { 543 describe('Updating another user', function () {
525 await getMyUserVideoQuotaUsed(server.url, accessTokenUser, 401) 544
545 it('Should be able to update another user', async function () {
546 await updateUser({
547 url: server.url,
548 userId,
549 accessToken,
550 email: 'updated2@example.com',
551 emailVerified: true,
552 videoQuota: 42,
553 role: UserRole.MODERATOR,
554 adminFlags: UserAdminFlag.NONE
555 })
556
557 const res = await getUserInformation(server.url, accessToken, userId)
558 const user = res.body
559
560 expect(user.username).to.equal('user_1')
561 expect(user.email).to.equal('updated2@example.com')
562 expect(user.emailVerified).to.be.true
563 expect(user.nsfwPolicy).to.equal('do_not_list')
564 expect(user.videoQuota).to.equal(42)
565 expect(user.roleLabel).to.equal('Moderator')
566 expect(user.id).to.be.a('number')
567 expect(user.adminFlags).to.equal(UserAdminFlag.NONE)
568 })
526 569
527 accessTokenUser = await userLogin(server, user) 570 it('Should have removed the user token', async function () {
528 }) 571 await getMyUserVideoQuotaUsed(server.url, accessTokenUser, 401)
529 572
530 it('Should be able to update another user password', async function () { 573 accessTokenUser = await userLogin(server, user)
531 await updateUser({
532 url: server.url,
533 userId,
534 accessToken,
535 password: 'password updated'
536 }) 574 })
537 575
538 await getMyUserVideoQuotaUsed(server.url, accessTokenUser, 401) 576 it('Should be able to update another user password', async function () {
577 await updateUser({
578 url: server.url,
579 userId,
580 accessToken,
581 password: 'password updated'
582 })
539 583
540 await userLogin(server, user, 400) 584 await getMyUserVideoQuotaUsed(server.url, accessTokenUser, 401)
541 585
542 user.password = 'password updated' 586 await userLogin(server, user, 400)
543 accessTokenUser = await userLogin(server, user)
544 })
545 587
546 it('Should be able to list video blacklist by a moderator', async function () { 588 user.password = 'password updated'
547 await getBlacklistedVideosList(server.url, accessTokenUser) 589 accessTokenUser = await userLogin(server, user)
590 })
548 }) 591 })
549 592
550 it('Should be able to remove this user', async function () { 593 describe('Video blacklists', function () {
551 await removeUser(server.url, userId, accessToken) 594 it('Should be able to list video blacklist by a moderator', async function () {
595 await getBlacklistedVideosList({ url: server.url, token: accessTokenUser })
596 })
552 }) 597 })
553 598
554 it('Should not be able to login with this user', async function () { 599 describe('Remove a user', function () {
555 await userLogin(server, user, 400) 600 it('Should be able to remove this user', async function () {
556 }) 601 await removeUser(server.url, userId, accessToken)
602 })
557 603
558 it('Should not have videos of this user', async function () { 604 it('Should not be able to login with this user', async function () {
559 const res = await getVideosList(server.url) 605 await userLogin(server, user, 400)
606 })
560 607
561 expect(res.body.total).to.equal(1) 608 it('Should not have videos of this user', async function () {
609 const res = await getVideosList(server.url)
562 610
563 const video = res.body.data[ 0 ] 611 expect(res.body.total).to.equal(1)
564 expect(video.account.name).to.equal('root')
565 })
566 612
567 it('Should register a new user', async function () { 613 const video = res.body.data[ 0 ]
568 await registerUser(server.url, 'user_15', 'my super password') 614 expect(video.account.name).to.equal('root')
615 })
569 }) 616 })
570 617
571 it('Should be able to login with this registered user', async function () { 618 describe('Registering a new user', function () {
572 const user15 = { 619 it('Should register a new user', async function () {
573 username: 'user_15', 620 await registerUser(server.url, 'user_15', 'my super password')
574 password: 'my super password' 621 })
575 }
576 622
577 accessToken = await userLogin(server, user15) 623 it('Should be able to login with this registered user', async function () {
578 }) 624 const user15 = {
625 username: 'user_15',
626 password: 'my super password'
627 }
579 628
580 it('Should have the correct video quota', async function () { 629 accessToken = await userLogin(server, user15)
581 const res = await getMyUserInformation(server.url, accessToken) 630 })
582 const user = res.body
583 631
584 expect(user.videoQuota).to.equal(5 * 1024 * 1024) 632 it('Should have the correct video quota', async function () {
585 }) 633 const res = await getMyUserInformation(server.url, accessToken)
634 const user = res.body
586 635
587 it('Should remove me', async function () { 636 expect(user.videoQuota).to.equal(5 * 1024 * 1024)
588 { 637 })
589 const res = await getUsersList(server.url, server.accessToken)
590 expect(res.body.data.find(u => u.username === 'user_15')).to.not.be.undefined
591 }
592 638
593 await deleteMe(server.url, accessToken) 639 it('Should remove me', async function () {
640 {
641 const res = await getUsersList(server.url, server.accessToken)
642 expect(res.body.data.find(u => u.username === 'user_15')).to.not.be.undefined
643 }
594 644
595 { 645 await deleteMe(server.url, accessToken)
596 const res = await getUsersList(server.url, server.accessToken) 646
597 expect(res.body.data.find(u => u.username === 'user_15')).to.be.undefined 647 {
598 } 648 const res = await getUsersList(server.url, server.accessToken)
649 expect(res.body.data.find(u => u.username === 'user_15')).to.be.undefined
650 }
651 })
599 }) 652 })
600 653
601 it('Should block and unblock a user', async function () { 654 describe('User blocking', function () {
602 const user16 = { 655 it('Should block and unblock a user', async function () {
603 username: 'user_16', 656 const user16 = {
604 password: 'my super password' 657 username: 'user_16',
605 } 658 password: 'my super password'
606 const resUser = await createUser(server.url, server.accessToken, user16.username, user16.password) 659 }
607 const user16Id = resUser.body.user.id 660 const resUser = await createUser({
661 url: server.url,
662 accessToken: server.accessToken,
663 username: user16.username,
664 password: user16.password
665 })
666 const user16Id = resUser.body.user.id
608 667
609 accessToken = await userLogin(server, user16) 668 accessToken = await userLogin(server, user16)
610 669
611 await getMyUserInformation(server.url, accessToken, 200) 670 await getMyUserInformation(server.url, accessToken, 200)
612 await blockUser(server.url, user16Id, server.accessToken) 671 await blockUser(server.url, user16Id, server.accessToken)
613 672
614 await getMyUserInformation(server.url, accessToken, 401) 673 await getMyUserInformation(server.url, accessToken, 401)
615 await userLogin(server, user16, 400) 674 await userLogin(server, user16, 400)
616 675
617 await unblockUser(server.url, user16Id, server.accessToken) 676 await unblockUser(server.url, user16Id, server.accessToken)
618 accessToken = await userLogin(server, user16) 677 accessToken = await userLogin(server, user16)
619 await getMyUserInformation(server.url, accessToken, 200) 678 await getMyUserInformation(server.url, accessToken, 200)
679 })
620 }) 680 })
621 681
622 after(async function () { 682 after(async function () {
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index f91678140..46486b777 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -164,7 +164,7 @@ describe('Test multiple servers', function () {
164 username: 'user1', 164 username: 'user1',
165 password: 'super_password' 165 password: 'super_password'
166 } 166 }
167 await createUser(servers[1].url, servers[1].accessToken, user.username, user.password) 167 await createUser({ url: servers[ 1 ].url, accessToken: servers[ 1 ].accessToken, username: user.username, password: user.password })
168 const userAccessToken = await userLogin(servers[1], user) 168 const userAccessToken = await userLogin(servers[1], user)
169 169
170 const videoAttributes = { 170 const videoAttributes = {
diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts
index 10b412a80..1feae19e9 100644
--- a/server/tests/api/videos/video-blacklist.ts
+++ b/server/tests/api/videos/video-blacklist.ts
@@ -5,29 +5,31 @@ import { orderBy } from 'lodash'
5import 'mocha' 5import 'mocha'
6import { 6import {
7 addVideoToBlacklist, 7 addVideoToBlacklist,
8 createUser,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
9 getBlacklistedVideosList, 10 getBlacklistedVideosList,
10 getBlacklistedVideosListWithTypeFilter,
11 getMyVideos, 11 getMyVideos,
12 getSortedBlacklistedVideosList,
13 getVideosList, 12 getVideosList,
14 killallServers, 13 killallServers,
15 removeVideoFromBlacklist, 14 removeVideoFromBlacklist,
15 reRunServer,
16 searchVideo, 16 searchVideo,
17 ServerInfo, 17 ServerInfo,
18 setAccessTokensToServers, 18 setAccessTokensToServers,
19 updateVideo, 19 updateVideo,
20 updateVideoBlacklist, 20 updateVideoBlacklist,
21 uploadVideo, 21 uploadVideo,
22 viewVideo 22 userLogin
23} from '../../../../shared/utils/index' 23} from '../../../../shared/utils/index'
24import { doubleFollow } from '../../../../shared/utils/server/follows' 24import { doubleFollow } from '../../../../shared/utils/server/follows'
25import { waitJobs } from '../../../../shared/utils/server/jobs' 25import { waitJobs } from '../../../../shared/utils/server/jobs'
26import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos' 26import { VideoBlacklist, VideoBlacklistType } from '../../../../shared/models/videos'
27import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
28import { UserRole } from '../../../../shared/models/users'
27 29
28const expect = chai.expect 30const expect = chai.expect
29 31
30describe('Test video blacklist management', function () { 32describe('Test video blacklist', function () {
31 let servers: ServerInfo[] = [] 33 let servers: ServerInfo[] = []
32 let videoId: number 34 let videoId: number
33 35
@@ -104,7 +106,7 @@ describe('Test video blacklist management', function () {
104 106
105 describe('When listing manually blacklisted videos', function () { 107 describe('When listing manually blacklisted videos', function () {
106 it('Should display all the blacklisted videos', async function () { 108 it('Should display all the blacklisted videos', async function () {
107 const res = await getBlacklistedVideosList(servers[0].url, servers[0].accessToken) 109 const res = await getBlacklistedVideosList({ url: servers[0].url, token: servers[0].accessToken })
108 110
109 expect(res.body.total).to.equal(2) 111 expect(res.body.total).to.equal(2)
110 112
@@ -119,7 +121,11 @@ describe('Test video blacklist management', function () {
119 }) 121 })
120 122
121 it('Should display all the blacklisted videos when applying manual type filter', async function () { 123 it('Should display all the blacklisted videos when applying manual type filter', async function () {
122 const res = await getBlacklistedVideosListWithTypeFilter(servers[0].url, servers[0].accessToken, VideoBlacklistType.MANUAL) 124 const res = await getBlacklistedVideosList({
125 url: servers[ 0 ].url,
126 token: servers[ 0 ].accessToken,
127 type: VideoBlacklistType.MANUAL
128 })
123 129
124 expect(res.body.total).to.equal(2) 130 expect(res.body.total).to.equal(2)
125 131
@@ -129,7 +135,11 @@ describe('Test video blacklist management', function () {
129 }) 135 })
130 136
131 it('Should display nothing when applying automatic type filter', async function () { 137 it('Should display nothing when applying automatic type filter', async function () {
132 const res = await getBlacklistedVideosListWithTypeFilter(servers[0].url, servers[0].accessToken, VideoBlacklistType.AUTO_BEFORE_PUBLISHED) // tslint:disable:max-line-length 138 const res = await getBlacklistedVideosList({
139 url: servers[ 0 ].url,
140 token: servers[ 0 ].accessToken,
141 type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
142 })
133 143
134 expect(res.body.total).to.equal(0) 144 expect(res.body.total).to.equal(0)
135 145
@@ -139,7 +149,7 @@ describe('Test video blacklist management', function () {
139 }) 149 })
140 150
141 it('Should get the correct sort when sorting by descending id', async function () { 151 it('Should get the correct sort when sorting by descending id', async function () {
142 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-id') 152 const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-id' })
143 expect(res.body.total).to.equal(2) 153 expect(res.body.total).to.equal(2)
144 154
145 const blacklistedVideos = res.body.data 155 const blacklistedVideos = res.body.data
@@ -152,7 +162,7 @@ describe('Test video blacklist management', function () {
152 }) 162 })
153 163
154 it('Should get the correct sort when sorting by descending video name', async function () { 164 it('Should get the correct sort when sorting by descending video name', async function () {
155 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') 165 const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' })
156 expect(res.body.total).to.equal(2) 166 expect(res.body.total).to.equal(2)
157 167
158 const blacklistedVideos = res.body.data 168 const blacklistedVideos = res.body.data
@@ -165,7 +175,7 @@ describe('Test video blacklist management', function () {
165 }) 175 })
166 176
167 it('Should get the correct sort when sorting by ascending creation date', async function () { 177 it('Should get the correct sort when sorting by ascending creation date', async function () {
168 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, 'createdAt') 178 const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: 'createdAt' })
169 expect(res.body.total).to.equal(2) 179 expect(res.body.total).to.equal(2)
170 180
171 const blacklistedVideos = res.body.data 181 const blacklistedVideos = res.body.data
@@ -182,7 +192,7 @@ describe('Test video blacklist management', function () {
182 it('Should change the reason', async function () { 192 it('Should change the reason', async function () {
183 await updateVideoBlacklist(servers[0].url, servers[0].accessToken, videoId, 'my super reason updated') 193 await updateVideoBlacklist(servers[0].url, servers[0].accessToken, videoId, 'my super reason updated')
184 194
185 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') 195 const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' })
186 const video = res.body.data.find(b => b.video.id === videoId) 196 const video = res.body.data.find(b => b.video.id === videoId)
187 197
188 expect(video.reason).to.equal('my super reason updated') 198 expect(video.reason).to.equal('my super reason updated')
@@ -218,7 +228,7 @@ describe('Test video blacklist management', function () {
218 228
219 it('Should remove a video from the blacklist on server 1', async function () { 229 it('Should remove a video from the blacklist on server 1', async function () {
220 // Get one video in the blacklist 230 // Get one video in the blacklist
221 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') 231 const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' })
222 videoToRemove = res.body.data[0] 232 videoToRemove = res.body.data[0]
223 blacklist = res.body.data.slice(1) 233 blacklist = res.body.data.slice(1)
224 234
@@ -239,7 +249,7 @@ describe('Test video blacklist management', function () {
239 }) 249 })
240 250
241 it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () { 251 it('Should not have the ex-blacklisted video in videos blacklist list on server 1', async function () {
242 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, '-name') 252 const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: '-name' })
243 expect(res.body.total).to.equal(1) 253 expect(res.body.total).to.equal(1)
244 254
245 const videos = res.body.data 255 const videos = res.body.data
@@ -313,7 +323,7 @@ describe('Test video blacklist management', function () {
313 }) 323 })
314 324
315 it('Should have the correct video blacklist unfederate attribute', async function () { 325 it('Should have the correct video blacklist unfederate attribute', async function () {
316 const res = await getSortedBlacklistedVideosList(servers[0].url, servers[0].accessToken, 'createdAt') 326 const res = await getBlacklistedVideosList({ url: servers[ 0 ].url, token: servers[ 0 ].accessToken, sort: 'createdAt' })
317 327
318 const blacklistedVideos: VideoBlacklist[] = res.body.data 328 const blacklistedVideos: VideoBlacklist[] = res.body.data
319 const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID) 329 const video3Blacklisted = blacklistedVideos.find(b => b.video.uuid === video3UUID)
@@ -338,6 +348,83 @@ describe('Test video blacklist management', function () {
338 348
339 }) 349 })
340 350
351 describe('When auto blacklist videos', function () {
352 let userWithoutFlag: string
353 let userWithFlag: string
354
355 before(async function () {
356 this.timeout(20000)
357
358 killallServers([ servers[0] ])
359
360 const config = {
361 'auto_blacklist': {
362 videos: {
363 'of_users': {
364 enabled: true
365 }
366 }
367 }
368 }
369 await reRunServer(servers[0], config)
370
371 {
372 const user = { username: 'user_without_flag', password: 'password' }
373 await createUser({
374 url: servers[ 0 ].url,
375 accessToken: servers[ 0 ].accessToken,
376 username: user.username,
377 adminFlags: UserAdminFlag.NONE,
378 password: user.password,
379 role: UserRole.USER
380 })
381
382 userWithoutFlag = await userLogin(servers[0], user)
383 }
384
385 {
386 const user = { username: 'user_with_flag', password: 'password' }
387 await createUser({
388 url: servers[ 0 ].url,
389 accessToken: servers[ 0 ].accessToken,
390 username: user.username,
391 adminFlags: UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST,
392 password: user.password,
393 role: UserRole.USER
394 })
395
396 userWithFlag = await userLogin(servers[0], user)
397 }
398
399 await waitJobs(servers)
400 })
401
402 it('Should auto blacklist a video', async function () {
403 await uploadVideo(servers[0].url, userWithoutFlag, { name: 'blacklisted' })
404
405 const res = await getBlacklistedVideosList({
406 url: servers[ 0 ].url,
407 token: servers[ 0 ].accessToken,
408 type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
409 })
410
411 expect(res.body.total).to.equal(1)
412 expect(res.body.data[0].video.name).to.equal('blacklisted')
413 })
414
415 it('Should not auto blacklist a video', async function () {
416 await uploadVideo(servers[0].url, userWithFlag, { name: 'not blacklisted' })
417
418 const res = await getBlacklistedVideosList({
419 url: servers[ 0 ].url,
420 token: servers[ 0 ].accessToken,
421 type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
422 })
423
424 expect(res.body.total).to.equal(1)
425 })
426 })
427
341 after(async function () { 428 after(async function () {
342 killallServers(servers) 429 killallServers(servers)
343 }) 430 })
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index 25675a966..a23e30dc0 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -46,8 +46,20 @@ describe('Test video change ownership - nominal', function () {
46 await setAccessTokensToServers(servers) 46 await setAccessTokensToServers(servers)
47 47
48 const videoQuota = 42000000 48 const videoQuota = 42000000
49 await createUser(servers[0].url, servers[0].accessToken, firstUser.username, firstUser.password, videoQuota) 49 await createUser({
50 await createUser(servers[0].url, servers[0].accessToken, secondUser.username, secondUser.password, videoQuota) 50 url: servers[ 0 ].url,
51 accessToken: servers[ 0 ].accessToken,
52 username: firstUser.username,
53 password: firstUser.password,
54 videoQuota: videoQuota
55 })
56 await createUser({
57 url: servers[ 0 ].url,
58 accessToken: servers[ 0 ].accessToken,
59 username: secondUser.username,
60 password: secondUser.password,
61 videoQuota: videoQuota
62 })
51 63
52 firstUserAccessToken = await userLogin(servers[0], firstUser) 64 firstUserAccessToken = await userLogin(servers[0], firstUser)
53 secondUserAccessToken = await userLogin(servers[0], secondUser) 65 secondUserAccessToken = await userLogin(servers[0], secondUser)
@@ -219,8 +231,20 @@ describe('Test video change ownership - quota too small', function () {
219 231
220 const videoQuota = 42000000 232 const videoQuota = 42000000
221 const limitedVideoQuota = 10 233 const limitedVideoQuota = 10
222 await createUser(server.url, server.accessToken, firstUser.username, firstUser.password, videoQuota) 234 await createUser({
223 await createUser(server.url, server.accessToken, secondUser.username, secondUser.password, limitedVideoQuota) 235 url: server.url,
236 accessToken: server.accessToken,
237 username: firstUser.username,
238 password: firstUser.password,
239 videoQuota: videoQuota
240 })
241 await createUser({
242 url: server.url,
243 accessToken: server.accessToken,
244 username: secondUser.username,
245 password: secondUser.password,
246 videoQuota: limitedVideoQuota
247 })
224 248
225 firstUserAccessToken = await userLogin(server, firstUser) 249 firstUserAccessToken = await userLogin(server, firstUser)
226 secondUserAccessToken = await userLogin(server, secondUser) 250 secondUserAccessToken = await userLogin(server, secondUser)
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 63514d69c..bd672cf41 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -270,7 +270,7 @@ describe('Test video channels', function () {
270 } 270 }
271 271
272 { 272 {
273 await createUser(servers[ 0 ].url, servers[ 0 ].accessToken, 'toto', 'password') 273 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: 'toto', password: 'password' })
274 const accessToken = await userLogin(servers[ 0 ], { username: 'toto', password: 'password' }) 274 const accessToken = await userLogin(servers[ 0 ], { username: 'toto', password: 'password' })
275 275
276 const res = await getMyUserInformation(servers[ 0 ].url, accessToken) 276 const res = await getMyUserInformation(servers[ 0 ].url, accessToken)
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index df1ee2eb9..cb972d921 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -144,7 +144,7 @@ describe('Test video NSFW policy', function () {
144 it('Should create a user having the default nsfw policy', async function () { 144 it('Should create a user having the default nsfw policy', async function () {
145 const username = 'user1' 145 const username = 'user1'
146 const password = 'my super password' 146 const password = 'my super password'
147 await createUser(server.url, server.accessToken, username, password) 147 await createUser({ url: server.url, accessToken: server.accessToken, username: username, password: password })
148 148
149 userAccessToken = await userLogin(server, { username, password }) 149 userAccessToken = await userLogin(server, { username, password })
150 150
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index fc2662808..d9cb71992 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -815,7 +815,12 @@ describe('Test video playlists', function () {
815 this.timeout(30000) 815 this.timeout(30000)
816 816
817 const user = { username: 'user_1', password: 'password' } 817 const user = { username: 'user_1', password: 'password' }
818 const res = await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) 818 const res = await createUser({
819 url: servers[ 0 ].url,
820 accessToken: servers[ 0 ].accessToken,
821 username: user.username,
822 password: user.password
823 })
819 824
820 const userId = res.body.user.id 825 const userId = res.body.user.id
821 const userAccessToken = await userLogin(servers[0], user) 826 const userAccessToken = await userLogin(servers[0], user)
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
index 0b4e66369..e1b5fb193 100644
--- a/server/tests/api/videos/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -78,7 +78,7 @@ describe('Test video privacy', function () {
78 username: 'hello', 78 username: 'hello',
79 password: 'super password' 79 password: 'super password'
80 } 80 }
81 await createUser(servers[0].url, servers[0].accessToken, user.username, user.password) 81 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: user.username, password: user.password })
82 82
83 const token = await userLogin(servers[0], user) 83 const token = await userLogin(servers[0], user)
84 await getVideoWithToken(servers[0].url, token, privateVideoUUID, 403) 84 await getVideoWithToken(servers[0].url, token, privateVideoUUID, 403)
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts
index 59e37ad86..920ca0023 100644
--- a/server/tests/api/videos/videos-filter.ts
+++ b/server/tests/api/videos/videos-filter.ts
@@ -64,13 +64,15 @@ describe('Test videos filter validator', function () {
64 for (const server of servers) { 64 for (const server of servers) {
65 const moderator = { username: 'moderator', password: 'my super password' } 65 const moderator = { username: 'moderator', password: 'my super password' }
66 await createUser( 66 await createUser(
67 server.url, 67 {
68 server.accessToken, 68 url: server.url,
69 moderator.username, 69 accessToken: server.accessToken,
70 moderator.password, 70 username: moderator.username,
71 undefined, 71 password: moderator.password,
72 undefined, 72 videoQuota: undefined,
73 UserRole.MODERATOR 73 videoQuotaDaily: undefined,
74 role: UserRole.MODERATOR
75 }
74 ) 76 )
75 server['moderatorAccessToken'] = await userLogin(server, moderator) 77 server['moderatorAccessToken'] = await userLogin(server, moderator)
76 78
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index f7d3a6aeb..ab40bb64c 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -58,7 +58,7 @@ describe('Test videos history', function () {
58 username: 'user_1', 58 username: 'user_1',
59 password: 'super password' 59 password: 'super password'
60 } 60 }
61 await createUser(server.url, server.accessToken, user.username, user.password) 61 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
62 userAccessToken = await userLogin(server, user) 62 userAccessToken = await userLogin(server, user)
63 }) 63 })
64 64
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts
index e2836d0c3..b0ae876d3 100644
--- a/server/tests/cli/peertube.ts
+++ b/server/tests/cli/peertube.ts
@@ -24,7 +24,7 @@ describe('Test CLI wrapper', function () {
24 server = await runServer(1) 24 server = await runServer(1)
25 await setAccessTokensToServers([ server ]) 25 await setAccessTokensToServers([ server ])
26 26
27 await createUser(server.url, server.accessToken, 'user_1', 'super password') 27 await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super password' })
28 }) 28 })
29 29
30 it('Should display no selected instance', async function () { 30 it('Should display no selected instance', async function () {
diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts
index 1b65f7e39..4c9f0c5f8 100644
--- a/server/tests/cli/reset-password.ts
+++ b/server/tests/cli/reset-password.ts
@@ -22,7 +22,7 @@ describe('Test reset password scripts', function () {
22 server = await runServer(1) 22 server = await runServer(1)
23 await setAccessTokensToServers([ server ]) 23 await setAccessTokensToServers([ server ])
24 24
25 await createUser(server.url, server.accessToken, 'user_1', 'super password') 25 await createUser({ url: server.url, accessToken: server.accessToken, username: 'user_1', password: 'super password' })
26 }) 26 })
27 27
28 it('Should change the user password from CLI', async function () { 28 it('Should change the user password from CLI', async function () {
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index d38bb4331..39533edea 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -50,7 +50,7 @@ describe('Test update host scripts', function () {
50 await uploadVideo(server.url, server.accessToken, videoAttributes) 50 await uploadVideo(server.url, server.accessToken, videoAttributes)
51 51
52 // Create a user 52 // Create a user
53 await createUser(server.url, server.accessToken, 'toto', 'coucou') 53 await createUser({ url: server.url, accessToken: server.accessToken, username: 'toto', password: 'coucou' })
54 54
55 // Create channel 55 // Create channel
56 const videoChannel = { 56 const videoChannel = {
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index a771474bc..d632be427 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -50,7 +50,7 @@ describe('Test syndication feeds', () => {
50 50
51 { 51 {
52 const attr = { username: 'john', password: 'password' } 52 const attr = { username: 'john', password: 'password' }
53 await createUser(servers[0].url, servers[0].accessToken, attr.username, attr.password) 53 await createUser({ url: servers[ 0 ].url, accessToken: servers[ 0 ].accessToken, username: attr.username, password: attr.password })
54 userAccessToken = await userLogin(servers[0], attr) 54 userAccessToken = await userLogin(servers[0], attr)
55 55
56 const res = await getMyUserInformation(servers[0].url, userAccessToken) 56 const res = await getMyUserInformation(servers[0].url, userAccessToken)
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts
index 5f82719da..104876f2f 100644
--- a/server/tests/misc-endpoints.ts
+++ b/server/tests/misc-endpoints.ts
@@ -149,8 +149,8 @@ describe('Test misc endpoints', function () {
149 await addVideoChannel(server.url, server.accessToken, { name: 'channel1', displayName: 'channel 1' }) 149 await addVideoChannel(server.url, server.accessToken, { name: 'channel1', displayName: 'channel 1' })
150 await addVideoChannel(server.url, server.accessToken, { name: 'channel2', displayName: 'channel 2' }) 150 await addVideoChannel(server.url, server.accessToken, { name: 'channel2', displayName: 'channel 2' })
151 151
152 await createUser(server.url, server.accessToken, 'user1', 'password') 152 await createUser({ url: server.url, accessToken: server.accessToken, username: 'user1', password: 'password' })
153 await createUser(server.url, server.accessToken, 'user2', 'password') 153 await createUser({ url: server.url, accessToken: server.accessToken, username: 'user2', password: 'password' })
154 154
155 const res = await makeGetRequest({ 155 const res = await makeGetRequest({
156 url: server.url, 156 url: server.url,
diff --git a/server/tests/real-world/populate-database.ts b/server/tests/real-world/populate-database.ts
index 016503498..3616127ad 100644
--- a/server/tests/real-world/populate-database.ts
+++ b/server/tests/real-world/populate-database.ts
@@ -78,7 +78,7 @@ function createUserCustom (server: ServerInfo) {
78 const username = Date.now().toString() + getRandomInt(0, 100000) 78 const username = Date.now().toString() + getRandomInt(0, 100000)
79 console.log('Creating user %s.', username) 79 console.log('Creating user %s.', username)
80 80
81 return createUser(server.url, server.accessToken, username, 'coucou') 81 return createUser({ url: server.url, accessToken: server.accessToken, username: username, password: 'coucou' })
82} 82}
83 83
84function uploadCustom (server: ServerInfo) { 84function uploadCustom (server: ServerInfo) {