aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/activitypub/cleaner.ts52
-rw-r--r--server/tests/api/activitypub/client.ts6
-rw-r--r--server/tests/api/activitypub/fetch.ts18
-rw-r--r--server/tests/api/activitypub/refresher.ts52
-rw-r--r--server/tests/api/activitypub/security.ts8
-rw-r--r--server/tests/api/check-params/abuses.ts28
-rw-r--r--server/tests/api/check-params/accounts.ts2
-rw-r--r--server/tests/api/check-params/blocklist.ts4
-rw-r--r--server/tests/api/check-params/bulk.ts4
-rw-r--r--server/tests/api/check-params/config.ts4
-rw-r--r--server/tests/api/check-params/contact-form.ts2
-rw-r--r--server/tests/api/check-params/custom-pages.ts4
-rw-r--r--server/tests/api/check-params/debug.ts4
-rw-r--r--server/tests/api/check-params/follows.ts4
-rw-r--r--server/tests/api/check-params/jobs.ts4
-rw-r--r--server/tests/api/check-params/live.ts30
-rw-r--r--server/tests/api/check-params/logs.ts4
-rw-r--r--server/tests/api/check-params/plugins.ts8
-rw-r--r--server/tests/api/check-params/redundancy.ts10
-rw-r--r--server/tests/api/check-params/search.ts2
-rw-r--r--server/tests/api/check-params/services.ts20
-rw-r--r--server/tests/api/check-params/upload-quota.ts30
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts4
-rw-r--r--server/tests/api/check-params/users.ts74
-rw-r--r--server/tests/api/check-params/video-blacklist.ts60
-rw-r--r--server/tests/api/check-params/video-captions.ts8
-rw-r--r--server/tests/api/check-params/video-channels.ts8
-rw-r--r--server/tests/api/check-params/video-comments.ts20
-rw-r--r--server/tests/api/check-params/video-imports.ts16
-rw-r--r--server/tests/api/check-params/video-playlists.ts16
-rw-r--r--server/tests/api/check-params/videos-filter.ts8
-rw-r--r--server/tests/api/check-params/videos-history.ts2
-rw-r--r--server/tests/api/check-params/videos-overviews.ts6
-rw-r--r--server/tests/api/check-params/videos.ts34
-rw-r--r--server/tests/api/live/live-constraints.ts24
-rw-r--r--server/tests/api/live/live-permanent.ts32
-rw-r--r--server/tests/api/live/live-save-replay.ts52
-rw-r--r--server/tests/api/live/live-socket-messages.ts38
-rw-r--r--server/tests/api/live/live-views.ts20
-rw-r--r--server/tests/api/live/live.ts72
-rw-r--r--server/tests/api/moderation/abuses.ts96
-rw-r--r--server/tests/api/moderation/blocklist-notification.ts46
-rw-r--r--server/tests/api/moderation/blocklist.ts76
-rw-r--r--server/tests/api/moderation/video-blacklist.ts58
-rw-r--r--server/tests/api/notifications/admin-notifications.ts12
-rw-r--r--server/tests/api/notifications/comments-notifications.ts92
-rw-r--r--server/tests/api/notifications/moderation-notifications.ts118
-rw-r--r--server/tests/api/notifications/notifications-api.ts42
-rw-r--r--server/tests/api/notifications/user-notifications.ts40
-rw-r--r--server/tests/api/redundancy/manage-redundancy.ts14
-rw-r--r--server/tests/api/redundancy/redundancy-constraints.ts24
-rw-r--r--server/tests/api/redundancy/redundancy.ts62
-rw-r--r--server/tests/api/search/search-activitypub-video-channels.ts32
-rw-r--r--server/tests/api/search/search-activitypub-video-playlists.ts28
-rw-r--r--server/tests/api/search/search-activitypub-videos.ts14
-rw-r--r--server/tests/api/search/search-channels.ts6
-rw-r--r--server/tests/api/search/search-index.ts14
-rw-r--r--server/tests/api/search/search-playlists.ts20
-rw-r--r--server/tests/api/search/search-videos.ts46
-rw-r--r--server/tests/api/server/auto-follows.ts20
-rw-r--r--server/tests/api/server/bulk.ts48
-rw-r--r--server/tests/api/server/config.ts36
-rw-r--r--server/tests/api/server/contact-form.ts2
-rw-r--r--server/tests/api/server/email.ts42
-rw-r--r--server/tests/api/server/follow-constraints.ts58
-rw-r--r--server/tests/api/server/follows-moderation.ts18
-rw-r--r--server/tests/api/server/follows.ts72
-rw-r--r--server/tests/api/server/handle-down.ts58
-rw-r--r--server/tests/api/server/homepage.ts4
-rw-r--r--server/tests/api/server/jobs.ts12
-rw-r--r--server/tests/api/server/logs.ts28
-rw-r--r--server/tests/api/server/plugins.ts20
-rw-r--r--server/tests/api/server/reverse-proxy.ts42
-rw-r--r--server/tests/api/server/services.ts22
-rw-r--r--server/tests/api/server/stats.ts60
-rw-r--r--server/tests/api/server/tracker.ts4
-rw-r--r--server/tests/api/users/user-subscriptions.ts34
-rw-r--r--server/tests/api/users/users-multiple-servers.ts40
-rw-r--r--server/tests/api/users/users-verification.ts34
-rw-r--r--server/tests/api/users/users.ts262
-rw-r--r--server/tests/api/videos/audio-only.ts8
-rw-r--r--server/tests/api/videos/multiple-servers.ts168
-rw-r--r--server/tests/api/videos/resumable-upload.ts18
-rw-r--r--server/tests/api/videos/single-server.ts90
-rw-r--r--server/tests/api/videos/video-captions.ts24
-rw-r--r--server/tests/api/videos/video-change-ownership.ts50
-rw-r--r--server/tests/api/videos/video-channels.ts92
-rw-r--r--server/tests/api/videos/video-comments.ts8
-rw-r--r--server/tests/api/videos/video-description.ts16
-rw-r--r--server/tests/api/videos/video-hls.ts22
-rw-r--r--server/tests/api/videos/video-imports.ts44
-rw-r--r--server/tests/api/videos/video-nsfw.ts52
-rw-r--r--server/tests/api/videos/video-playlist-thumbnails.ts36
-rw-r--r--server/tests/api/videos/video-playlists.ts184
-rw-r--r--server/tests/api/videos/video-privacy.ts56
-rw-r--r--server/tests/api/videos/video-schedule-update.ts20
-rw-r--r--server/tests/api/videos/video-transcoder.ts122
-rw-r--r--server/tests/api/videos/videos-filter.ts10
-rw-r--r--server/tests/api/videos/videos-history.ts30
-rw-r--r--server/tests/api/videos/videos-overview.ts24
-rw-r--r--server/tests/api/videos/videos-views-cleaner.ts22
-rw-r--r--server/tests/cli/create-import-video-file-job.ts22
-rw-r--r--server/tests/cli/create-transcoding-job.ts38
-rw-r--r--server/tests/cli/optimize-old-videos.ts18
-rw-r--r--server/tests/cli/peertube.ts28
-rw-r--r--server/tests/cli/plugins.ts10
-rw-r--r--server/tests/cli/prune-storage.ts30
-rw-r--r--server/tests/cli/regenerate-thumbnails.ts20
-rw-r--r--server/tests/cli/reset-password.ts6
-rw-r--r--server/tests/cli/update-host.ts24
-rw-r--r--server/tests/client.ts76
-rw-r--r--server/tests/external-plugins/auth-ldap.ts34
-rw-r--r--server/tests/external-plugins/auto-block-videos.ts22
-rw-r--r--server/tests/external-plugins/auto-mute.ts34
-rw-r--r--server/tests/feeds/feeds.ts110
-rw-r--r--server/tests/misc-endpoints.ts14
-rw-r--r--server/tests/plugins/action-hooks.ts40
-rw-r--r--server/tests/plugins/external-auth.ts66
-rw-r--r--server/tests/plugins/filter-hooks.ts160
-rw-r--r--server/tests/plugins/html-injection.ts2
-rw-r--r--server/tests/plugins/id-and-pass-auth.ts64
-rw-r--r--server/tests/plugins/plugin-helpers.ts42
-rw-r--r--server/tests/plugins/plugin-router.ts4
-rw-r--r--server/tests/plugins/plugin-storage.ts12
-rw-r--r--server/tests/plugins/plugin-transcoding.ts52
-rw-r--r--server/tests/plugins/plugin-unloading.ts6
-rw-r--r--server/tests/plugins/translations.ts2
-rw-r--r--server/tests/plugins/video-constants.ts32
128 files changed, 2307 insertions, 2307 deletions
diff --git a/server/tests/api/activitypub/cleaner.ts b/server/tests/api/activitypub/cleaner.ts
index dcf758711..1421824da 100644
--- a/server/tests/api/activitypub/cleaner.ts
+++ b/server/tests/api/activitypub/cleaner.ts
@@ -46,9 +46,9 @@ describe('Test AP cleaner', function () {
46 // Create 1 comment per video 46 // Create 1 comment per video
47 // Update 1 remote URL and 1 local URL on 47 // Update 1 remote URL and 1 local URL on
48 48
49 videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'server 1' })).uuid 49 videoUUID1 = (await servers[0].videos.quickUpload({ name: 'server 1' })).uuid
50 videoUUID2 = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid 50 videoUUID2 = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid
51 videoUUID3 = (await servers[2].videosCommand.quickUpload({ name: 'server 3' })).uuid 51 videoUUID3 = (await servers[2].videos.quickUpload({ name: 'server 3' })).uuid
52 52
53 videoUUIDs = [ videoUUID1, videoUUID2, videoUUID3 ] 53 videoUUIDs = [ videoUUID1, videoUUID2, videoUUID3 ]
54 54
@@ -56,8 +56,8 @@ describe('Test AP cleaner', function () {
56 56
57 for (const server of servers) { 57 for (const server of servers) {
58 for (const uuid of videoUUIDs) { 58 for (const uuid of videoUUIDs) {
59 await server.videosCommand.rate({ id: uuid, rating: 'like' }) 59 await server.videos.rate({ id: uuid, rating: 'like' })
60 await server.commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 60 await server.comments.createThread({ videoId: uuid, text: 'comment' })
61 } 61 }
62 } 62 }
63 63
@@ -67,7 +67,7 @@ describe('Test AP cleaner', function () {
67 it('Should have the correct likes', async function () { 67 it('Should have the correct likes', async function () {
68 for (const server of servers) { 68 for (const server of servers) {
69 for (const uuid of videoUUIDs) { 69 for (const uuid of videoUUIDs) {
70 const video = await server.videosCommand.get({ id: uuid }) 70 const video = await server.videos.get({ id: uuid })
71 71
72 expect(video.likes).to.equal(3) 72 expect(video.likes).to.equal(3)
73 expect(video.dislikes).to.equal(0) 73 expect(video.dislikes).to.equal(0)
@@ -78,9 +78,9 @@ describe('Test AP cleaner', function () {
78 it('Should destroy server 3 internal likes and correctly clean them', async function () { 78 it('Should destroy server 3 internal likes and correctly clean them', async function () {
79 this.timeout(20000) 79 this.timeout(20000)
80 80
81 await servers[2].sqlCommand.deleteAll('accountVideoRate') 81 await servers[2].sql.deleteAll('accountVideoRate')
82 for (const uuid of videoUUIDs) { 82 for (const uuid of videoUUIDs) {
83 await servers[2].sqlCommand.setVideoField(uuid, 'likes', '0') 83 await servers[2].sql.setVideoField(uuid, 'likes', '0')
84 } 84 }
85 85
86 await wait(5000) 86 await wait(5000)
@@ -88,14 +88,14 @@ describe('Test AP cleaner', function () {
88 88
89 // Updated rates of my video 89 // Updated rates of my video
90 { 90 {
91 const video = await servers[0].videosCommand.get({ id: videoUUID1 }) 91 const video = await servers[0].videos.get({ id: videoUUID1 })
92 expect(video.likes).to.equal(2) 92 expect(video.likes).to.equal(2)
93 expect(video.dislikes).to.equal(0) 93 expect(video.dislikes).to.equal(0)
94 } 94 }
95 95
96 // Did not update rates of a remote video 96 // Did not update rates of a remote video
97 { 97 {
98 const video = await servers[0].videosCommand.get({ id: videoUUID2 }) 98 const video = await servers[0].videos.get({ id: videoUUID2 })
99 expect(video.likes).to.equal(3) 99 expect(video.likes).to.equal(3)
100 expect(video.dislikes).to.equal(0) 100 expect(video.dislikes).to.equal(0)
101 } 101 }
@@ -106,7 +106,7 @@ describe('Test AP cleaner', function () {
106 106
107 for (const server of servers) { 107 for (const server of servers) {
108 for (const uuid of videoUUIDs) { 108 for (const uuid of videoUUIDs) {
109 await server.videosCommand.rate({ id: uuid, rating: 'dislike' }) 109 await server.videos.rate({ id: uuid, rating: 'dislike' })
110 } 110 }
111 } 111 }
112 112
@@ -114,7 +114,7 @@ describe('Test AP cleaner', function () {
114 114
115 for (const server of servers) { 115 for (const server of servers) {
116 for (const uuid of videoUUIDs) { 116 for (const uuid of videoUUIDs) {
117 const video = await server.videosCommand.get({ id: uuid }) 117 const video = await server.videos.get({ id: uuid })
118 expect(video.likes).to.equal(0) 118 expect(video.likes).to.equal(0)
119 expect(video.dislikes).to.equal(3) 119 expect(video.dislikes).to.equal(3)
120 } 120 }
@@ -124,10 +124,10 @@ describe('Test AP cleaner', function () {
124 it('Should destroy server 3 internal dislikes and correctly clean them', async function () { 124 it('Should destroy server 3 internal dislikes and correctly clean them', async function () {
125 this.timeout(20000) 125 this.timeout(20000)
126 126
127 await servers[2].sqlCommand.deleteAll('accountVideoRate') 127 await servers[2].sql.deleteAll('accountVideoRate')
128 128
129 for (const uuid of videoUUIDs) { 129 for (const uuid of videoUUIDs) {
130 await servers[2].sqlCommand.setVideoField(uuid, 'dislikes', '0') 130 await servers[2].sql.setVideoField(uuid, 'dislikes', '0')
131 } 131 }
132 132
133 await wait(5000) 133 await wait(5000)
@@ -135,14 +135,14 @@ describe('Test AP cleaner', function () {
135 135
136 // Updated rates of my video 136 // Updated rates of my video
137 { 137 {
138 const video = await servers[0].videosCommand.get({ id: videoUUID1 }) 138 const video = await servers[0].videos.get({ id: videoUUID1 })
139 expect(video.likes).to.equal(0) 139 expect(video.likes).to.equal(0)
140 expect(video.dislikes).to.equal(2) 140 expect(video.dislikes).to.equal(2)
141 } 141 }
142 142
143 // Did not update rates of a remote video 143 // Did not update rates of a remote video
144 { 144 {
145 const video = await servers[0].videosCommand.get({ id: videoUUID2 }) 145 const video = await servers[0].videos.get({ id: videoUUID2 })
146 expect(video.likes).to.equal(0) 146 expect(video.likes).to.equal(0)
147 expect(video.dislikes).to.equal(3) 147 expect(video.dislikes).to.equal(3)
148 } 148 }
@@ -151,15 +151,15 @@ describe('Test AP cleaner', function () {
151 it('Should destroy server 3 internal shares and correctly clean them', async function () { 151 it('Should destroy server 3 internal shares and correctly clean them', async function () {
152 this.timeout(20000) 152 this.timeout(20000)
153 153
154 const preCount = await servers[0].sqlCommand.getCount('videoShare') 154 const preCount = await servers[0].sql.getCount('videoShare')
155 expect(preCount).to.equal(6) 155 expect(preCount).to.equal(6)
156 156
157 await servers[2].sqlCommand.deleteAll('videoShare') 157 await servers[2].sql.deleteAll('videoShare')
158 await wait(5000) 158 await wait(5000)
159 await waitJobs(servers) 159 await waitJobs(servers)
160 160
161 // Still 6 because we don't have remote shares on local videos 161 // Still 6 because we don't have remote shares on local videos
162 const postCount = await servers[0].sqlCommand.getCount('videoShare') 162 const postCount = await servers[0].sql.getCount('videoShare')
163 expect(postCount).to.equal(6) 163 expect(postCount).to.equal(6)
164 }) 164 })
165 165
@@ -167,17 +167,17 @@ describe('Test AP cleaner', function () {
167 this.timeout(20000) 167 this.timeout(20000)
168 168
169 { 169 {
170 const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID1 }) 170 const { total } = await servers[0].comments.listThreads({ videoId: videoUUID1 })
171 expect(total).to.equal(3) 171 expect(total).to.equal(3)
172 } 172 }
173 173
174 await servers[2].sqlCommand.deleteAll('videoComment') 174 await servers[2].sql.deleteAll('videoComment')
175 175
176 await wait(5000) 176 await wait(5000)
177 await waitJobs(servers) 177 await waitJobs(servers)
178 178
179 { 179 {
180 const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID1 }) 180 const { total } = await servers[0].comments.listThreads({ videoId: videoUUID1 })
181 expect(total).to.equal(2) 181 expect(total).to.equal(2)
182 } 182 }
183 }) 183 })
@@ -188,7 +188,7 @@ describe('Test AP cleaner', function () {
188 async function check (like: string, ofServerUrl: string, urlSuffix: string, remote: 'true' | 'false') { 188 async function check (like: string, ofServerUrl: string, urlSuffix: string, remote: 'true' | 'false') {
189 const query = `SELECT "videoId", "accountVideoRate".url FROM "accountVideoRate" ` + 189 const query = `SELECT "videoId", "accountVideoRate".url FROM "accountVideoRate" ` +
190 `INNER JOIN video ON "accountVideoRate"."videoId" = video.id AND remote IS ${remote} WHERE "accountVideoRate"."url" LIKE '${like}'` 190 `INNER JOIN video ON "accountVideoRate"."videoId" = video.id AND remote IS ${remote} WHERE "accountVideoRate"."url" LIKE '${like}'`
191 const res = await servers[0].sqlCommand.selectQuery(query) 191 const res = await servers[0].sql.selectQuery(query)
192 192
193 for (const rate of res) { 193 for (const rate of res) {
194 const matcher = new RegExp(`^${ofServerUrl}/accounts/root/dislikes/\\d+${urlSuffix}$`) 194 const matcher = new RegExp(`^${ofServerUrl}/accounts/root/dislikes/\\d+${urlSuffix}$`)
@@ -217,7 +217,7 @@ describe('Test AP cleaner', function () {
217 217
218 { 218 {
219 const query = `UPDATE "accountVideoRate" SET url = url || 'stan'` 219 const query = `UPDATE "accountVideoRate" SET url = url || 'stan'`
220 await servers[1].sqlCommand.updateQuery(query) 220 await servers[1].sql.updateQuery(query)
221 221
222 await wait(5000) 222 await wait(5000)
223 await waitJobs(servers) 223 await waitJobs(servers)
@@ -234,7 +234,7 @@ describe('Test AP cleaner', function () {
234 const query = `SELECT "videoId", "videoComment".url, uuid as "videoUUID" FROM "videoComment" ` + 234 const query = `SELECT "videoId", "videoComment".url, uuid as "videoUUID" FROM "videoComment" ` +
235 `INNER JOIN video ON "videoComment"."videoId" = video.id AND remote IS ${remote} WHERE "videoComment"."url" LIKE '${like}'` 235 `INNER JOIN video ON "videoComment"."videoId" = video.id AND remote IS ${remote} WHERE "videoComment"."url" LIKE '${like}'`
236 236
237 const res = await servers[0].sqlCommand.selectQuery(query) 237 const res = await servers[0].sql.selectQuery(query)
238 238
239 for (const comment of res) { 239 for (const comment of res) {
240 const matcher = new RegExp(`${ofServerUrl}/videos/watch/${comment.videoUUID}/comments/\\d+${urlSuffix}`) 240 const matcher = new RegExp(`${ofServerUrl}/videos/watch/${comment.videoUUID}/comments/\\d+${urlSuffix}`)
@@ -260,7 +260,7 @@ describe('Test AP cleaner', function () {
260 260
261 { 261 {
262 const query = `UPDATE "videoComment" SET url = url || 'kyle'` 262 const query = `UPDATE "videoComment" SET url = url || 'kyle'`
263 await servers[1].sqlCommand.updateQuery(query) 263 await servers[1].sql.updateQuery(query)
264 264
265 await wait(5000) 265 await wait(5000)
266 await waitJobs(servers) 266 await waitJobs(servers)
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts
index 0190df04c..5845045a3 100644
--- a/server/tests/api/activitypub/client.ts
+++ b/server/tests/api/activitypub/client.ts
@@ -68,12 +68,12 @@ describe('Test activitypub', function () {
68 await setDefaultVideoChannel(servers) 68 await setDefaultVideoChannel(servers)
69 69
70 { 70 {
71 video = await await servers[0].videosCommand.quickUpload({ name: 'video' }) 71 video = await await servers[0].videos.quickUpload({ name: 'video' })
72 } 72 }
73 73
74 { 74 {
75 const attributes = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].videoChannel.id } 75 const attributes = { displayName: 'playlist', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[0].store.channel.id }
76 playlist = await servers[0].playlistsCommand.create({ attributes }) 76 playlist = await servers[0].playlists.create({ attributes })
77 } 77 }
78 78
79 await doubleFollow(servers[0], servers[1]) 79 await doubleFollow(servers[0], servers[1])
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts
index 5ab4a85d7..34694a773 100644
--- a/server/tests/api/activitypub/fetch.ts
+++ b/server/tests/api/activitypub/fetch.ts
@@ -21,24 +21,24 @@ describe('Test ActivityPub fetcher', function () {
21 21
22 const user = { username: 'user1', password: 'password' } 22 const user = { username: 'user1', password: 'password' }
23 for (const server of servers) { 23 for (const server of servers) {
24 await server.usersCommand.create({ username: user.username, password: user.password }) 24 await server.users.create({ username: user.username, password: user.password })
25 } 25 }
26 26
27 const userAccessToken = await servers[0].loginCommand.getAccessToken(user) 27 const userAccessToken = await servers[0].login.getAccessToken(user)
28 28
29 await servers[0].videosCommand.upload({ attributes: { name: 'video root' } }) 29 await servers[0].videos.upload({ attributes: { name: 'video root' } })
30 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'bad video root' } }) 30 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'bad video root' } })
31 await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'video user' } }) 31 await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'video user' } })
32 32
33 { 33 {
34 const to = 'http://localhost:' + servers[0].port + '/accounts/user1' 34 const to = 'http://localhost:' + servers[0].port + '/accounts/user1'
35 const value = 'http://localhost:' + servers[1].port + '/accounts/user1' 35 const value = 'http://localhost:' + servers[1].port + '/accounts/user1'
36 await servers[0].sqlCommand.setActorField(to, 'url', value) 36 await servers[0].sql.setActorField(to, 'url', value)
37 } 37 }
38 38
39 { 39 {
40 const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid 40 const value = 'http://localhost:' + servers[2].port + '/videos/watch/' + uuid
41 await servers[0].sqlCommand.setVideoField(uuid, 'url', value) 41 await servers[0].sql.setVideoField(uuid, 'url', value)
42 } 42 }
43 }) 43 })
44 44
@@ -49,7 +49,7 @@ describe('Test ActivityPub fetcher', function () {
49 await waitJobs(servers) 49 await waitJobs(servers)
50 50
51 { 51 {
52 const { total, data } = await servers[0].videosCommand.list({ sort: 'createdAt' }) 52 const { total, data } = await servers[0].videos.list({ sort: 'createdAt' })
53 53
54 expect(total).to.equal(3) 54 expect(total).to.equal(3)
55 expect(data[0].name).to.equal('video root') 55 expect(data[0].name).to.equal('video root')
@@ -58,7 +58,7 @@ describe('Test ActivityPub fetcher', function () {
58 } 58 }
59 59
60 { 60 {
61 const { total, data } = await servers[1].videosCommand.list({ sort: 'createdAt' }) 61 const { total, data } = await servers[1].videos.list({ sort: 'createdAt' })
62 62
63 expect(total).to.equal(1) 63 expect(total).to.equal(1)
64 expect(data[0].name).to.equal('video root') 64 expect(data[0].name).to.equal('video root')
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts
index 5af4b1edb..d2f71e857 100644
--- a/server/tests/api/activitypub/refresher.ts
+++ b/server/tests/api/activitypub/refresher.ts
@@ -34,28 +34,28 @@ describe('Test AP refresher', function () {
34 await setDefaultVideoChannel(servers) 34 await setDefaultVideoChannel(servers)
35 35
36 { 36 {
37 videoUUID1 = (await servers[1].videosCommand.quickUpload({ name: 'video1' })).uuid 37 videoUUID1 = (await servers[1].videos.quickUpload({ name: 'video1' })).uuid
38 videoUUID2 = (await servers[1].videosCommand.quickUpload({ name: 'video2' })).uuid 38 videoUUID2 = (await servers[1].videos.quickUpload({ name: 'video2' })).uuid
39 videoUUID3 = (await servers[1].videosCommand.quickUpload({ name: 'video3' })).uuid 39 videoUUID3 = (await servers[1].videos.quickUpload({ name: 'video3' })).uuid
40 } 40 }
41 41
42 { 42 {
43 const token1 = await servers[1].usersCommand.generateUserAndToken('user1') 43 const token1 = await servers[1].users.generateUserAndToken('user1')
44 await servers[1].videosCommand.upload({ token: token1, attributes: { name: 'video4' } }) 44 await servers[1].videos.upload({ token: token1, attributes: { name: 'video4' } })
45 45
46 const token2 = await servers[1].usersCommand.generateUserAndToken('user2') 46 const token2 = await servers[1].users.generateUserAndToken('user2')
47 await servers[1].videosCommand.upload({ token: token2, attributes: { name: 'video5' } }) 47 await servers[1].videos.upload({ token: token2, attributes: { name: 'video5' } })
48 } 48 }
49 49
50 { 50 {
51 const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } 51 const attributes = { displayName: 'playlist1', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].store.channel.id }
52 const created = await servers[1].playlistsCommand.create({ attributes }) 52 const created = await servers[1].playlists.create({ attributes })
53 playlistUUID1 = created.uuid 53 playlistUUID1 = created.uuid
54 } 54 }
55 55
56 { 56 {
57 const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].videoChannel.id } 57 const attributes = { displayName: 'playlist2', privacy: VideoPlaylistPrivacy.PUBLIC, videoChannelId: servers[1].store.channel.id }
58 const created = await servers[1].playlistsCommand.create({ attributes }) 58 const created = await servers[1].playlists.create({ attributes })
59 playlistUUID2 = created.uuid 59 playlistUUID2 = created.uuid
60 } 60 }
61 61
@@ -70,15 +70,15 @@ describe('Test AP refresher', function () {
70 await wait(10000) 70 await wait(10000)
71 71
72 // Change UUID so the remote server returns a 404 72 // Change UUID so the remote server returns a 404
73 await servers[1].sqlCommand.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f') 73 await servers[1].sql.setVideoField(videoUUID1, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174f')
74 74
75 await servers[0].videosCommand.get({ id: videoUUID1 }) 75 await servers[0].videos.get({ id: videoUUID1 })
76 await servers[0].videosCommand.get({ id: videoUUID2 }) 76 await servers[0].videos.get({ id: videoUUID2 })
77 77
78 await waitJobs(servers) 78 await waitJobs(servers)
79 79
80 await servers[0].videosCommand.get({ id: videoUUID1, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 80 await servers[0].videos.get({ id: videoUUID1, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
81 await servers[0].videosCommand.get({ id: videoUUID2 }) 81 await servers[0].videos.get({ id: videoUUID2 })
82 }) 82 })
83 83
84 it('Should not update a remote video if the remote instance is down', async function () { 84 it('Should not update a remote video if the remote instance is down', async function () {
@@ -86,18 +86,18 @@ describe('Test AP refresher', function () {
86 86
87 await killallServers([ servers[1] ]) 87 await killallServers([ servers[1] ])
88 88
89 await servers[1].sqlCommand.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e') 89 await servers[1].sql.setVideoField(videoUUID3, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b174e')
90 90
91 // Video will need a refresh 91 // Video will need a refresh
92 await wait(10000) 92 await wait(10000)
93 93
94 await servers[0].videosCommand.get({ id: videoUUID3 }) 94 await servers[0].videos.get({ id: videoUUID3 })
95 // The refresh should fail 95 // The refresh should fail
96 await waitJobs([ servers[0] ]) 96 await waitJobs([ servers[0] ])
97 97
98 await reRunServer(servers[1]) 98 await reRunServer(servers[1])
99 99
100 await servers[0].videosCommand.get({ id: videoUUID3 }) 100 await servers[0].videos.get({ id: videoUUID3 })
101 }) 101 })
102 }) 102 })
103 103
@@ -106,13 +106,13 @@ describe('Test AP refresher', function () {
106 it('Should remove a deleted actor', async function () { 106 it('Should remove a deleted actor', async function () {
107 this.timeout(60000) 107 this.timeout(60000)
108 108
109 const command = servers[0].accountsCommand 109 const command = servers[0].accounts
110 110
111 await wait(10000) 111 await wait(10000)
112 112
113 // Change actor name so the remote server returns a 404 113 // Change actor name so the remote server returns a 404
114 const to = 'http://localhost:' + servers[1].port + '/accounts/user2' 114 const to = 'http://localhost:' + servers[1].port + '/accounts/user2'
115 await servers[1].sqlCommand.setActorField(to, 'preferredUsername', 'toto') 115 await servers[1].sql.setActorField(to, 'preferredUsername', 'toto')
116 116
117 await command.get({ accountName: 'user1@localhost:' + servers[1].port }) 117 await command.get({ accountName: 'user1@localhost:' + servers[1].port })
118 await command.get({ accountName: 'user2@localhost:' + servers[1].port }) 118 await command.get({ accountName: 'user2@localhost:' + servers[1].port })
@@ -132,15 +132,15 @@ describe('Test AP refresher', function () {
132 await wait(10000) 132 await wait(10000)
133 133
134 // Change UUID so the remote server returns a 404 134 // Change UUID so the remote server returns a 404
135 await servers[1].sqlCommand.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e') 135 await servers[1].sql.setPlaylistField(playlistUUID2, 'uuid', '304afe4f-39f9-4d49-8ed7-ac57b86b178e')
136 136
137 await servers[0].playlistsCommand.get({ playlistId: playlistUUID1 }) 137 await servers[0].playlists.get({ playlistId: playlistUUID1 })
138 await servers[0].playlistsCommand.get({ playlistId: playlistUUID2 }) 138 await servers[0].playlists.get({ playlistId: playlistUUID2 })
139 139
140 await waitJobs(servers) 140 await waitJobs(servers)
141 141
142 await servers[0].playlistsCommand.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 }) 142 await servers[0].playlists.get({ playlistId: playlistUUID1, expectedStatus: HttpStatusCode.OK_200 })
143 await servers[0].playlistsCommand.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 143 await servers[0].playlists.get({ playlistId: playlistUUID2, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
144 }) 144 })
145 }) 145 })
146 146
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index c32940070..ab0eb256e 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -24,8 +24,8 @@ function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey:
24 const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' 24 const url = 'http://localhost:' + ofServer.port + '/accounts/peertube'
25 25
26 return Promise.all([ 26 return Promise.all([
27 onServer.sqlCommand.setActorField(url, 'publicKey', publicKey), 27 onServer.sql.setActorField(url, 'publicKey', publicKey),
28 onServer.sqlCommand.setActorField(url, 'privateKey', privateKey) 28 onServer.sql.setActorField(url, 'privateKey', privateKey)
29 ]) 29 ])
30} 30}
31 31
@@ -33,8 +33,8 @@ function setUpdatedAtOfServer (onServer: ServerInfo, ofServer: ServerInfo, updat
33 const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' 33 const url = 'http://localhost:' + ofServer.port + '/accounts/peertube'
34 34
35 return Promise.all([ 35 return Promise.all([
36 onServer.sqlCommand.setActorField(url, 'createdAt', updatedAt), 36 onServer.sql.setActorField(url, 'createdAt', updatedAt),
37 onServer.sqlCommand.setActorField(url, 'updatedAt', updatedAt) 37 onServer.sql.setActorField(url, 'updatedAt', updatedAt)
38 ]) 38 ])
39} 39}
40 40
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts
index 199cc5599..7a6790ba8 100644
--- a/server/tests/api/check-params/abuses.ts
+++ b/server/tests/api/check-params/abuses.ts
@@ -39,12 +39,12 @@ describe('Test abuses API validators', function () {
39 39
40 await setAccessTokensToServers([ server ]) 40 await setAccessTokensToServers([ server ])
41 41
42 userToken = await server.usersCommand.generateUserAndToken('user_1') 42 userToken = await server.users.generateUserAndToken('user_1')
43 userToken2 = await server.usersCommand.generateUserAndToken('user_2') 43 userToken2 = await server.users.generateUserAndToken('user_2')
44 44
45 server.video = await server.videosCommand.upload() 45 server.store.video = await server.videos.upload()
46 46
47 command = server.abusesCommand 47 command = server.abuses
48 }) 48 })
49 49
50 describe('When listing abuses for admins', function () { 50 describe('When listing abuses for admins', function () {
@@ -224,25 +224,25 @@ describe('Test abuses API validators', function () {
224 }) 224 })
225 225
226 it('Should fail with a non authenticated user', async function () { 226 it('Should fail with a non authenticated user', async function () {
227 const fields = { video: { id: server.video.id }, reason: 'my super reason' } 227 const fields = { video: { id: server.store.video.id }, reason: 'my super reason' }
228 228
229 await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 229 await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
230 }) 230 })
231 231
232 it('Should fail with a reason too short', async function () { 232 it('Should fail with a reason too short', async function () {
233 const fields = { video: { id: server.video.id }, reason: 'h' } 233 const fields = { video: { id: server.store.video.id }, reason: 'h' }
234 234
235 await makePostBodyRequest({ url: server.url, path, token: userToken, fields }) 235 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
236 }) 236 })
237 237
238 it('Should fail with a too big reason', async function () { 238 it('Should fail with a too big reason', async function () {
239 const fields = { video: { id: server.video.id }, reason: 'super'.repeat(605) } 239 const fields = { video: { id: server.store.video.id }, reason: 'super'.repeat(605) }
240 240
241 await makePostBodyRequest({ url: server.url, path, token: userToken, fields }) 241 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
242 }) 242 })
243 243
244 it('Should succeed with the correct parameters (basic)', async function () { 244 it('Should succeed with the correct parameters (basic)', async function () {
245 const fields: AbuseCreate = { video: { id: server.video.shortUUID }, reason: 'my super reason' } 245 const fields: AbuseCreate = { video: { id: server.store.video.shortUUID }, reason: 'my super reason' }
246 246
247 const res = await makePostBodyRequest({ 247 const res = await makePostBodyRequest({
248 url: server.url, 248 url: server.url,
@@ -255,19 +255,19 @@ describe('Test abuses API validators', function () {
255 }) 255 })
256 256
257 it('Should fail with a wrong predefined reason', async function () { 257 it('Should fail with a wrong predefined reason', async function () {
258 const fields = { video: { id: server.video.id }, reason: 'my super reason', predefinedReasons: [ 'wrongPredefinedReason' ] } 258 const fields = { video: { id: server.store.video.id }, reason: 'my super reason', predefinedReasons: [ 'wrongPredefinedReason' ] }
259 259
260 await makePostBodyRequest({ url: server.url, path, token: userToken, fields }) 260 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
261 }) 261 })
262 262
263 it('Should fail with negative timestamps', async function () { 263 it('Should fail with negative timestamps', async function () {
264 const fields = { video: { id: server.video.id, startAt: -1 }, reason: 'my super reason' } 264 const fields = { video: { id: server.store.video.id, startAt: -1 }, reason: 'my super reason' }
265 265
266 await makePostBodyRequest({ url: server.url, path, token: userToken, fields }) 266 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
267 }) 267 })
268 268
269 it('Should fail mith misordered startAt/endAt', async function () { 269 it('Should fail mith misordered startAt/endAt', async function () {
270 const fields = { video: { id: server.video.id, startAt: 5, endAt: 1 }, reason: 'my super reason' } 270 const fields = { video: { id: server.store.video.id, startAt: 5, endAt: 1 }, reason: 'my super reason' }
271 271
272 await makePostBodyRequest({ url: server.url, path, token: userToken, fields }) 272 await makePostBodyRequest({ url: server.url, path, token: userToken, fields })
273 }) 273 })
@@ -275,7 +275,7 @@ describe('Test abuses API validators', function () {
275 it('Should succeed with the corret parameters (advanced)', async function () { 275 it('Should succeed with the corret parameters (advanced)', async function () {
276 const fields: AbuseCreate = { 276 const fields: AbuseCreate = {
277 video: { 277 video: {
278 id: server.video.id, 278 id: server.store.video.id,
279 startAt: 1, 279 startAt: 1,
280 endAt: 5 280 endAt: 5
281 }, 281 },
@@ -414,8 +414,8 @@ describe('Test abuses API validators', function () {
414 414
415 await doubleFollow(anotherServer, server) 415 await doubleFollow(anotherServer, server)
416 416
417 const server2VideoId = await anotherServer.videosCommand.getId({ uuid: server.video.uuid }) 417 const server2VideoId = await anotherServer.videos.getId({ uuid: server.store.video.uuid })
418 await anotherServer.abusesCommand.report({ reason: 'remote server', videoId: server2VideoId }) 418 await anotherServer.abuses.report({ reason: 'remote server', videoId: server2VideoId })
419 419
420 await waitJobs([ server, anotherServer ]) 420 await waitJobs([ server, anotherServer ])
421 421
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts
index 45d440c47..223322626 100644
--- a/server/tests/api/check-params/accounts.ts
+++ b/server/tests/api/check-params/accounts.ts
@@ -40,7 +40,7 @@ describe('Test accounts API validators', function () {
40 describe('When getting an account', function () { 40 describe('When getting an account', function () {
41 41
42 it('Should return 404 with a non existing name', async function () { 42 it('Should return 404 with a non existing name', async function () {
43 await server.accountsCommand.get({ accountName: 'arfaze', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 43 await server.accounts.get({ accountName: 'arfaze', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
44 }) 44 })
45 }) 45 })
46 46
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts
index 18238bb04..14e45e503 100644
--- a/server/tests/api/check-params/blocklist.ts
+++ b/server/tests/api/check-params/blocklist.ts
@@ -33,9 +33,9 @@ describe('Test blocklist API validators', function () {
33 server = servers[0] 33 server = servers[0]
34 34
35 const user = { username: 'user1', password: 'password' } 35 const user = { username: 'user1', password: 'password' }
36 await server.usersCommand.create({ username: user.username, password: user.password }) 36 await server.users.create({ username: user.username, password: user.password })
37 37
38 userAccessToken = await server.loginCommand.getAccessToken(user) 38 userAccessToken = await server.login.getAccessToken(user)
39 39
40 await doubleFollow(servers[0], servers[1]) 40 await doubleFollow(servers[0], servers[1])
41 }) 41 })
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts
index 3f80c79a8..69ff7dd96 100644
--- a/server/tests/api/check-params/bulk.ts
+++ b/server/tests/api/check-params/bulk.ts
@@ -23,9 +23,9 @@ describe('Test bulk API validators', function () {
23 await setAccessTokensToServers([ server ]) 23 await setAccessTokensToServers([ server ])
24 24
25 const user = { username: 'user1', password: 'password' } 25 const user = { username: 'user1', password: 'password' }
26 await server.usersCommand.create({ username: user.username, password: user.password }) 26 await server.users.create({ username: user.username, password: user.password })
27 27
28 userAccessToken = await server.loginCommand.getAccessToken(user) 28 userAccessToken = await server.login.getAccessToken(user)
29 }) 29 })
30 30
31 describe('When removing comments of', function () { 31 describe('When removing comments of', function () {
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index c204d9415..6fd26864e 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -205,8 +205,8 @@ describe('Test config API validators', function () {
205 username: 'user1', 205 username: 'user1',
206 password: 'password' 206 password: 'password'
207 } 207 }
208 await server.usersCommand.create({ username: user.username, password: user.password }) 208 await server.users.create({ username: user.username, password: user.password })
209 userAccessToken = await server.loginCommand.getAccessToken(user) 209 userAccessToken = await server.login.getAccessToken(user)
210 }) 210 })
211 211
212 describe('When getting the configuration', function () { 212 describe('When getting the configuration', function () {
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts
index 4eed1661a..d2541777f 100644
--- a/server/tests/api/check-params/contact-form.ts
+++ b/server/tests/api/check-params/contact-form.ts
@@ -26,7 +26,7 @@ describe('Test contact form API validators', function () {
26 26
27 // Email is disabled 27 // Email is disabled
28 server = await flushAndRunServer(1) 28 server = await flushAndRunServer(1)
29 command = server.contactFormCommand 29 command = server.contactForm
30 }) 30 })
31 31
32 it('Should not accept a contact form if emails are disabled', async function () { 32 it('Should not accept a contact form if emails are disabled', async function () {
diff --git a/server/tests/api/check-params/custom-pages.ts b/server/tests/api/check-params/custom-pages.ts
index 58b0b8600..3d84fb3e6 100644
--- a/server/tests/api/check-params/custom-pages.ts
+++ b/server/tests/api/check-params/custom-pages.ts
@@ -25,9 +25,9 @@ describe('Test custom pages validators', function () {
25 await setAccessTokensToServers([ server ]) 25 await setAccessTokensToServers([ server ])
26 26
27 const user = { username: 'user1', password: 'password' } 27 const user = { username: 'user1', password: 'password' }
28 await server.usersCommand.create({ username: user.username, password: user.password }) 28 await server.users.create({ username: user.username, password: user.password })
29 29
30 userAccessToken = await server.loginCommand.getAccessToken(user) 30 userAccessToken = await server.login.getAccessToken(user)
31 }) 31 })
32 32
33 describe('When updating instance homepage', function () { 33 describe('When updating instance homepage', function () {
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts
index 2a7485cf3..609f9566e 100644
--- a/server/tests/api/check-params/debug.ts
+++ b/server/tests/api/check-params/debug.ts
@@ -29,8 +29,8 @@ describe('Test debug API validators', function () {
29 username: 'user1', 29 username: 'user1',
30 password: 'my super password' 30 password: 'my super password'
31 } 31 }
32 await server.usersCommand.create({ username: user.username, password: user.password }) 32 await server.users.create({ username: user.username, password: user.password })
33 userAccessToken = await server.loginCommand.getAccessToken(user) 33 userAccessToken = await server.login.getAccessToken(user)
34 }) 34 })
35 35
36 describe('When getting debug endpoint', function () { 36 describe('When getting debug endpoint', function () {
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index 24e483448..fae3712ce 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -39,8 +39,8 @@ describe('Test server follows API validators', function () {
39 password: 'password' 39 password: 'password'
40 } 40 }
41 41
42 await server.usersCommand.create({ username: user.username, password: user.password }) 42 await server.users.create({ username: user.username, password: user.password })
43 userAccessToken = await server.loginCommand.getAccessToken(user) 43 userAccessToken = await server.login.getAccessToken(user)
44 }) 44 })
45 45
46 describe('When adding follows', function () { 46 describe('When adding follows', function () {
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index 29439bebf..3786e8612 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -34,8 +34,8 @@ describe('Test jobs API validators', function () {
34 username: 'user1', 34 username: 'user1',
35 password: 'my super password' 35 password: 'my super password'
36 } 36 }
37 await server.usersCommand.create({ username: user.username, password: user.password }) 37 await server.users.create({ username: user.username, password: user.password })
38 userAccessToken = await server.loginCommand.getAccessToken(user) 38 userAccessToken = await server.login.getAccessToken(user)
39 }) 39 })
40 40
41 describe('When listing jobs', function () { 41 describe('When listing jobs', function () {
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index 4b54fc31c..20f27dd1d 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -35,7 +35,7 @@ describe('Test video lives API validator', function () {
35 35
36 await setAccessTokensToServers([ server ]) 36 await setAccessTokensToServers([ server ])
37 37
38 await server.configCommand.updateCustomSubConfig({ 38 await server.config.updateCustomSubConfig({
39 newConfig: { 39 newConfig: {
40 live: { 40 live: {
41 enabled: true, 41 enabled: true,
@@ -48,19 +48,19 @@ describe('Test video lives API validator', function () {
48 48
49 const username = 'user1' 49 const username = 'user1'
50 const password = 'my super password' 50 const password = 'my super password'
51 await server.usersCommand.create({ username: username, password: password }) 51 await server.users.create({ username: username, password: password })
52 userAccessToken = await server.loginCommand.getAccessToken({ username, password }) 52 userAccessToken = await server.login.getAccessToken({ username, password })
53 53
54 { 54 {
55 const { videoChannels } = await server.usersCommand.getMyInfo() 55 const { videoChannels } = await server.users.getMyInfo()
56 channelId = videoChannels[0].id 56 channelId = videoChannels[0].id
57 } 57 }
58 58
59 { 59 {
60 videoIdNotLive = (await server.videosCommand.quickUpload({ name: 'not live' })).id 60 videoIdNotLive = (await server.videos.quickUpload({ name: 'not live' })).id
61 } 61 }
62 62
63 command = server.liveCommand 63 command = server.live
64 }) 64 })
65 65
66 describe('When creating a live', function () { 66 describe('When creating a live', function () {
@@ -144,10 +144,10 @@ describe('Test video lives API validator', function () {
144 username: 'fake', 144 username: 'fake',
145 password: 'fake_password' 145 password: 'fake_password'
146 } 146 }
147 await server.usersCommand.create({ username: user.username, password: user.password }) 147 await server.users.create({ username: user.username, password: user.password })
148 148
149 const accessTokenUser = await server.loginCommand.getAccessToken(user) 149 const accessTokenUser = await server.login.getAccessToken(user)
150 const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser }) 150 const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
151 const customChannelId = videoChannels[0].id 151 const customChannelId = videoChannels[0].id
152 152
153 const fields = { ...baseCorrectParams, channelId: customChannelId } 153 const fields = { ...baseCorrectParams, channelId: customChannelId }
@@ -230,7 +230,7 @@ describe('Test video lives API validator', function () {
230 }) 230 })
231 231
232 it('Should forbid if live is disabled', async function () { 232 it('Should forbid if live is disabled', async function () {
233 await server.configCommand.updateCustomSubConfig({ 233 await server.config.updateCustomSubConfig({
234 newConfig: { 234 newConfig: {
235 live: { 235 live: {
236 enabled: false 236 enabled: false
@@ -250,7 +250,7 @@ describe('Test video lives API validator', function () {
250 it('Should forbid to save replay if not enabled by the admin', async function () { 250 it('Should forbid to save replay if not enabled by the admin', async function () {
251 const fields = { ...baseCorrectParams, saveReplay: true } 251 const fields = { ...baseCorrectParams, saveReplay: true }
252 252
253 await server.configCommand.updateCustomSubConfig({ 253 await server.config.updateCustomSubConfig({
254 newConfig: { 254 newConfig: {
255 live: { 255 live: {
256 enabled: true, 256 enabled: true,
@@ -271,7 +271,7 @@ describe('Test video lives API validator', function () {
271 it('Should allow to save replay if enabled by the admin', async function () { 271 it('Should allow to save replay if enabled by the admin', async function () {
272 const fields = { ...baseCorrectParams, saveReplay: true } 272 const fields = { ...baseCorrectParams, saveReplay: true }
273 273
274 await server.configCommand.updateCustomSubConfig({ 274 await server.config.updateCustomSubConfig({
275 newConfig: { 275 newConfig: {
276 live: { 276 live: {
277 enabled: true, 277 enabled: true,
@@ -290,7 +290,7 @@ describe('Test video lives API validator', function () {
290 }) 290 })
291 291
292 it('Should not allow live if max instance lives is reached', async function () { 292 it('Should not allow live if max instance lives is reached', async function () {
293 await server.configCommand.updateCustomSubConfig({ 293 await server.config.updateCustomSubConfig({
294 newConfig: { 294 newConfig: {
295 live: { 295 live: {
296 enabled: true, 296 enabled: true,
@@ -309,7 +309,7 @@ describe('Test video lives API validator', function () {
309 }) 309 })
310 310
311 it('Should not allow live if max user lives is reached', async function () { 311 it('Should not allow live if max user lives is reached', async function () {
312 await server.configCommand.updateCustomSubConfig({ 312 await server.config.updateCustomSubConfig({
313 newConfig: { 313 newConfig: {
314 live: { 314 live: {
315 enabled: true, 315 enabled: true,
@@ -401,7 +401,7 @@ describe('Test video lives API validator', function () {
401 }) 401 })
402 402
403 it('Should fail to update replay status if replay is not allowed on the instance', async function () { 403 it('Should fail to update replay status if replay is not allowed on the instance', async function () {
404 await server.configCommand.updateCustomSubConfig({ 404 await server.config.updateCustomSubConfig({
405 newConfig: { 405 newConfig: {
406 live: { 406 live: {
407 enabled: true, 407 enabled: true,
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts
index 69eaad69f..cf8f77959 100644
--- a/server/tests/api/check-params/logs.ts
+++ b/server/tests/api/check-params/logs.ts
@@ -29,8 +29,8 @@ describe('Test logs API validators', function () {
29 username: 'user1', 29 username: 'user1',
30 password: 'my super password' 30 password: 'my super password'
31 } 31 }
32 await server.usersCommand.create({ username: user.username, password: user.password }) 32 await server.users.create({ username: user.username, password: user.password })
33 userAccessToken = await server.loginCommand.getAccessToken(user) 33 userAccessToken = await server.login.getAccessToken(user)
34 }) 34 })
35 35
36 describe('When getting logs', function () { 36 describe('When getting logs', function () {
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts
index 08fb2397f..d4b72c0f4 100644
--- a/server/tests/api/check-params/plugins.ts
+++ b/server/tests/api/check-params/plugins.ts
@@ -42,17 +42,17 @@ describe('Test server plugins API validators', function () {
42 password: 'password' 42 password: 'password'
43 } 43 }
44 44
45 await server.usersCommand.create({ username: user.username, password: user.password }) 45 await server.users.create({ username: user.username, password: user.password })
46 userAccessToken = await server.loginCommand.getAccessToken(user) 46 userAccessToken = await server.login.getAccessToken(user)
47 47
48 { 48 {
49 const res = await server.pluginsCommand.install({ npmName: npmPlugin }) 49 const res = await server.plugins.install({ npmName: npmPlugin })
50 const plugin = res.body as PeerTubePlugin 50 const plugin = res.body as PeerTubePlugin
51 npmVersion = plugin.version 51 npmVersion = plugin.version
52 } 52 }
53 53
54 { 54 {
55 const res = await server.pluginsCommand.install({ npmName: themePlugin }) 55 const res = await server.plugins.install({ npmName: themePlugin })
56 const plugin = res.body as PeerTubePlugin 56 const plugin = res.body as PeerTubePlugin
57 themeVersion = plugin.version 57 themeVersion = plugin.version
58 } 58 }
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index b1692b986..fca92fde4 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -40,16 +40,16 @@ describe('Test server redundancy API validators', function () {
40 password: 'password' 40 password: 'password'
41 } 41 }
42 42
43 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 43 await servers[0].users.create({ username: user.username, password: user.password })
44 userAccessToken = await servers[0].loginCommand.getAccessToken(user) 44 userAccessToken = await servers[0].login.getAccessToken(user)
45 45
46 videoIdLocal = (await servers[0].videosCommand.quickUpload({ name: 'video' })).id 46 videoIdLocal = (await servers[0].videos.quickUpload({ name: 'video' })).id
47 47
48 const remoteUUID = (await servers[1].videosCommand.quickUpload({ name: 'video' })).uuid 48 const remoteUUID = (await servers[1].videos.quickUpload({ name: 'video' })).uuid
49 49
50 await waitJobs(servers) 50 await waitJobs(servers)
51 51
52 videoRemote = await servers[0].videosCommand.get({ id: remoteUUID }) 52 videoRemote = await servers[0].videos.get({ id: remoteUUID })
53 }) 53 })
54 54
55 describe('When listing redundancies', function () { 55 describe('When listing redundancies', function () {
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts
index 7973c112f..1acfa0922 100644
--- a/server/tests/api/check-params/search.ts
+++ b/server/tests/api/check-params/search.ts
@@ -14,7 +14,7 @@ import {
14} from '@shared/extra-utils' 14} from '@shared/extra-utils'
15 15
16function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) { 16function updateSearchIndex (server: ServerInfo, enabled: boolean, disableLocalSearch = false) {
17 return server.configCommand.updateCustomSubConfig({ 17 return server.config.updateCustomSubConfig({
18 newConfig: { 18 newConfig: {
19 search: { 19 search: {
20 searchIndex: { 20 searchIndex: {
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index f86712b4e..83435c24a 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -25,14 +25,14 @@ describe('Test services API validators', function () {
25 await setAccessTokensToServers([ server ]) 25 await setAccessTokensToServers([ server ])
26 await setDefaultVideoChannel([ server ]) 26 await setDefaultVideoChannel([ server ])
27 27
28 server.video = await server.videosCommand.upload({ attributes: { name: 'my super name' } }) 28 server.store.video = await server.videos.upload({ attributes: { name: 'my super name' } })
29 29
30 { 30 {
31 const created = await server.playlistsCommand.create({ 31 const created = await server.playlists.create({
32 attributes: { 32 attributes: {
33 displayName: 'super playlist', 33 displayName: 'super playlist',
34 privacy: VideoPlaylistPrivacy.PUBLIC, 34 privacy: VideoPlaylistPrivacy.PUBLIC,
35 videoChannelId: server.videoChannel.id 35 videoChannelId: server.store.channel.id
36 } 36 }
37 }) 37 })
38 38
@@ -48,7 +48,7 @@ describe('Test services API validators', function () {
48 }) 48 })
49 49
50 it('Should fail with an invalid host', async function () { 50 it('Should fail with an invalid host', async function () {
51 const embedUrl = 'http://hello.com/videos/watch/' + server.video.uuid 51 const embedUrl = 'http://hello.com/videos/watch/' + server.store.video.uuid
52 await checkParamEmbed(server, embedUrl) 52 await checkParamEmbed(server, embedUrl)
53 }) 53 })
54 54
@@ -63,37 +63,37 @@ describe('Test services API validators', function () {
63 }) 63 })
64 64
65 it('Should fail with an invalid path', async function () { 65 it('Should fail with an invalid path', async function () {
66 const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.video.uuid}` 66 const embedUrl = `http://localhost:${server.port}/videos/watchs/${server.store.video.uuid}`
67 67
68 await checkParamEmbed(server, embedUrl) 68 await checkParamEmbed(server, embedUrl)
69 }) 69 })
70 70
71 it('Should fail with an invalid max height', async function () { 71 it('Should fail with an invalid max height', async function () {
72 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 72 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
73 73
74 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxheight: 'hello' }) 74 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxheight: 'hello' })
75 }) 75 })
76 76
77 it('Should fail with an invalid max width', async function () { 77 it('Should fail with an invalid max width', async function () {
78 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 78 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
79 79
80 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxwidth: 'hello' }) 80 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxwidth: 'hello' })
81 }) 81 })
82 82
83 it('Should fail with an invalid format', async function () { 83 it('Should fail with an invalid format', async function () {
84 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 84 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
85 85
86 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { format: 'blabla' }) 86 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { format: 'blabla' })
87 }) 87 })
88 88
89 it('Should fail with a non supported format', async function () { 89 it('Should fail with a non supported format', async function () {
90 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 90 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
91 91
92 await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' }) 92 await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' })
93 }) 93 })
94 94
95 it('Should succeed with the correct params with a video', async function () { 95 it('Should succeed with the correct params with a video', async function () {
96 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 96 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.store.video.uuid}`
97 const query = { 97 const query = {
98 format: 'json', 98 format: 'json',
99 maxheight: 400, 99 maxheight: 400,
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts
index 164c581e3..4ca544790 100644
--- a/server/tests/api/check-params/upload-quota.ts
+++ b/server/tests/api/check-params/upload-quota.ts
@@ -29,12 +29,12 @@ describe('Test upload quota', function () {
29 await setAccessTokensToServers([ server ]) 29 await setAccessTokensToServers([ server ])
30 await setDefaultVideoChannel([ server ]) 30 await setDefaultVideoChannel([ server ])
31 31
32 const user = await server.usersCommand.getMyInfo() 32 const user = await server.users.getMyInfo()
33 rootId = user.id 33 rootId = user.id
34 34
35 await server.usersCommand.update({ userId: rootId, videoQuota: 42 }) 35 await server.users.update({ userId: rootId, videoQuota: 42 })
36 36
37 command = server.videosCommand 37 command = server.videos
38 }) 38 })
39 39
40 describe('When having a video quota', function () { 40 describe('When having a video quota', function () {
@@ -43,8 +43,8 @@ describe('Test upload quota', function () {
43 this.timeout(30000) 43 this.timeout(30000)
44 44
45 const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } 45 const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
46 await server.usersCommand.register(user) 46 await server.users.register(user)
47 const userToken = await server.loginCommand.getAccessToken(user) 47 const userToken = await server.login.getAccessToken(user)
48 48
49 const attributes = { fixture: 'video_short2.webm' } 49 const attributes = { fixture: 'video_short2.webm' }
50 for (let i = 0; i < 5; i++) { 50 for (let i = 0; i < 5; i++) {
@@ -58,8 +58,8 @@ describe('Test upload quota', function () {
58 this.timeout(30000) 58 this.timeout(30000)
59 59
60 const user = { username: 'registered' + randomInt(1, 1500), password: 'password' } 60 const user = { username: 'registered' + randomInt(1, 1500), password: 'password' }
61 await server.usersCommand.register(user) 61 await server.users.register(user)
62 const userToken = await server.loginCommand.getAccessToken(user) 62 const userToken = await server.login.getAccessToken(user)
63 63
64 const attributes = { fixture: 'video_short2.webm' } 64 const attributes = { fixture: 'video_short2.webm' }
65 for (let i = 0; i < 5; i++) { 65 for (let i = 0; i < 5; i++) {
@@ -73,16 +73,16 @@ describe('Test upload quota', function () {
73 this.timeout(120000) 73 this.timeout(120000)
74 74
75 const baseAttributes = { 75 const baseAttributes = {
76 channelId: server.videoChannel.id, 76 channelId: server.store.channel.id,
77 privacy: VideoPrivacy.PUBLIC 77 privacy: VideoPrivacy.PUBLIC
78 } 78 }
79 await server.importsCommand.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } }) 79 await server.imports.importVideo({ attributes: { ...baseAttributes, targetUrl: ImportsCommand.getGoodVideoUrl() } })
80 await server.importsCommand.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } }) 80 await server.imports.importVideo({ attributes: { ...baseAttributes, magnetUri: ImportsCommand.getMagnetURI() } })
81 await server.importsCommand.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } }) 81 await server.imports.importVideo({ attributes: { ...baseAttributes, torrentfile: 'video-720p.torrent' as any } })
82 82
83 await waitJobs([ server ]) 83 await waitJobs([ server ])
84 84
85 const { total, data: videoImports } = await server.importsCommand.getMyVideoImports() 85 const { total, data: videoImports } = await server.imports.getMyVideoImports()
86 expect(total).to.equal(3) 86 expect(total).to.equal(3)
87 87
88 expect(videoImports).to.have.lengthOf(3) 88 expect(videoImports).to.have.lengthOf(3)
@@ -98,7 +98,7 @@ describe('Test upload quota', function () {
98 describe('When having a daily video quota', function () { 98 describe('When having a daily video quota', function () {
99 99
100 it('Should fail with a user having too many videos daily', async function () { 100 it('Should fail with a user having too many videos daily', async function () {
101 await server.usersCommand.update({ userId: rootId, videoQuotaDaily: 42 }) 101 await server.users.update({ userId: rootId, videoQuotaDaily: 42 })
102 102
103 await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' }) 103 await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'legacy' })
104 await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' }) 104 await command.upload({ expectedStatus: HttpStatusCode.PAYLOAD_TOO_LARGE_413, mode: 'resumable' })
@@ -107,7 +107,7 @@ describe('Test upload quota', function () {
107 107
108 describe('When having an absolute and daily video quota', function () { 108 describe('When having an absolute and daily video quota', function () {
109 it('Should fail if exceeding total quota', async function () { 109 it('Should fail if exceeding total quota', async function () {
110 await server.usersCommand.update({ 110 await server.users.update({
111 userId: rootId, 111 userId: rootId,
112 videoQuota: 42, 112 videoQuota: 42,
113 videoQuotaDaily: 1024 * 1024 * 1024 113 videoQuotaDaily: 1024 * 1024 * 1024
@@ -118,7 +118,7 @@ describe('Test upload quota', function () {
118 }) 118 })
119 119
120 it('Should fail if exceeding daily quota', async function () { 120 it('Should fail if exceeding daily quota', async function () {
121 await server.usersCommand.update({ 121 await server.users.update({
122 userId: rootId, 122 userId: rootId,
123 videoQuota: 1024 * 1024 * 1024, 123 videoQuota: 1024 * 1024 * 1024,
124 videoQuotaDaily: 42 124 videoQuotaDaily: 42
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 8ce201d61..885ad68e4 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -38,8 +38,8 @@ describe('Test user subscriptions API validators', function () {
38 username: 'user1', 38 username: 'user1',
39 password: 'my super password' 39 password: 'my super password'
40 } 40 }
41 await server.usersCommand.create({ username: user.username, password: user.password }) 41 await server.users.create({ username: user.username, password: user.password })
42 userAccessToken = await server.loginCommand.getAccessToken(user) 42 userAccessToken = await server.login.getAccessToken(user)
43 }) 43 })
44 44
45 describe('When listing my subscriptions', function () { 45 describe('When listing my subscriptions', function () {
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 33c48a009..bce3f0774 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -60,27 +60,27 @@ describe('Test users API validators', function () {
60 60
61 { 61 {
62 const user = { username: 'user1' } 62 const user = { username: 'user1' }
63 await server.usersCommand.create({ ...user }) 63 await server.users.create({ ...user })
64 userToken = await server.loginCommand.getAccessToken(user) 64 userToken = await server.login.getAccessToken(user)
65 } 65 }
66 66
67 { 67 {
68 const moderator = { username: 'moderator1' } 68 const moderator = { username: 'moderator1' }
69 await server.usersCommand.create({ ...moderator, role: UserRole.MODERATOR }) 69 await server.users.create({ ...moderator, role: UserRole.MODERATOR })
70 moderatorToken = await server.loginCommand.getAccessToken(moderator) 70 moderatorToken = await server.login.getAccessToken(moderator)
71 } 71 }
72 72
73 { 73 {
74 const moderator = { username: 'moderator2' } 74 const moderator = { username: 'moderator2' }
75 await server.usersCommand.create({ ...moderator, role: UserRole.MODERATOR }) 75 await server.users.create({ ...moderator, role: UserRole.MODERATOR })
76 } 76 }
77 77
78 { 78 {
79 video = await server.videosCommand.upload() 79 video = await server.videos.upload()
80 } 80 }
81 81
82 { 82 {
83 const { data } = await server.usersCommand.list() 83 const { data } = await server.users.list()
84 userId = data.find(u => u.username === 'user1').id 84 userId = data.find(u => u.username === 'user1').id
85 rootId = data.find(u => u.username === 'root').id 85 rootId = data.find(u => u.username === 'root').id
86 moderatorId = data.find(u => u.username === 'moderator2').id 86 moderatorId = data.find(u => u.username === 'moderator2').id
@@ -341,7 +341,7 @@ describe('Test users API validators', function () {
341 341
342 it('Should fail with a non admin user', async function () { 342 it('Should fail with a non admin user', async function () {
343 const user = { username: 'user1' } 343 const user = { username: 'user1' }
344 userToken = await server.loginCommand.getAccessToken(user) 344 userToken = await server.login.getAccessToken(user)
345 345
346 const fields = { 346 const fields = {
347 username: 'user3', 347 username: 'user3',
@@ -596,28 +596,28 @@ describe('Test users API validators', function () {
596 describe('When managing my scoped tokens', function () { 596 describe('When managing my scoped tokens', function () {
597 597
598 it('Should fail to get my scoped tokens with an non authenticated user', async function () { 598 it('Should fail to get my scoped tokens with an non authenticated user', async function () {
599 await server.usersCommand.getMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 599 await server.users.getMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
600 }) 600 })
601 601
602 it('Should fail to get my scoped tokens with a bad token', async function () { 602 it('Should fail to get my scoped tokens with a bad token', async function () {
603 await server.usersCommand.getMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 603 await server.users.getMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
604 604
605 }) 605 })
606 606
607 it('Should succeed to get my scoped tokens', async function () { 607 it('Should succeed to get my scoped tokens', async function () {
608 await server.usersCommand.getMyScopedTokens() 608 await server.users.getMyScopedTokens()
609 }) 609 })
610 610
611 it('Should fail to renew my scoped tokens with an non authenticated user', async function () { 611 it('Should fail to renew my scoped tokens with an non authenticated user', async function () {
612 await server.usersCommand.renewMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 612 await server.users.renewMyScopedTokens({ token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
613 }) 613 })
614 614
615 it('Should fail to renew my scoped tokens with a bad token', async function () { 615 it('Should fail to renew my scoped tokens with a bad token', async function () {
616 await server.usersCommand.renewMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 616 await server.users.renewMyScopedTokens({ token: 'bad', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
617 }) 617 })
618 618
619 it('Should succeed to renew my scoped tokens', async function () { 619 it('Should succeed to renew my scoped tokens', async function () {
620 await server.usersCommand.renewMyScopedTokens() 620 await server.users.renewMyScopedTokens()
621 }) 621 })
622 }) 622 })
623 623
@@ -769,11 +769,11 @@ describe('Test users API validators', function () {
769 769
770 describe('When getting my information', function () { 770 describe('When getting my information', function () {
771 it('Should fail with a non authenticated user', async function () { 771 it('Should fail with a non authenticated user', async function () {
772 await server.usersCommand.getMyInfo({ token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 772 await server.users.getMyInfo({ token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
773 }) 773 })
774 774
775 it('Should success with the correct parameters', async function () { 775 it('Should success with the correct parameters', async function () {
776 await server.usersCommand.getMyInfo({ token: userToken }) 776 await server.users.getMyInfo({ token: userToken })
777 }) 777 })
778 }) 778 })
779 779
@@ -781,7 +781,7 @@ describe('Test users API validators', function () {
781 let command: UsersCommand 781 let command: UsersCommand
782 782
783 before(function () { 783 before(function () {
784 command = server.usersCommand 784 command = server.users
785 }) 785 })
786 786
787 it('Should fail with a non authenticated user', async function () { 787 it('Should fail with a non authenticated user', async function () {
@@ -846,54 +846,54 @@ describe('Test users API validators', function () {
846 it('Should fail with an incorrect id', async function () { 846 it('Should fail with an incorrect id', async function () {
847 const options = { userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 } 847 const options = { userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }
848 848
849 await server.usersCommand.remove(options) 849 await server.users.remove(options)
850 await server.usersCommand.banUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 850 await server.users.banUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
851 await server.usersCommand.unbanUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 851 await server.users.unbanUser({ userId: 'blabla' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
852 }) 852 })
853 853
854 it('Should fail with the root user', async function () { 854 it('Should fail with the root user', async function () {
855 const options = { userId: rootId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 } 855 const options = { userId: rootId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }
856 856
857 await server.usersCommand.remove(options) 857 await server.users.remove(options)
858 await server.usersCommand.banUser(options) 858 await server.users.banUser(options)
859 await server.usersCommand.unbanUser(options) 859 await server.users.unbanUser(options)
860 }) 860 })
861 861
862 it('Should return 404 with a non existing id', async function () { 862 it('Should return 404 with a non existing id', async function () {
863 const options = { userId: 4545454, expectedStatus: HttpStatusCode.NOT_FOUND_404 } 863 const options = { userId: 4545454, expectedStatus: HttpStatusCode.NOT_FOUND_404 }
864 864
865 await server.usersCommand.remove(options) 865 await server.users.remove(options)
866 await server.usersCommand.banUser(options) 866 await server.users.banUser(options)
867 await server.usersCommand.unbanUser(options) 867 await server.users.unbanUser(options)
868 }) 868 })
869 869
870 it('Should fail with a non admin user', async function () { 870 it('Should fail with a non admin user', async function () {
871 const options = { userId, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 } 871 const options = { userId, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
872 872
873 await server.usersCommand.remove(options) 873 await server.users.remove(options)
874 await server.usersCommand.banUser(options) 874 await server.users.banUser(options)
875 await server.usersCommand.unbanUser(options) 875 await server.users.unbanUser(options)
876 }) 876 })
877 877
878 it('Should fail on a moderator with a moderator', async function () { 878 it('Should fail on a moderator with a moderator', async function () {
879 const options = { userId: moderatorId, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 } 879 const options = { userId: moderatorId, token: moderatorToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }
880 880
881 await server.usersCommand.remove(options) 881 await server.users.remove(options)
882 await server.usersCommand.banUser(options) 882 await server.users.banUser(options)
883 await server.usersCommand.unbanUser(options) 883 await server.users.unbanUser(options)
884 }) 884 })
885 885
886 it('Should succeed on a user with a moderator', async function () { 886 it('Should succeed on a user with a moderator', async function () {
887 const options = { userId, token: moderatorToken } 887 const options = { userId, token: moderatorToken }
888 888
889 await server.usersCommand.banUser(options) 889 await server.users.banUser(options)
890 await server.usersCommand.unbanUser(options) 890 await server.users.unbanUser(options)
891 }) 891 })
892 }) 892 })
893 893
894 describe('When deleting our account', function () { 894 describe('When deleting our account', function () {
895 it('Should fail with with the root account', async function () { 895 it('Should fail with with the root account', async function () {
896 await server.usersCommand.deleteMe({ expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 896 await server.users.deleteMe({ expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
897 }) 897 })
898 }) 898 })
899 899
@@ -1011,7 +1011,7 @@ describe('Test users API validators', function () {
1011 1011
1012 it('Should fail with an existing channel', async function () { 1012 it('Should fail with an existing channel', async function () {
1013 const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' } 1013 const attributes = { name: 'existing_channel', displayName: 'hello', description: 'super description' }
1014 await server.channelsCommand.create({ attributes }) 1014 await server.channels.create({ attributes })
1015 1015
1016 const fields = { ...baseCorrectParams, channel: { name: 'existing_channel', displayName: 'toto' } } 1016 const fields = { ...baseCorrectParams, channel: { name: 'existing_channel', displayName: 'toto' } }
1017 1017
@@ -1055,7 +1055,7 @@ describe('Test users API validators', function () {
1055 1055
1056 describe('When registering multiple users on a server with users limit', function () { 1056 describe('When registering multiple users on a server with users limit', function () {
1057 it('Should fail when after 3 registrations', async function () { 1057 it('Should fail when after 3 registrations', async function () {
1058 await server.usersCommand.register({ username: 'user42', expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 1058 await server.users.register({ username: 'user42', expectedStatus: HttpStatusCode.FORBIDDEN_403 })
1059 }) 1059 })
1060 }) 1060 })
1061 1061
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index 0fda31b29..51609b982 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -40,41 +40,41 @@ describe('Test video blacklist API validators', function () {
40 { 40 {
41 const username = 'user1' 41 const username = 'user1'
42 const password = 'my super password' 42 const password = 'my super password'
43 await servers[0].usersCommand.create({ username: username, password: password }) 43 await servers[0].users.create({ username: username, password: password })
44 userAccessToken1 = await servers[0].loginCommand.getAccessToken({ username, password }) 44 userAccessToken1 = await servers[0].login.getAccessToken({ username, password })
45 } 45 }
46 46
47 { 47 {
48 const username = 'user2' 48 const username = 'user2'
49 const password = 'my super password' 49 const password = 'my super password'
50 await servers[0].usersCommand.create({ username: username, password: password }) 50 await servers[0].users.create({ username: username, password: password })
51 userAccessToken2 = await servers[0].loginCommand.getAccessToken({ username, password }) 51 userAccessToken2 = await servers[0].login.getAccessToken({ username, password })
52 } 52 }
53 53
54 { 54 {
55 servers[0].video = await servers[0].videosCommand.upload({ token: userAccessToken1 }) 55 servers[0].store.video = await servers[0].videos.upload({ token: userAccessToken1 })
56 } 56 }
57 57
58 { 58 {
59 const { uuid } = await servers[0].videosCommand.upload() 59 const { uuid } = await servers[0].videos.upload()
60 notBlacklistedVideoId = uuid 60 notBlacklistedVideoId = uuid
61 } 61 }
62 62
63 { 63 {
64 const { uuid } = await servers[1].videosCommand.upload() 64 const { uuid } = await servers[1].videos.upload()
65 remoteVideoUUID = uuid 65 remoteVideoUUID = uuid
66 } 66 }
67 67
68 await waitJobs(servers) 68 await waitJobs(servers)
69 69
70 command = servers[0].blacklistCommand 70 command = servers[0].blacklist
71 }) 71 })
72 72
73 describe('When adding a video in blacklist', function () { 73 describe('When adding a video in blacklist', function () {
74 const basePath = '/api/v1/videos/' 74 const basePath = '/api/v1/videos/'
75 75
76 it('Should fail with nothing', async function () { 76 it('Should fail with nothing', async function () {
77 const path = basePath + servers[0].video + '/blacklist' 77 const path = basePath + servers[0].store.video + '/blacklist'
78 const fields = {} 78 const fields = {}
79 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) 79 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
80 }) 80 })
@@ -86,13 +86,13 @@ describe('Test video blacklist API validators', function () {
86 }) 86 })
87 87
88 it('Should fail with a non authenticated user', async function () { 88 it('Should fail with a non authenticated user', async function () {
89 const path = basePath + servers[0].video + '/blacklist' 89 const path = basePath + servers[0].store.video + '/blacklist'
90 const fields = {} 90 const fields = {}
91 await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 91 await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
92 }) 92 })
93 93
94 it('Should fail with a non admin user', async function () { 94 it('Should fail with a non admin user', async function () {
95 const path = basePath + servers[0].video + '/blacklist' 95 const path = basePath + servers[0].store.video + '/blacklist'
96 const fields = {} 96 const fields = {}
97 await makePostBodyRequest({ 97 await makePostBodyRequest({
98 url: servers[0].url, 98 url: servers[0].url,
@@ -104,7 +104,7 @@ describe('Test video blacklist API validators', function () {
104 }) 104 })
105 105
106 it('Should fail with an invalid reason', async function () { 106 it('Should fail with an invalid reason', async function () {
107 const path = basePath + servers[0].video.uuid + '/blacklist' 107 const path = basePath + servers[0].store.video.uuid + '/blacklist'
108 const fields = { reason: 'a'.repeat(305) } 108 const fields = { reason: 'a'.repeat(305) }
109 109
110 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) 110 await makePostBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
@@ -124,7 +124,7 @@ describe('Test video blacklist API validators', function () {
124 }) 124 })
125 125
126 it('Should succeed with the correct params', async function () { 126 it('Should succeed with the correct params', async function () {
127 const path = basePath + servers[0].video.uuid + '/blacklist' 127 const path = basePath + servers[0].store.video.uuid + '/blacklist'
128 const fields = {} 128 const fields = {}
129 129
130 await makePostBodyRequest({ 130 await makePostBodyRequest({
@@ -159,13 +159,13 @@ describe('Test video blacklist API validators', function () {
159 }) 159 })
160 160
161 it('Should fail with a non authenticated user', async function () { 161 it('Should fail with a non authenticated user', async function () {
162 const path = basePath + servers[0].video + '/blacklist' 162 const path = basePath + servers[0].store.video + '/blacklist'
163 const fields = {} 163 const fields = {}
164 await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 164 await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
165 }) 165 })
166 166
167 it('Should fail with a non admin user', async function () { 167 it('Should fail with a non admin user', async function () {
168 const path = basePath + servers[0].video + '/blacklist' 168 const path = basePath + servers[0].store.video + '/blacklist'
169 const fields = {} 169 const fields = {}
170 await makePutBodyRequest({ 170 await makePutBodyRequest({
171 url: servers[0].url, 171 url: servers[0].url,
@@ -177,14 +177,14 @@ describe('Test video blacklist API validators', function () {
177 }) 177 })
178 178
179 it('Should fail with an invalid reason', async function () { 179 it('Should fail with an invalid reason', async function () {
180 const path = basePath + servers[0].video.uuid + '/blacklist' 180 const path = basePath + servers[0].store.video.uuid + '/blacklist'
181 const fields = { reason: 'a'.repeat(305) } 181 const fields = { reason: 'a'.repeat(305) }
182 182
183 await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields }) 183 await makePutBodyRequest({ url: servers[0].url, path, token: servers[0].accessToken, fields })
184 }) 184 })
185 185
186 it('Should succeed with the correct params', async function () { 186 it('Should succeed with the correct params', async function () {
187 const path = basePath + servers[0].video.shortUUID + '/blacklist' 187 const path = basePath + servers[0].store.video.shortUUID + '/blacklist'
188 const fields = { reason: 'hello' } 188 const fields = { reason: 'hello' }
189 189
190 await makePutBodyRequest({ 190 await makePutBodyRequest({
@@ -200,27 +200,27 @@ describe('Test video blacklist API validators', function () {
200 describe('When getting blacklisted video', function () { 200 describe('When getting blacklisted video', function () {
201 201
202 it('Should fail with a non authenticated user', async function () { 202 it('Should fail with a non authenticated user', async function () {
203 await servers[0].videosCommand.get({ id: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 203 await servers[0].videos.get({ id: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
204 }) 204 })
205 205
206 it('Should fail with another user', async function () { 206 it('Should fail with another user', async function () {
207 await servers[0].videosCommand.getWithToken({ 207 await servers[0].videos.getWithToken({
208 token: userAccessToken2, 208 token: userAccessToken2,
209 id: servers[0].video.uuid, 209 id: servers[0].store.video.uuid,
210 expectedStatus: HttpStatusCode.FORBIDDEN_403 210 expectedStatus: HttpStatusCode.FORBIDDEN_403
211 }) 211 })
212 }) 212 })
213 213
214 it('Should succeed with the owner authenticated user', async function () { 214 it('Should succeed with the owner authenticated user', async function () {
215 const video = await servers[0].videosCommand.getWithToken({ token: userAccessToken1, id: servers[0].video.uuid }) 215 const video = await servers[0].videos.getWithToken({ token: userAccessToken1, id: servers[0].store.video.uuid })
216 expect(video.blacklisted).to.be.true 216 expect(video.blacklisted).to.be.true
217 }) 217 })
218 218
219 it('Should succeed with an admin', async function () { 219 it('Should succeed with an admin', async function () {
220 const video = servers[0].video 220 const video = servers[0].store.video
221 221
222 for (const id of [ video.id, video.uuid, video.shortUUID ]) { 222 for (const id of [ video.id, video.uuid, video.shortUUID ]) {
223 const video = await servers[0].videosCommand.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 }) 223 const video = await servers[0].videos.getWithToken({ id, expectedStatus: HttpStatusCode.OK_200 })
224 expect(video.blacklisted).to.be.true 224 expect(video.blacklisted).to.be.true
225 } 225 }
226 }) 226 })
@@ -229,11 +229,11 @@ describe('Test video blacklist API validators', function () {
229 describe('When removing a video in blacklist', function () { 229 describe('When removing a video in blacklist', function () {
230 230
231 it('Should fail with a non authenticated user', async function () { 231 it('Should fail with a non authenticated user', async function () {
232 await command.remove({ token: 'fake token', videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 232 await command.remove({ token: 'fake token', videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
233 }) 233 })
234 234
235 it('Should fail with a non admin user', async function () { 235 it('Should fail with a non admin user', async function () {
236 await command.remove({ token: userAccessToken2, videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 236 await command.remove({ token: userAccessToken2, videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
237 }) 237 })
238 238
239 it('Should fail with an incorrect id', async function () { 239 it('Should fail with an incorrect id', async function () {
@@ -246,7 +246,7 @@ describe('Test video blacklist API validators', function () {
246 }) 246 })
247 247
248 it('Should succeed with the correct params', async function () { 248 it('Should succeed with the correct params', async function () {
249 await command.remove({ videoId: servers[0].video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) 249 await command.remove({ videoId: servers[0].store.video.uuid, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
250 }) 250 })
251 }) 251 })
252 252
@@ -254,11 +254,11 @@ describe('Test video blacklist API validators', function () {
254 const basePath = '/api/v1/videos/blacklist/' 254 const basePath = '/api/v1/videos/blacklist/'
255 255
256 it('Should fail with a non authenticated user', async function () { 256 it('Should fail with a non authenticated user', async function () {
257 await servers[0].blacklistCommand.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 257 await servers[0].blacklist.list({ token: 'fake token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
258 }) 258 })
259 259
260 it('Should fail with a non admin user', async function () { 260 it('Should fail with a non admin user', async function () {
261 await servers[0].blacklistCommand.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 261 await servers[0].blacklist.list({ token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
262 }) 262 })
263 263
264 it('Should fail with a bad start pagination', async function () { 264 it('Should fail with a bad start pagination', async function () {
@@ -274,11 +274,11 @@ describe('Test video blacklist API validators', function () {
274 }) 274 })
275 275
276 it('Should fail with an invalid type', async function () { 276 it('Should fail with an invalid type', async function () {
277 await servers[0].blacklistCommand.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 277 await servers[0].blacklist.list({ type: 0, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
278 }) 278 })
279 279
280 it('Should succeed with the correct parameters', async function () { 280 it('Should succeed with the correct parameters', async function () {
281 await servers[0].blacklistCommand.list({ type: VideoBlacklistType.MANUAL }) 281 await servers[0].blacklist.list({ type: VideoBlacklistType.MANUAL })
282 }) 282 })
283 }) 283 })
284 284
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index f3941b3fa..913f894b9 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -30,15 +30,15 @@ describe('Test video captions API validator', function () {
30 30
31 await setAccessTokensToServers([ server ]) 31 await setAccessTokensToServers([ server ])
32 32
33 video = await server.videosCommand.upload() 33 video = await server.videos.upload()
34 34
35 { 35 {
36 const user = { 36 const user = {
37 username: 'user1', 37 username: 'user1',
38 password: 'my super password' 38 password: 'my super password'
39 } 39 }
40 await server.usersCommand.create({ username: user.username, password: user.password }) 40 await server.users.create({ username: user.username, password: user.password })
41 userAccessToken = await server.loginCommand.getAccessToken(user) 41 userAccessToken = await server.login.getAccessToken(user)
42 } 42 }
43 }) 43 })
44 44
@@ -152,7 +152,7 @@ describe('Test video captions API validator', function () {
152 // }) 152 // })
153 153
154 it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () { 154 it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () {
155 await server.captionsCommand.createVideoCaption({ 155 await server.captions.createVideoCaption({
156 language: 'zh', 156 language: 'zh',
157 videoId: video.uuid, 157 videoId: video.uuid,
158 fixture: 'subtitle-good.srt', 158 fixture: 'subtitle-good.srt',
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 2b4c17ea1..8e6e32f20 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -44,11 +44,11 @@ describe('Test video channels API validator', function () {
44 } 44 }
45 45
46 { 46 {
47 await server.usersCommand.create({ username: user.username, password: user.password }) 47 await server.users.create({ username: user.username, password: user.password })
48 accessTokenUser = await server.loginCommand.getAccessToken(user) 48 accessTokenUser = await server.login.getAccessToken(user)
49 } 49 }
50 50
51 command = server.channelsCommand 51 command = server.channels
52 }) 52 })
53 53
54 describe('When listing a video channels', function () { 54 describe('When listing a video channels', function () {
@@ -81,7 +81,7 @@ describe('Test video channels API validator', function () {
81 }) 81 })
82 82
83 it('Should fail with a unknown account', async function () { 83 it('Should fail with a unknown account', async function () {
84 await server.channelsCommand.listByAccount({ accountName: 'unknown', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 84 await server.channels.listByAccount({ accountName: 'unknown', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
85 }) 85 })
86 86
87 it('Should succeed with the correct parameters', async function () { 87 it('Should succeed with the correct parameters', async function () {
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index bdf7f91ee..44af9d7e3 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -38,26 +38,26 @@ describe('Test video comments API validator', function () {
38 await setAccessTokensToServers([ server ]) 38 await setAccessTokensToServers([ server ])
39 39
40 { 40 {
41 const video = await server.videosCommand.upload({ attributes: {} }) 41 const video = await server.videos.upload({ attributes: {} })
42 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads' 42 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
43 } 43 }
44 44
45 { 45 {
46 const created = await server.commentsCommand.createThread({ videoId: video.uuid, text: 'coucou' }) 46 const created = await server.comments.createThread({ videoId: video.uuid, text: 'coucou' })
47 commentId = created.id 47 commentId = created.id
48 pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId 48 pathComment = '/api/v1/videos/' + video.uuid + '/comments/' + commentId
49 } 49 }
50 50
51 { 51 {
52 const user = { username: 'user1', password: 'my super password' } 52 const user = { username: 'user1', password: 'my super password' }
53 await server.usersCommand.create({ username: user.username, password: user.password }) 53 await server.users.create({ username: user.username, password: user.password })
54 userAccessToken = await server.loginCommand.getAccessToken(user) 54 userAccessToken = await server.login.getAccessToken(user)
55 } 55 }
56 56
57 { 57 {
58 const user = { username: 'user2', password: 'my super password' } 58 const user = { username: 'user2', password: 'my super password' }
59 await server.usersCommand.create({ username: user.username, password: user.password }) 59 await server.users.create({ username: user.username, password: user.password })
60 userAccessToken2 = await server.loginCommand.getAccessToken(user) 60 userAccessToken2 = await server.login.getAccessToken(user)
61 } 61 }
62 }) 62 })
63 63
@@ -274,7 +274,7 @@ describe('Test video comments API validator', function () {
274 let commentToDelete: number 274 let commentToDelete: number
275 275
276 { 276 {
277 const created = await server.commentsCommand.createThread({ videoId: video.uuid, token: userAccessToken, text: 'hello' }) 277 const created = await server.comments.createThread({ videoId: video.uuid, token: userAccessToken, text: 'hello' })
278 commentToDelete = created.id 278 commentToDelete = created.id
279 } 279 }
280 280
@@ -289,12 +289,12 @@ describe('Test video comments API validator', function () {
289 let anotherVideoUUID: string 289 let anotherVideoUUID: string
290 290
291 { 291 {
292 const { uuid } = await server.videosCommand.upload({ token: userAccessToken, attributes: { name: 'video' } }) 292 const { uuid } = await server.videos.upload({ token: userAccessToken, attributes: { name: 'video' } })
293 anotherVideoUUID = uuid 293 anotherVideoUUID = uuid
294 } 294 }
295 295
296 { 296 {
297 const created = await server.commentsCommand.createThread({ videoId: anotherVideoUUID, text: 'hello' }) 297 const created = await server.comments.createThread({ videoId: anotherVideoUUID, text: 'hello' })
298 commentToDelete = created.id 298 commentToDelete = created.id
299 } 299 }
300 300
@@ -316,7 +316,7 @@ describe('Test video comments API validator', function () {
316 316
317 describe('When a video has comments disabled', function () { 317 describe('When a video has comments disabled', function () {
318 before(async function () { 318 before(async function () {
319 video = await server.videosCommand.upload({ attributes: { commentsEnabled: false } }) 319 video = await server.videos.upload({ attributes: { commentsEnabled: false } })
320 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads' 320 pathThread = '/api/v1/videos/' + video.uuid + '/comment-threads'
321 }) 321 })
322 322
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index d09e473de..1a6b6075f 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -36,11 +36,11 @@ describe('Test video imports API validator', function () {
36 36
37 const username = 'user1' 37 const username = 'user1'
38 const password = 'my super password' 38 const password = 'my super password'
39 await server.usersCommand.create({ username: username, password: password }) 39 await server.users.create({ username: username, password: password })
40 userAccessToken = await server.loginCommand.getAccessToken({ username, password }) 40 userAccessToken = await server.login.getAccessToken({ username, password })
41 41
42 { 42 {
43 const { videoChannels } = await server.usersCommand.getMyInfo() 43 const { videoChannels } = await server.users.getMyInfo()
44 channelId = videoChannels[0].id 44 channelId = videoChannels[0].id
45 } 45 }
46 }) 46 })
@@ -162,10 +162,10 @@ describe('Test video imports API validator', function () {
162 username: 'fake', 162 username: 'fake',
163 password: 'fake_password' 163 password: 'fake_password'
164 } 164 }
165 await server.usersCommand.create({ username: user.username, password: user.password }) 165 await server.users.create({ username: user.username, password: user.password })
166 166
167 const accessTokenUser = await server.loginCommand.getAccessToken(user) 167 const accessTokenUser = await server.login.getAccessToken(user)
168 const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser }) 168 const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
169 const customChannelId = videoChannels[0].id 169 const customChannelId = videoChannels[0].id
170 170
171 const fields = { ...baseCorrectParams, channelId: customChannelId } 171 const fields = { ...baseCorrectParams, channelId: customChannelId }
@@ -256,7 +256,7 @@ describe('Test video imports API validator', function () {
256 }) 256 })
257 257
258 it('Should forbid to import http videos', async function () { 258 it('Should forbid to import http videos', async function () {
259 await server.configCommand.updateCustomSubConfig({ 259 await server.config.updateCustomSubConfig({
260 newConfig: { 260 newConfig: {
261 import: { 261 import: {
262 videos: { 262 videos: {
@@ -281,7 +281,7 @@ describe('Test video imports API validator', function () {
281 }) 281 })
282 282
283 it('Should forbid to import torrent videos', async function () { 283 it('Should forbid to import torrent videos', async function () {
284 await server.configCommand.updateCustomSubConfig({ 284 await server.config.updateCustomSubConfig({
285 newConfig: { 285 newConfig: {
286 import: { 286 import: {
287 videos: { 287 videos: {
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index ebd7e2413..e0e42ebb0 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -47,10 +47,10 @@ describe('Test video playlists API validator', function () {
47 await setAccessTokensToServers([ server ]) 47 await setAccessTokensToServers([ server ])
48 await setDefaultVideoChannel([ server ]) 48 await setDefaultVideoChannel([ server ])
49 49
50 userAccessToken = await server.usersCommand.generateUserAndToken('user1') 50 userAccessToken = await server.users.generateUserAndToken('user1')
51 videoId = (await server.videosCommand.quickUpload({ name: 'video 1' })).id 51 videoId = (await server.videos.quickUpload({ name: 'video 1' })).id
52 52
53 command = server.playlistsCommand 53 command = server.playlists
54 54
55 { 55 {
56 const { data } = await command.listByAccount({ 56 const { data } = await command.listByAccount({
@@ -68,7 +68,7 @@ describe('Test video playlists API validator', function () {
68 attributes: { 68 attributes: {
69 displayName: 'super playlist', 69 displayName: 'super playlist',
70 privacy: VideoPlaylistPrivacy.PUBLIC, 70 privacy: VideoPlaylistPrivacy.PUBLIC,
71 videoChannelId: server.videoChannel.id 71 videoChannelId: server.store.channel.id
72 } 72 }
73 }) 73 })
74 } 74 }
@@ -176,7 +176,7 @@ describe('Test video playlists API validator', function () {
176 const playlist = await command.create({ 176 const playlist = await command.create({
177 attributes: { 177 attributes: {
178 displayName: 'super playlist', 178 displayName: 'super playlist',
179 videoChannelId: server.videoChannel.id, 179 videoChannelId: server.store.channel.id,
180 privacy: VideoPlaylistPrivacy.UNLISTED 180 privacy: VideoPlaylistPrivacy.UNLISTED
181 } 181 }
182 }) 182 })
@@ -200,7 +200,7 @@ describe('Test video playlists API validator', function () {
200 displayName: 'display name', 200 displayName: 'display name',
201 privacy: VideoPlaylistPrivacy.UNLISTED, 201 privacy: VideoPlaylistPrivacy.UNLISTED,
202 thumbnailfile: 'thumbnail.jpg', 202 thumbnailfile: 'thumbnail.jpg',
203 videoChannelId: server.videoChannel.id, 203 videoChannelId: server.store.channel.id,
204 204
205 ...attributes 205 ...attributes
206 }, 206 },
@@ -485,8 +485,8 @@ describe('Test video playlists API validator', function () {
485 } 485 }
486 486
487 before(async function () { 487 before(async function () {
488 videoId3 = (await server.videosCommand.quickUpload({ name: 'video 3' })).id 488 videoId3 = (await server.videos.quickUpload({ name: 'video 3' })).id
489 videoId4 = (await server.videosCommand.quickUpload({ name: 'video 4' })).id 489 videoId4 = (await server.videos.quickUpload({ name: 'video 4' })).id
490 490
491 for (const id of [ videoId3, videoId4 ]) { 491 for (const id of [ videoId3, videoId4 ]) {
492 await command.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: id } }) 492 await command.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: id } })
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts
index d7bf081d4..cbfdef1db 100644
--- a/server/tests/api/check-params/videos-filter.ts
+++ b/server/tests/api/check-params/videos-filter.ts
@@ -49,13 +49,13 @@ describe('Test video filters validators', function () {
49 await setDefaultVideoChannel([ server ]) 49 await setDefaultVideoChannel([ server ])
50 50
51 const user = { username: 'user1', password: 'my super password' } 51 const user = { username: 'user1', password: 'my super password' }
52 await server.usersCommand.create({ username: user.username, password: user.password }) 52 await server.users.create({ username: user.username, password: user.password })
53 userAccessToken = await server.loginCommand.getAccessToken(user) 53 userAccessToken = await server.login.getAccessToken(user)
54 54
55 const moderator = { username: 'moderator', password: 'my super password' } 55 const moderator = { username: 'moderator', password: 'my super password' }
56 await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR }) 56 await server.users.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
57 57
58 moderatorAccessToken = await server.loginCommand.getAccessToken(moderator) 58 moderatorAccessToken = await server.login.getAccessToken(moderator)
59 }) 59 })
60 60
61 describe('When setting a video filter', function () { 61 describe('When setting a video filter', function () {
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts
index 1da922a17..549c9fa1f 100644
--- a/server/tests/api/check-params/videos-history.ts
+++ b/server/tests/api/check-params/videos-history.ts
@@ -29,7 +29,7 @@ describe('Test videos history API validator', function () {
29 29
30 await setAccessTokensToServers([ server ]) 30 await setAccessTokensToServers([ server ])
31 31
32 const { uuid } = await server.videosCommand.upload() 32 const { uuid } = await server.videos.upload()
33 watchingPath = '/api/v1/videos/' + uuid + '/watching' 33 watchingPath = '/api/v1/videos/' + uuid + '/watching'
34 }) 34 })
35 35
diff --git a/server/tests/api/check-params/videos-overviews.ts b/server/tests/api/check-params/videos-overviews.ts
index 44a936c9f..3597c81d3 100644
--- a/server/tests/api/check-params/videos-overviews.ts
+++ b/server/tests/api/check-params/videos-overviews.ts
@@ -17,12 +17,12 @@ describe('Test videos overview', function () {
17 describe('When getting videos overview', function () { 17 describe('When getting videos overview', function () {
18 18
19 it('Should fail with a bad pagination', async function () { 19 it('Should fail with a bad pagination', async function () {
20 await server.overviewsCommand.getVideos({ page: 0, expectedStatus: 400 }) 20 await server.overviews.getVideos({ page: 0, expectedStatus: 400 })
21 await server.overviewsCommand.getVideos({ page: 100, expectedStatus: 400 }) 21 await server.overviews.getVideos({ page: 100, expectedStatus: 400 })
22 }) 22 })
23 23
24 it('Should succeed with a good pagination', async function () { 24 it('Should succeed with a good pagination', async function () {
25 await server.overviewsCommand.getVideos({ page: 1 }) 25 await server.overviews.getVideos({ page: 1 })
26 }) 26 })
27 }) 27 })
28 28
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index 8f9f33b8c..69bdae7cf 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -44,11 +44,11 @@ describe('Test videos API validator', function () {
44 44
45 const username = 'user1' 45 const username = 'user1'
46 const password = 'my super password' 46 const password = 'my super password'
47 await server.usersCommand.create({ username: username, password: password }) 47 await server.users.create({ username: username, password: password })
48 userAccessToken = await server.loginCommand.getAccessToken({ username, password }) 48 userAccessToken = await server.login.getAccessToken({ username, password })
49 49
50 { 50 {
51 const body = await server.usersCommand.getMyInfo() 51 const body = await server.users.getMyInfo()
52 channelId = body.videoChannels[0].id 52 channelId = body.videoChannels[0].id
53 channelName = body.videoChannels[0].name 53 channelName = body.videoChannels[0].name
54 accountName = body.account.name + '@' + body.account.host 54 accountName = body.account.name + '@' + body.account.host
@@ -274,10 +274,10 @@ describe('Test videos API validator', function () {
274 username: 'fake' + randomInt(0, 1500), 274 username: 'fake' + randomInt(0, 1500),
275 password: 'fake_password' 275 password: 'fake_password'
276 } 276 }
277 await server.usersCommand.create({ username: user.username, password: user.password }) 277 await server.users.create({ username: user.username, password: user.password })
278 278
279 const accessTokenUser = await server.loginCommand.getAccessToken(user) 279 const accessTokenUser = await server.login.getAccessToken(user)
280 const { videoChannels } = await server.usersCommand.getMyInfo({ token: accessTokenUser }) 280 const { videoChannels } = await server.users.getMyInfo({ token: accessTokenUser })
281 const customChannelId = videoChannels[0].id 281 const customChannelId = videoChannels[0].id
282 282
283 const fields = { ...baseCorrectParams, channelId: customChannelId } 283 const fields = { ...baseCorrectParams, channelId: customChannelId }
@@ -484,7 +484,7 @@ describe('Test videos API validator', function () {
484 } 484 }
485 485
486 before(async function () { 486 before(async function () {
487 const { data } = await server.videosCommand.list() 487 const { data } = await server.videos.list()
488 video = data[0] 488 video = data[0]
489 }) 489 })
490 490
@@ -710,15 +710,15 @@ describe('Test videos API validator', function () {
710 }) 710 })
711 711
712 it('Should fail without a correct uuid', async function () { 712 it('Should fail without a correct uuid', async function () {
713 await server.videosCommand.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 713 await server.videos.get({ id: 'coucou', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
714 }) 714 })
715 715
716 it('Should return 404 with an incorrect video', async function () { 716 it('Should return 404 with an incorrect video', async function () {
717 await server.videosCommand.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 717 await server.videos.get({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
718 }) 718 })
719 719
720 it('Shoud report the appropriate error', async function () { 720 it('Shoud report the appropriate error', async function () {
721 const body = await server.videosCommand.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 721 const body = await server.videos.get({ id: 'hi', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
722 const error = body as unknown as PeerTubeProblemDocument 722 const error = body as unknown as PeerTubeProblemDocument
723 723
724 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo') 724 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/getVideo')
@@ -734,7 +734,7 @@ describe('Test videos API validator', function () {
734 }) 734 })
735 735
736 it('Should succeed with the correct parameters', async function () { 736 it('Should succeed with the correct parameters', async function () {
737 await server.videosCommand.get({ id: video.shortUUID }) 737 await server.videos.get({ id: video.shortUUID })
738 }) 738 })
739 }) 739 })
740 740
@@ -742,7 +742,7 @@ describe('Test videos API validator', function () {
742 let videoId: number 742 let videoId: number
743 743
744 before(async function () { 744 before(async function () {
745 const { data } = await server.videosCommand.list() 745 const { data } = await server.videos.list()
746 videoId = data[0].id 746 videoId = data[0].id
747 }) 747 })
748 748
@@ -797,21 +797,21 @@ describe('Test videos API validator', function () {
797 }) 797 })
798 798
799 it('Should fail without a correct uuid', async function () { 799 it('Should fail without a correct uuid', async function () {
800 await server.videosCommand.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 800 await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
801 }) 801 })
802 802
803 it('Should fail with a video which does not exist', async function () { 803 it('Should fail with a video which does not exist', async function () {
804 await server.videosCommand.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 804 await server.videos.remove({ id: '4da6fde3-88f7-4d16-b119-108df5630b06', expectedStatus: HttpStatusCode.NOT_FOUND_404 })
805 }) 805 })
806 806
807 it('Should fail with a video of another user without the appropriate right', async function () { 807 it('Should fail with a video of another user without the appropriate right', async function () {
808 await server.videosCommand.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 808 await server.videos.remove({ token: userAccessToken, id: video.uuid, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
809 }) 809 })
810 810
811 it('Should fail with a video of another server') 811 it('Should fail with a video of another server')
812 812
813 it('Shoud report the appropriate error', async function () { 813 it('Shoud report the appropriate error', async function () {
814 const body = await server.videosCommand.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 814 const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
815 const error = body as unknown as PeerTubeProblemDocument 815 const error = body as unknown as PeerTubeProblemDocument
816 816
817 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') 817 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
@@ -827,7 +827,7 @@ describe('Test videos API validator', function () {
827 }) 827 })
828 828
829 it('Should succeed with the correct parameters', async function () { 829 it('Should succeed with the correct parameters', async function () {
830 await server.videosCommand.remove({ id: video.uuid }) 830 await server.videos.remove({ id: video.uuid })
831 }) 831 })
832 }) 832 })
833 833
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts
index 7900b1abe..1c380883c 100644
--- a/server/tests/api/live/live-constraints.ts
+++ b/server/tests/api/live/live-constraints.ts
@@ -32,13 +32,13 @@ describe('Test live constraints', function () {
32 saveReplay 32 saveReplay
33 } 33 }
34 34
35 const { uuid } = await servers[0].liveCommand.create({ token: userAccessToken, fields: liveAttributes }) 35 const { uuid } = await servers[0].live.create({ token: userAccessToken, fields: liveAttributes })
36 return uuid 36 return uuid
37 } 37 }
38 38
39 async function checkSaveReplay (videoId: string, resolutions = [ 720 ]) { 39 async function checkSaveReplay (videoId: string, resolutions = [ 720 ]) {
40 for (const server of servers) { 40 for (const server of servers) {
41 const video = await server.videosCommand.get({ id: videoId }) 41 const video = await server.videos.get({ id: videoId })
42 expect(video.isLive).to.be.false 42 expect(video.isLive).to.be.false
43 expect(video.duration).to.be.greaterThan(0) 43 expect(video.duration).to.be.greaterThan(0)
44 } 44 }
@@ -48,12 +48,12 @@ describe('Test live constraints', function () {
48 48
49 async function waitUntilLivePublishedOnAllServers (videoId: string) { 49 async function waitUntilLivePublishedOnAllServers (videoId: string) {
50 for (const server of servers) { 50 for (const server of servers) {
51 await server.liveCommand.waitUntilPublished({ videoId }) 51 await server.live.waitUntilPublished({ videoId })
52 } 52 }
53 } 53 }
54 54
55 function updateQuota (options: { total: number, daily: number }) { 55 function updateQuota (options: { total: number, daily: number }) {
56 return servers[0].usersCommand.update({ 56 return servers[0].users.update({
57 userId, 57 userId,
58 videoQuota: options.total, 58 videoQuota: options.total,
59 videoQuotaDaily: options.daily 59 videoQuotaDaily: options.daily
@@ -69,7 +69,7 @@ describe('Test live constraints', function () {
69 await setAccessTokensToServers(servers) 69 await setAccessTokensToServers(servers)
70 await setDefaultVideoChannel(servers) 70 await setDefaultVideoChannel(servers)
71 71
72 await servers[0].configCommand.updateCustomSubConfig({ 72 await servers[0].config.updateCustomSubConfig({
73 newConfig: { 73 newConfig: {
74 live: { 74 live: {
75 enabled: true, 75 enabled: true,
@@ -82,7 +82,7 @@ describe('Test live constraints', function () {
82 }) 82 })
83 83
84 { 84 {
85 const res = await servers[0].usersCommand.generate('user1') 85 const res = await servers[0].users.generate('user1')
86 userId = res.userId 86 userId = res.userId
87 userChannelId = res.userChannelId 87 userChannelId = res.userChannelId
88 userAccessToken = res.token 88 userAccessToken = res.token
@@ -98,7 +98,7 @@ describe('Test live constraints', function () {
98 this.timeout(60000) 98 this.timeout(60000)
99 99
100 const userVideoLiveoId = await createLiveWrapper(false) 100 const userVideoLiveoId = await createLiveWrapper(false)
101 await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false }) 101 await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
102 }) 102 })
103 103
104 it('Should have size limit depending on user global quota if save replay is enabled', async function () { 104 it('Should have size limit depending on user global quota if save replay is enabled', async function () {
@@ -108,7 +108,7 @@ describe('Test live constraints', function () {
108 await wait(5000) 108 await wait(5000)
109 109
110 const userVideoLiveoId = await createLiveWrapper(true) 110 const userVideoLiveoId = await createLiveWrapper(true)
111 await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }) 111 await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
112 112
113 await waitUntilLivePublishedOnAllServers(userVideoLiveoId) 113 await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
114 await waitJobs(servers) 114 await waitJobs(servers)
@@ -125,7 +125,7 @@ describe('Test live constraints', function () {
125 await updateQuota({ total: -1, daily: 1 }) 125 await updateQuota({ total: -1, daily: 1 })
126 126
127 const userVideoLiveoId = await createLiveWrapper(true) 127 const userVideoLiveoId = await createLiveWrapper(true)
128 await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }) 128 await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
129 129
130 await waitUntilLivePublishedOnAllServers(userVideoLiveoId) 130 await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
131 await waitJobs(servers) 131 await waitJobs(servers)
@@ -142,13 +142,13 @@ describe('Test live constraints', function () {
142 await updateQuota({ total: 10 * 1000 * 1000, daily: -1 }) 142 await updateQuota({ total: 10 * 1000 * 1000, daily: -1 })
143 143
144 const userVideoLiveoId = await createLiveWrapper(true) 144 const userVideoLiveoId = await createLiveWrapper(true)
145 await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false }) 145 await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: false })
146 }) 146 })
147 147
148 it('Should have max duration limit', async function () { 148 it('Should have max duration limit', async function () {
149 this.timeout(60000) 149 this.timeout(60000)
150 150
151 await servers[0].configCommand.updateCustomSubConfig({ 151 await servers[0].config.updateCustomSubConfig({
152 newConfig: { 152 newConfig: {
153 live: { 153 live: {
154 enabled: true, 154 enabled: true,
@@ -163,7 +163,7 @@ describe('Test live constraints', function () {
163 }) 163 })
164 164
165 const userVideoLiveoId = await createLiveWrapper(true) 165 const userVideoLiveoId = await createLiveWrapper(true)
166 await servers[0].liveCommand.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true }) 166 await servers[0].live.runAndTestStreamError({ token: userAccessToken, videoId: userVideoLiveoId, shouldHaveError: true })
167 167
168 await waitUntilLivePublishedOnAllServers(userVideoLiveoId) 168 await waitUntilLivePublishedOnAllServers(userVideoLiveoId)
169 await waitJobs(servers) 169 await waitJobs(servers)
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts
index 707f2edf8..900bd6f5c 100644
--- a/server/tests/api/live/live-permanent.ts
+++ b/server/tests/api/live/live-permanent.ts
@@ -24,20 +24,20 @@ describe('Permanent live', function () {
24 24
25 async function createLiveWrapper (permanentLive: boolean) { 25 async function createLiveWrapper (permanentLive: boolean) {
26 const attributes: LiveVideoCreate = { 26 const attributes: LiveVideoCreate = {
27 channelId: servers[0].videoChannel.id, 27 channelId: servers[0].store.channel.id,
28 privacy: VideoPrivacy.PUBLIC, 28 privacy: VideoPrivacy.PUBLIC,
29 name: 'my super live', 29 name: 'my super live',
30 saveReplay: false, 30 saveReplay: false,
31 permanentLive 31 permanentLive
32 } 32 }
33 33
34 const { uuid } = await servers[0].liveCommand.create({ fields: attributes }) 34 const { uuid } = await servers[0].live.create({ fields: attributes })
35 return uuid 35 return uuid
36 } 36 }
37 37
38 async function checkVideoState (videoId: string, state: VideoState) { 38 async function checkVideoState (videoId: string, state: VideoState) {
39 for (const server of servers) { 39 for (const server of servers) {
40 const video = await server.videosCommand.get({ id: videoId }) 40 const video = await server.videos.get({ id: videoId })
41 expect(video.state.id).to.equal(state) 41 expect(video.state.id).to.equal(state)
42 } 42 }
43 } 43 }
@@ -54,7 +54,7 @@ describe('Permanent live', function () {
54 // Server 1 and server 2 follow each other 54 // Server 1 and server 2 follow each other
55 await doubleFollow(servers[0], servers[1]) 55 await doubleFollow(servers[0], servers[1])
56 56
57 await servers[0].configCommand.updateCustomSubConfig({ 57 await servers[0].config.updateCustomSubConfig({
58 newConfig: { 58 newConfig: {
59 live: { 59 live: {
60 enabled: true, 60 enabled: true,
@@ -75,14 +75,14 @@ describe('Permanent live', function () {
75 const videoUUID = await createLiveWrapper(false) 75 const videoUUID = await createLiveWrapper(false)
76 76
77 { 77 {
78 const live = await servers[0].liveCommand.get({ videoId: videoUUID }) 78 const live = await servers[0].live.get({ videoId: videoUUID })
79 expect(live.permanentLive).to.be.false 79 expect(live.permanentLive).to.be.false
80 } 80 }
81 81
82 await servers[0].liveCommand.update({ videoId: videoUUID, fields: { permanentLive: true } }) 82 await servers[0].live.update({ videoId: videoUUID, fields: { permanentLive: true } })
83 83
84 { 84 {
85 const live = await servers[0].liveCommand.get({ videoId: videoUUID }) 85 const live = await servers[0].live.get({ videoId: videoUUID })
86 expect(live.permanentLive).to.be.true 86 expect(live.permanentLive).to.be.true
87 } 87 }
88 }) 88 })
@@ -92,7 +92,7 @@ describe('Permanent live', function () {
92 92
93 videoUUID = await createLiveWrapper(true) 93 videoUUID = await createLiveWrapper(true)
94 94
95 const live = await servers[0].liveCommand.get({ videoId: videoUUID }) 95 const live = await servers[0].live.get({ videoId: videoUUID })
96 expect(live.permanentLive).to.be.true 96 expect(live.permanentLive).to.be.true
97 97
98 await waitJobs(servers) 98 await waitJobs(servers)
@@ -101,16 +101,16 @@ describe('Permanent live', function () {
101 it('Should stream into this permanent live', async function () { 101 it('Should stream into this permanent live', async function () {
102 this.timeout(120000) 102 this.timeout(120000)
103 103
104 const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID }) 104 const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID })
105 105
106 for (const server of servers) { 106 for (const server of servers) {
107 await server.liveCommand.waitUntilPublished({ videoId: videoUUID }) 107 await server.live.waitUntilPublished({ videoId: videoUUID })
108 } 108 }
109 109
110 await checkVideoState(videoUUID, VideoState.PUBLISHED) 110 await checkVideoState(videoUUID, VideoState.PUBLISHED)
111 111
112 await stopFfmpeg(ffmpegCommand) 112 await stopFfmpeg(ffmpegCommand)
113 await servers[0].liveCommand.waitUntilWaiting({ videoId: videoUUID }) 113 await servers[0].live.waitUntilWaiting({ videoId: videoUUID })
114 114
115 await waitJobs(servers) 115 await waitJobs(servers)
116 }) 116 })
@@ -122,7 +122,7 @@ describe('Permanent live', function () {
122 await waitJobs(servers) 122 await waitJobs(servers)
123 123
124 for (const server of servers) { 124 for (const server of servers) {
125 const videoDetails = await server.videosCommand.get({ id: videoUUID }) 125 const videoDetails = await server.videos.get({ id: videoUUID })
126 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 126 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
127 } 127 }
128 }) 128 })
@@ -136,7 +136,7 @@ describe('Permanent live', function () {
136 it('Should be able to stream again in the permanent live', async function () { 136 it('Should be able to stream again in the permanent live', async function () {
137 this.timeout(20000) 137 this.timeout(20000)
138 138
139 await servers[0].configCommand.updateCustomSubConfig({ 139 await servers[0].config.updateCustomSubConfig({
140 newConfig: { 140 newConfig: {
141 live: { 141 live: {
142 enabled: true, 142 enabled: true,
@@ -150,15 +150,15 @@ describe('Permanent live', function () {
150 } 150 }
151 }) 151 })
152 152
153 const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: videoUUID }) 153 const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: videoUUID })
154 154
155 for (const server of servers) { 155 for (const server of servers) {
156 await server.liveCommand.waitUntilPublished({ videoId: videoUUID }) 156 await server.live.waitUntilPublished({ videoId: videoUUID })
157 } 157 }
158 158
159 await checkVideoState(videoUUID, VideoState.PUBLISHED) 159 await checkVideoState(videoUUID, VideoState.PUBLISHED)
160 160
161 const count = await servers[0].liveCommand.countPlaylists({ videoUUID }) 161 const count = await servers[0].live.countPlaylists({ videoUUID })
162 // master playlist and 720p playlist 162 // master playlist and 720p playlist
163 expect(count).to.equal(2) 163 expect(count).to.equal(2)
164 164
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index a87a2cd12..7a33df90a 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -30,19 +30,19 @@ describe('Save replay setting', function () {
30 async function createLiveWrapper (saveReplay: boolean) { 30 async function createLiveWrapper (saveReplay: boolean) {
31 if (liveVideoUUID) { 31 if (liveVideoUUID) {
32 try { 32 try {
33 await servers[0].videosCommand.remove({ id: liveVideoUUID }) 33 await servers[0].videos.remove({ id: liveVideoUUID })
34 await waitJobs(servers) 34 await waitJobs(servers)
35 } catch {} 35 } catch {}
36 } 36 }
37 37
38 const attributes: LiveVideoCreate = { 38 const attributes: LiveVideoCreate = {
39 channelId: servers[0].videoChannel.id, 39 channelId: servers[0].store.channel.id,
40 privacy: VideoPrivacy.PUBLIC, 40 privacy: VideoPrivacy.PUBLIC,
41 name: 'my super live', 41 name: 'my super live',
42 saveReplay 42 saveReplay
43 } 43 }
44 44
45 const { uuid } = await servers[0].liveCommand.create({ fields: attributes }) 45 const { uuid } = await servers[0].live.create({ fields: attributes })
46 return uuid 46 return uuid
47 } 47 }
48 48
@@ -50,32 +50,32 @@ describe('Save replay setting', function () {
50 for (const server of servers) { 50 for (const server of servers) {
51 const length = existsInList ? 1 : 0 51 const length = existsInList ? 1 : 0
52 52
53 const { data, total } = await server.videosCommand.list() 53 const { data, total } = await server.videos.list()
54 expect(data).to.have.lengthOf(length) 54 expect(data).to.have.lengthOf(length)
55 expect(total).to.equal(length) 55 expect(total).to.equal(length)
56 56
57 if (expectedStatus) { 57 if (expectedStatus) {
58 await server.videosCommand.get({ id: videoId, expectedStatus }) 58 await server.videos.get({ id: videoId, expectedStatus })
59 } 59 }
60 } 60 }
61 } 61 }
62 62
63 async function checkVideoState (videoId: string, state: VideoState) { 63 async function checkVideoState (videoId: string, state: VideoState) {
64 for (const server of servers) { 64 for (const server of servers) {
65 const video = await server.videosCommand.get({ id: videoId }) 65 const video = await server.videos.get({ id: videoId })
66 expect(video.state.id).to.equal(state) 66 expect(video.state.id).to.equal(state)
67 } 67 }
68 } 68 }
69 69
70 async function waitUntilLivePublishedOnAllServers (videoId: string) { 70 async function waitUntilLivePublishedOnAllServers (videoId: string) {
71 for (const server of servers) { 71 for (const server of servers) {
72 await server.liveCommand.waitUntilPublished({ videoId }) 72 await server.live.waitUntilPublished({ videoId })
73 } 73 }
74 } 74 }
75 75
76 async function waitUntilLiveSavedOnAllServers (videoId: string) { 76 async function waitUntilLiveSavedOnAllServers (videoId: string) {
77 for (const server of servers) { 77 for (const server of servers) {
78 await server.liveCommand.waitUntilSaved({ videoId }) 78 await server.live.waitUntilSaved({ videoId })
79 } 79 }
80 } 80 }
81 81
@@ -91,7 +91,7 @@ describe('Save replay setting', function () {
91 // Server 1 and server 2 follow each other 91 // Server 1 and server 2 follow each other
92 await doubleFollow(servers[0], servers[1]) 92 await doubleFollow(servers[0], servers[1])
93 93
94 await servers[0].configCommand.updateCustomSubConfig({ 94 await servers[0].config.updateCustomSubConfig({
95 newConfig: { 95 newConfig: {
96 live: { 96 live: {
97 enabled: true, 97 enabled: true,
@@ -126,7 +126,7 @@ describe('Save replay setting', function () {
126 it('Should correctly have updated the live and federated it when streaming in the live', async function () { 126 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
127 this.timeout(30000) 127 this.timeout(30000)
128 128
129 ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 129 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
130 130
131 await waitUntilLivePublishedOnAllServers(liveVideoUUID) 131 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
132 132
@@ -142,7 +142,7 @@ describe('Save replay setting', function () {
142 await stopFfmpeg(ffmpegCommand) 142 await stopFfmpeg(ffmpegCommand)
143 143
144 for (const server of servers) { 144 for (const server of servers) {
145 await server.liveCommand.waitUntilEnded({ videoId: liveVideoUUID }) 145 await server.live.waitUntilEnded({ videoId: liveVideoUUID })
146 } 146 }
147 await waitJobs(servers) 147 await waitJobs(servers)
148 148
@@ -159,7 +159,7 @@ describe('Save replay setting', function () {
159 159
160 liveVideoUUID = await createLiveWrapper(false) 160 liveVideoUUID = await createLiveWrapper(false)
161 161
162 ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 162 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
163 163
164 await waitUntilLivePublishedOnAllServers(liveVideoUUID) 164 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
165 165
@@ -167,7 +167,7 @@ describe('Save replay setting', function () {
167 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 167 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
168 168
169 await Promise.all([ 169 await Promise.all([
170 servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), 170 servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
171 testFfmpegStreamError(ffmpegCommand, true) 171 testFfmpegStreamError(ffmpegCommand, true)
172 ]) 172 ])
173 173
@@ -175,8 +175,8 @@ describe('Save replay setting', function () {
175 175
176 await checkVideosExist(liveVideoUUID, false) 176 await checkVideosExist(liveVideoUUID, false)
177 177
178 await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 178 await servers[0].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
179 await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 179 await servers[1].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
180 180
181 await wait(5000) 181 await wait(5000)
182 await waitJobs(servers) 182 await waitJobs(servers)
@@ -188,7 +188,7 @@ describe('Save replay setting', function () {
188 188
189 liveVideoUUID = await createLiveWrapper(false) 189 liveVideoUUID = await createLiveWrapper(false)
190 190
191 ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 191 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
192 192
193 await waitUntilLivePublishedOnAllServers(liveVideoUUID) 193 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
194 194
@@ -197,7 +197,7 @@ describe('Save replay setting', function () {
197 197
198 await Promise.all([ 198 await Promise.all([
199 testFfmpegStreamError(ffmpegCommand, true), 199 testFfmpegStreamError(ffmpegCommand, true),
200 servers[0].videosCommand.remove({ id: liveVideoUUID }) 200 servers[0].videos.remove({ id: liveVideoUUID })
201 ]) 201 ])
202 202
203 await wait(5000) 203 await wait(5000)
@@ -224,7 +224,7 @@ describe('Save replay setting', function () {
224 it('Should correctly have updated the live and federated it when streaming in the live', async function () { 224 it('Should correctly have updated the live and federated it when streaming in the live', async function () {
225 this.timeout(20000) 225 this.timeout(20000)
226 226
227 ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 227 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
228 await waitUntilLivePublishedOnAllServers(liveVideoUUID) 228 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
229 229
230 await waitJobs(servers) 230 await waitJobs(servers)
@@ -249,11 +249,11 @@ describe('Save replay setting', function () {
249 it('Should update the saved live and correctly federate the updated attributes', async function () { 249 it('Should update the saved live and correctly federate the updated attributes', async function () {
250 this.timeout(30000) 250 this.timeout(30000)
251 251
252 await servers[0].videosCommand.update({ id: liveVideoUUID, attributes: { name: 'video updated' } }) 252 await servers[0].videos.update({ id: liveVideoUUID, attributes: { name: 'video updated' } })
253 await waitJobs(servers) 253 await waitJobs(servers)
254 254
255 for (const server of servers) { 255 for (const server of servers) {
256 const video = await server.videosCommand.get({ id: liveVideoUUID }) 256 const video = await server.videos.get({ id: liveVideoUUID })
257 expect(video.name).to.equal('video updated') 257 expect(video.name).to.equal('video updated')
258 expect(video.isLive).to.be.false 258 expect(video.isLive).to.be.false
259 } 259 }
@@ -268,14 +268,14 @@ describe('Save replay setting', function () {
268 268
269 liveVideoUUID = await createLiveWrapper(true) 269 liveVideoUUID = await createLiveWrapper(true)
270 270
271 ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 271 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
272 await waitUntilLivePublishedOnAllServers(liveVideoUUID) 272 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
273 273
274 await waitJobs(servers) 274 await waitJobs(servers)
275 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 275 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
276 276
277 await Promise.all([ 277 await Promise.all([
278 servers[0].blacklistCommand.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }), 278 servers[0].blacklist.add({ videoId: liveVideoUUID, reason: 'bad live', unfederate: true }),
279 testFfmpegStreamError(ffmpegCommand, true) 279 testFfmpegStreamError(ffmpegCommand, true)
280 ]) 280 ])
281 281
@@ -283,8 +283,8 @@ describe('Save replay setting', function () {
283 283
284 await checkVideosExist(liveVideoUUID, false) 284 await checkVideosExist(liveVideoUUID, false)
285 285
286 await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 286 await servers[0].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
287 await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 287 await servers[1].videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
288 288
289 await wait(5000) 289 await wait(5000)
290 await waitJobs(servers) 290 await waitJobs(servers)
@@ -296,14 +296,14 @@ describe('Save replay setting', function () {
296 296
297 liveVideoUUID = await createLiveWrapper(true) 297 liveVideoUUID = await createLiveWrapper(true)
298 298
299 ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 299 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
300 await waitUntilLivePublishedOnAllServers(liveVideoUUID) 300 await waitUntilLivePublishedOnAllServers(liveVideoUUID)
301 301
302 await waitJobs(servers) 302 await waitJobs(servers)
303 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 303 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
304 304
305 await Promise.all([ 305 await Promise.all([
306 servers[0].videosCommand.remove({ id: liveVideoUUID }), 306 servers[0].videos.remove({ id: liveVideoUUID }),
307 testFfmpegStreamError(ffmpegCommand, true) 307 testFfmpegStreamError(ffmpegCommand, true)
308 ]) 308 ])
309 309
diff --git a/server/tests/api/live/live-socket-messages.ts b/server/tests/api/live/live-socket-messages.ts
index 1f3d455a8..ad67d6285 100644
--- a/server/tests/api/live/live-socket-messages.ts
+++ b/server/tests/api/live/live-socket-messages.ts
@@ -30,7 +30,7 @@ describe('Test live', function () {
30 await setAccessTokensToServers(servers) 30 await setAccessTokensToServers(servers)
31 await setDefaultVideoChannel(servers) 31 await setDefaultVideoChannel(servers)
32 32
33 await servers[0].configCommand.updateCustomSubConfig({ 33 await servers[0].config.updateCustomSubConfig({
34 newConfig: { 34 newConfig: {
35 live: { 35 live: {
36 enabled: true, 36 enabled: true,
@@ -51,11 +51,11 @@ describe('Test live', function () {
51 async function createLiveWrapper () { 51 async function createLiveWrapper () {
52 const liveAttributes = { 52 const liveAttributes = {
53 name: 'live video', 53 name: 'live video',
54 channelId: servers[0].videoChannel.id, 54 channelId: servers[0].store.channel.id,
55 privacy: VideoPrivacy.PUBLIC 55 privacy: VideoPrivacy.PUBLIC
56 } 56 }
57 57
58 const { uuid } = await servers[0].liveCommand.create({ fields: liveAttributes }) 58 const { uuid } = await servers[0].live.create({ fields: liveAttributes })
59 return uuid 59 return uuid
60 } 60 }
61 61
@@ -69,22 +69,22 @@ describe('Test live', function () {
69 await waitJobs(servers) 69 await waitJobs(servers)
70 70
71 { 71 {
72 const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID }) 72 const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID })
73 73
74 const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket() 74 const localSocket = servers[0].socketIO.getLiveNotificationSocket()
75 localSocket.on('state-change', data => localStateChanges.push(data.state)) 75 localSocket.on('state-change', data => localStateChanges.push(data.state))
76 localSocket.emit('subscribe', { videoId }) 76 localSocket.emit('subscribe', { videoId })
77 } 77 }
78 78
79 { 79 {
80 const videoId = await servers[1].videosCommand.getId({ uuid: liveVideoUUID }) 80 const videoId = await servers[1].videos.getId({ uuid: liveVideoUUID })
81 81
82 const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket() 82 const remoteSocket = servers[1].socketIO.getLiveNotificationSocket()
83 remoteSocket.on('state-change', data => remoteStateChanges.push(data.state)) 83 remoteSocket.on('state-change', data => remoteStateChanges.push(data.state))
84 remoteSocket.emit('subscribe', { videoId }) 84 remoteSocket.emit('subscribe', { videoId })
85 } 85 }
86 86
87 const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 87 const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
88 88
89 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 89 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
90 await waitJobs(servers) 90 await waitJobs(servers)
@@ -97,7 +97,7 @@ describe('Test live', function () {
97 await stopFfmpeg(ffmpegCommand) 97 await stopFfmpeg(ffmpegCommand)
98 98
99 for (const server of servers) { 99 for (const server of servers) {
100 await server.liveCommand.waitUntilEnded({ videoId: liveVideoUUID }) 100 await server.live.waitUntilEnded({ videoId: liveVideoUUID })
101 } 101 }
102 await waitJobs(servers) 102 await waitJobs(servers)
103 103
@@ -117,22 +117,22 @@ describe('Test live', function () {
117 await waitJobs(servers) 117 await waitJobs(servers)
118 118
119 { 119 {
120 const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID }) 120 const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID })
121 121
122 const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket() 122 const localSocket = servers[0].socketIO.getLiveNotificationSocket()
123 localSocket.on('views-change', data => { localLastVideoViews = data.views }) 123 localSocket.on('views-change', data => { localLastVideoViews = data.views })
124 localSocket.emit('subscribe', { videoId }) 124 localSocket.emit('subscribe', { videoId })
125 } 125 }
126 126
127 { 127 {
128 const videoId = await servers[1].videosCommand.getId({ uuid: liveVideoUUID }) 128 const videoId = await servers[1].videos.getId({ uuid: liveVideoUUID })
129 129
130 const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket() 130 const remoteSocket = servers[1].socketIO.getLiveNotificationSocket()
131 remoteSocket.on('views-change', data => { remoteLastVideoViews = data.views }) 131 remoteSocket.on('views-change', data => { remoteLastVideoViews = data.views })
132 remoteSocket.emit('subscribe', { videoId }) 132 remoteSocket.emit('subscribe', { videoId })
133 } 133 }
134 134
135 const ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 135 const ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
136 136
137 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 137 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
138 await waitJobs(servers) 138 await waitJobs(servers)
@@ -140,8 +140,8 @@ describe('Test live', function () {
140 expect(localLastVideoViews).to.equal(0) 140 expect(localLastVideoViews).to.equal(0)
141 expect(remoteLastVideoViews).to.equal(0) 141 expect(remoteLastVideoViews).to.equal(0)
142 142
143 await servers[0].videosCommand.view({ id: liveVideoUUID }) 143 await servers[0].videos.view({ id: liveVideoUUID })
144 await servers[1].videosCommand.view({ id: liveVideoUUID }) 144 await servers[1].videos.view({ id: liveVideoUUID })
145 145
146 await waitJobs(servers) 146 await waitJobs(servers)
147 await wait(5000) 147 await wait(5000)
@@ -161,13 +161,13 @@ describe('Test live', function () {
161 const liveVideoUUID = await createLiveWrapper() 161 const liveVideoUUID = await createLiveWrapper()
162 await waitJobs(servers) 162 await waitJobs(servers)
163 163
164 const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID }) 164 const videoId = await servers[0].videos.getId({ uuid: liveVideoUUID })
165 165
166 const socket = servers[0].socketIOCommand.getLiveNotificationSocket() 166 const socket = servers[0].socketIO.getLiveNotificationSocket()
167 socket.on('state-change', data => stateChanges.push(data.state)) 167 socket.on('state-change', data => stateChanges.push(data.state))
168 socket.emit('subscribe', { videoId }) 168 socket.emit('subscribe', { videoId })
169 169
170 const command = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoUUID }) 170 const command = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoUUID })
171 171
172 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID) 172 await waitUntilLivePublishedOnAllServers(servers, liveVideoUUID)
173 await waitJobs(servers) 173 await waitJobs(servers)
diff --git a/server/tests/api/live/live-views.ts b/server/tests/api/live/live-views.ts
index 1951b11a5..43222f9c9 100644
--- a/server/tests/api/live/live-views.ts
+++ b/server/tests/api/live/live-views.ts
@@ -31,7 +31,7 @@ describe('Test live', function () {
31 await setAccessTokensToServers(servers) 31 await setAccessTokensToServers(servers)
32 await setDefaultVideoChannel(servers) 32 await setDefaultVideoChannel(servers)
33 33
34 await servers[0].configCommand.updateCustomSubConfig({ 34 await servers[0].config.updateCustomSubConfig({
35 newConfig: { 35 newConfig: {
36 live: { 36 live: {
37 enabled: true, 37 enabled: true,
@@ -53,7 +53,7 @@ describe('Test live', function () {
53 53
54 async function countViews (expected: number) { 54 async function countViews (expected: number) {
55 for (const server of servers) { 55 for (const server of servers) {
56 const video = await server.videosCommand.get({ id: liveVideoId }) 56 const video = await server.videos.get({ id: liveVideoId })
57 expect(video.views).to.equal(expected) 57 expect(video.views).to.equal(expected)
58 } 58 }
59 } 59 }
@@ -63,14 +63,14 @@ describe('Test live', function () {
63 63
64 const liveAttributes = { 64 const liveAttributes = {
65 name: 'live video', 65 name: 'live video',
66 channelId: servers[0].videoChannel.id, 66 channelId: servers[0].store.channel.id,
67 privacy: VideoPrivacy.PUBLIC 67 privacy: VideoPrivacy.PUBLIC
68 } 68 }
69 69
70 const live = await servers[0].liveCommand.create({ fields: liveAttributes }) 70 const live = await servers[0].live.create({ fields: liveAttributes })
71 liveVideoId = live.uuid 71 liveVideoId = live.uuid
72 72
73 command = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId }) 73 command = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId })
74 await waitUntilLivePublishedOnAllServers(servers, liveVideoId) 74 await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
75 await waitJobs(servers) 75 await waitJobs(servers)
76 }) 76 })
@@ -82,8 +82,8 @@ describe('Test live', function () {
82 it('Should view a live twice and display 1 view', async function () { 82 it('Should view a live twice and display 1 view', async function () {
83 this.timeout(30000) 83 this.timeout(30000)
84 84
85 await servers[0].videosCommand.view({ id: liveVideoId }) 85 await servers[0].videos.view({ id: liveVideoId })
86 await servers[0].videosCommand.view({ id: liveVideoId }) 86 await servers[0].videos.view({ id: liveVideoId })
87 87
88 await wait(7000) 88 await wait(7000)
89 89
@@ -104,9 +104,9 @@ describe('Test live', function () {
104 it('Should view a live on a remote and on local and display 2 views', async function () { 104 it('Should view a live on a remote and on local and display 2 views', async function () {
105 this.timeout(30000) 105 this.timeout(30000)
106 106
107 await servers[0].videosCommand.view({ id: liveVideoId }) 107 await servers[0].videos.view({ id: liveVideoId })
108 await servers[1].videosCommand.view({ id: liveVideoId }) 108 await servers[1].videos.view({ id: liveVideoId })
109 await servers[1].videosCommand.view({ id: liveVideoId }) 109 await servers[1].videos.view({ id: liveVideoId })
110 110
111 await wait(7000) 111 await wait(7000)
112 await waitJobs(servers) 112 await waitJobs(servers)
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index c88143982..2cce1f448 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -44,7 +44,7 @@ describe('Test live', function () {
44 await setAccessTokensToServers(servers) 44 await setAccessTokensToServers(servers)
45 await setDefaultVideoChannel(servers) 45 await setDefaultVideoChannel(servers)
46 46
47 await servers[0].configCommand.updateCustomSubConfig({ 47 await servers[0].config.updateCustomSubConfig({
48 newConfig: { 48 newConfig: {
49 live: { 49 live: {
50 enabled: true, 50 enabled: true,
@@ -59,7 +59,7 @@ describe('Test live', function () {
59 // Server 1 and server 2 follow each other 59 // Server 1 and server 2 follow each other
60 await doubleFollow(servers[0], servers[1]) 60 await doubleFollow(servers[0], servers[1])
61 61
62 commands = servers.map(s => s.liveCommand) 62 commands = servers.map(s => s.live)
63 }) 63 })
64 64
65 describe('Live creation, update and delete', function () { 65 describe('Live creation, update and delete', function () {
@@ -74,7 +74,7 @@ describe('Test live', function () {
74 language: 'fr', 74 language: 'fr',
75 description: 'super live description', 75 description: 'super live description',
76 support: 'support field', 76 support: 'support field',
77 channelId: servers[0].videoChannel.id, 77 channelId: servers[0].store.channel.id,
78 nsfw: false, 78 nsfw: false,
79 waitTranscoding: false, 79 waitTranscoding: false,
80 name: 'my super live', 80 name: 'my super live',
@@ -93,7 +93,7 @@ describe('Test live', function () {
93 await waitJobs(servers) 93 await waitJobs(servers)
94 94
95 for (const server of servers) { 95 for (const server of servers) {
96 const video = await server.videosCommand.get({ id: liveVideoUUID }) 96 const video = await server.videos.get({ id: liveVideoUUID })
97 97
98 expect(video.category.id).to.equal(1) 98 expect(video.category.id).to.equal(1)
99 expect(video.licence.id).to.equal(2) 99 expect(video.licence.id).to.equal(2)
@@ -101,8 +101,8 @@ describe('Test live', function () {
101 expect(video.description).to.equal('super live description') 101 expect(video.description).to.equal('super live description')
102 expect(video.support).to.equal('support field') 102 expect(video.support).to.equal('support field')
103 103
104 expect(video.channel.name).to.equal(servers[0].videoChannel.name) 104 expect(video.channel.name).to.equal(servers[0].store.channel.name)
105 expect(video.channel.host).to.equal(servers[0].videoChannel.host) 105 expect(video.channel.host).to.equal(servers[0].store.channel.host)
106 106
107 expect(video.isLive).to.be.true 107 expect(video.isLive).to.be.true
108 108
@@ -117,7 +117,7 @@ describe('Test live', function () {
117 await testImage(server.url, 'video_short1-preview.webm', video.previewPath) 117 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
118 await testImage(server.url, 'video_short1.webm', video.thumbnailPath) 118 await testImage(server.url, 'video_short1.webm', video.thumbnailPath)
119 119
120 const live = await server.liveCommand.get({ videoId: liveVideoUUID }) 120 const live = await server.live.get({ videoId: liveVideoUUID })
121 121
122 if (server.url === servers[0].url) { 122 if (server.url === servers[0].url) {
123 expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live') 123 expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
@@ -136,7 +136,7 @@ describe('Test live', function () {
136 136
137 const attributes: LiveVideoCreate = { 137 const attributes: LiveVideoCreate = {
138 name: 'default live thumbnail', 138 name: 'default live thumbnail',
139 channelId: servers[0].videoChannel.id, 139 channelId: servers[0].store.channel.id,
140 privacy: VideoPrivacy.UNLISTED, 140 privacy: VideoPrivacy.UNLISTED,
141 nsfw: true 141 nsfw: true
142 } 142 }
@@ -147,7 +147,7 @@ describe('Test live', function () {
147 await waitJobs(servers) 147 await waitJobs(servers)
148 148
149 for (const server of servers) { 149 for (const server of servers) {
150 const video = await server.videosCommand.get({ id: videoId }) 150 const video = await server.videos.get({ id: videoId })
151 expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED) 151 expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED)
152 expect(video.nsfw).to.be.true 152 expect(video.nsfw).to.be.true
153 153
@@ -158,7 +158,7 @@ describe('Test live', function () {
158 158
159 it('Should not have the live listed since nobody streams into', async function () { 159 it('Should not have the live listed since nobody streams into', async function () {
160 for (const server of servers) { 160 for (const server of servers) {
161 const { total, data } = await server.videosCommand.list() 161 const { total, data } = await server.videos.list()
162 162
163 expect(total).to.equal(0) 163 expect(total).to.equal(0)
164 expect(data).to.have.lengthOf(0) 164 expect(data).to.have.lengthOf(0)
@@ -178,7 +178,7 @@ describe('Test live', function () {
178 178
179 it('Have the live updated', async function () { 179 it('Have the live updated', async function () {
180 for (const server of servers) { 180 for (const server of servers) {
181 const live = await server.liveCommand.get({ videoId: liveVideoUUID }) 181 const live = await server.live.get({ videoId: liveVideoUUID })
182 182
183 if (server.url === servers[0].url) { 183 if (server.url === servers[0].url) {
184 expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live') 184 expect(live.rtmpUrl).to.equal('rtmp://' + server.hostname + ':' + servers[0].rtmpPort + '/live')
@@ -195,14 +195,14 @@ describe('Test live', function () {
195 it('Delete the live', async function () { 195 it('Delete the live', async function () {
196 this.timeout(10000) 196 this.timeout(10000)
197 197
198 await servers[0].videosCommand.remove({ id: liveVideoUUID }) 198 await servers[0].videos.remove({ id: liveVideoUUID })
199 await waitJobs(servers) 199 await waitJobs(servers)
200 }) 200 })
201 201
202 it('Should have the live deleted', async function () { 202 it('Should have the live deleted', async function () {
203 for (const server of servers) { 203 for (const server of servers) {
204 await server.videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 204 await server.videos.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
205 await server.liveCommand.get({ videoId: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 205 await server.live.get({ videoId: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
206 } 206 }
207 }) 207 })
208 }) 208 })
@@ -215,19 +215,19 @@ describe('Test live', function () {
215 before(async function () { 215 before(async function () {
216 this.timeout(120000) 216 this.timeout(120000)
217 217
218 vodVideoId = (await servers[0].videosCommand.quickUpload({ name: 'vod video' })).uuid 218 vodVideoId = (await servers[0].videos.quickUpload({ name: 'vod video' })).uuid
219 219
220 const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].videoChannel.id } 220 const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].store.channel.id }
221 const live = await commands[0].create({ fields: liveOptions }) 221 const live = await commands[0].create({ fields: liveOptions })
222 liveVideoId = live.uuid 222 liveVideoId = live.uuid
223 223
224 ffmpegCommand = await servers[0].liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId }) 224 ffmpegCommand = await servers[0].live.sendRTMPStreamInVideo({ videoId: liveVideoId })
225 await waitUntilLivePublishedOnAllServers(servers, liveVideoId) 225 await waitUntilLivePublishedOnAllServers(servers, liveVideoId)
226 await waitJobs(servers) 226 await waitJobs(servers)
227 }) 227 })
228 228
229 it('Should only display lives', async function () { 229 it('Should only display lives', async function () {
230 const { data, total } = await servers[0].videosCommand.list({ isLive: true }) 230 const { data, total } = await servers[0].videos.list({ isLive: true })
231 231
232 expect(total).to.equal(1) 232 expect(total).to.equal(1)
233 expect(data).to.have.lengthOf(1) 233 expect(data).to.have.lengthOf(1)
@@ -235,7 +235,7 @@ describe('Test live', function () {
235 }) 235 })
236 236
237 it('Should not display lives', async function () { 237 it('Should not display lives', async function () {
238 const { data, total } = await servers[0].videosCommand.list({ isLive: false }) 238 const { data, total } = await servers[0].videos.list({ isLive: false })
239 239
240 expect(total).to.equal(1) 240 expect(total).to.equal(1)
241 expect(data).to.have.lengthOf(1) 241 expect(data).to.have.lengthOf(1)
@@ -248,22 +248,22 @@ describe('Test live', function () {
248 await stopFfmpeg(ffmpegCommand) 248 await stopFfmpeg(ffmpegCommand)
249 await waitJobs(servers) 249 await waitJobs(servers)
250 250
251 const { data } = await servers[0].videosCommand.listMyVideos({ isLive: true }) 251 const { data } = await servers[0].videos.listMyVideos({ isLive: true })
252 252
253 const result = data.every(v => v.isLive) 253 const result = data.every(v => v.isLive)
254 expect(result).to.be.true 254 expect(result).to.be.true
255 }) 255 })
256 256
257 it('Should not display my lives', async function () { 257 it('Should not display my lives', async function () {
258 const { data } = await servers[0].videosCommand.listMyVideos({ isLive: false }) 258 const { data } = await servers[0].videos.listMyVideos({ isLive: false })
259 259
260 const result = data.every(v => !v.isLive) 260 const result = data.every(v => !v.isLive)
261 expect(result).to.be.true 261 expect(result).to.be.true
262 }) 262 })
263 263
264 after(async function () { 264 after(async function () {
265 await servers[0].videosCommand.remove({ id: vodVideoId }) 265 await servers[0].videos.remove({ id: vodVideoId })
266 await servers[0].videosCommand.remove({ id: liveVideoId }) 266 await servers[0].videos.remove({ id: liveVideoId })
267 }) 267 })
268 }) 268 })
269 269
@@ -278,7 +278,7 @@ describe('Test live', function () {
278 async function createLiveWrapper () { 278 async function createLiveWrapper () {
279 const liveAttributes = { 279 const liveAttributes = {
280 name: 'user live', 280 name: 'user live',
281 channelId: servers[0].videoChannel.id, 281 channelId: servers[0].store.channel.id,
282 privacy: VideoPrivacy.PUBLIC, 282 privacy: VideoPrivacy.PUBLIC,
283 saveReplay: false 283 saveReplay: false
284 } 284 }
@@ -286,7 +286,7 @@ describe('Test live', function () {
286 const { uuid } = await commands[0].create({ fields: liveAttributes }) 286 const { uuid } = await commands[0].create({ fields: liveAttributes })
287 287
288 const live = await commands[0].get({ videoId: uuid }) 288 const live = await commands[0].get({ videoId: uuid })
289 const video = await servers[0].videosCommand.get({ id: uuid }) 289 const video = await servers[0].videos.get({ id: uuid })
290 290
291 return Object.assign(video, live) 291 return Object.assign(video, live)
292 } 292 }
@@ -316,7 +316,7 @@ describe('Test live', function () {
316 316
317 it('Should list this live now someone stream into it', async function () { 317 it('Should list this live now someone stream into it', async function () {
318 for (const server of servers) { 318 for (const server of servers) {
319 const { total, data } = await server.videosCommand.list() 319 const { total, data } = await server.videos.list()
320 320
321 expect(total).to.equal(1) 321 expect(total).to.equal(1)
322 expect(data).to.have.lengthOf(1) 322 expect(data).to.have.lengthOf(1)
@@ -332,7 +332,7 @@ describe('Test live', function () {
332 332
333 liveVideo = await createLiveWrapper() 333 liveVideo = await createLiveWrapper()
334 334
335 await servers[0].blacklistCommand.add({ videoId: liveVideo.uuid }) 335 await servers[0].blacklist.add({ videoId: liveVideo.uuid })
336 336
337 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey) 337 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
338 await testFfmpegStreamError(command, true) 338 await testFfmpegStreamError(command, true)
@@ -343,7 +343,7 @@ describe('Test live', function () {
343 343
344 liveVideo = await createLiveWrapper() 344 liveVideo = await createLiveWrapper()
345 345
346 await servers[0].videosCommand.remove({ id: liveVideo.uuid }) 346 await servers[0].videos.remove({ id: liveVideo.uuid })
347 347
348 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey) 348 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
349 await testFfmpegStreamError(command, true) 349 await testFfmpegStreamError(command, true)
@@ -356,7 +356,7 @@ describe('Test live', function () {
356 async function createLiveWrapper (saveReplay: boolean) { 356 async function createLiveWrapper (saveReplay: boolean) {
357 const liveAttributes = { 357 const liveAttributes = {
358 name: 'live video', 358 name: 'live video',
359 channelId: servers[0].videoChannel.id, 359 channelId: servers[0].store.channel.id,
360 privacy: VideoPrivacy.PUBLIC, 360 privacy: VideoPrivacy.PUBLIC,
361 saveReplay 361 saveReplay
362 } 362 }
@@ -367,10 +367,10 @@ describe('Test live', function () {
367 367
368 async function testVideoResolutions (liveVideoId: string, resolutions: number[]) { 368 async function testVideoResolutions (liveVideoId: string, resolutions: number[]) {
369 for (const server of servers) { 369 for (const server of servers) {
370 const { data } = await server.videosCommand.list() 370 const { data } = await server.videos.list()
371 expect(data.find(v => v.uuid === liveVideoId)).to.exist 371 expect(data.find(v => v.uuid === liveVideoId)).to.exist
372 372
373 const video = await server.videosCommand.get({ id: liveVideoId }) 373 const video = await server.videos.get({ id: liveVideoId })
374 374
375 expect(video.streamingPlaylists).to.have.lengthOf(1) 375 expect(video.streamingPlaylists).to.have.lengthOf(1)
376 376
@@ -387,7 +387,7 @@ describe('Test live', function () {
387 const segmentName = `${i}-00000${segmentNum}.ts` 387 const segmentName = `${i}-00000${segmentNum}.ts`
388 await commands[0].waitUntilSegmentGeneration({ videoUUID: video.uuid, resolution: i, segment: segmentNum }) 388 await commands[0].waitUntilSegmentGeneration({ videoUUID: video.uuid, resolution: i, segment: segmentNum })
389 389
390 const subPlaylist = await servers[0].streamingPlaylistsCommand.get({ 390 const subPlaylist = await servers[0].streamingPlaylists.get({
391 url: `${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8` 391 url: `${servers[0].url}/static/streaming-playlists/hls/${video.uuid}/${i}.m3u8`
392 }) 392 })
393 393
@@ -406,7 +406,7 @@ describe('Test live', function () {
406 } 406 }
407 407
408 function updateConf (resolutions: number[]) { 408 function updateConf (resolutions: number[]) {
409 return servers[0].configCommand.updateCustomSubConfig({ 409 return servers[0].config.updateCustomSubConfig({
410 newConfig: { 410 newConfig: {
411 live: { 411 live: {
412 enabled: true, 412 enabled: true,
@@ -490,7 +490,7 @@ describe('Test live', function () {
490 } 490 }
491 491
492 for (const server of servers) { 492 for (const server of servers) {
493 const video = await server.videosCommand.get({ id: liveVideoId }) 493 const video = await server.videos.get({ id: liveVideoId })
494 494
495 expect(video.state.id).to.equal(VideoState.PUBLISHED) 495 expect(video.state.id).to.equal(VideoState.PUBLISHED)
496 expect(video.duration).to.be.greaterThan(1) 496 expect(video.duration).to.be.greaterThan(1)
@@ -515,7 +515,7 @@ describe('Test live', function () {
515 } 515 }
516 516
517 const filename = `${video.uuid}-${resolution}-fragmented.mp4` 517 const filename = `${video.uuid}-${resolution}-fragmented.mp4`
518 const segmentPath = servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename)) 518 const segmentPath = servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', video.uuid, filename))
519 519
520 const probe = await ffprobePromise(segmentPath) 520 const probe = await ffprobePromise(segmentPath)
521 const videoStream = await getVideoStreamFromFile(segmentPath, probe) 521 const videoStream = await getVideoStreamFromFile(segmentPath, probe)
@@ -542,7 +542,7 @@ describe('Test live', function () {
542 async function createLiveWrapper (saveReplay: boolean) { 542 async function createLiveWrapper (saveReplay: boolean) {
543 const liveAttributes = { 543 const liveAttributes = {
544 name: 'live video', 544 name: 'live video',
545 channelId: servers[0].videoChannel.id, 545 channelId: servers[0].store.channel.id,
546 privacy: VideoPrivacy.PUBLIC, 546 privacy: VideoPrivacy.PUBLIC,
547 saveReplay 547 saveReplay
548 } 548 }
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts
index 7574b8f4a..97a0d95c4 100644
--- a/server/tests/api/moderation/abuses.ts
+++ b/server/tests/api/moderation/abuses.ts
@@ -33,7 +33,7 @@ describe('Test abuses', function () {
33 // Server 1 and server 2 follow each other 33 // Server 1 and server 2 follow each other
34 await doubleFollow(servers[0], servers[1]) 34 await doubleFollow(servers[0], servers[1])
35 35
36 commands = servers.map(s => s.abusesCommand) 36 commands = servers.map(s => s.abuses)
37 }) 37 })
38 38
39 describe('Video abuses', function () { 39 describe('Video abuses', function () {
@@ -47,7 +47,7 @@ describe('Test abuses', function () {
47 name: 'my super name for server 1', 47 name: 'my super name for server 1',
48 description: 'my super description for server 1' 48 description: 'my super description for server 1'
49 } 49 }
50 await servers[0].videosCommand.upload({ attributes }) 50 await servers[0].videos.upload({ attributes })
51 } 51 }
52 52
53 { 53 {
@@ -55,17 +55,17 @@ describe('Test abuses', function () {
55 name: 'my super name for server 2', 55 name: 'my super name for server 2',
56 description: 'my super description for server 2' 56 description: 'my super description for server 2'
57 } 57 }
58 await servers[1].videosCommand.upload({ attributes }) 58 await servers[1].videos.upload({ attributes })
59 } 59 }
60 60
61 // Wait videos propagation, server 2 has transcoding enabled 61 // Wait videos propagation, server 2 has transcoding enabled
62 await waitJobs(servers) 62 await waitJobs(servers)
63 63
64 const { data } = await servers[0].videosCommand.list() 64 const { data } = await servers[0].videos.list()
65 expect(data.length).to.equal(2) 65 expect(data.length).to.equal(2)
66 66
67 servers[0].video = data.find(video => video.name === 'my super name for server 1') 67 servers[0].store.video = data.find(video => video.name === 'my super name for server 1')
68 servers[1].video = data.find(video => video.name === 'my super name for server 2') 68 servers[1].store.video = data.find(video => video.name === 'my super name for server 2')
69 }) 69 })
70 70
71 it('Should not have abuses', async function () { 71 it('Should not have abuses', async function () {
@@ -80,7 +80,7 @@ describe('Test abuses', function () {
80 this.timeout(15000) 80 this.timeout(15000)
81 81
82 const reason = 'my super bad reason' 82 const reason = 'my super bad reason'
83 await commands[0].report({ videoId: servers[0].video.id, reason }) 83 await commands[0].report({ videoId: servers[0].store.video.id, reason })
84 84
85 // We wait requests propagation, even if the server 1 is not supposed to make a request to server 2 85 // We wait requests propagation, even if the server 1 is not supposed to make a request to server 2
86 await waitJobs(servers) 86 await waitJobs(servers)
@@ -100,7 +100,7 @@ describe('Test abuses', function () {
100 expect(abuse.reporterAccount.name).to.equal('root') 100 expect(abuse.reporterAccount.name).to.equal('root')
101 expect(abuse.reporterAccount.host).to.equal(servers[0].host) 101 expect(abuse.reporterAccount.host).to.equal(servers[0].host)
102 102
103 expect(abuse.video.id).to.equal(servers[0].video.id) 103 expect(abuse.video.id).to.equal(servers[0].store.video.id)
104 expect(abuse.video.channel).to.exist 104 expect(abuse.video.channel).to.exist
105 105
106 expect(abuse.comment).to.be.null 106 expect(abuse.comment).to.be.null
@@ -127,7 +127,7 @@ describe('Test abuses', function () {
127 this.timeout(10000) 127 this.timeout(10000)
128 128
129 const reason = 'my super bad reason 2' 129 const reason = 'my super bad reason 2'
130 const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid }) 130 const videoId = await servers[0].videos.getId({ uuid: servers[1].store.video.uuid })
131 await commands[0].report({ videoId, reason }) 131 await commands[0].report({ videoId, reason })
132 132
133 // We wait requests propagation 133 // We wait requests propagation
@@ -146,7 +146,7 @@ describe('Test abuses', function () {
146 expect(abuse1.reporterAccount.name).to.equal('root') 146 expect(abuse1.reporterAccount.name).to.equal('root')
147 expect(abuse1.reporterAccount.host).to.equal(servers[0].host) 147 expect(abuse1.reporterAccount.host).to.equal(servers[0].host)
148 148
149 expect(abuse1.video.id).to.equal(servers[0].video.id) 149 expect(abuse1.video.id).to.equal(servers[0].store.video.id)
150 expect(abuse1.video.countReports).to.equal(1) 150 expect(abuse1.video.countReports).to.equal(1)
151 expect(abuse1.video.nthReport).to.equal(1) 151 expect(abuse1.video.nthReport).to.equal(1)
152 152
@@ -165,7 +165,7 @@ describe('Test abuses', function () {
165 expect(abuse2.reporterAccount.name).to.equal('root') 165 expect(abuse2.reporterAccount.name).to.equal('root')
166 expect(abuse2.reporterAccount.host).to.equal(servers[0].host) 166 expect(abuse2.reporterAccount.host).to.equal(servers[0].host)
167 167
168 expect(abuse2.video.id).to.equal(servers[1].video.id) 168 expect(abuse2.video.id).to.equal(servers[1].store.video.id)
169 169
170 expect(abuse2.comment).to.be.null 170 expect(abuse2.comment).to.be.null
171 171
@@ -200,7 +200,7 @@ describe('Test abuses', function () {
200 this.timeout(10000) 200 this.timeout(10000)
201 201
202 { 202 {
203 const videoId = await servers[1].videosCommand.getId({ uuid: servers[0].video.uuid }) 203 const videoId = await servers[1].videos.getId({ uuid: servers[0].store.video.uuid })
204 await commands[1].report({ videoId, reason: 'will mute this' }) 204 await commands[1].report({ videoId, reason: 'will mute this' })
205 await waitJobs(servers) 205 await waitJobs(servers)
206 206
@@ -211,7 +211,7 @@ describe('Test abuses', function () {
211 const accountToBlock = 'root@' + servers[1].host 211 const accountToBlock = 'root@' + servers[1].host
212 212
213 { 213 {
214 await servers[0].blocklistCommand.addToServerBlocklist({ account: accountToBlock }) 214 await servers[0].blocklist.addToServerBlocklist({ account: accountToBlock })
215 215
216 const body = await commands[0].getAdminList() 216 const body = await commands[0].getAdminList()
217 expect(body.total).to.equal(2) 217 expect(body.total).to.equal(2)
@@ -221,7 +221,7 @@ describe('Test abuses', function () {
221 } 221 }
222 222
223 { 223 {
224 await servers[0].blocklistCommand.removeFromServerBlocklist({ account: accountToBlock }) 224 await servers[0].blocklist.removeFromServerBlocklist({ account: accountToBlock })
225 225
226 const body = await commands[0].getAdminList() 226 const body = await commands[0].getAdminList()
227 expect(body.total).to.equal(3) 227 expect(body.total).to.equal(3)
@@ -232,7 +232,7 @@ describe('Test abuses', function () {
232 const serverToBlock = servers[1].host 232 const serverToBlock = servers[1].host
233 233
234 { 234 {
235 await servers[0].blocklistCommand.addToServerBlocklist({ server: serverToBlock }) 235 await servers[0].blocklist.addToServerBlocklist({ server: serverToBlock })
236 236
237 const body = await commands[0].getAdminList() 237 const body = await commands[0].getAdminList()
238 expect(body.total).to.equal(2) 238 expect(body.total).to.equal(2)
@@ -242,7 +242,7 @@ describe('Test abuses', function () {
242 } 242 }
243 243
244 { 244 {
245 await servers[0].blocklistCommand.removeFromServerBlocklist({ server: serverToBlock }) 245 await servers[0].blocklist.removeFromServerBlocklist({ server: serverToBlock })
246 246
247 const body = await commands[0].getAdminList() 247 const body = await commands[0].getAdminList()
248 expect(body.total).to.equal(3) 248 expect(body.total).to.equal(3)
@@ -252,7 +252,7 @@ describe('Test abuses', function () {
252 it('Should keep the video abuse when deleting the video', async function () { 252 it('Should keep the video abuse when deleting the video', async function () {
253 this.timeout(10000) 253 this.timeout(10000)
254 254
255 await servers[1].videosCommand.remove({ id: abuseServer2.video.uuid }) 255 await servers[1].videos.remove({ id: abuseServer2.video.uuid })
256 256
257 await waitJobs(servers) 257 await waitJobs(servers)
258 258
@@ -272,15 +272,15 @@ describe('Test abuses', function () {
272 272
273 // register a second user to have two reporters/reportees 273 // register a second user to have two reporters/reportees
274 const user = { username: 'user2', password: 'password' } 274 const user = { username: 'user2', password: 'password' }
275 await servers[0].usersCommand.create({ ...user }) 275 await servers[0].users.create({ ...user })
276 const userAccessToken = await servers[0].loginCommand.getAccessToken(user) 276 const userAccessToken = await servers[0].login.getAccessToken(user)
277 277
278 // upload a third video via this user 278 // upload a third video via this user
279 const attributes = { 279 const attributes = {
280 name: 'my second super name for server 1', 280 name: 'my second super name for server 1',
281 description: 'my second super description for server 1' 281 description: 'my second super description for server 1'
282 } 282 }
283 const { id } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) 283 const { id } = await servers[0].videos.upload({ token: userAccessToken, attributes })
284 const video3Id = id 284 const video3Id = id
285 285
286 // resume with the test 286 // resume with the test
@@ -288,7 +288,7 @@ describe('Test abuses', function () {
288 await commands[0].report({ videoId: video3Id, reason: reason3 }) 288 await commands[0].report({ videoId: video3Id, reason: reason3 })
289 289
290 const reason4 = 'my super bad reason 4' 290 const reason4 = 'my super bad reason 4'
291 await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: reason4 }) 291 await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: reason4 })
292 292
293 { 293 {
294 const body = await commands[0].getAdminList() 294 const body = await commands[0].getAdminList()
@@ -301,7 +301,7 @@ describe('Test abuses', function () {
301 expect(abuseVideo3.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse") 301 expect(abuseVideo3.countReportsForReportee).to.equal(1, "wrong reports count for reporter on video 3 abuse")
302 expect(abuseVideo3.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse") 302 expect(abuseVideo3.countReportsForReporter).to.equal(3, "wrong reports count for reportee on video 3 abuse")
303 303
304 const abuseServer1 = abuses.find(a => a.video.id === servers[0].video.id) 304 const abuseServer1 = abuses.find(a => a.video.id === servers[0].store.video.id)
305 expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse") 305 expect(abuseServer1.countReportsForReportee).to.equal(3, "wrong reports count for reporter on video 1 abuse")
306 } 306 }
307 }) 307 })
@@ -312,7 +312,7 @@ describe('Test abuses', function () {
312 const reason5 = 'my super bad reason 5' 312 const reason5 = 'my super bad reason 5'
313 const predefinedReasons5: AbusePredefinedReasonsString[] = [ 'violentOrRepulsive', 'captions' ] 313 const predefinedReasons5: AbusePredefinedReasonsString[] = [ 'violentOrRepulsive', 'captions' ]
314 const createRes = await commands[0].report({ 314 const createRes = await commands[0].report({
315 videoId: servers[0].video.id, 315 videoId: servers[0].store.video.id,
316 reason: reason5, 316 reason: reason5,
317 predefinedReasons: predefinedReasons5, 317 predefinedReasons: predefinedReasons5,
318 startAt: 1, 318 startAt: 1,
@@ -391,10 +391,10 @@ describe('Test abuses', function () {
391 391
392 async function getComment (server: ServerInfo, videoIdArg: number | string) { 392 async function getComment (server: ServerInfo, videoIdArg: number | string) {
393 const videoId = typeof videoIdArg === 'string' 393 const videoId = typeof videoIdArg === 'string'
394 ? await server.videosCommand.getId({ uuid: videoIdArg }) 394 ? await server.videos.getId({ uuid: videoIdArg })
395 : videoIdArg 395 : videoIdArg
396 396
397 const { data } = await server.commentsCommand.listThreads({ videoId }) 397 const { data } = await server.comments.listThreads({ videoId })
398 398
399 return data[0] 399 return data[0]
400 } 400 }
@@ -402,11 +402,11 @@ describe('Test abuses', function () {
402 before(async function () { 402 before(async function () {
403 this.timeout(50000) 403 this.timeout(50000)
404 404
405 servers[0].video = await await servers[0].videosCommand.quickUpload({ name: 'server 1' }) 405 servers[0].store.video = await await servers[0].videos.quickUpload({ name: 'server 1' })
406 servers[1].video = await await servers[1].videosCommand.quickUpload({ name: 'server 2' }) 406 servers[1].store.video = await await servers[1].videos.quickUpload({ name: 'server 2' })
407 407
408 await servers[0].commentsCommand.createThread({ videoId: servers[0].video.id, text: 'comment server 1' }) 408 await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' })
409 await servers[1].commentsCommand.createThread({ videoId: servers[1].video.id, text: 'comment server 2' }) 409 await servers[1].comments.createThread({ videoId: servers[1].store.video.id, text: 'comment server 2' })
410 410
411 await waitJobs(servers) 411 await waitJobs(servers)
412 }) 412 })
@@ -414,7 +414,7 @@ describe('Test abuses', function () {
414 it('Should report abuse on a comment', async function () { 414 it('Should report abuse on a comment', async function () {
415 this.timeout(15000) 415 this.timeout(15000)
416 416
417 const comment = await getComment(servers[0], servers[0].video.id) 417 const comment = await getComment(servers[0], servers[0].store.video.id)
418 418
419 const reason = 'it is a bad comment' 419 const reason = 'it is a bad comment'
420 await commands[0].report({ commentId: comment.id, reason }) 420 await commands[0].report({ commentId: comment.id, reason })
@@ -424,7 +424,7 @@ describe('Test abuses', function () {
424 424
425 it('Should have 1 comment abuse on server 1 and 0 on server 2', async function () { 425 it('Should have 1 comment abuse on server 1 and 0 on server 2', async function () {
426 { 426 {
427 const comment = await getComment(servers[0], servers[0].video.id) 427 const comment = await getComment(servers[0], servers[0].store.video.id)
428 const body = await commands[0].getAdminList({ filter: 'comment' }) 428 const body = await commands[0].getAdminList({ filter: 'comment' })
429 429
430 expect(body.total).to.equal(1) 430 expect(body.total).to.equal(1)
@@ -442,8 +442,8 @@ describe('Test abuses', function () {
442 expect(abuse.comment.id).to.equal(comment.id) 442 expect(abuse.comment.id).to.equal(comment.id)
443 expect(abuse.comment.text).to.equal(comment.text) 443 expect(abuse.comment.text).to.equal(comment.text)
444 expect(abuse.comment.video.name).to.equal('server 1') 444 expect(abuse.comment.video.name).to.equal('server 1')
445 expect(abuse.comment.video.id).to.equal(servers[0].video.id) 445 expect(abuse.comment.video.id).to.equal(servers[0].store.video.id)
446 expect(abuse.comment.video.uuid).to.equal(servers[0].video.uuid) 446 expect(abuse.comment.video.uuid).to.equal(servers[0].store.video.uuid)
447 447
448 expect(abuse.countReportsForReporter).to.equal(5) 448 expect(abuse.countReportsForReporter).to.equal(5)
449 expect(abuse.countReportsForReportee).to.equal(5) 449 expect(abuse.countReportsForReportee).to.equal(5)
@@ -459,7 +459,7 @@ describe('Test abuses', function () {
459 it('Should report abuse on a remote comment', async function () { 459 it('Should report abuse on a remote comment', async function () {
460 this.timeout(10000) 460 this.timeout(10000)
461 461
462 const comment = await getComment(servers[0], servers[1].video.uuid) 462 const comment = await getComment(servers[0], servers[1].store.video.uuid)
463 463
464 const reason = 'it is a really bad comment' 464 const reason = 'it is a really bad comment'
465 await commands[0].report({ commentId: comment.id, reason }) 465 await commands[0].report({ commentId: comment.id, reason })
@@ -468,7 +468,7 @@ describe('Test abuses', function () {
468 }) 468 })
469 469
470 it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () { 470 it('Should have 2 comment abuses on server 1 and 1 on server 2', async function () {
471 const commentServer2 = await getComment(servers[0], servers[1].video.id) 471 const commentServer2 = await getComment(servers[0], servers[1].store.video.id)
472 472
473 { 473 {
474 const body = await commands[0].getAdminList({ filter: 'comment' }) 474 const body = await commands[0].getAdminList({ filter: 'comment' })
@@ -493,7 +493,7 @@ describe('Test abuses', function () {
493 expect(abuse2.comment.id).to.equal(commentServer2.id) 493 expect(abuse2.comment.id).to.equal(commentServer2.id)
494 expect(abuse2.comment.text).to.equal(commentServer2.text) 494 expect(abuse2.comment.text).to.equal(commentServer2.text)
495 expect(abuse2.comment.video.name).to.equal('server 2') 495 expect(abuse2.comment.video.name).to.equal('server 2')
496 expect(abuse2.comment.video.uuid).to.equal(servers[1].video.uuid) 496 expect(abuse2.comment.video.uuid).to.equal(servers[1].store.video.uuid)
497 497
498 expect(abuse2.state.id).to.equal(AbuseState.PENDING) 498 expect(abuse2.state.id).to.equal(AbuseState.PENDING)
499 expect(abuse2.state.label).to.equal('Pending') 499 expect(abuse2.state.label).to.equal('Pending')
@@ -527,9 +527,9 @@ describe('Test abuses', function () {
527 it('Should keep the comment abuse when deleting the comment', async function () { 527 it('Should keep the comment abuse when deleting the comment', async function () {
528 this.timeout(10000) 528 this.timeout(10000)
529 529
530 const commentServer2 = await getComment(servers[0], servers[1].video.id) 530 const commentServer2 = await getComment(servers[0], servers[1].store.video.id)
531 531
532 await servers[0].commentsCommand.delete({ videoId: servers[1].video.uuid, commentId: commentServer2.id }) 532 await servers[0].comments.delete({ videoId: servers[1].store.video.uuid, commentId: commentServer2.id })
533 533
534 await waitJobs(servers) 534 await waitJobs(servers)
535 535
@@ -592,16 +592,16 @@ describe('Test abuses', function () {
592 describe('Account abuses', function () { 592 describe('Account abuses', function () {
593 593
594 function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) { 594 function getAccountFromServer (server: ServerInfo, targetName: string, targetServer: ServerInfo) {
595 return server.accountsCommand.get({ accountName: targetName + '@' + targetServer.host }) 595 return server.accounts.get({ accountName: targetName + '@' + targetServer.host })
596 } 596 }
597 597
598 before(async function () { 598 before(async function () {
599 this.timeout(50000) 599 this.timeout(50000)
600 600
601 await servers[0].usersCommand.create({ username: 'user_1', password: 'donald' }) 601 await servers[0].users.create({ username: 'user_1', password: 'donald' })
602 602
603 const token = await servers[1].usersCommand.generateUserAndToken('user_2') 603 const token = await servers[1].users.generateUserAndToken('user_2')
604 await servers[1].videosCommand.upload({ token, attributes: { name: 'super video' } }) 604 await servers[1].videos.upload({ token, attributes: { name: 'super video' } })
605 605
606 await waitJobs(servers) 606 await waitJobs(servers)
607 }) 607 })
@@ -702,7 +702,7 @@ describe('Test abuses', function () {
702 this.timeout(10000) 702 this.timeout(10000)
703 703
704 const account = await getAccountFromServer(servers[1], 'user_2', servers[1]) 704 const account = await getAccountFromServer(servers[1], 'user_2', servers[1])
705 await servers[1].usersCommand.remove({ userId: account.userId }) 705 await servers[1].users.remove({ userId: account.userId })
706 706
707 await waitJobs(servers) 707 await waitJobs(servers)
708 708
@@ -759,11 +759,11 @@ describe('Test abuses', function () {
759 let userAccessToken: string 759 let userAccessToken: string
760 760
761 before(async function () { 761 before(async function () {
762 userAccessToken = await servers[0].usersCommand.generateUserAndToken('user_42') 762 userAccessToken = await servers[0].users.generateUserAndToken('user_42')
763 763
764 await commands[0].report({ token: userAccessToken, videoId: servers[0].video.id, reason: 'user reason 1' }) 764 await commands[0].report({ token: userAccessToken, videoId: servers[0].store.video.id, reason: 'user reason 1' })
765 765
766 const videoId = await servers[0].videosCommand.getId({ uuid: servers[1].video.uuid }) 766 const videoId = await servers[0].videos.getId({ uuid: servers[1].store.video.uuid })
767 await commands[0].report({ token: userAccessToken, videoId, reason: 'user reason 2' }) 767 await commands[0].report({ token: userAccessToken, videoId, reason: 'user reason 2' })
768 }) 768 })
769 769
@@ -830,9 +830,9 @@ describe('Test abuses', function () {
830 let abuseMessageModerationId: number 830 let abuseMessageModerationId: number
831 831
832 before(async function () { 832 before(async function () {
833 userToken = await servers[0].usersCommand.generateUserAndToken('user_43') 833 userToken = await servers[0].users.generateUserAndToken('user_43')
834 834
835 const body = await commands[0].report({ token: userToken, videoId: servers[0].video.id, reason: 'user 43 reason 1' }) 835 const body = await commands[0].report({ token: userToken, videoId: servers[0].store.video.id, reason: 'user 43 reason 1' })
836 abuseId = body.abuse.id 836 abuseId = body.abuse.id
837 }) 837 })
838 838
diff --git a/server/tests/api/moderation/blocklist-notification.ts b/server/tests/api/moderation/blocklist-notification.ts
index 92a0ec681..6b56fdd65 100644
--- a/server/tests/api/moderation/blocklist-notification.ts
+++ b/server/tests/api/moderation/blocklist-notification.ts
@@ -8,7 +8,7 @@ import { UserNotificationType } from '@shared/models'
8const expect = chai.expect 8const expect = chai.expect
9 9
10async function checkNotifications (server: ServerInfo, token: string, expected: UserNotificationType[]) { 10async function checkNotifications (server: ServerInfo, token: string, expected: UserNotificationType[]) {
11 const { data } = await server.notificationsCommand.list({ token, start: 0, count: 10, unread: true }) 11 const { data } = await server.notifications.list({ token, start: 0, count: 10, unread: true })
12 expect(data).to.have.lengthOf(expected.length) 12 expect(data).to.have.lengthOf(expected.length)
13 13
14 for (const type of expected) { 14 for (const type of expected) {
@@ -26,24 +26,24 @@ describe('Test blocklist', function () {
26 26
27 async function resetState () { 27 async function resetState () {
28 try { 28 try {
29 await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host }) 29 await servers[1].subscriptions.remove({ token: remoteUserToken, uri: 'user1_channel@' + servers[0].host })
30 await servers[1].subscriptionsCommand.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host }) 30 await servers[1].subscriptions.remove({ token: remoteUserToken, uri: 'user2_channel@' + servers[0].host })
31 } catch {} 31 } catch {}
32 32
33 await waitJobs(servers) 33 await waitJobs(servers)
34 34
35 await servers[0].notificationsCommand.markAsReadAll({ token: userToken1 }) 35 await servers[0].notifications.markAsReadAll({ token: userToken1 })
36 await servers[0].notificationsCommand.markAsReadAll({ token: userToken2 }) 36 await servers[0].notifications.markAsReadAll({ token: userToken2 })
37 37
38 { 38 {
39 const { uuid } = await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video' } }) 39 const { uuid } = await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video' } })
40 videoUUID = uuid 40 videoUUID = uuid
41 41
42 await waitJobs(servers) 42 await waitJobs(servers)
43 } 43 }
44 44
45 { 45 {
46 await servers[1].commentsCommand.createThread({ 46 await servers[1].comments.createThread({
47 token: remoteUserToken, 47 token: remoteUserToken,
48 videoId: videoUUID, 48 videoId: videoUUID,
49 text: '@user2@' + servers[0].host + ' hello' 49 text: '@user2@' + servers[0].host + ' hello'
@@ -52,8 +52,8 @@ describe('Test blocklist', function () {
52 52
53 { 53 {
54 54
55 await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host }) 55 await servers[1].subscriptions.add({ token: remoteUserToken, targetUri: 'user1_channel@' + servers[0].host })
56 await servers[1].subscriptionsCommand.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host }) 56 await servers[1].subscriptions.add({ token: remoteUserToken, targetUri: 'user2_channel@' + servers[0].host })
57 } 57 }
58 58
59 await waitJobs(servers) 59 await waitJobs(servers)
@@ -67,29 +67,29 @@ describe('Test blocklist', function () {
67 67
68 { 68 {
69 const user = { username: 'user1', password: 'password' } 69 const user = { username: 'user1', password: 'password' }
70 await servers[0].usersCommand.create({ 70 await servers[0].users.create({
71 username: user.username, 71 username: user.username,
72 password: user.password, 72 password: user.password,
73 videoQuota: -1, 73 videoQuota: -1,
74 videoQuotaDaily: -1 74 videoQuotaDaily: -1
75 }) 75 })
76 76
77 userToken1 = await servers[0].loginCommand.getAccessToken(user) 77 userToken1 = await servers[0].login.getAccessToken(user)
78 await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video user 1' } }) 78 await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video user 1' } })
79 } 79 }
80 80
81 { 81 {
82 const user = { username: 'user2', password: 'password' } 82 const user = { username: 'user2', password: 'password' }
83 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 83 await servers[0].users.create({ username: user.username, password: user.password })
84 84
85 userToken2 = await servers[0].loginCommand.getAccessToken(user) 85 userToken2 = await servers[0].login.getAccessToken(user)
86 } 86 }
87 87
88 { 88 {
89 const user = { username: 'user3', password: 'password' } 89 const user = { username: 'user3', password: 'password' }
90 await servers[1].usersCommand.create({ username: user.username, password: user.password }) 90 await servers[1].users.create({ username: user.username, password: user.password })
91 91
92 remoteUserToken = await servers[1].loginCommand.getAccessToken(user) 92 remoteUserToken = await servers[1].login.getAccessToken(user)
93 } 93 }
94 94
95 await doubleFollow(servers[0], servers[1]) 95 await doubleFollow(servers[0], servers[1])
@@ -111,7 +111,7 @@ describe('Test blocklist', function () {
111 it('Should block an account', async function () { 111 it('Should block an account', async function () {
112 this.timeout(10000) 112 this.timeout(10000)
113 113
114 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host }) 114 await servers[0].blocklist.addToMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
115 await waitJobs(servers) 115 await waitJobs(servers)
116 }) 116 })
117 117
@@ -124,7 +124,7 @@ describe('Test blocklist', function () {
124 124
125 await checkNotifications(servers[0], userToken2, notifs) 125 await checkNotifications(servers[0], userToken2, notifs)
126 126
127 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host }) 127 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken1, account: 'user3@' + servers[1].host })
128 }) 128 })
129 }) 129 })
130 130
@@ -144,7 +144,7 @@ describe('Test blocklist', function () {
144 it('Should block an account', async function () { 144 it('Should block an account', async function () {
145 this.timeout(10000) 145 this.timeout(10000)
146 146
147 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken1, server: servers[1].host }) 147 await servers[0].blocklist.addToMyBlocklist({ token: userToken1, server: servers[1].host })
148 await waitJobs(servers) 148 await waitJobs(servers)
149 }) 149 })
150 150
@@ -157,7 +157,7 @@ describe('Test blocklist', function () {
157 157
158 await checkNotifications(servers[0], userToken2, notifs) 158 await checkNotifications(servers[0], userToken2, notifs)
159 159
160 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken1, server: servers[1].host }) 160 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken1, server: servers[1].host })
161 }) 161 })
162 }) 162 })
163 163
@@ -184,7 +184,7 @@ describe('Test blocklist', function () {
184 it('Should block an account', async function () { 184 it('Should block an account', async function () {
185 this.timeout(10000) 185 this.timeout(10000)
186 186
187 await servers[0].blocklistCommand.addToServerBlocklist({ account: 'user3@' + servers[1].host }) 187 await servers[0].blocklist.addToServerBlocklist({ account: 'user3@' + servers[1].host })
188 await waitJobs(servers) 188 await waitJobs(servers)
189 }) 189 })
190 190
@@ -192,7 +192,7 @@ describe('Test blocklist', function () {
192 await checkNotifications(servers[0], userToken1, []) 192 await checkNotifications(servers[0], userToken1, [])
193 await checkNotifications(servers[0], userToken2, []) 193 await checkNotifications(servers[0], userToken2, [])
194 194
195 await servers[0].blocklistCommand.removeFromServerBlocklist({ account: 'user3@' + servers[1].host }) 195 await servers[0].blocklist.removeFromServerBlocklist({ account: 'user3@' + servers[1].host })
196 }) 196 })
197 }) 197 })
198 198
@@ -219,7 +219,7 @@ describe('Test blocklist', function () {
219 it('Should block an account', async function () { 219 it('Should block an account', async function () {
220 this.timeout(10000) 220 this.timeout(10000)
221 221
222 await servers[0].blocklistCommand.addToServerBlocklist({ server: servers[1].host }) 222 await servers[0].blocklist.addToServerBlocklist({ server: servers[1].host })
223 await waitJobs(servers) 223 await waitJobs(servers)
224 }) 224 })
225 225
diff --git a/server/tests/api/moderation/blocklist.ts b/server/tests/api/moderation/blocklist.ts
index 3c3b2d6fd..9a4a3b3b9 100644
--- a/server/tests/api/moderation/blocklist.ts
+++ b/server/tests/api/moderation/blocklist.ts
@@ -18,24 +18,24 @@ const expect = chai.expect
18 18
19async function checkAllVideos (server: ServerInfo, token: string) { 19async function checkAllVideos (server: ServerInfo, token: string) {
20 { 20 {
21 const { data } = await server.videosCommand.listWithToken({ token }) 21 const { data } = await server.videos.listWithToken({ token })
22 expect(data).to.have.lengthOf(5) 22 expect(data).to.have.lengthOf(5)
23 } 23 }
24 24
25 { 25 {
26 const { data } = await server.videosCommand.list() 26 const { data } = await server.videos.list()
27 expect(data).to.have.lengthOf(5) 27 expect(data).to.have.lengthOf(5)
28 } 28 }
29} 29}
30 30
31async function checkAllComments (server: ServerInfo, token: string, videoUUID: string) { 31async function checkAllComments (server: ServerInfo, token: string, videoUUID: string) {
32 const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token }) 32 const { data } = await server.comments.listThreads({ videoId: videoUUID, start: 0, count: 25, sort: '-createdAt', token })
33 33
34 const threads = data.filter(t => t.isDeleted === false) 34 const threads = data.filter(t => t.isDeleted === false)
35 expect(threads).to.have.lengthOf(2) 35 expect(threads).to.have.lengthOf(2)
36 36
37 for (const thread of threads) { 37 for (const thread of threads) {
38 const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId: thread.id, token }) 38 const tree = await server.comments.getThread({ videoId: videoUUID, threadId: thread.id, token })
39 expect(tree.children).to.have.lengthOf(1) 39 expect(tree.children).to.have.lengthOf(1)
40 } 40 }
41} 41}
@@ -45,13 +45,13 @@ async function checkCommentNotification (
45 comment: { server: ServerInfo, token: string, videoUUID: string, text: string }, 45 comment: { server: ServerInfo, token: string, videoUUID: string, text: string },
46 check: 'presence' | 'absence' 46 check: 'presence' | 'absence'
47) { 47) {
48 const command = comment.server.commentsCommand 48 const command = comment.server.comments
49 49
50 const { threadId, createdAt } = await command.createThread({ token: comment.token, videoId: comment.videoUUID, text: comment.text }) 50 const { threadId, createdAt } = await command.createThread({ token: comment.token, videoId: comment.videoUUID, text: comment.text })
51 51
52 await waitJobs([ mainServer, comment.server ]) 52 await waitJobs([ mainServer, comment.server ])
53 53
54 const { data } = await mainServer.notificationsCommand.list({ start: 0, count: 30 }) 54 const { data } = await mainServer.notifications.list({ start: 0, count: 30 })
55 const commentNotifications = data.filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt) 55 const commentNotifications = data.filter(n => n.comment && n.comment.video.uuid === comment.videoUUID && n.createdAt >= createdAt)
56 56
57 if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1) 57 if (check === 'presence') expect(commentNotifications).to.have.lengthOf(1)
@@ -80,44 +80,44 @@ describe('Test blocklist', function () {
80 servers = await flushAndRunMultipleServers(3) 80 servers = await flushAndRunMultipleServers(3)
81 await setAccessTokensToServers(servers) 81 await setAccessTokensToServers(servers)
82 82
83 command = servers[0].blocklistCommand 83 command = servers[0].blocklist
84 commentsCommand = servers.map(s => s.commentsCommand) 84 commentsCommand = servers.map(s => s.comments)
85 85
86 { 86 {
87 const user = { username: 'user1', password: 'password' } 87 const user = { username: 'user1', password: 'password' }
88 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 88 await servers[0].users.create({ username: user.username, password: user.password })
89 89
90 userToken1 = await servers[0].loginCommand.getAccessToken(user) 90 userToken1 = await servers[0].login.getAccessToken(user)
91 await servers[0].videosCommand.upload({ token: userToken1, attributes: { name: 'video user 1' } }) 91 await servers[0].videos.upload({ token: userToken1, attributes: { name: 'video user 1' } })
92 } 92 }
93 93
94 { 94 {
95 const user = { username: 'moderator', password: 'password' } 95 const user = { username: 'moderator', password: 'password' }
96 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 96 await servers[0].users.create({ username: user.username, password: user.password })
97 97
98 userModeratorToken = await servers[0].loginCommand.getAccessToken(user) 98 userModeratorToken = await servers[0].login.getAccessToken(user)
99 } 99 }
100 100
101 { 101 {
102 const user = { username: 'user2', password: 'password' } 102 const user = { username: 'user2', password: 'password' }
103 await servers[1].usersCommand.create({ username: user.username, password: user.password }) 103 await servers[1].users.create({ username: user.username, password: user.password })
104 104
105 userToken2 = await servers[1].loginCommand.getAccessToken(user) 105 userToken2 = await servers[1].login.getAccessToken(user)
106 await servers[1].videosCommand.upload({ token: userToken2, attributes: { name: 'video user 2' } }) 106 await servers[1].videos.upload({ token: userToken2, attributes: { name: 'video user 2' } })
107 } 107 }
108 108
109 { 109 {
110 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video server 1' } }) 110 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video server 1' } })
111 videoUUID1 = uuid 111 videoUUID1 = uuid
112 } 112 }
113 113
114 { 114 {
115 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video server 2' } }) 115 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video server 2' } })
116 videoUUID2 = uuid 116 videoUUID2 = uuid
117 } 117 }
118 118
119 { 119 {
120 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 2 server 1' } }) 120 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } })
121 videoUUID3 = uuid 121 videoUUID3 = uuid
122 } 122 }
123 123
@@ -159,7 +159,7 @@ describe('Test blocklist', function () {
159 }) 159 })
160 160
161 it('Should hide its videos', async function () { 161 it('Should hide its videos', async function () {
162 const { data } = await servers[0].videosCommand.listWithToken() 162 const { data } = await servers[0].videos.listWithToken()
163 163
164 expect(data).to.have.lengthOf(4) 164 expect(data).to.have.lengthOf(4)
165 165
@@ -172,7 +172,7 @@ describe('Test blocklist', function () {
172 }) 172 })
173 173
174 it('Should hide its videos', async function () { 174 it('Should hide its videos', async function () {
175 const { data } = await servers[0].videosCommand.listWithToken() 175 const { data } = await servers[0].videos.listWithToken()
176 176
177 expect(data).to.have.lengthOf(3) 177 expect(data).to.have.lengthOf(3)
178 178
@@ -289,12 +289,12 @@ describe('Test blocklist', function () {
289 289
290 // Server 1 and 3 should only have uploader comments 290 // Server 1 and 3 should only have uploader comments
291 for (const server of [ servers[0], servers[2] ]) { 291 for (const server of [ servers[0], servers[2] ]) {
292 const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' }) 292 const { data } = await server.comments.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
293 293
294 expect(data).to.have.lengthOf(1) 294 expect(data).to.have.lengthOf(1)
295 expect(data[0].text).to.equal('uploader') 295 expect(data[0].text).to.equal('uploader')
296 296
297 const tree = await server.commentsCommand.getThread({ videoId: videoUUID3, threadId: data[0].id }) 297 const tree = await server.comments.getThread({ videoId: videoUUID3, threadId: data[0].id })
298 298
299 if (server.serverNumber === 1) expect(tree.children).to.have.lengthOf(0) 299 if (server.serverNumber === 1) expect(tree.children).to.have.lengthOf(0)
300 else expect(tree.children).to.have.lengthOf(1) 300 else expect(tree.children).to.have.lengthOf(1)
@@ -306,7 +306,7 @@ describe('Test blocklist', function () {
306 }) 306 })
307 307
308 it('Should display its videos', async function () { 308 it('Should display its videos', async function () {
309 const { data } = await servers[0].videosCommand.listWithToken() 309 const { data } = await servers[0].videos.listWithToken()
310 expect(data).to.have.lengthOf(4) 310 expect(data).to.have.lengthOf(4)
311 311
312 const v = data.find(v => v.name === 'video user 2') 312 const v = data.find(v => v.name === 'video user 2')
@@ -315,7 +315,7 @@ describe('Test blocklist', function () {
315 315
316 it('Should display its comments on my video', async function () { 316 it('Should display its comments on my video', async function () {
317 for (const server of servers) { 317 for (const server of servers) {
318 const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' }) 318 const { data } = await server.comments.listThreads({ videoId: videoUUID3, count: 25, sort: '-createdAt' })
319 319
320 // Server 3 should not have 2 comment threads, because server 1 did not forward the server 2 comment 320 // Server 3 should not have 2 comment threads, because server 1 did not forward the server 2 comment
321 if (server.serverNumber === 3) { 321 if (server.serverNumber === 3) {
@@ -327,7 +327,7 @@ describe('Test blocklist', function () {
327 expect(data[0].text).to.equal('uploader') 327 expect(data[0].text).to.equal('uploader')
328 expect(data[1].text).to.equal('comment user 2') 328 expect(data[1].text).to.equal('comment user 2')
329 329
330 const tree = await server.commentsCommand.getThread({ videoId: videoUUID3, threadId: data[0].id }) 330 const tree = await server.comments.getThread({ videoId: videoUUID3, threadId: data[0].id })
331 expect(tree.children).to.have.lengthOf(1) 331 expect(tree.children).to.have.lengthOf(1)
332 expect(tree.children[0].comment.text).to.equal('reply by user 2') 332 expect(tree.children[0].comment.text).to.equal('reply by user 2')
333 expect(tree.children[0].children).to.have.lengthOf(1) 333 expect(tree.children[0].children).to.have.lengthOf(1)
@@ -378,7 +378,7 @@ describe('Test blocklist', function () {
378 }) 378 })
379 379
380 it('Should hide its videos', async function () { 380 it('Should hide its videos', async function () {
381 const { data } = await servers[0].videosCommand.listWithToken() 381 const { data } = await servers[0].videos.listWithToken()
382 382
383 expect(data).to.have.lengthOf(3) 383 expect(data).to.have.lengthOf(3)
384 384
@@ -488,7 +488,7 @@ describe('Test blocklist', function () {
488 488
489 it('Should hide its videos', async function () { 489 it('Should hide its videos', async function () {
490 for (const token of [ userModeratorToken, servers[0].accessToken ]) { 490 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
491 const { data } = await servers[0].videosCommand.listWithToken({ token }) 491 const { data } = await servers[0].videos.listWithToken({ token })
492 492
493 expect(data).to.have.lengthOf(4) 493 expect(data).to.have.lengthOf(4)
494 494
@@ -503,7 +503,7 @@ describe('Test blocklist', function () {
503 503
504 it('Should hide its videos', async function () { 504 it('Should hide its videos', async function () {
505 for (const token of [ userModeratorToken, servers[0].accessToken ]) { 505 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
506 const { data } = await servers[0].videosCommand.listWithToken({ token }) 506 const { data } = await servers[0].videos.listWithToken({ token })
507 507
508 expect(data).to.have.lengthOf(3) 508 expect(data).to.have.lengthOf(3)
509 509
@@ -581,7 +581,7 @@ describe('Test blocklist', function () {
581 581
582 it('Should display its videos', async function () { 582 it('Should display its videos', async function () {
583 for (const token of [ userModeratorToken, servers[0].accessToken ]) { 583 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
584 const { data } = await servers[0].videosCommand.listWithToken({ token }) 584 const { data } = await servers[0].videos.listWithToken({ token })
585 expect(data).to.have.lengthOf(4) 585 expect(data).to.have.lengthOf(4)
586 586
587 const v = data.find(v => v.name === 'video user 2') 587 const v = data.find(v => v.name === 'video user 2')
@@ -639,8 +639,8 @@ describe('Test blocklist', function () {
639 it('Should hide its videos', async function () { 639 it('Should hide its videos', async function () {
640 for (const token of [ userModeratorToken, servers[0].accessToken ]) { 640 for (const token of [ userModeratorToken, servers[0].accessToken ]) {
641 const requests = [ 641 const requests = [
642 servers[0].videosCommand.list(), 642 servers[0].videos.list(),
643 servers[0].videosCommand.listWithToken({ token }) 643 servers[0].videos.listWithToken({ token })
644 ] 644 ]
645 645
646 for (const req of requests) { 646 for (const req of requests) {
@@ -688,13 +688,13 @@ describe('Test blocklist', function () {
688 688
689 { 689 {
690 const now = new Date() 690 const now = new Date()
691 await servers[1].followsCommand.unfollow({ target: servers[0] }) 691 await servers[1].follows.unfollow({ target: servers[0] })
692 await waitJobs(servers) 692 await waitJobs(servers)
693 await servers[1].followsCommand.follow({ targets: [ servers[0].host ] }) 693 await servers[1].follows.follow({ targets: [ servers[0].host ] })
694 694
695 await waitJobs(servers) 695 await waitJobs(servers)
696 696
697 const { data } = await servers[0].notificationsCommand.list({ start: 0, count: 30 }) 697 const { data } = await servers[0].notifications.list({ start: 0, count: 30 })
698 const commentNotifications = data.filter(n => { 698 const commentNotifications = data.filter(n => {
699 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString() 699 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString()
700 }) 700 })
@@ -749,13 +749,13 @@ describe('Test blocklist', function () {
749 749
750 { 750 {
751 const now = new Date() 751 const now = new Date()
752 await servers[1].followsCommand.unfollow({ target: servers[0] }) 752 await servers[1].follows.unfollow({ target: servers[0] })
753 await waitJobs(servers) 753 await waitJobs(servers)
754 await servers[1].followsCommand.follow({ targets: [ servers[0].host ] }) 754 await servers[1].follows.follow({ targets: [ servers[0].host ] })
755 755
756 await waitJobs(servers) 756 await waitJobs(servers)
757 757
758 const { data } = await servers[0].notificationsCommand.list({ start: 0, count: 30 }) 758 const { data } = await servers[0].notifications.list({ start: 0, count: 30 })
759 const commentNotifications = data.filter(n => { 759 const commentNotifications = data.filter(n => {
760 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString() 760 return n.type === UserNotificationType.NEW_INSTANCE_FOLLOWER && n.createdAt >= now.toISOString()
761 }) 761 })
diff --git a/server/tests/api/moderation/video-blacklist.ts b/server/tests/api/moderation/video-blacklist.ts
index 2f2e678e7..d23d23bcb 100644
--- a/server/tests/api/moderation/video-blacklist.ts
+++ b/server/tests/api/moderation/video-blacklist.ts
@@ -25,10 +25,10 @@ describe('Test video blacklist', function () {
25 let command: BlacklistCommand 25 let command: BlacklistCommand
26 26
27 async function blacklistVideosOnServer (server: ServerInfo) { 27 async function blacklistVideosOnServer (server: ServerInfo) {
28 const { data } = await server.videosCommand.list() 28 const { data } = await server.videos.list()
29 29
30 for (const video of data) { 30 for (const video of data) {
31 await server.blacklistCommand.add({ videoId: video.id, reason: 'super reason' }) 31 await server.blacklist.add({ videoId: video.id, reason: 'super reason' })
32 } 32 }
33 } 33 }
34 34
@@ -45,13 +45,13 @@ describe('Test video blacklist', function () {
45 await doubleFollow(servers[0], servers[1]) 45 await doubleFollow(servers[0], servers[1])
46 46
47 // Upload 2 videos on server 2 47 // Upload 2 videos on server 2
48 await servers[1].videosCommand.upload({ attributes: { name: 'My 1st video', description: 'A video on server 2' } }) 48 await servers[1].videos.upload({ attributes: { name: 'My 1st video', description: 'A video on server 2' } })
49 await servers[1].videosCommand.upload({ attributes: { name: 'My 2nd video', description: 'A video on server 2' } }) 49 await servers[1].videos.upload({ attributes: { name: 'My 2nd video', description: 'A video on server 2' } })
50 50
51 // Wait videos propagation, server 2 has transcoding enabled 51 // Wait videos propagation, server 2 has transcoding enabled
52 await waitJobs(servers) 52 await waitJobs(servers)
53 53
54 command = servers[0].blacklistCommand 54 command = servers[0].blacklist
55 55
56 // Blacklist the two videos on server 1 56 // Blacklist the two videos on server 1
57 await blacklistVideosOnServer(servers[0]) 57 await blacklistVideosOnServer(servers[0])
@@ -61,7 +61,7 @@ describe('Test video blacklist', function () {
61 61
62 it('Should not have the video blacklisted in videos list/search on server 1', async function () { 62 it('Should not have the video blacklisted in videos list/search on server 1', async function () {
63 { 63 {
64 const { total, data } = await servers[0].videosCommand.list() 64 const { total, data } = await servers[0].videos.list()
65 65
66 expect(total).to.equal(0) 66 expect(total).to.equal(0)
67 expect(data).to.be.an('array') 67 expect(data).to.be.an('array')
@@ -69,7 +69,7 @@ describe('Test video blacklist', function () {
69 } 69 }
70 70
71 { 71 {
72 const body = await servers[0].searchCommand.searchVideos({ search: 'video' }) 72 const body = await servers[0].search.searchVideos({ search: 'video' })
73 73
74 expect(body.total).to.equal(0) 74 expect(body.total).to.equal(0)
75 expect(body.data).to.be.an('array') 75 expect(body.data).to.be.an('array')
@@ -79,7 +79,7 @@ describe('Test video blacklist', function () {
79 79
80 it('Should have the blacklisted video in videos list/search on server 2', async function () { 80 it('Should have the blacklisted video in videos list/search on server 2', async function () {
81 { 81 {
82 const { total, data } = await servers[1].videosCommand.list() 82 const { total, data } = await servers[1].videos.list()
83 83
84 expect(total).to.equal(2) 84 expect(total).to.equal(2)
85 expect(data).to.be.an('array') 85 expect(data).to.be.an('array')
@@ -87,7 +87,7 @@ describe('Test video blacklist', function () {
87 } 87 }
88 88
89 { 89 {
90 const body = await servers[1].searchCommand.searchVideos({ search: 'video' }) 90 const body = await servers[1].search.searchVideos({ search: 'video' })
91 91
92 expect(body.total).to.equal(2) 92 expect(body.total).to.equal(2)
93 expect(body.data).to.be.an('array') 93 expect(body.data).to.be.an('array')
@@ -181,7 +181,7 @@ describe('Test video blacklist', function () {
181 it('Should display blacklisted videos', async function () { 181 it('Should display blacklisted videos', async function () {
182 await blacklistVideosOnServer(servers[1]) 182 await blacklistVideosOnServer(servers[1])
183 183
184 const { total, data } = await servers[1].videosCommand.listMyVideos() 184 const { total, data } = await servers[1].videos.listMyVideos()
185 185
186 expect(total).to.equal(2) 186 expect(total).to.equal(2)
187 expect(data).to.have.lengthOf(2) 187 expect(data).to.have.lengthOf(2)
@@ -198,7 +198,7 @@ describe('Test video blacklist', function () {
198 let blacklist = [] 198 let blacklist = []
199 199
200 it('Should not have any video in videos list on server 1', async function () { 200 it('Should not have any video in videos list on server 1', async function () {
201 const { total, data } = await servers[0].videosCommand.list() 201 const { total, data } = await servers[0].videos.list()
202 expect(total).to.equal(0) 202 expect(total).to.equal(0)
203 expect(data).to.be.an('array') 203 expect(data).to.be.an('array')
204 expect(data.length).to.equal(0) 204 expect(data.length).to.equal(0)
@@ -215,7 +215,7 @@ describe('Test video blacklist', function () {
215 }) 215 })
216 216
217 it('Should have the ex-blacklisted video in videos list on server 1', async function () { 217 it('Should have the ex-blacklisted video in videos list on server 1', async function () {
218 const { total, data } = await servers[0].videosCommand.list() 218 const { total, data } = await servers[0].videos.list()
219 expect(total).to.equal(1) 219 expect(total).to.equal(1)
220 220
221 expect(data).to.be.an('array') 221 expect(data).to.be.an('array')
@@ -244,11 +244,11 @@ describe('Test video blacklist', function () {
244 this.timeout(10000) 244 this.timeout(10000)
245 245
246 { 246 {
247 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'Video 3' } }) 247 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'Video 3' } })
248 video3UUID = uuid 248 video3UUID = uuid
249 } 249 }
250 { 250 {
251 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'Video 4' } }) 251 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'Video 4' } })
252 video4UUID = uuid 252 video4UUID = uuid
253 } 253 }
254 254
@@ -263,12 +263,12 @@ describe('Test video blacklist', function () {
263 await waitJobs(servers) 263 await waitJobs(servers)
264 264
265 { 265 {
266 const { data } = await servers[0].videosCommand.list() 266 const { data } = await servers[0].videos.list()
267 expect(data.find(v => v.uuid === video3UUID)).to.be.undefined 267 expect(data.find(v => v.uuid === video3UUID)).to.be.undefined
268 } 268 }
269 269
270 { 270 {
271 const { data } = await servers[1].videosCommand.list() 271 const { data } = await servers[1].videos.list()
272 expect(data.find(v => v.uuid === video3UUID)).to.not.be.undefined 272 expect(data.find(v => v.uuid === video3UUID)).to.not.be.undefined
273 } 273 }
274 }) 274 })
@@ -281,7 +281,7 @@ describe('Test video blacklist', function () {
281 await waitJobs(servers) 281 await waitJobs(servers)
282 282
283 for (const server of servers) { 283 for (const server of servers) {
284 const { data } = await server.videosCommand.list() 284 const { data } = await server.videos.list()
285 expect(data.find(v => v.uuid === video4UUID)).to.be.undefined 285 expect(data.find(v => v.uuid === video4UUID)).to.be.undefined
286 } 286 }
287 }) 287 })
@@ -289,12 +289,12 @@ describe('Test video blacklist', function () {
289 it('Should have the video unfederated even after an Update AP message', async function () { 289 it('Should have the video unfederated even after an Update AP message', async function () {
290 this.timeout(10000) 290 this.timeout(10000)
291 291
292 await servers[0].videosCommand.update({ id: video4UUID, attributes: { description: 'super description' } }) 292 await servers[0].videos.update({ id: video4UUID, attributes: { description: 'super description' } })
293 293
294 await waitJobs(servers) 294 await waitJobs(servers)
295 295
296 for (const server of servers) { 296 for (const server of servers) {
297 const { data } = await server.videosCommand.list() 297 const { data } = await server.videos.list()
298 expect(data.find(v => v.uuid === video4UUID)).to.be.undefined 298 expect(data.find(v => v.uuid === video4UUID)).to.be.undefined
299 } 299 }
300 }) 300 })
@@ -318,7 +318,7 @@ describe('Test video blacklist', function () {
318 await waitJobs(servers) 318 await waitJobs(servers)
319 319
320 for (const server of servers) { 320 for (const server of servers) {
321 const { data } = await server.videosCommand.list() 321 const { data } = await server.videos.list()
322 expect(data.find(v => v.uuid === video4UUID)).to.not.be.undefined 322 expect(data.find(v => v.uuid === video4UUID)).to.not.be.undefined
323 } 323 }
324 }) 324 })
@@ -348,36 +348,36 @@ describe('Test video blacklist', function () {
348 348
349 { 349 {
350 const user = { username: 'user_without_flag', password: 'password' } 350 const user = { username: 'user_without_flag', password: 'password' }
351 await servers[0].usersCommand.create({ 351 await servers[0].users.create({
352 username: user.username, 352 username: user.username,
353 adminFlags: UserAdminFlag.NONE, 353 adminFlags: UserAdminFlag.NONE,
354 password: user.password, 354 password: user.password,
355 role: UserRole.USER 355 role: UserRole.USER
356 }) 356 })
357 357
358 userWithoutFlag = await servers[0].loginCommand.getAccessToken(user) 358 userWithoutFlag = await servers[0].login.getAccessToken(user)
359 359
360 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: userWithoutFlag }) 360 const { videoChannels } = await servers[0].users.getMyInfo({ token: userWithoutFlag })
361 channelOfUserWithoutFlag = videoChannels[0].id 361 channelOfUserWithoutFlag = videoChannels[0].id
362 } 362 }
363 363
364 { 364 {
365 const user = { username: 'user_with_flag', password: 'password' } 365 const user = { username: 'user_with_flag', password: 'password' }
366 await servers[0].usersCommand.create({ 366 await servers[0].users.create({
367 username: user.username, 367 username: user.username,
368 adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST, 368 adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST,
369 password: user.password, 369 password: user.password,
370 role: UserRole.USER 370 role: UserRole.USER
371 }) 371 })
372 372
373 userWithFlag = await servers[0].loginCommand.getAccessToken(user) 373 userWithFlag = await servers[0].login.getAccessToken(user)
374 } 374 }
375 375
376 await waitJobs(servers) 376 await waitJobs(servers)
377 }) 377 })
378 378
379 it('Should auto blacklist a video on upload', async function () { 379 it('Should auto blacklist a video on upload', async function () {
380 await servers[0].videosCommand.upload({ token: userWithoutFlag, attributes: { name: 'blacklisted' } }) 380 await servers[0].videos.upload({ token: userWithoutFlag, attributes: { name: 'blacklisted' } })
381 381
382 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) 382 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
383 expect(body.total).to.equal(1) 383 expect(body.total).to.equal(1)
@@ -392,7 +392,7 @@ describe('Test video blacklist', function () {
392 name: 'URL import', 392 name: 'URL import',
393 channelId: channelOfUserWithoutFlag 393 channelId: channelOfUserWithoutFlag
394 } 394 }
395 await servers[0].importsCommand.importVideo({ token: userWithoutFlag, attributes }) 395 await servers[0].imports.importVideo({ token: userWithoutFlag, attributes })
396 396
397 const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) 397 const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
398 expect(body.total).to.equal(2) 398 expect(body.total).to.equal(2)
@@ -405,7 +405,7 @@ describe('Test video blacklist', function () {
405 name: 'Torrent import', 405 name: 'Torrent import',
406 channelId: channelOfUserWithoutFlag 406 channelId: channelOfUserWithoutFlag
407 } 407 }
408 await servers[0].importsCommand.importVideo({ token: userWithoutFlag, attributes }) 408 await servers[0].imports.importVideo({ token: userWithoutFlag, attributes })
409 409
410 const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) 410 const body = await command.list({ sort: 'createdAt', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
411 expect(body.total).to.equal(3) 411 expect(body.total).to.equal(3)
@@ -413,7 +413,7 @@ describe('Test video blacklist', function () {
413 }) 413 })
414 414
415 it('Should not auto blacklist a video on upload if the user has the bypass blacklist flag', async function () { 415 it('Should not auto blacklist a video on upload if the user has the bypass blacklist flag', async function () {
416 await servers[0].videosCommand.upload({ token: userWithFlag, attributes: { name: 'not blacklisted' } }) 416 await servers[0].videos.upload({ token: userWithFlag, attributes: { name: 'not blacklisted' } })
417 417
418 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED }) 418 const body = await command.list({ type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED })
419 expect(body.total).to.equal(3) 419 expect(body.total).to.equal(3)
diff --git a/server/tests/api/notifications/admin-notifications.ts b/server/tests/api/notifications/admin-notifications.ts
index 03fbe0b70..5a5bdb0c8 100644
--- a/server/tests/api/notifications/admin-notifications.ts
+++ b/server/tests/api/notifications/admin-notifications.ts
@@ -58,8 +58,8 @@ describe('Test admin notifications', function () {
58 token: server.accessToken 58 token: server.accessToken
59 } 59 }
60 60
61 await server.pluginsCommand.install({ npmName: 'peertube-plugin-hello-world' }) 61 await server.plugins.install({ npmName: 'peertube-plugin-hello-world' })
62 await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' }) 62 await server.plugins.install({ npmName: 'peertube-theme-background-red' })
63 }) 63 })
64 64
65 describe('Latest PeerTube version notification', function () { 65 describe('Latest PeerTube version notification', function () {
@@ -118,8 +118,8 @@ describe('Test admin notifications', function () {
118 it('Should send a notification to admins on new plugin version', async function () { 118 it('Should send a notification to admins on new plugin version', async function () {
119 this.timeout(30000) 119 this.timeout(30000)
120 120
121 await server.sqlCommand.setPluginVersion('hello-world', '0.0.1') 121 await server.sql.setPluginVersion('hello-world', '0.0.1')
122 await server.sqlCommand.setPluginLatestVersion('hello-world', '0.0.1') 122 await server.sql.setPluginLatestVersion('hello-world', '0.0.1')
123 await wait(6000) 123 await wait(6000)
124 124
125 await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'presence') 125 await checkNewPluginVersion(baseParams, PluginType.PLUGIN, 'hello-world', 'presence')
@@ -140,8 +140,8 @@ describe('Test admin notifications', function () {
140 it('Should send a new notification after a new plugin release', async function () { 140 it('Should send a new notification after a new plugin release', async function () {
141 this.timeout(30000) 141 this.timeout(30000)
142 142
143 await server.sqlCommand.setPluginVersion('hello-world', '0.0.1') 143 await server.sql.setPluginVersion('hello-world', '0.0.1')
144 await server.sqlCommand.setPluginLatestVersion('hello-world', '0.0.1') 144 await server.sql.setPluginLatestVersion('hello-world', '0.0.1')
145 await wait(6000) 145 await wait(6000)
146 146
147 expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2) 147 expect(adminNotifications.filter(n => n.type === UserNotificationType.NEW_PEERTUBE_VERSION)).to.have.lengthOf(2)
diff --git a/server/tests/api/notifications/comments-notifications.ts b/server/tests/api/notifications/comments-notifications.ts
index a74b38e8a..133b6340f 100644
--- a/server/tests/api/notifications/comments-notifications.ts
+++ b/server/tests/api/notifications/comments-notifications.ts
@@ -52,9 +52,9 @@ describe('Test comments notifications', function () {
52 it('Should not send a new comment notification after a comment on another video', async function () { 52 it('Should not send a new comment notification after a comment on another video', async function () {
53 this.timeout(20000) 53 this.timeout(20000)
54 54
55 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 55 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
56 56
57 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 57 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
58 const commentId = created.id 58 const commentId = created.id
59 59
60 await waitJobs(servers) 60 await waitJobs(servers)
@@ -64,9 +64,9 @@ describe('Test comments notifications', function () {
64 it('Should not send a new comment notification if I comment my own video', async function () { 64 it('Should not send a new comment notification if I comment my own video', async function () {
65 this.timeout(20000) 65 this.timeout(20000)
66 66
67 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 67 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
68 68
69 const created = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: 'comment' }) 69 const created = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: 'comment' })
70 const commentId = created.id 70 const commentId = created.id
71 71
72 await waitJobs(servers) 72 await waitJobs(servers)
@@ -76,25 +76,25 @@ describe('Test comments notifications', function () {
76 it('Should not send a new comment notification if the account is muted', async function () { 76 it('Should not send a new comment notification if the account is muted', async function () {
77 this.timeout(20000) 77 this.timeout(20000)
78 78
79 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' }) 79 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
80 80
81 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 81 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
82 82
83 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 83 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
84 const commentId = created.id 84 const commentId = created.id
85 85
86 await waitJobs(servers) 86 await waitJobs(servers)
87 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence') 87 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, commentId, 'absence')
88 88
89 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' }) 89 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
90 }) 90 })
91 91
92 it('Should send a new comment notification after a local comment on my video', async function () { 92 it('Should send a new comment notification after a local comment on my video', async function () {
93 this.timeout(20000) 93 this.timeout(20000)
94 94
95 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 95 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
96 96
97 const created = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 97 const created = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
98 const commentId = created.id 98 const commentId = created.id
99 99
100 await waitJobs(servers) 100 await waitJobs(servers)
@@ -104,15 +104,15 @@ describe('Test comments notifications', function () {
104 it('Should send a new comment notification after a remote comment on my video', async function () { 104 it('Should send a new comment notification after a remote comment on my video', async function () {
105 this.timeout(20000) 105 this.timeout(20000)
106 106
107 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 107 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
108 108
109 await waitJobs(servers) 109 await waitJobs(servers)
110 110
111 await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 111 await servers[1].comments.createThread({ videoId: uuid, text: 'comment' })
112 112
113 await waitJobs(servers) 113 await waitJobs(servers)
114 114
115 const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid }) 115 const { data } = await servers[0].comments.listThreads({ videoId: uuid })
116 expect(data).to.have.lengthOf(1) 116 expect(data).to.have.lengthOf(1)
117 117
118 const commentId = data[0].id 118 const commentId = data[0].id
@@ -122,11 +122,11 @@ describe('Test comments notifications', function () {
122 it('Should send a new comment notification after a local reply on my video', async function () { 122 it('Should send a new comment notification after a local reply on my video', async function () {
123 this.timeout(20000) 123 this.timeout(20000)
124 124
125 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 125 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
126 126
127 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 127 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
128 128
129 const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }) 129 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
130 130
131 await waitJobs(servers) 131 await waitJobs(servers)
132 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence') 132 await checkNewCommentOnMyVideo(baseParams, uuid, commentId, threadId, 'presence')
@@ -135,22 +135,22 @@ describe('Test comments notifications', function () {
135 it('Should send a new comment notification after a remote reply on my video', async function () { 135 it('Should send a new comment notification after a remote reply on my video', async function () {
136 this.timeout(20000) 136 this.timeout(20000)
137 137
138 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 138 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
139 await waitJobs(servers) 139 await waitJobs(servers)
140 140
141 { 141 {
142 const created = await servers[1].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 142 const created = await servers[1].comments.createThread({ videoId: uuid, text: 'comment' })
143 const threadId = created.id 143 const threadId = created.id
144 await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' }) 144 await servers[1].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'reply' })
145 } 145 }
146 146
147 await waitJobs(servers) 147 await waitJobs(servers)
148 148
149 const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid }) 149 const { data } = await servers[0].comments.listThreads({ videoId: uuid })
150 expect(data).to.have.lengthOf(1) 150 expect(data).to.have.lengthOf(1)
151 151
152 const threadId = data[0].id 152 const threadId = data[0].id
153 const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId }) 153 const tree = await servers[0].comments.getThread({ videoId: uuid, threadId })
154 154
155 expect(tree.children).to.have.lengthOf(1) 155 expect(tree.children).to.have.lengthOf(1)
156 const commentId = tree.children[0].comment.id 156 const commentId = tree.children[0].comment.id
@@ -161,9 +161,9 @@ describe('Test comments notifications', function () {
161 it('Should convert markdown in comment to html', async function () { 161 it('Should convert markdown in comment to html', async function () {
162 this.timeout(20000) 162 this.timeout(20000)
163 163
164 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'cool video' } }) 164 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'cool video' } })
165 165
166 await servers[0].commentsCommand.createThread({ videoId: uuid, text: commentText }) 166 await servers[0].comments.createThread({ videoId: uuid, text: commentText })
167 167
168 await waitJobs(servers) 168 await waitJobs(servers)
169 169
@@ -183,16 +183,16 @@ describe('Test comments notifications', function () {
183 token: userToken 183 token: userToken
184 } 184 }
185 185
186 await servers[0].usersCommand.updateMe({ displayName: 'super root name' }) 186 await servers[0].users.updateMe({ displayName: 'super root name' })
187 await servers[1].usersCommand.updateMe({ displayName: 'super root 2 name' }) 187 await servers[1].users.updateMe({ displayName: 'super root 2 name' })
188 }) 188 })
189 189
190 it('Should not send a new mention comment notification if I mention the video owner', async function () { 190 it('Should not send a new mention comment notification if I mention the video owner', async function () {
191 this.timeout(10000) 191 this.timeout(10000)
192 192
193 const { uuid } = await servers[0].videosCommand.upload({ token: userToken, attributes: { name: 'super video' } }) 193 const { uuid } = await servers[0].videos.upload({ token: userToken, attributes: { name: 'super video' } })
194 194
195 const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) 195 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
196 196
197 await waitJobs(servers) 197 await waitJobs(servers)
198 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 198 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
@@ -201,9 +201,9 @@ describe('Test comments notifications', function () {
201 it('Should not send a new mention comment notification if I mention myself', async function () { 201 it('Should not send a new mention comment notification if I mention myself', async function () {
202 this.timeout(10000) 202 this.timeout(10000)
203 203
204 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 204 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
205 205
206 const { id: commentId } = await servers[0].commentsCommand.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' }) 206 const { id: commentId } = await servers[0].comments.createThread({ token: userToken, videoId: uuid, text: '@user_1 hello' })
207 207
208 await waitJobs(servers) 208 await waitJobs(servers)
209 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 209 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
@@ -212,25 +212,25 @@ describe('Test comments notifications', function () {
212 it('Should not send a new mention notification if the account is muted', async function () { 212 it('Should not send a new mention notification if the account is muted', async function () {
213 this.timeout(10000) 213 this.timeout(10000)
214 214
215 await servers[0].blocklistCommand.addToMyBlocklist({ token: userToken, account: 'root' }) 215 await servers[0].blocklist.addToMyBlocklist({ token: userToken, account: 'root' })
216 216
217 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 217 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
218 218
219 const { id: commentId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) 219 const { id: commentId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
220 220
221 await waitJobs(servers) 221 await waitJobs(servers)
222 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence') 222 await checkCommentMention(baseParams, uuid, commentId, commentId, 'super root name', 'absence')
223 223
224 await servers[0].blocklistCommand.removeFromMyBlocklist({ token: userToken, account: 'root' }) 224 await servers[0].blocklist.removeFromMyBlocklist({ token: userToken, account: 'root' })
225 }) 225 })
226 226
227 it('Should not send a new mention notification if the remote account mention a local account', async function () { 227 it('Should not send a new mention notification if the remote account mention a local account', async function () {
228 this.timeout(20000) 228 this.timeout(20000)
229 229
230 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 230 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
231 231
232 await waitJobs(servers) 232 await waitJobs(servers)
233 const { id: threadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello' }) 233 const { id: threadId } = await servers[1].comments.createThread({ videoId: uuid, text: '@user_1 hello' })
234 234
235 await waitJobs(servers) 235 await waitJobs(servers)
236 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence') 236 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root 2 name', 'absence')
@@ -239,14 +239,14 @@ describe('Test comments notifications', function () {
239 it('Should send a new mention notification after local comments', async function () { 239 it('Should send a new mention notification after local comments', async function () {
240 this.timeout(10000) 240 this.timeout(10000)
241 241
242 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 242 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
243 243
244 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' }) 244 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hellotext: 1' })
245 245
246 await waitJobs(servers) 246 await waitJobs(servers)
247 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence') 247 await checkCommentMention(baseParams, uuid, threadId, threadId, 'super root name', 'presence')
248 248
249 const { id: commentId } = await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' }) 249 const { id: commentId } = await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: 'hello 2 @user_1' })
250 250
251 await waitJobs(servers) 251 await waitJobs(servers)
252 await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence') 252 await checkCommentMention(baseParams, uuid, commentId, threadId, 'super root name', 'presence')
@@ -255,27 +255,27 @@ describe('Test comments notifications', function () {
255 it('Should send a new mention notification after remote comments', async function () { 255 it('Should send a new mention notification after remote comments', async function () {
256 this.timeout(20000) 256 this.timeout(20000)
257 257
258 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 258 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
259 259
260 await waitJobs(servers) 260 await waitJobs(servers)
261 261
262 const text1 = `hello @user_1@localhost:${servers[0].port} 1` 262 const text1 = `hello @user_1@localhost:${servers[0].port} 1`
263 const { id: server2ThreadId } = await servers[1].commentsCommand.createThread({ videoId: uuid, text: text1 }) 263 const { id: server2ThreadId } = await servers[1].comments.createThread({ videoId: uuid, text: text1 })
264 264
265 await waitJobs(servers) 265 await waitJobs(servers)
266 266
267 const { data } = await servers[0].commentsCommand.listThreads({ videoId: uuid }) 267 const { data } = await servers[0].comments.listThreads({ videoId: uuid })
268 expect(data).to.have.lengthOf(1) 268 expect(data).to.have.lengthOf(1)
269 269
270 const server1ThreadId = data[0].id 270 const server1ThreadId = data[0].id
271 await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence') 271 await checkCommentMention(baseParams, uuid, server1ThreadId, server1ThreadId, 'super root 2 name', 'presence')
272 272
273 const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}` 273 const text2 = `@user_1@localhost:${servers[0].port} hello 2 @root@localhost:${servers[0].port}`
274 await servers[1].commentsCommand.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 }) 274 await servers[1].comments.addReply({ videoId: uuid, toCommentId: server2ThreadId, text: text2 })
275 275
276 await waitJobs(servers) 276 await waitJobs(servers)
277 277
278 const tree = await servers[0].commentsCommand.getThread({ videoId: uuid, threadId: server1ThreadId }) 278 const tree = await servers[0].comments.getThread({ videoId: uuid, threadId: server1ThreadId })
279 279
280 expect(tree.children).to.have.lengthOf(1) 280 expect(tree.children).to.have.lengthOf(1)
281 const commentId = tree.children[0].comment.id 281 const commentId = tree.children[0].comment.id
@@ -286,11 +286,11 @@ describe('Test comments notifications', function () {
286 it('Should convert markdown in comment to html', async function () { 286 it('Should convert markdown in comment to html', async function () {
287 this.timeout(10000) 287 this.timeout(10000)
288 288
289 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'super video' } }) 289 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'super video' } })
290 290
291 const { id: threadId } = await servers[0].commentsCommand.createThread({ videoId: uuid, text: '@user_1 hello 1' }) 291 const { id: threadId } = await servers[0].comments.createThread({ videoId: uuid, text: '@user_1 hello 1' })
292 292
293 await servers[0].commentsCommand.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText }) 293 await servers[0].comments.addReply({ videoId: uuid, toCommentId: threadId, text: '@user_1 ' + commentText })
294 294
295 await waitJobs(servers) 295 await waitJobs(servers)
296 296
diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts
index 91a2b4fa5..e7c5badd2 100644
--- a/server/tests/api/notifications/moderation-notifications.ts
+++ b/server/tests/api/notifications/moderation-notifications.ts
@@ -62,9 +62,9 @@ describe('Test moderation notifications', function () {
62 this.timeout(20000) 62 this.timeout(20000)
63 63
64 const name = 'video for abuse ' + buildUUID() 64 const name = 'video for abuse ' + buildUUID()
65 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 65 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
66 66
67 await servers[0].abusesCommand.report({ videoId: video.id, reason: 'super reason' }) 67 await servers[0].abuses.report({ videoId: video.id, reason: 'super reason' })
68 68
69 await waitJobs(servers) 69 await waitJobs(servers)
70 await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence') 70 await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence')
@@ -74,12 +74,12 @@ describe('Test moderation notifications', function () {
74 this.timeout(20000) 74 this.timeout(20000)
75 75
76 const name = 'video for abuse ' + buildUUID() 76 const name = 'video for abuse ' + buildUUID()
77 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 77 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
78 78
79 await waitJobs(servers) 79 await waitJobs(servers)
80 80
81 const videoId = await servers[1].videosCommand.getId({ uuid: video.uuid }) 81 const videoId = await servers[1].videos.getId({ uuid: video.uuid })
82 await servers[1].abusesCommand.report({ videoId, reason: 'super reason' }) 82 await servers[1].abuses.report({ videoId, reason: 'super reason' })
83 83
84 await waitJobs(servers) 84 await waitJobs(servers)
85 await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence') 85 await checkNewVideoAbuseForModerators(baseParams, video.uuid, name, 'presence')
@@ -89,8 +89,8 @@ describe('Test moderation notifications', function () {
89 this.timeout(20000) 89 this.timeout(20000)
90 90
91 const name = 'video for abuse ' + buildUUID() 91 const name = 'video for abuse ' + buildUUID()
92 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 92 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
93 const comment = await servers[0].commentsCommand.createThread({ 93 const comment = await servers[0].comments.createThread({
94 token: userAccessToken, 94 token: userAccessToken,
95 videoId: video.id, 95 videoId: video.id,
96 text: 'comment abuse ' + buildUUID() 96 text: 'comment abuse ' + buildUUID()
@@ -98,7 +98,7 @@ describe('Test moderation notifications', function () {
98 98
99 await waitJobs(servers) 99 await waitJobs(servers)
100 100
101 await servers[0].abusesCommand.report({ commentId: comment.id, reason: 'super reason' }) 101 await servers[0].abuses.report({ commentId: comment.id, reason: 'super reason' })
102 102
103 await waitJobs(servers) 103 await waitJobs(servers)
104 await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence') 104 await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence')
@@ -108,9 +108,9 @@ describe('Test moderation notifications', function () {
108 this.timeout(20000) 108 this.timeout(20000)
109 109
110 const name = 'video for abuse ' + buildUUID() 110 const name = 'video for abuse ' + buildUUID()
111 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 111 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
112 112
113 await servers[0].commentsCommand.createThread({ 113 await servers[0].comments.createThread({
114 token: userAccessToken, 114 token: userAccessToken,
115 videoId: video.id, 115 videoId: video.id,
116 text: 'comment abuse ' + buildUUID() 116 text: 'comment abuse ' + buildUUID()
@@ -118,9 +118,9 @@ describe('Test moderation notifications', function () {
118 118
119 await waitJobs(servers) 119 await waitJobs(servers)
120 120
121 const { data } = await servers[1].commentsCommand.listThreads({ videoId: video.uuid }) 121 const { data } = await servers[1].comments.listThreads({ videoId: video.uuid })
122 const commentId = data[0].id 122 const commentId = data[0].id
123 await servers[1].abusesCommand.report({ commentId, reason: 'super reason' }) 123 await servers[1].abuses.report({ commentId, reason: 'super reason' })
124 124
125 await waitJobs(servers) 125 await waitJobs(servers)
126 await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence') 126 await checkNewCommentAbuseForModerators(baseParams, video.uuid, name, 'presence')
@@ -130,10 +130,10 @@ describe('Test moderation notifications', function () {
130 this.timeout(20000) 130 this.timeout(20000)
131 131
132 const username = 'user' + new Date().getTime() 132 const username = 'user' + new Date().getTime()
133 const { account } = await servers[0].usersCommand.create({ username, password: 'donald' }) 133 const { account } = await servers[0].users.create({ username, password: 'donald' })
134 const accountId = account.id 134 const accountId = account.id
135 135
136 await servers[0].abusesCommand.report({ accountId, reason: 'super reason' }) 136 await servers[0].abuses.report({ accountId, reason: 'super reason' })
137 137
138 await waitJobs(servers) 138 await waitJobs(servers)
139 await checkNewAccountAbuseForModerators(baseParams, username, 'presence') 139 await checkNewAccountAbuseForModerators(baseParams, username, 'presence')
@@ -143,13 +143,13 @@ describe('Test moderation notifications', function () {
143 this.timeout(20000) 143 this.timeout(20000)
144 144
145 const username = 'user' + new Date().getTime() 145 const username = 'user' + new Date().getTime()
146 const tmpToken = await servers[0].usersCommand.generateUserAndToken(username) 146 const tmpToken = await servers[0].users.generateUserAndToken(username)
147 await servers[0].videosCommand.upload({ token: tmpToken, attributes: { name: 'super video' } }) 147 await servers[0].videos.upload({ token: tmpToken, attributes: { name: 'super video' } })
148 148
149 await waitJobs(servers) 149 await waitJobs(servers)
150 150
151 const account = await servers[1].accountsCommand.get({ accountName: username + '@' + servers[0].host }) 151 const account = await servers[1].accounts.get({ accountName: username + '@' + servers[0].host })
152 await servers[1].abusesCommand.report({ accountId: account.id, reason: 'super reason' }) 152 await servers[1].abuses.report({ accountId: account.id, reason: 'super reason' })
153 153
154 await waitJobs(servers) 154 await waitJobs(servers)
155 await checkNewAccountAbuseForModerators(baseParams, username, 'presence') 155 await checkNewAccountAbuseForModerators(baseParams, username, 'presence')
@@ -169,16 +169,16 @@ describe('Test moderation notifications', function () {
169 } 169 }
170 170
171 const name = 'abuse ' + buildUUID() 171 const name = 'abuse ' + buildUUID()
172 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 172 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
173 173
174 const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) 174 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
175 abuseId = body.abuse.id 175 abuseId = body.abuse.id
176 }) 176 })
177 177
178 it('Should send a notification to reporter if the abuse has been accepted', async function () { 178 it('Should send a notification to reporter if the abuse has been accepted', async function () {
179 this.timeout(10000) 179 this.timeout(10000)
180 180
181 await servers[0].abusesCommand.update({ abuseId, body: { state: AbuseState.ACCEPTED } }) 181 await servers[0].abuses.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
182 await waitJobs(servers) 182 await waitJobs(servers)
183 183
184 await checkAbuseStateChange(baseParams, abuseId, AbuseState.ACCEPTED, 'presence') 184 await checkAbuseStateChange(baseParams, abuseId, AbuseState.ACCEPTED, 'presence')
@@ -187,7 +187,7 @@ describe('Test moderation notifications', function () {
187 it('Should send a notification to reporter if the abuse has been rejected', async function () { 187 it('Should send a notification to reporter if the abuse has been rejected', async function () {
188 this.timeout(10000) 188 this.timeout(10000)
189 189
190 await servers[0].abusesCommand.update({ abuseId, body: { state: AbuseState.REJECTED } }) 190 await servers[0].abuses.update({ abuseId, body: { state: AbuseState.REJECTED } })
191 await waitJobs(servers) 191 await waitJobs(servers)
192 192
193 await checkAbuseStateChange(baseParams, abuseId, AbuseState.REJECTED, 'presence') 193 await checkAbuseStateChange(baseParams, abuseId, AbuseState.REJECTED, 'presence')
@@ -216,15 +216,15 @@ describe('Test moderation notifications', function () {
216 } 216 }
217 217
218 const name = 'abuse ' + buildUUID() 218 const name = 'abuse ' + buildUUID()
219 const video = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 219 const video = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
220 220
221 { 221 {
222 const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) 222 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' })
223 abuseId = body.abuse.id 223 abuseId = body.abuse.id
224 } 224 }
225 225
226 { 226 {
227 const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' }) 227 const body = await servers[0].abuses.report({ token: userAccessToken, videoId: video.id, reason: 'super reason 2' })
228 abuseId2 = body.abuse.id 228 abuseId2 = body.abuse.id
229 } 229 }
230 }) 230 })
@@ -233,7 +233,7 @@ describe('Test moderation notifications', function () {
233 this.timeout(10000) 233 this.timeout(10000)
234 234
235 const message = 'my super message to users' 235 const message = 'my super message to users'
236 await servers[0].abusesCommand.addMessage({ abuseId, message }) 236 await servers[0].abuses.addMessage({ abuseId, message })
237 await waitJobs(servers) 237 await waitJobs(servers)
238 238
239 await checkNewAbuseMessage(baseParamsUser, abuseId, message, 'user_1@example.com', 'presence') 239 await checkNewAbuseMessage(baseParamsUser, abuseId, message, 'user_1@example.com', 'presence')
@@ -243,7 +243,7 @@ describe('Test moderation notifications', function () {
243 this.timeout(10000) 243 this.timeout(10000)
244 244
245 const message = 'my super message that should not be sent to the admin' 245 const message = 'my super message that should not be sent to the admin'
246 await servers[0].abusesCommand.addMessage({ abuseId, message }) 246 await servers[0].abuses.addMessage({ abuseId, message })
247 await waitJobs(servers) 247 await waitJobs(servers)
248 248
249 await checkNewAbuseMessage(baseParamsAdmin, abuseId, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'absence') 249 await checkNewAbuseMessage(baseParamsAdmin, abuseId, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'absence')
@@ -253,7 +253,7 @@ describe('Test moderation notifications', function () {
253 this.timeout(10000) 253 this.timeout(10000)
254 254
255 const message = 'my super message to moderators' 255 const message = 'my super message to moderators'
256 await servers[0].abusesCommand.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) 256 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
257 await waitJobs(servers) 257 await waitJobs(servers)
258 258
259 await checkNewAbuseMessage(baseParamsAdmin, abuseId2, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'presence') 259 await checkNewAbuseMessage(baseParamsAdmin, abuseId2, message, 'admin' + servers[0].internalServerNumber + '@example.com', 'presence')
@@ -263,7 +263,7 @@ describe('Test moderation notifications', function () {
263 this.timeout(10000) 263 this.timeout(10000)
264 264
265 const message = 'my super message that should not be sent to reporter' 265 const message = 'my super message that should not be sent to reporter'
266 await servers[0].abusesCommand.addMessage({ token: userAccessToken, abuseId: abuseId2, message }) 266 await servers[0].abuses.addMessage({ token: userAccessToken, abuseId: abuseId2, message })
267 await waitJobs(servers) 267 await waitJobs(servers)
268 268
269 await checkNewAbuseMessage(baseParamsUser, abuseId2, message, 'user_1@example.com', 'absence') 269 await checkNewAbuseMessage(baseParamsUser, abuseId2, message, 'user_1@example.com', 'absence')
@@ -286,9 +286,9 @@ describe('Test moderation notifications', function () {
286 this.timeout(10000) 286 this.timeout(10000)
287 287
288 const name = 'video for abuse ' + buildUUID() 288 const name = 'video for abuse ' + buildUUID()
289 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 289 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
290 290
291 await servers[0].blacklistCommand.add({ videoId: uuid }) 291 await servers[0].blacklist.add({ videoId: uuid })
292 292
293 await waitJobs(servers) 293 await waitJobs(servers)
294 await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist') 294 await checkNewBlacklistOnMyVideo(baseParams, uuid, name, 'blacklist')
@@ -298,12 +298,12 @@ describe('Test moderation notifications', function () {
298 this.timeout(10000) 298 this.timeout(10000)
299 299
300 const name = 'video for abuse ' + buildUUID() 300 const name = 'video for abuse ' + buildUUID()
301 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name } }) 301 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name } })
302 302
303 await servers[0].blacklistCommand.add({ videoId: uuid }) 303 await servers[0].blacklist.add({ videoId: uuid })
304 304
305 await waitJobs(servers) 305 await waitJobs(servers)
306 await servers[0].blacklistCommand.remove({ videoId: uuid }) 306 await servers[0].blacklist.remove({ videoId: uuid })
307 await waitJobs(servers) 307 await waitJobs(servers)
308 308
309 await wait(500) 309 await wait(500)
@@ -326,7 +326,7 @@ describe('Test moderation notifications', function () {
326 it('Should send a notification only to moderators when a user registers on the instance', async function () { 326 it('Should send a notification only to moderators when a user registers on the instance', async function () {
327 this.timeout(10000) 327 this.timeout(10000)
328 328
329 await servers[0].usersCommand.register({ username: 'user_45' }) 329 await servers[0].users.register({ username: 'user_45' })
330 330
331 await waitJobs(servers) 331 await waitJobs(servers)
332 332
@@ -368,7 +368,7 @@ describe('Test moderation notifications', function () {
368 it('Should send a notification only to admin when there is a new instance follower', async function () { 368 it('Should send a notification only to admin when there is a new instance follower', async function () {
369 this.timeout(20000) 369 this.timeout(20000)
370 370
371 await servers[2].followsCommand.follow({ targets: [ servers[0].url ] }) 371 await servers[2].follows.follow({ targets: [ servers[0].url ] })
372 372
373 await waitJobs(servers) 373 await waitJobs(servers)
374 374
@@ -381,7 +381,7 @@ describe('Test moderation notifications', function () {
381 it('Should send a notification on auto follow back', async function () { 381 it('Should send a notification on auto follow back', async function () {
382 this.timeout(40000) 382 this.timeout(40000)
383 383
384 await servers[2].followsCommand.unfollow({ target: servers[0] }) 384 await servers[2].follows.unfollow({ target: servers[0] })
385 await waitJobs(servers) 385 await waitJobs(servers)
386 386
387 const config = { 387 const config = {
@@ -391,9 +391,9 @@ describe('Test moderation notifications', function () {
391 } 391 }
392 } 392 }
393 } 393 }
394 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 394 await servers[0].config.updateCustomSubConfig({ newConfig: config })
395 395
396 await servers[2].followsCommand.follow({ targets: [ servers[0].url ] }) 396 await servers[2].follows.follow({ targets: [ servers[0].url ] })
397 397
398 await waitJobs(servers) 398 await waitJobs(servers)
399 399
@@ -405,16 +405,16 @@ describe('Test moderation notifications', function () {
405 await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence') 405 await checkAutoInstanceFollowing({ ...baseParams, ...userOverride }, followerHost, followingHost, 'absence')
406 406
407 config.followings.instance.autoFollowBack.enabled = false 407 config.followings.instance.autoFollowBack.enabled = false
408 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 408 await servers[0].config.updateCustomSubConfig({ newConfig: config })
409 await servers[0].followsCommand.unfollow({ target: servers[2] }) 409 await servers[0].follows.unfollow({ target: servers[2] })
410 await servers[2].followsCommand.unfollow({ target: servers[0] }) 410 await servers[2].follows.unfollow({ target: servers[0] })
411 }) 411 })
412 412
413 it('Should send a notification on auto instances index follow', async function () { 413 it('Should send a notification on auto instances index follow', async function () {
414 this.timeout(30000) 414 this.timeout(30000)
415 await servers[0].followsCommand.unfollow({ target: servers[1] }) 415 await servers[0].follows.unfollow({ target: servers[1] })
416 416
417 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 417 await servers[0].config.updateCustomSubConfig({ newConfig: config })
418 418
419 await wait(5000) 419 await wait(5000)
420 await waitJobs(servers) 420 await waitJobs(servers)
@@ -424,8 +424,8 @@ describe('Test moderation notifications', function () {
424 await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence') 424 await checkAutoInstanceFollowing(baseParams, followerHost, followingHost, 'presence')
425 425
426 config.followings.instance.autoFollowIndex.enabled = false 426 config.followings.instance.autoFollowIndex.enabled = false
427 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 427 await servers[0].config.updateCustomSubConfig({ newConfig: config })
428 await servers[0].followsCommand.unfollow({ target: servers[1] }) 428 await servers[0].follows.unfollow({ target: servers[1] })
429 }) 429 })
430 }) 430 })
431 431
@@ -460,7 +460,7 @@ describe('Test moderation notifications', function () {
460 token: userAccessToken 460 token: userAccessToken
461 } 461 }
462 462
463 currentCustomConfig = await servers[0].configCommand.getCustomConfig() 463 currentCustomConfig = await servers[0].config.getCustomConfig()
464 464
465 const autoBlacklistTestsCustomConfig = { 465 const autoBlacklistTestsCustomConfig = {
466 ...currentCustomConfig, 466 ...currentCustomConfig,
@@ -476,10 +476,10 @@ describe('Test moderation notifications', function () {
476 476
477 // enable transcoding otherwise own publish notification after transcoding not expected 477 // enable transcoding otherwise own publish notification after transcoding not expected
478 autoBlacklistTestsCustomConfig.transcoding.enabled = true 478 autoBlacklistTestsCustomConfig.transcoding.enabled = true
479 await servers[0].configCommand.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig }) 479 await servers[0].config.updateCustomConfig({ newCustomConfig: autoBlacklistTestsCustomConfig })
480 480
481 await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 481 await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
482 await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 482 await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
483 483
484 }) 484 })
485 485
@@ -487,7 +487,7 @@ describe('Test moderation notifications', function () {
487 this.timeout(40000) 487 this.timeout(40000)
488 488
489 videoName = 'video with auto-blacklist ' + buildUUID() 489 videoName = 'video with auto-blacklist ' + buildUUID()
490 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: videoName } }) 490 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: videoName } })
491 videoUUID = uuid 491 videoUUID = uuid
492 492
493 await waitJobs(servers) 493 await waitJobs(servers)
@@ -509,7 +509,7 @@ describe('Test moderation notifications', function () {
509 it('Should send video published and unblacklist after video unblacklisted', async function () { 509 it('Should send video published and unblacklist after video unblacklisted', async function () {
510 this.timeout(40000) 510 this.timeout(40000)
511 511
512 await servers[0].blacklistCommand.remove({ videoId: videoUUID }) 512 await servers[0].blacklist.remove({ videoId: videoUUID })
513 513
514 await waitJobs(servers) 514 await waitJobs(servers)
515 515
@@ -543,9 +543,9 @@ describe('Test moderation notifications', function () {
543 } 543 }
544 } 544 }
545 545
546 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) 546 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes })
547 547
548 await servers[0].blacklistCommand.remove({ videoId: uuid }) 548 await servers[0].blacklist.remove({ videoId: uuid })
549 549
550 await waitJobs(servers) 550 await waitJobs(servers)
551 await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist') 551 await checkNewBlacklistOnMyVideo(userBaseParams, uuid, name, 'unblacklist')
@@ -575,7 +575,7 @@ describe('Test moderation notifications', function () {
575 } 575 }
576 } 576 }
577 577
578 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken, attributes }) 578 const { uuid } = await servers[0].videos.upload({ token: userAccessToken, attributes })
579 579
580 await wait(6000) 580 await wait(6000)
581 await checkVideoIsPublished(userBaseParams, name, uuid, 'absence') 581 await checkVideoIsPublished(userBaseParams, name, uuid, 'absence')
@@ -589,17 +589,17 @@ describe('Test moderation notifications', function () {
589 const name = 'video without auto-blacklist ' + buildUUID() 589 const name = 'video without auto-blacklist ' + buildUUID()
590 590
591 // admin with blacklist right will not be auto-blacklisted 591 // admin with blacklist right will not be auto-blacklisted
592 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name } }) 592 const { uuid } = await servers[0].videos.upload({ attributes: { name } })
593 593
594 await waitJobs(servers) 594 await waitJobs(servers)
595 await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence') 595 await checkVideoAutoBlacklistForModerators(adminBaseParamsServer1, uuid, name, 'absence')
596 }) 596 })
597 597
598 after(async () => { 598 after(async () => {
599 await servers[0].configCommand.updateCustomConfig({ newCustomConfig: currentCustomConfig }) 599 await servers[0].config.updateCustomConfig({ newCustomConfig: currentCustomConfig })
600 600
601 await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) 601 await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
602 await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) 602 await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
603 }) 603 })
604 }) 604 })
605 605
diff --git a/server/tests/api/notifications/notifications-api.ts b/server/tests/api/notifications/notifications-api.ts
index 41e1b8015..647d783b5 100644
--- a/server/tests/api/notifications/notifications-api.ts
+++ b/server/tests/api/notifications/notifications-api.ts
@@ -31,10 +31,10 @@ describe('Test notifications API', function () {
31 userNotifications = res.userNotifications 31 userNotifications = res.userNotifications
32 server = res.servers[0] 32 server = res.servers[0]
33 33
34 await server.subscriptionsCommand.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port }) 34 await server.subscriptions.add({ token: userToken, targetUri: 'root_channel@localhost:' + server.port })
35 35
36 for (let i = 0; i < 10; i++) { 36 for (let i = 0; i < 10; i++) {
37 await server.videosCommand.randomUpload({ wait: false }) 37 await server.videos.randomUpload({ wait: false })
38 } 38 }
39 39
40 await waitJobs([ server ]) 40 await waitJobs([ server ])
@@ -43,14 +43,14 @@ describe('Test notifications API', function () {
43 describe('Mark as read', function () { 43 describe('Mark as read', function () {
44 44
45 it('Should mark as read some notifications', async function () { 45 it('Should mark as read some notifications', async function () {
46 const { data } = await server.notificationsCommand.list({ token: userToken, start: 2, count: 3 }) 46 const { data } = await server.notifications.list({ token: userToken, start: 2, count: 3 })
47 const ids = data.map(n => n.id) 47 const ids = data.map(n => n.id)
48 48
49 await server.notificationsCommand.markAsRead({ token: userToken, ids }) 49 await server.notifications.markAsRead({ token: userToken, ids })
50 }) 50 })
51 51
52 it('Should have the notifications marked as read', async function () { 52 it('Should have the notifications marked as read', async function () {
53 const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10 }) 53 const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10 })
54 54
55 expect(data[0].read).to.be.false 55 expect(data[0].read).to.be.false
56 expect(data[1].read).to.be.false 56 expect(data[1].read).to.be.false
@@ -61,7 +61,7 @@ describe('Test notifications API', function () {
61 }) 61 })
62 62
63 it('Should only list read notifications', async function () { 63 it('Should only list read notifications', async function () {
64 const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: false }) 64 const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: false })
65 65
66 for (const notification of data) { 66 for (const notification of data) {
67 expect(notification.read).to.be.true 67 expect(notification.read).to.be.true
@@ -69,7 +69,7 @@ describe('Test notifications API', function () {
69 }) 69 })
70 70
71 it('Should only list unread notifications', async function () { 71 it('Should only list unread notifications', async function () {
72 const { data } = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: true }) 72 const { data } = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: true })
73 73
74 for (const notification of data) { 74 for (const notification of data) {
75 expect(notification.read).to.be.false 75 expect(notification.read).to.be.false
@@ -77,9 +77,9 @@ describe('Test notifications API', function () {
77 }) 77 })
78 78
79 it('Should mark as read all notifications', async function () { 79 it('Should mark as read all notifications', async function () {
80 await server.notificationsCommand.markAsReadAll({ token: userToken }) 80 await server.notifications.markAsReadAll({ token: userToken })
81 81
82 const body = await server.notificationsCommand.list({ token: userToken, start: 0, count: 10, unread: true }) 82 const body = await server.notifications.list({ token: userToken, start: 0, count: 10, unread: true })
83 83
84 expect(body.total).to.equal(0) 84 expect(body.total).to.equal(0)
85 expect(body.data).to.have.lengthOf(0) 85 expect(body.data).to.have.lengthOf(0)
@@ -101,17 +101,17 @@ describe('Test notifications API', function () {
101 it('Should not have notifications', async function () { 101 it('Should not have notifications', async function () {
102 this.timeout(20000) 102 this.timeout(20000)
103 103
104 await server.notificationsCommand.updateMySettings({ 104 await server.notifications.updateMySettings({
105 token: userToken, 105 token: userToken,
106 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.NONE } 106 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.NONE }
107 }) 107 })
108 108
109 { 109 {
110 const info = await server.usersCommand.getMyInfo({ token: userToken }) 110 const info = await server.users.getMyInfo({ token: userToken })
111 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE) 111 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.NONE)
112 } 112 }
113 113
114 const { name, uuid } = await server.videosCommand.randomUpload() 114 const { name, uuid } = await server.videos.randomUpload()
115 115
116 const check = { web: true, mail: true } 116 const check = { web: true, mail: true }
117 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence') 117 await checkNewVideoFromSubscription({ ...baseParams, check }, name, uuid, 'absence')
@@ -120,17 +120,17 @@ describe('Test notifications API', function () {
120 it('Should only have web notifications', async function () { 120 it('Should only have web notifications', async function () {
121 this.timeout(20000) 121 this.timeout(20000)
122 122
123 await server.notificationsCommand.updateMySettings({ 123 await server.notifications.updateMySettings({
124 token: userToken, 124 token: userToken,
125 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.WEB } 125 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.WEB }
126 }) 126 })
127 127
128 { 128 {
129 const info = await server.usersCommand.getMyInfo({ token: userToken }) 129 const info = await server.users.getMyInfo({ token: userToken })
130 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB) 130 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
131 } 131 }
132 132
133 const { name, uuid } = await server.videosCommand.randomUpload() 133 const { name, uuid } = await server.videos.randomUpload()
134 134
135 { 135 {
136 const check = { mail: true, web: false } 136 const check = { mail: true, web: false }
@@ -146,17 +146,17 @@ describe('Test notifications API', function () {
146 it('Should only have mail notifications', async function () { 146 it('Should only have mail notifications', async function () {
147 this.timeout(20000) 147 this.timeout(20000)
148 148
149 await server.notificationsCommand.updateMySettings({ 149 await server.notifications.updateMySettings({
150 token: userToken, 150 token: userToken,
151 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.EMAIL } 151 settings: { ...getAllNotificationsSettings(), newVideoFromSubscription: UserNotificationSettingValue.EMAIL }
152 }) 152 })
153 153
154 { 154 {
155 const info = await server.usersCommand.getMyInfo({ token: userToken }) 155 const info = await server.users.getMyInfo({ token: userToken })
156 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL) 156 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.EMAIL)
157 } 157 }
158 158
159 const { name, uuid } = await server.videosCommand.randomUpload() 159 const { name, uuid } = await server.videos.randomUpload()
160 160
161 { 161 {
162 const check = { mail: false, web: true } 162 const check = { mail: false, web: true }
@@ -172,7 +172,7 @@ describe('Test notifications API', function () {
172 it('Should have email and web notifications', async function () { 172 it('Should have email and web notifications', async function () {
173 this.timeout(20000) 173 this.timeout(20000)
174 174
175 await server.notificationsCommand.updateMySettings({ 175 await server.notifications.updateMySettings({
176 token: userToken, 176 token: userToken,
177 settings: { 177 settings: {
178 ...getAllNotificationsSettings(), 178 ...getAllNotificationsSettings(),
@@ -181,13 +181,13 @@ describe('Test notifications API', function () {
181 }) 181 })
182 182
183 { 183 {
184 const info = await server.usersCommand.getMyInfo({ token: userToken }) 184 const info = await server.users.getMyInfo({ token: userToken })
185 expect(info.notificationSettings.newVideoFromSubscription).to.equal( 185 expect(info.notificationSettings.newVideoFromSubscription).to.equal(
186 UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL 186 UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
187 ) 187 )
188 } 188 }
189 189
190 const { name, uuid } = await server.videosCommand.randomUpload() 190 const { name, uuid } = await server.videos.randomUpload()
191 191
192 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 192 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
193 }) 193 })
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts
index 4db8c1576..53f8c7594 100644
--- a/server/tests/api/notifications/user-notifications.ts
+++ b/server/tests/api/notifications/user-notifications.ts
@@ -61,7 +61,7 @@ describe('Test user notifications', function () {
61 61
62 await uploadRandomVideoOnServers(servers, 1) 62 await uploadRandomVideoOnServers(servers, 1)
63 63
64 const notification = await servers[0].notificationsCommand.getLastest({ token: userAccessToken }) 64 const notification = await servers[0].notifications.getLastest({ token: userAccessToken })
65 expect(notification).to.be.undefined 65 expect(notification).to.be.undefined
66 66
67 expect(emails).to.have.lengthOf(0) 67 expect(emails).to.have.lengthOf(0)
@@ -71,7 +71,7 @@ describe('Test user notifications', function () {
71 it('Should send a new video notification if the user follows the local video publisher', async function () { 71 it('Should send a new video notification if the user follows the local video publisher', async function () {
72 this.timeout(15000) 72 this.timeout(15000)
73 73
74 await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) 74 await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
75 await waitJobs(servers) 75 await waitJobs(servers)
76 76
77 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1) 77 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1)
@@ -81,7 +81,7 @@ describe('Test user notifications', function () {
81 it('Should send a new video notification from a remote account', async function () { 81 it('Should send a new video notification from a remote account', async function () {
82 this.timeout(150000) // Server 2 has transcoding enabled 82 this.timeout(150000) // Server 2 has transcoding enabled
83 83
84 await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port }) 84 await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[1].port })
85 await waitJobs(servers) 85 await waitJobs(servers)
86 86
87 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2) 87 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2)
@@ -153,7 +153,7 @@ describe('Test user notifications', function () {
153 153
154 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 154 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
155 155
156 await servers[0].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) 156 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
157 157
158 await waitJobs(servers) 158 await waitJobs(servers)
159 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 159 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
@@ -167,7 +167,7 @@ describe('Test user notifications', function () {
167 167
168 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 168 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
169 169
170 await servers[1].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) 170 await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } })
171 171
172 await waitJobs(servers) 172 await waitJobs(servers)
173 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 173 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
@@ -179,7 +179,7 @@ describe('Test user notifications', function () {
179 const data = { privacy: VideoPrivacy.PRIVATE } 179 const data = { privacy: VideoPrivacy.PRIVATE }
180 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data) 180 const { name, uuid } = await uploadRandomVideoOnServers(servers, 1, data)
181 181
182 await servers[0].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } }) 182 await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
183 183
184 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 184 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
185 }) 185 })
@@ -190,7 +190,7 @@ describe('Test user notifications', function () {
190 const data = { privacy: VideoPrivacy.PRIVATE } 190 const data = { privacy: VideoPrivacy.PRIVATE }
191 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data) 191 const { name, uuid } = await uploadRandomVideoOnServers(servers, 2, data)
192 192
193 await servers[1].videosCommand.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } }) 193 await servers[1].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.UNLISTED } })
194 194
195 await waitJobs(servers) 195 await waitJobs(servers)
196 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence') 196 await checkNewVideoFromSubscription(baseParams, name, uuid, 'absence')
@@ -207,7 +207,7 @@ describe('Test user notifications', function () {
207 privacy: VideoPrivacy.PUBLIC, 207 privacy: VideoPrivacy.PUBLIC,
208 targetUrl: ImportsCommand.getGoodVideoUrl() 208 targetUrl: ImportsCommand.getGoodVideoUrl()
209 } 209 }
210 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 210 const { video } = await servers[0].imports.importVideo({ attributes })
211 211
212 await waitJobs(servers) 212 await waitJobs(servers)
213 213
@@ -242,7 +242,7 @@ describe('Test user notifications', function () {
242 await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: false }) 242 await uploadRandomVideoOnServers(servers, 2, { waitTranscoding: false })
243 await waitJobs(servers) 243 await waitJobs(servers)
244 244
245 const notification = await servers[0].notificationsCommand.getLastest({ token: userAccessToken }) 245 const notification = await servers[0].notifications.getLastest({ token: userAccessToken })
246 if (notification) { 246 if (notification) {
247 expect(notification.type).to.not.equal(UserNotificationType.MY_VIDEO_PUBLISHED) 247 expect(notification.type).to.not.equal(UserNotificationType.MY_VIDEO_PUBLISHED)
248 } 248 }
@@ -278,7 +278,7 @@ describe('Test user notifications', function () {
278 targetUrl: ImportsCommand.getGoodVideoUrl(), 278 targetUrl: ImportsCommand.getGoodVideoUrl(),
279 waitTranscoding: true 279 waitTranscoding: true
280 } 280 }
281 const { video } = await servers[1].importsCommand.importVideo({ attributes }) 281 const { video } = await servers[1].imports.importVideo({ attributes })
282 282
283 await waitJobs(servers) 283 await waitJobs(servers)
284 await checkVideoIsPublished(baseParams, name, video.uuid, 'presence') 284 await checkVideoIsPublished(baseParams, name, video.uuid, 'presence')
@@ -345,7 +345,7 @@ describe('Test user notifications', function () {
345 privacy: VideoPrivacy.PRIVATE, 345 privacy: VideoPrivacy.PRIVATE,
346 targetUrl: ImportsCommand.getBadVideoUrl() 346 targetUrl: ImportsCommand.getBadVideoUrl()
347 } 347 }
348 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 348 const { video } = await servers[0].imports.importVideo({ attributes })
349 349
350 await waitJobs(servers) 350 await waitJobs(servers)
351 await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence') 351 await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getBadVideoUrl(), false, 'presence')
@@ -362,7 +362,7 @@ describe('Test user notifications', function () {
362 privacy: VideoPrivacy.PRIVATE, 362 privacy: VideoPrivacy.PRIVATE,
363 targetUrl: ImportsCommand.getGoodVideoUrl() 363 targetUrl: ImportsCommand.getGoodVideoUrl()
364 } 364 }
365 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 365 const { video } = await servers[0].imports.importVideo({ attributes })
366 366
367 await waitJobs(servers) 367 await waitJobs(servers)
368 await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence') 368 await checkMyVideoImportIsFinished(baseParams, name, video.uuid, ImportsCommand.getGoodVideoUrl(), true, 'presence')
@@ -382,16 +382,16 @@ describe('Test user notifications', function () {
382 token: userAccessToken 382 token: userAccessToken
383 } 383 }
384 384
385 await servers[0].usersCommand.updateMe({ displayName: 'super root name' }) 385 await servers[0].users.updateMe({ displayName: 'super root name' })
386 386
387 await servers[0].usersCommand.updateMe({ 387 await servers[0].users.updateMe({
388 token: userAccessToken, 388 token: userAccessToken,
389 displayName: myUserName 389 displayName: myUserName
390 }) 390 })
391 391
392 await servers[1].usersCommand.updateMe({ displayName: 'super root 2 name' }) 392 await servers[1].users.updateMe({ displayName: 'super root 2 name' })
393 393
394 await servers[0].channelsCommand.update({ 394 await servers[0].channels.update({
395 token: userAccessToken, 395 token: userAccessToken,
396 channelName: 'user_1_channel', 396 channelName: 'user_1_channel',
397 attributes: { displayName: myChannelName } 397 attributes: { displayName: myChannelName }
@@ -401,23 +401,23 @@ describe('Test user notifications', function () {
401 it('Should notify when a local channel is following one of our channel', async function () { 401 it('Should notify when a local channel is following one of our channel', async function () {
402 this.timeout(50000) 402 this.timeout(50000)
403 403
404 await servers[0].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 404 await servers[0].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
405 await waitJobs(servers) 405 await waitJobs(servers)
406 406
407 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') 407 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence')
408 408
409 await servers[0].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) 409 await servers[0].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
410 }) 410 })
411 411
412 it('Should notify when a remote channel is following one of our channel', async function () { 412 it('Should notify when a remote channel is following one of our channel', async function () {
413 this.timeout(50000) 413 this.timeout(50000)
414 414
415 await servers[1].subscriptionsCommand.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port }) 415 await servers[1].subscriptions.add({ targetUri: 'user_1_channel@localhost:' + servers[0].port })
416 await waitJobs(servers) 416 await waitJobs(servers)
417 417
418 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') 418 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence')
419 419
420 await servers[1].subscriptionsCommand.remove({ uri: 'user_1_channel@localhost:' + servers[0].port }) 420 await servers[1].subscriptions.remove({ uri: 'user_1_channel@localhost:' + servers[0].port })
421 }) 421 })
422 422
423 // PeerTube does not support accout -> account follows 423 // PeerTube does not support accout -> account follows
diff --git a/server/tests/api/redundancy/manage-redundancy.ts b/server/tests/api/redundancy/manage-redundancy.ts
index efb60dc56..e193b968e 100644
--- a/server/tests/api/redundancy/manage-redundancy.ts
+++ b/server/tests/api/redundancy/manage-redundancy.ts
@@ -53,15 +53,15 @@ describe('Test manage videos redundancy', function () {
53 // Get the access tokens 53 // Get the access tokens
54 await setAccessTokensToServers(servers) 54 await setAccessTokensToServers(servers)
55 55
56 commands = servers.map(s => s.redundancyCommand) 56 commands = servers.map(s => s.redundancy)
57 57
58 { 58 {
59 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } }) 59 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
60 video1Server2UUID = uuid 60 video1Server2UUID = uuid
61 } 61 }
62 62
63 { 63 {
64 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 2 server 2' } }) 64 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 2 server 2' } })
65 video2Server2UUID = uuid 65 video2Server2UUID = uuid
66 } 66 }
67 67
@@ -87,7 +87,7 @@ describe('Test manage videos redundancy', function () {
87 this.timeout(120000) 87 this.timeout(120000)
88 88
89 await waitJobs(servers) 89 await waitJobs(servers)
90 await servers[0].serversCommand.waitUntilLog('Duplicated ', 10) 90 await servers[0].servers.waitUntilLog('Duplicated ', 10)
91 await waitJobs(servers) 91 await waitJobs(servers)
92 92
93 const body = await commands[1].listVideos({ target: 'remote-videos' }) 93 const body = await commands[1].listVideos({ target: 'remote-videos' })
@@ -203,14 +203,14 @@ describe('Test manage videos redundancy', function () {
203 it('Should manually add a redundancy and list it', async function () { 203 it('Should manually add a redundancy and list it', async function () {
204 this.timeout(120000) 204 this.timeout(120000)
205 205
206 const uuid = (await servers[1].videosCommand.quickUpload({ name: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid 206 const uuid = (await servers[1].videos.quickUpload({ name: 'video 3 server 2', privacy: VideoPrivacy.UNLISTED })).uuid
207 await waitJobs(servers) 207 await waitJobs(servers)
208 const videoId = await servers[0].videosCommand.getId({ uuid }) 208 const videoId = await servers[0].videos.getId({ uuid })
209 209
210 await commands[0].addVideo({ videoId }) 210 await commands[0].addVideo({ videoId })
211 211
212 await waitJobs(servers) 212 await waitJobs(servers)
213 await servers[0].serversCommand.waitUntilLog('Duplicated ', 15) 213 await servers[0].servers.waitUntilLog('Duplicated ', 15)
214 await waitJobs(servers) 214 await waitJobs(servers)
215 215
216 { 216 {
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts
index b3f6ed160..0378cc122 100644
--- a/server/tests/api/redundancy/redundancy-constraints.ts
+++ b/server/tests/api/redundancy/redundancy-constraints.ts
@@ -36,21 +36,21 @@ describe('Test redundancy constraints', function () {
36 36
37 async function uploadWrapper (videoName: string) { 37 async function uploadWrapper (videoName: string) {
38 // Wait for transcoding 38 // Wait for transcoding
39 const { id } = await localServer.videosCommand.upload({ attributes: { name: 'to transcode', privacy: VideoPrivacy.PRIVATE } }) 39 const { id } = await localServer.videos.upload({ attributes: { name: 'to transcode', privacy: VideoPrivacy.PRIVATE } })
40 await waitJobs([ localServer ]) 40 await waitJobs([ localServer ])
41 41
42 // Update video to schedule a federation 42 // Update video to schedule a federation
43 await localServer.videosCommand.update({ id, attributes: { name: videoName, privacy: VideoPrivacy.PUBLIC } }) 43 await localServer.videos.update({ id, attributes: { name: videoName, privacy: VideoPrivacy.PUBLIC } })
44 } 44 }
45 45
46 async function getTotalRedundanciesLocalServer () { 46 async function getTotalRedundanciesLocalServer () {
47 const body = await localServer.redundancyCommand.listVideos({ target: 'my-videos' }) 47 const body = await localServer.redundancy.listVideos({ target: 'my-videos' })
48 48
49 return body.total 49 return body.total
50 } 50 }
51 51
52 async function getTotalRedundanciesRemoteServer () { 52 async function getTotalRedundanciesRemoteServer () {
53 const body = await remoteServer.redundancyCommand.listVideos({ target: 'remote-videos' }) 53 const body = await remoteServer.redundancy.listVideos({ target: 'remote-videos' })
54 54
55 return body.total 55 return body.total
56 } 56 }
@@ -78,14 +78,14 @@ describe('Test redundancy constraints', function () {
78 // Get the access tokens 78 // Get the access tokens
79 await setAccessTokensToServers(servers) 79 await setAccessTokensToServers(servers)
80 80
81 await localServer.videosCommand.upload({ attributes: { name: 'video 1 server 2' } }) 81 await localServer.videos.upload({ attributes: { name: 'video 1 server 2' } })
82 82
83 await waitJobs(servers) 83 await waitJobs(servers)
84 84
85 // Server 1 and server 2 follow each other 85 // Server 1 and server 2 follow each other
86 await remoteServer.followsCommand.follow({ targets: [ localServer.url ] }) 86 await remoteServer.follows.follow({ targets: [ localServer.url ] })
87 await waitJobs(servers) 87 await waitJobs(servers)
88 await remoteServer.redundancyCommand.updateRedundancy({ host: localServer.host, redundancyAllowed: true }) 88 await remoteServer.redundancy.updateRedundancy({ host: localServer.host, redundancyAllowed: true })
89 89
90 await waitJobs(servers) 90 await waitJobs(servers)
91 }) 91 })
@@ -94,7 +94,7 @@ describe('Test redundancy constraints', function () {
94 this.timeout(120000) 94 this.timeout(120000)
95 95
96 await waitJobs(servers) 96 await waitJobs(servers)
97 await remoteServer.serversCommand.waitUntilLog('Duplicated ', 5) 97 await remoteServer.servers.waitUntilLog('Duplicated ', 5)
98 await waitJobs(servers) 98 await waitJobs(servers)
99 99
100 { 100 {
@@ -123,7 +123,7 @@ describe('Test redundancy constraints', function () {
123 123
124 await uploadWrapper('video 2 server 2') 124 await uploadWrapper('video 2 server 2')
125 125
126 await remoteServer.serversCommand.waitUntilLog('Duplicated ', 10) 126 await remoteServer.servers.waitUntilLog('Duplicated ', 10)
127 await waitJobs(servers) 127 await waitJobs(servers)
128 128
129 { 129 {
@@ -152,7 +152,7 @@ describe('Test redundancy constraints', function () {
152 152
153 await uploadWrapper('video 3 server 2') 153 await uploadWrapper('video 3 server 2')
154 154
155 await remoteServer.serversCommand.waitUntilLog('Duplicated ', 15) 155 await remoteServer.servers.waitUntilLog('Duplicated ', 15)
156 await waitJobs(servers) 156 await waitJobs(servers)
157 157
158 { 158 {
@@ -169,11 +169,11 @@ describe('Test redundancy constraints', function () {
169 it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () { 169 it('Should have redundancy on server 1 and on server 2 with followings filter now server 2 follows server 1', async function () {
170 this.timeout(120000) 170 this.timeout(120000)
171 171
172 await localServer.followsCommand.follow({ targets: [ remoteServer.url ] }) 172 await localServer.follows.follow({ targets: [ remoteServer.url ] })
173 await waitJobs(servers) 173 await waitJobs(servers)
174 174
175 await uploadWrapper('video 4 server 2') 175 await uploadWrapper('video 4 server 2')
176 await remoteServer.serversCommand.waitUntilLog('Duplicated ', 20) 176 await remoteServer.servers.waitUntilLog('Duplicated ', 20)
177 await waitJobs(servers) 177 await waitJobs(servers)
178 178
179 { 179 {
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 6ca9c9303..77ea2278e 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -78,11 +78,11 @@ async function flushAndRunServers (strategy: VideoRedundancyStrategy | null, add
78 await setAccessTokensToServers(servers) 78 await setAccessTokensToServers(servers)
79 79
80 { 80 {
81 const { uuid, id } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } }) 81 const { uuid, id } = await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
82 video1Server2UUID = uuid 82 video1Server2UUID = uuid
83 video1Server2Id = id 83 video1Server2Id = id
84 84
85 await servers[1].videosCommand.view({ id: video1Server2UUID }) 85 await servers[1].videos.view({ id: video1Server2UUID })
86 } 86 }
87 87
88 await waitJobs(servers) 88 await waitJobs(servers)
@@ -106,7 +106,7 @@ async function check1WebSeed (videoUUID?: string) {
106 106
107 for (const server of servers) { 107 for (const server of servers) {
108 // With token to avoid issues with video follow constraints 108 // With token to avoid issues with video follow constraints
109 const video = await server.videosCommand.getWithToken({ id: videoUUID }) 109 const video = await server.videos.getWithToken({ id: videoUUID })
110 110
111 for (const f of video.files) { 111 for (const f of video.files) {
112 checkMagnetWebseeds(f, webseeds, server) 112 checkMagnetWebseeds(f, webseeds, server)
@@ -123,7 +123,7 @@ async function check2Webseeds (videoUUID?: string) {
123 ] 123 ]
124 124
125 for (const server of servers) { 125 for (const server of servers) {
126 const video = await server.videosCommand.get({ id: videoUUID }) 126 const video = await server.videos.get({ id: videoUUID })
127 127
128 for (const file of video.files) { 128 for (const file of video.files) {
129 checkMagnetWebseeds(file, webseeds, server) 129 checkMagnetWebseeds(file, webseeds, server)
@@ -163,7 +163,7 @@ async function check0PlaylistRedundancies (videoUUID?: string) {
163 163
164 for (const server of servers) { 164 for (const server of servers) {
165 // With token to avoid issues with video follow constraints 165 // With token to avoid issues with video follow constraints
166 const video = await server.videosCommand.getWithToken({ id: videoUUID }) 166 const video = await server.videos.getWithToken({ id: videoUUID })
167 167
168 expect(video.streamingPlaylists).to.be.an('array') 168 expect(video.streamingPlaylists).to.be.an('array')
169 expect(video.streamingPlaylists).to.have.lengthOf(1) 169 expect(video.streamingPlaylists).to.have.lengthOf(1)
@@ -175,7 +175,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) {
175 if (!videoUUID) videoUUID = video1Server2UUID 175 if (!videoUUID) videoUUID = video1Server2UUID
176 176
177 for (const server of servers) { 177 for (const server of servers) {
178 const video = await server.videosCommand.get({ id: videoUUID }) 178 const video = await server.videos.get({ id: videoUUID })
179 179
180 expect(video.streamingPlaylists).to.have.lengthOf(1) 180 expect(video.streamingPlaylists).to.have.lengthOf(1)
181 expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(1) 181 expect(video.streamingPlaylists[0].redundancies).to.have.lengthOf(1)
@@ -188,7 +188,7 @@ async function check1PlaylistRedundancies (videoUUID?: string) {
188 const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls' 188 const baseUrlPlaylist = servers[1].url + '/static/streaming-playlists/hls'
189 const baseUrlSegment = servers[0].url + '/static/redundancy/hls' 189 const baseUrlSegment = servers[0].url + '/static/redundancy/hls'
190 190
191 const video = await servers[0].videosCommand.get({ id: videoUUID }) 191 const video = await servers[0].videos.get({ id: videoUUID })
192 const hlsPlaylist = video.streamingPlaylists[0] 192 const hlsPlaylist = video.streamingPlaylists[0]
193 193
194 for (const resolution of [ 240, 360, 480, 720 ]) { 194 for (const resolution of [ 240, 360, 480, 720 ]) {
@@ -221,7 +221,7 @@ async function checkStatsGlobal (strategy: VideoRedundancyStrategyWithManual) {
221 statsLength = 2 221 statsLength = 2
222 } 222 }
223 223
224 const data = await servers[0].statsCommand.get() 224 const data = await servers[0].stats.get()
225 expect(data.videosRedundancy).to.have.lengthOf(statsLength) 225 expect(data.videosRedundancy).to.have.lengthOf(statsLength)
226 226
227 const stat = data.videosRedundancy[0] 227 const stat = data.videosRedundancy[0]
@@ -248,7 +248,7 @@ async function checkStatsWithoutRedundancy (strategy: VideoRedundancyStrategyWit
248} 248}
249 249
250async function findServerFollows () { 250async function findServerFollows () {
251 const body = await servers[0].followsCommand.getFollowings({ start: 0, count: 5, sort: '-createdAt' }) 251 const body = await servers[0].follows.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
252 const follows = body.data 252 const follows = body.data
253 const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`) 253 const server2 = follows.find(f => f.following.host === `localhost:${servers[1].port}`)
254 const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`) 254 const server3 = follows.find(f => f.following.host === `localhost:${servers[2].port}`)
@@ -257,7 +257,7 @@ async function findServerFollows () {
257} 257}
258 258
259async function enableRedundancyOnServer1 () { 259async function enableRedundancyOnServer1 () {
260 await servers[0].redundancyCommand.updateRedundancy({ host: servers[1].host, redundancyAllowed: true }) 260 await servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: true })
261 261
262 const { server2, server3 } = await findServerFollows() 262 const { server2, server3 } = await findServerFollows()
263 263
@@ -269,7 +269,7 @@ async function enableRedundancyOnServer1 () {
269} 269}
270 270
271async function disableRedundancyOnServer1 () { 271async function disableRedundancyOnServer1 () {
272 await servers[0].redundancyCommand.updateRedundancy({ host: servers[1].host, redundancyAllowed: false }) 272 await servers[0].redundancy.updateRedundancy({ host: servers[1].host, redundancyAllowed: false })
273 273
274 const { server2, server3 } = await findServerFollows() 274 const { server2, server3 } = await findServerFollows()
275 275
@@ -305,7 +305,7 @@ describe('Test videos redundancy', function () {
305 this.timeout(80000) 305 this.timeout(80000)
306 306
307 await waitJobs(servers) 307 await waitJobs(servers)
308 await servers[0].serversCommand.waitUntilLog('Duplicated ', 5) 308 await servers[0].servers.waitUntilLog('Duplicated ', 5)
309 await waitJobs(servers) 309 await waitJobs(servers)
310 310
311 await check2Webseeds() 311 await check2Webseeds()
@@ -355,7 +355,7 @@ describe('Test videos redundancy', function () {
355 this.timeout(80000) 355 this.timeout(80000)
356 356
357 await waitJobs(servers) 357 await waitJobs(servers)
358 await servers[0].serversCommand.waitUntilLog('Duplicated ', 5) 358 await servers[0].servers.waitUntilLog('Duplicated ', 5)
359 await waitJobs(servers) 359 await waitJobs(servers)
360 360
361 await check2Webseeds() 361 await check2Webseeds()
@@ -366,7 +366,7 @@ describe('Test videos redundancy', function () {
366 it('Should unfollow on server 1 and remove duplicated videos', async function () { 366 it('Should unfollow on server 1 and remove duplicated videos', async function () {
367 this.timeout(80000) 367 this.timeout(80000)
368 368
369 await servers[0].followsCommand.unfollow({ target: servers[1] }) 369 await servers[0].follows.unfollow({ target: servers[1] })
370 370
371 await waitJobs(servers) 371 await waitJobs(servers)
372 await wait(5000) 372 await wait(5000)
@@ -416,8 +416,8 @@ describe('Test videos redundancy', function () {
416 it('Should view 2 times the first video to have > min_views config', async function () { 416 it('Should view 2 times the first video to have > min_views config', async function () {
417 this.timeout(80000) 417 this.timeout(80000)
418 418
419 await servers[0].videosCommand.view({ id: video1Server2UUID }) 419 await servers[0].videos.view({ id: video1Server2UUID })
420 await servers[2].videosCommand.view({ id: video1Server2UUID }) 420 await servers[2].videos.view({ id: video1Server2UUID })
421 421
422 await wait(10000) 422 await wait(10000)
423 await waitJobs(servers) 423 await waitJobs(servers)
@@ -427,7 +427,7 @@ describe('Test videos redundancy', function () {
427 this.timeout(80000) 427 this.timeout(80000)
428 428
429 await waitJobs(servers) 429 await waitJobs(servers)
430 await servers[0].serversCommand.waitUntilLog('Duplicated ', 5) 430 await servers[0].servers.waitUntilLog('Duplicated ', 5)
431 await waitJobs(servers) 431 await waitJobs(servers)
432 432
433 await check2Webseeds() 433 await check2Webseeds()
@@ -438,7 +438,7 @@ describe('Test videos redundancy', function () {
438 it('Should remove the video and the redundancy files', async function () { 438 it('Should remove the video and the redundancy files', async function () {
439 this.timeout(20000) 439 this.timeout(20000)
440 440
441 await servers[1].videosCommand.remove({ id: video1Server2UUID }) 441 await servers[1].videos.remove({ id: video1Server2UUID })
442 442
443 await waitJobs(servers) 443 await waitJobs(servers)
444 444
@@ -484,14 +484,14 @@ describe('Test videos redundancy', function () {
484 it('Should have 1 redundancy on the first video', async function () { 484 it('Should have 1 redundancy on the first video', async function () {
485 this.timeout(160000) 485 this.timeout(160000)
486 486
487 await servers[0].videosCommand.view({ id: video1Server2UUID }) 487 await servers[0].videos.view({ id: video1Server2UUID })
488 await servers[2].videosCommand.view({ id: video1Server2UUID }) 488 await servers[2].videos.view({ id: video1Server2UUID })
489 489
490 await wait(10000) 490 await wait(10000)
491 await waitJobs(servers) 491 await waitJobs(servers)
492 492
493 await waitJobs(servers) 493 await waitJobs(servers)
494 await servers[0].serversCommand.waitUntilLog('Duplicated ', 1) 494 await servers[0].servers.waitUntilLog('Duplicated ', 1)
495 await waitJobs(servers) 495 await waitJobs(servers)
496 496
497 await check1PlaylistRedundancies() 497 await check1PlaylistRedundancies()
@@ -501,7 +501,7 @@ describe('Test videos redundancy', function () {
501 it('Should remove the video and the redundancy files', async function () { 501 it('Should remove the video and the redundancy files', async function () {
502 this.timeout(20000) 502 this.timeout(20000)
503 503
504 await servers[1].videosCommand.remove({ id: video1Server2UUID }) 504 await servers[1].videos.remove({ id: video1Server2UUID })
505 505
506 await waitJobs(servers) 506 await waitJobs(servers)
507 507
@@ -529,14 +529,14 @@ describe('Test videos redundancy', function () {
529 }) 529 })
530 530
531 it('Should create a redundancy on first video', async function () { 531 it('Should create a redundancy on first video', async function () {
532 await servers[0].redundancyCommand.addVideo({ videoId: video1Server2Id }) 532 await servers[0].redundancy.addVideo({ videoId: video1Server2Id })
533 }) 533 })
534 534
535 it('Should have 2 webseeds on the first video', async function () { 535 it('Should have 2 webseeds on the first video', async function () {
536 this.timeout(80000) 536 this.timeout(80000)
537 537
538 await waitJobs(servers) 538 await waitJobs(servers)
539 await servers[0].serversCommand.waitUntilLog('Duplicated ', 5) 539 await servers[0].servers.waitUntilLog('Duplicated ', 5)
540 await waitJobs(servers) 540 await waitJobs(servers)
541 541
542 await check2Webseeds() 542 await check2Webseeds()
@@ -547,7 +547,7 @@ describe('Test videos redundancy', function () {
547 it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () { 547 it('Should manually remove redundancies on server 1 and remove duplicated videos', async function () {
548 this.timeout(80000) 548 this.timeout(80000)
549 549
550 const body = await servers[0].redundancyCommand.listVideos({ target: 'remote-videos' }) 550 const body = await servers[0].redundancy.listVideos({ target: 'remote-videos' })
551 551
552 const videos = body.data 552 const videos = body.data
553 expect(videos).to.have.lengthOf(1) 553 expect(videos).to.have.lengthOf(1)
@@ -555,7 +555,7 @@ describe('Test videos redundancy', function () {
555 const video = videos[0] 555 const video = videos[0]
556 556
557 for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) { 557 for (const r of video.redundancies.files.concat(video.redundancies.streamingPlaylists)) {
558 await servers[0].redundancyCommand.removeVideo({ redundancyId: r.id }) 558 await servers[0].redundancy.removeVideo({ redundancyId: r.id })
559 } 559 }
560 560
561 await waitJobs(servers) 561 await waitJobs(servers)
@@ -577,7 +577,7 @@ describe('Test videos redundancy', function () {
577 577
578 async function checkContains (servers: ServerInfo[], str: string) { 578 async function checkContains (servers: ServerInfo[], str: string) {
579 for (const server of servers) { 579 for (const server of servers) {
580 const video = await server.videosCommand.get({ id: video1Server2UUID }) 580 const video = await server.videos.get({ id: video1Server2UUID })
581 581
582 for (const f of video.files) { 582 for (const f of video.files) {
583 expect(f.magnetUri).to.contain(str) 583 expect(f.magnetUri).to.contain(str)
@@ -587,7 +587,7 @@ describe('Test videos redundancy', function () {
587 587
588 async function checkNotContains (servers: ServerInfo[], str: string) { 588 async function checkNotContains (servers: ServerInfo[], str: string) {
589 for (const server of servers) { 589 for (const server of servers) {
590 const video = await server.videosCommand.get({ id: video1Server2UUID }) 590 const video = await server.videos.get({ id: video1Server2UUID })
591 591
592 for (const f of video.files) { 592 for (const f of video.files) {
593 expect(f.magnetUri).to.not.contain(str) 593 expect(f.magnetUri).to.not.contain(str)
@@ -645,20 +645,20 @@ describe('Test videos redundancy', function () {
645 await enableRedundancyOnServer1() 645 await enableRedundancyOnServer1()
646 646
647 await waitJobs(servers) 647 await waitJobs(servers)
648 await servers[0].serversCommand.waitUntilLog('Duplicated ', 5) 648 await servers[0].servers.waitUntilLog('Duplicated ', 5)
649 await waitJobs(servers) 649 await waitJobs(servers)
650 650
651 await check2Webseeds(video1Server2UUID) 651 await check2Webseeds(video1Server2UUID)
652 await check1PlaylistRedundancies(video1Server2UUID) 652 await check1PlaylistRedundancies(video1Server2UUID)
653 await checkStatsWith1Redundancy(strategy) 653 await checkStatsWith1Redundancy(strategy)
654 654
655 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE } }) 655 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 2 server 2', privacy: VideoPrivacy.PRIVATE } })
656 video2Server2UUID = uuid 656 video2Server2UUID = uuid
657 657
658 // Wait transcoding before federation 658 // Wait transcoding before federation
659 await waitJobs(servers) 659 await waitJobs(servers)
660 660
661 await servers[1].videosCommand.update({ id: video2Server2UUID, attributes: { privacy: VideoPrivacy.PUBLIC } }) 661 await servers[1].videos.update({ id: video2Server2UUID, attributes: { privacy: VideoPrivacy.PUBLIC } })
662 }) 662 })
663 663
664 it('Should cache video 2 webseeds on the first video', async function () { 664 it('Should cache video 2 webseeds on the first video', async function () {
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts
index 75794402d..71e9367e5 100644
--- a/server/tests/api/search/search-activitypub-video-channels.ts
+++ b/server/tests/api/search/search-activitypub-video-channels.ts
@@ -30,34 +30,34 @@ describe('Test ActivityPub video channels search', function () {
30 await setAccessTokensToServers(servers) 30 await setAccessTokensToServers(servers)
31 31
32 { 32 {
33 await servers[0].usersCommand.create({ username: 'user1_server1', password: 'password' }) 33 await servers[0].users.create({ username: 'user1_server1', password: 'password' })
34 const channel = { 34 const channel = {
35 name: 'channel1_server1', 35 name: 'channel1_server1',
36 displayName: 'Channel 1 server 1' 36 displayName: 'Channel 1 server 1'
37 } 37 }
38 await servers[0].channelsCommand.create({ attributes: channel }) 38 await servers[0].channels.create({ attributes: channel })
39 } 39 }
40 40
41 { 41 {
42 const user = { username: 'user1_server2', password: 'password' } 42 const user = { username: 'user1_server2', password: 'password' }
43 await servers[1].usersCommand.create({ username: user.username, password: user.password }) 43 await servers[1].users.create({ username: user.username, password: user.password })
44 userServer2Token = await servers[1].loginCommand.getAccessToken(user) 44 userServer2Token = await servers[1].login.getAccessToken(user)
45 45
46 const channel = { 46 const channel = {
47 name: 'channel1_server2', 47 name: 'channel1_server2',
48 displayName: 'Channel 1 server 2' 48 displayName: 'Channel 1 server 2'
49 } 49 }
50 const created = await servers[1].channelsCommand.create({ token: userServer2Token, attributes: channel }) 50 const created = await servers[1].channels.create({ token: userServer2Token, attributes: channel })
51 channelIdServer2 = created.id 51 channelIdServer2 = created.id
52 52
53 const attributes = { name: 'video 1 server 2', channelId: channelIdServer2 } 53 const attributes = { name: 'video 1 server 2', channelId: channelIdServer2 }
54 const { uuid } = await servers[1].videosCommand.upload({ token: userServer2Token, attributes }) 54 const { uuid } = await servers[1].videos.upload({ token: userServer2Token, attributes })
55 videoServer2UUID = uuid 55 videoServer2UUID = uuid
56 } 56 }
57 57
58 await waitJobs(servers) 58 await waitJobs(servers)
59 59
60 command = servers[0].searchCommand 60 command = servers[0].search
61 }) 61 })
62 62
63 it('Should not find a remote video channel', async function () { 63 it('Should not find a remote video channel', async function () {
@@ -134,7 +134,7 @@ describe('Test ActivityPub video channels search', function () {
134 }) 134 })
135 135
136 it('Should not list this remote video channel', async function () { 136 it('Should not list this remote video channel', async function () {
137 const body = await servers[0].channelsCommand.list() 137 const body = await servers[0].channels.list()
138 expect(body.total).to.equal(3) 138 expect(body.total).to.equal(3)
139 expect(body.data).to.have.lengthOf(3) 139 expect(body.data).to.have.lengthOf(3)
140 expect(body.data[0].name).to.equal('channel1_server1') 140 expect(body.data[0].name).to.equal('channel1_server1')
@@ -147,7 +147,7 @@ describe('Test ActivityPub video channels search', function () {
147 147
148 await waitJobs(servers) 148 await waitJobs(servers)
149 149
150 const { total, data } = await servers[0].videosCommand.listByChannel({ 150 const { total, data } = await servers[0].videos.listByChannel({
151 token: null, 151 token: null,
152 videoChannelName: 'channel1_server2@localhost:' + servers[1].port 152 videoChannelName: 'channel1_server2@localhost:' + servers[1].port
153 }) 153 })
@@ -156,7 +156,7 @@ describe('Test ActivityPub video channels search', function () {
156 }) 156 })
157 157
158 it('Should list video channel videos of server 2 with token', async function () { 158 it('Should list video channel videos of server 2 with token', async function () {
159 const { total, data } = await servers[0].videosCommand.listByChannel({ 159 const { total, data } = await servers[0].videos.listByChannel({
160 videoChannelName: 'channel1_server2@localhost:' + servers[1].port 160 videoChannelName: 'channel1_server2@localhost:' + servers[1].port
161 }) 161 })
162 162
@@ -167,12 +167,12 @@ describe('Test ActivityPub video channels search', function () {
167 it('Should update video channel of server 2, and refresh it on server 1', async function () { 167 it('Should update video channel of server 2, and refresh it on server 1', async function () {
168 this.timeout(60000) 168 this.timeout(60000)
169 169
170 await servers[1].channelsCommand.update({ 170 await servers[1].channels.update({
171 token: userServer2Token, 171 token: userServer2Token,
172 channelName: 'channel1_server2', 172 channelName: 'channel1_server2',
173 attributes: { displayName: 'channel updated' } 173 attributes: { displayName: 'channel updated' }
174 }) 174 })
175 await servers[1].usersCommand.updateMe({ token: userServer2Token, displayName: 'user updated' }) 175 await servers[1].users.updateMe({ token: userServer2Token, displayName: 'user updated' })
176 176
177 await waitJobs(servers) 177 await waitJobs(servers)
178 // Expire video channel 178 // Expire video channel
@@ -193,8 +193,8 @@ describe('Test ActivityPub video channels search', function () {
193 it('Should update and add a video on server 2, and update it on server 1 after a search', async function () { 193 it('Should update and add a video on server 2, and update it on server 1 after a search', async function () {
194 this.timeout(60000) 194 this.timeout(60000)
195 195
196 await servers[1].videosCommand.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } }) 196 await servers[1].videos.update({ token: userServer2Token, id: videoServer2UUID, attributes: { name: 'video 1 updated' } })
197 await servers[1].videosCommand.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } }) 197 await servers[1].videos.upload({ token: userServer2Token, attributes: { name: 'video 2 server 2', channelId: channelIdServer2 } })
198 198
199 await waitJobs(servers) 199 await waitJobs(servers)
200 200
@@ -207,7 +207,7 @@ describe('Test ActivityPub video channels search', function () {
207 await waitJobs(servers) 207 await waitJobs(servers)
208 208
209 const videoChannelName = 'channel1_server2@localhost:' + servers[1].port 209 const videoChannelName = 'channel1_server2@localhost:' + servers[1].port
210 const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName, sort: '-createdAt' }) 210 const { total, data } = await servers[0].videos.listByChannel({ videoChannelName, sort: '-createdAt' })
211 211
212 expect(total).to.equal(2) 212 expect(total).to.equal(2)
213 expect(data[0].name).to.equal('video 2 server 2') 213 expect(data[0].name).to.equal('video 2 server 2')
@@ -217,7 +217,7 @@ describe('Test ActivityPub video channels search', function () {
217 it('Should delete video channel of server 2, and delete it on server 1', async function () { 217 it('Should delete video channel of server 2, and delete it on server 1', async function () {
218 this.timeout(60000) 218 this.timeout(60000)
219 219
220 await servers[1].channelsCommand.delete({ token: userServer2Token, channelName: 'channel1_server2' }) 220 await servers[1].channels.delete({ token: userServer2Token, channelName: 'channel1_server2' })
221 221
222 await waitJobs(servers) 222 await waitJobs(servers)
223 // Expire video 223 // Expire video
diff --git a/server/tests/api/search/search-activitypub-video-playlists.ts b/server/tests/api/search/search-activitypub-video-playlists.ts
index 46105c12c..7c99b954b 100644
--- a/server/tests/api/search/search-activitypub-video-playlists.ts
+++ b/server/tests/api/search/search-activitypub-video-playlists.ts
@@ -33,40 +33,40 @@ describe('Test ActivityPub playlists search', function () {
33 await setDefaultVideoChannel(servers) 33 await setDefaultVideoChannel(servers)
34 34
35 { 35 {
36 const video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid 36 const video1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).uuid
37 const video2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid 37 const video2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).uuid
38 38
39 const attributes = { 39 const attributes = {
40 displayName: 'playlist 1 on server 1', 40 displayName: 'playlist 1 on server 1',
41 privacy: VideoPlaylistPrivacy.PUBLIC, 41 privacy: VideoPlaylistPrivacy.PUBLIC,
42 videoChannelId: servers[0].videoChannel.id 42 videoChannelId: servers[0].store.channel.id
43 } 43 }
44 const created = await servers[0].playlistsCommand.create({ attributes }) 44 const created = await servers[0].playlists.create({ attributes })
45 playlistServer1UUID = created.uuid 45 playlistServer1UUID = created.uuid
46 46
47 for (const videoId of [ video1, video2 ]) { 47 for (const videoId of [ video1, video2 ]) {
48 await servers[0].playlistsCommand.addElement({ playlistId: playlistServer1UUID, attributes: { videoId } }) 48 await servers[0].playlists.addElement({ playlistId: playlistServer1UUID, attributes: { videoId } })
49 } 49 }
50 } 50 }
51 51
52 { 52 {
53 const videoId = (await servers[1].videosCommand.quickUpload({ name: 'video 1' })).uuid 53 const videoId = (await servers[1].videos.quickUpload({ name: 'video 1' })).uuid
54 video2Server2 = (await servers[1].videosCommand.quickUpload({ name: 'video 2' })).uuid 54 video2Server2 = (await servers[1].videos.quickUpload({ name: 'video 2' })).uuid
55 55
56 const attributes = { 56 const attributes = {
57 displayName: 'playlist 1 on server 2', 57 displayName: 'playlist 1 on server 2',
58 privacy: VideoPlaylistPrivacy.PUBLIC, 58 privacy: VideoPlaylistPrivacy.PUBLIC,
59 videoChannelId: servers[1].videoChannel.id 59 videoChannelId: servers[1].store.channel.id
60 } 60 }
61 const created = await servers[1].playlistsCommand.create({ attributes }) 61 const created = await servers[1].playlists.create({ attributes })
62 playlistServer2UUID = created.uuid 62 playlistServer2UUID = created.uuid
63 63
64 await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } }) 64 await servers[1].playlists.addElement({ playlistId: playlistServer2UUID, attributes: { videoId } })
65 } 65 }
66 66
67 await waitJobs(servers) 67 await waitJobs(servers)
68 68
69 command = servers[0].searchCommand 69 command = servers[0].search
70 }) 70 })
71 71
72 it('Should not find a remote playlist', async function () { 72 it('Should not find a remote playlist', async function () {
@@ -139,7 +139,7 @@ describe('Test ActivityPub playlists search', function () {
139 }) 139 })
140 140
141 it('Should not list this remote playlist', async function () { 141 it('Should not list this remote playlist', async function () {
142 const body = await servers[0].playlistsCommand.list({ start: 0, count: 10 }) 142 const body = await servers[0].playlists.list({ start: 0, count: 10 })
143 expect(body.total).to.equal(1) 143 expect(body.total).to.equal(1)
144 expect(body.data).to.have.lengthOf(1) 144 expect(body.data).to.have.lengthOf(1)
145 expect(body.data[0].displayName).to.equal('playlist 1 on server 1') 145 expect(body.data[0].displayName).to.equal('playlist 1 on server 1')
@@ -148,7 +148,7 @@ describe('Test ActivityPub playlists search', function () {
148 it('Should update the playlist of server 2, and refresh it on server 1', async function () { 148 it('Should update the playlist of server 2, and refresh it on server 1', async function () {
149 this.timeout(60000) 149 this.timeout(60000)
150 150
151 await servers[1].playlistsCommand.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } }) 151 await servers[1].playlists.addElement({ playlistId: playlistServer2UUID, attributes: { videoId: video2Server2 } })
152 152
153 await waitJobs(servers) 153 await waitJobs(servers)
154 // Expire playlist 154 // Expire playlist
@@ -172,7 +172,7 @@ describe('Test ActivityPub playlists search', function () {
172 it('Should delete playlist of server 2, and delete it on server 1', async function () { 172 it('Should delete playlist of server 2, and delete it on server 1', async function () {
173 this.timeout(60000) 173 this.timeout(60000)
174 174
175 await servers[1].playlistsCommand.delete({ playlistId: playlistServer2UUID }) 175 await servers[1].playlists.delete({ playlistId: playlistServer2UUID })
176 176
177 await waitJobs(servers) 177 await waitJobs(servers)
178 // Expiration 178 // Expiration
diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts
index 19b4d5ed8..0dfc63446 100644
--- a/server/tests/api/search/search-activitypub-videos.ts
+++ b/server/tests/api/search/search-activitypub-videos.ts
@@ -30,18 +30,18 @@ describe('Test ActivityPub videos search', function () {
30 await setAccessTokensToServers(servers) 30 await setAccessTokensToServers(servers)
31 31
32 { 32 {
33 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1 on server 1' } }) 33 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 1 on server 1' } })
34 videoServer1UUID = uuid 34 videoServer1UUID = uuid
35 } 35 }
36 36
37 { 37 {
38 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video 1 on server 2' } }) 38 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video 1 on server 2' } })
39 videoServer2UUID = uuid 39 videoServer2UUID = uuid
40 } 40 }
41 41
42 await waitJobs(servers) 42 await waitJobs(servers)
43 43
44 command = servers[0].searchCommand 44 command = servers[0].search
45 }) 45 })
46 46
47 it('Should not find a remote video', async function () { 47 it('Should not find a remote video', async function () {
@@ -105,7 +105,7 @@ describe('Test ActivityPub videos search', function () {
105 }) 105 })
106 106
107 it('Should not list this remote video', async function () { 107 it('Should not list this remote video', async function () {
108 const { total, data } = await servers[0].videosCommand.list() 108 const { total, data } = await servers[0].videos.list()
109 expect(total).to.equal(1) 109 expect(total).to.equal(1)
110 expect(data).to.have.lengthOf(1) 110 expect(data).to.have.lengthOf(1)
111 expect(data[0].name).to.equal('video 1 on server 1') 111 expect(data[0].name).to.equal('video 1 on server 1')
@@ -118,7 +118,7 @@ describe('Test ActivityPub videos search', function () {
118 name: 'super_channel', 118 name: 'super_channel',
119 displayName: 'super channel' 119 displayName: 'super channel'
120 } 120 }
121 const created = await servers[1].channelsCommand.create({ attributes: channelAttributes }) 121 const created = await servers[1].channels.create({ attributes: channelAttributes })
122 const videoChannelId = created.id 122 const videoChannelId = created.id
123 123
124 const attributes = { 124 const attributes = {
@@ -127,7 +127,7 @@ describe('Test ActivityPub videos search', function () {
127 privacy: VideoPrivacy.UNLISTED, 127 privacy: VideoPrivacy.UNLISTED,
128 channelId: videoChannelId 128 channelId: videoChannelId
129 } 129 }
130 await servers[1].videosCommand.update({ id: videoServer2UUID, attributes }) 130 await servers[1].videos.update({ id: videoServer2UUID, attributes })
131 131
132 await waitJobs(servers) 132 await waitJobs(servers)
133 // Expire video 133 // Expire video
@@ -153,7 +153,7 @@ describe('Test ActivityPub videos search', function () {
153 it('Should delete video of server 2, and delete it on server 1', async function () { 153 it('Should delete video of server 2, and delete it on server 1', async function () {
154 this.timeout(120000) 154 this.timeout(120000)
155 155
156 await servers[1].videosCommand.remove({ id: videoServer2UUID }) 156 await servers[1].videos.remove({ id: videoServer2UUID })
157 157
158 await waitJobs(servers) 158 await waitJobs(servers)
159 // Expire video 159 // Expire video
diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts
index 4d2104708..7035fbd62 100644
--- a/server/tests/api/search/search-channels.ts
+++ b/server/tests/api/search/search-channels.ts
@@ -19,15 +19,15 @@ describe('Test channels search', function () {
19 await setAccessTokensToServers([ server ]) 19 await setAccessTokensToServers([ server ])
20 20
21 { 21 {
22 await server.usersCommand.create({ username: 'user1', password: 'password' }) 22 await server.users.create({ username: 'user1', password: 'password' })
23 const channel = { 23 const channel = {
24 name: 'squall_channel', 24 name: 'squall_channel',
25 displayName: 'Squall channel' 25 displayName: 'Squall channel'
26 } 26 }
27 await server.channelsCommand.create({ attributes: channel }) 27 await server.channels.create({ attributes: channel })
28 } 28 }
29 29
30 command = server.searchCommand 30 command = server.search
31 }) 31 })
32 32
33 it('Should make a simple search and not have results', async function () { 33 it('Should make a simple search and not have results', async function () {
diff --git a/server/tests/api/search/search-index.ts b/server/tests/api/search/search-index.ts
index d5dc40f60..b54c0da22 100644
--- a/server/tests/api/search/search-index.ts
+++ b/server/tests/api/search/search-index.ts
@@ -20,9 +20,9 @@ describe('Test videos search', function () {
20 20
21 await setAccessTokensToServers([ server ]) 21 await setAccessTokensToServers([ server ])
22 22
23 await server.videosCommand.upload({ attributes: { name: localVideoName } }) 23 await server.videos.upload({ attributes: { name: localVideoName } })
24 24
25 command = server.searchCommand 25 command = server.search
26 }) 26 })
27 27
28 describe('Default search', async function () { 28 describe('Default search', async function () {
@@ -30,7 +30,7 @@ describe('Test videos search', function () {
30 it('Should make a local videos search by default', async function () { 30 it('Should make a local videos search by default', async function () {
31 this.timeout(10000) 31 this.timeout(10000)
32 32
33 await server.configCommand.updateCustomSubConfig({ 33 await server.config.updateCustomSubConfig({
34 newConfig: { 34 newConfig: {
35 search: { 35 search: {
36 searchIndex: { 36 searchIndex: {
@@ -57,7 +57,7 @@ describe('Test videos search', function () {
57 }) 57 })
58 58
59 it('Should make an index videos search by default', async function () { 59 it('Should make an index videos search by default', async function () {
60 await server.configCommand.updateCustomSubConfig({ 60 await server.config.updateCustomSubConfig({
61 newConfig: { 61 newConfig: {
62 search: { 62 search: {
63 searchIndex: { 63 searchIndex: {
@@ -79,7 +79,7 @@ describe('Test videos search', function () {
79 }) 79 })
80 80
81 it('Should make an index videos search if local search is disabled', async function () { 81 it('Should make an index videos search if local search is disabled', async function () {
82 await server.configCommand.updateCustomSubConfig({ 82 await server.config.updateCustomSubConfig({
83 newConfig: { 83 newConfig: {
84 search: { 84 search: {
85 searchIndex: { 85 searchIndex: {
@@ -213,7 +213,7 @@ describe('Test videos search', function () {
213 let nsfwUUID: string 213 let nsfwUUID: string
214 214
215 { 215 {
216 await server.configCommand.updateCustomSubConfig({ 216 await server.config.updateCustomSubConfig({
217 newConfig: { 217 newConfig: {
218 instance: { defaultNSFWPolicy: 'display' } 218 instance: { defaultNSFWPolicy: 'display' }
219 } 219 }
@@ -229,7 +229,7 @@ describe('Test videos search', function () {
229 } 229 }
230 230
231 { 231 {
232 await server.configCommand.updateCustomSubConfig({ 232 await server.config.updateCustomSubConfig({
233 newConfig: { 233 newConfig: {
234 instance: { defaultNSFWPolicy: 'do_not_list' } 234 instance: { defaultNSFWPolicy: 'do_not_list' }
235 } 235 }
diff --git a/server/tests/api/search/search-playlists.ts b/server/tests/api/search/search-playlists.ts
index 2e4773ed6..e15128c8e 100644
--- a/server/tests/api/search/search-playlists.ts
+++ b/server/tests/api/search/search-playlists.ts
@@ -26,40 +26,40 @@ describe('Test playlists search', function () {
26 await setAccessTokensToServers([ server ]) 26 await setAccessTokensToServers([ server ])
27 await setDefaultVideoChannel([ server ]) 27 await setDefaultVideoChannel([ server ])
28 28
29 const videoId = (await server.videosCommand.quickUpload({ name: 'video' })).uuid 29 const videoId = (await server.videos.quickUpload({ name: 'video' })).uuid
30 30
31 { 31 {
32 const attributes = { 32 const attributes = {
33 displayName: 'Dr. Kenzo Tenma hospital videos', 33 displayName: 'Dr. Kenzo Tenma hospital videos',
34 privacy: VideoPlaylistPrivacy.PUBLIC, 34 privacy: VideoPlaylistPrivacy.PUBLIC,
35 videoChannelId: server.videoChannel.id 35 videoChannelId: server.store.channel.id
36 } 36 }
37 const created = await server.playlistsCommand.create({ attributes }) 37 const created = await server.playlists.create({ attributes })
38 38
39 await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } }) 39 await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } })
40 } 40 }
41 41
42 { 42 {
43 const attributes = { 43 const attributes = {
44 displayName: 'Johan & Anna Libert musics', 44 displayName: 'Johan & Anna Libert musics',
45 privacy: VideoPlaylistPrivacy.PUBLIC, 45 privacy: VideoPlaylistPrivacy.PUBLIC,
46 videoChannelId: server.videoChannel.id 46 videoChannelId: server.store.channel.id
47 } 47 }
48 const created = await server.playlistsCommand.create({ attributes }) 48 const created = await server.playlists.create({ attributes })
49 49
50 await server.playlistsCommand.addElement({ playlistId: created.id, attributes: { videoId } }) 50 await server.playlists.addElement({ playlistId: created.id, attributes: { videoId } })
51 } 51 }
52 52
53 { 53 {
54 const attributes = { 54 const attributes = {
55 displayName: 'Inspector Lunge playlist', 55 displayName: 'Inspector Lunge playlist',
56 privacy: VideoPlaylistPrivacy.PUBLIC, 56 privacy: VideoPlaylistPrivacy.PUBLIC,
57 videoChannelId: server.videoChannel.id 57 videoChannelId: server.store.channel.id
58 } 58 }
59 await server.playlistsCommand.create({ attributes }) 59 await server.playlists.create({ attributes })
60 } 60 }
61 61
62 command = server.searchCommand 62 command = server.search
63 }) 63 })
64 64
65 it('Should make a simple search and not have results', async function () { 65 it('Should make a simple search and not have results', async function () {
diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts
index 148499d5f..478ebafc9 100644
--- a/server/tests/api/search/search-videos.ts
+++ b/server/tests/api/search/search-videos.ts
@@ -40,24 +40,24 @@ describe('Test videos search', function () {
40 nsfw: false, 40 nsfw: false,
41 language: 'fr' 41 language: 'fr'
42 } 42 }
43 await server.videosCommand.upload({ attributes: attributes1 }) 43 await server.videos.upload({ attributes: attributes1 })
44 44
45 const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' } 45 const attributes2 = { ...attributes1, name: attributes1.name + ' - 2', fixture: 'video_short.mp4' }
46 await server.videosCommand.upload({ attributes: attributes2 }) 46 await server.videos.upload({ attributes: attributes2 })
47 47
48 { 48 {
49 const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined } 49 const attributes3 = { ...attributes1, name: attributes1.name + ' - 3', language: undefined }
50 const { id, uuid } = await server.videosCommand.upload({ attributes: attributes3 }) 50 const { id, uuid } = await server.videos.upload({ attributes: attributes3 })
51 videoUUID = uuid 51 videoUUID = uuid
52 52
53 await server.captionsCommand.createVideoCaption({ 53 await server.captions.createVideoCaption({
54 language: 'en', 54 language: 'en',
55 videoId: id, 55 videoId: id,
56 fixture: 'subtitle-good2.vtt', 56 fixture: 'subtitle-good2.vtt',
57 mimeType: 'application/octet-stream' 57 mimeType: 'application/octet-stream'
58 }) 58 })
59 59
60 await server.captionsCommand.createVideoCaption({ 60 await server.captions.createVideoCaption({
61 language: 'aa', 61 language: 'aa',
62 videoId: id, 62 videoId: id,
63 fixture: 'subtitle-good2.vtt', 63 fixture: 'subtitle-good2.vtt',
@@ -66,23 +66,23 @@ describe('Test videos search', function () {
66 } 66 }
67 67
68 const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true } 68 const attributes4 = { ...attributes1, name: attributes1.name + ' - 4', language: 'pl', nsfw: true }
69 await server.videosCommand.upload({ attributes: attributes4 }) 69 await server.videos.upload({ attributes: attributes4 })
70 70
71 await wait(1000) 71 await wait(1000)
72 72
73 startDate = new Date().toISOString() 73 startDate = new Date().toISOString()
74 74
75 const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined } 75 const attributes5 = { ...attributes1, name: attributes1.name + ' - 5', licence: 2, language: undefined }
76 await server.videosCommand.upload({ attributes: attributes5 }) 76 await server.videos.upload({ attributes: attributes5 })
77 77
78 const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] } 78 const attributes6 = { ...attributes1, name: attributes1.name + ' - 6', tags: [ 't1', 't2' ] }
79 await server.videosCommand.upload({ attributes: attributes6 }) 79 await server.videos.upload({ attributes: attributes6 })
80 80
81 const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' } 81 const attributes7 = { ...attributes1, name: attributes1.name + ' - 7', originallyPublishedAt: '2019-02-12T09:58:08.286Z' }
82 await server.videosCommand.upload({ attributes: attributes7 }) 82 await server.videos.upload({ attributes: attributes7 })
83 83
84 const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 } 84 const attributes8 = { ...attributes1, name: attributes1.name + ' - 8', licence: 4 }
85 await server.videosCommand.upload({ attributes: attributes8 }) 85 await server.videos.upload({ attributes: attributes8 })
86 } 86 }
87 87
88 { 88 {
@@ -93,9 +93,9 @@ describe('Test videos search', function () {
93 licence: 2, 93 licence: 2,
94 language: 'en' 94 language: 'en'
95 } 95 }
96 await server.videosCommand.upload({ attributes: attributes }) 96 await server.videos.upload({ attributes: attributes })
97 97
98 await server.videosCommand.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } }) 98 await server.videos.upload({ attributes: { ...attributes, name: attributes.name + ' duplicate' } })
99 } 99 }
100 100
101 { 101 {
@@ -106,7 +106,7 @@ describe('Test videos search', function () {
106 licence: 3, 106 licence: 3,
107 language: 'pl' 107 language: 'pl'
108 } 108 }
109 await server.videosCommand.upload({ attributes: attributes }) 109 await server.videos.upload({ attributes: attributes })
110 } 110 }
111 111
112 { 112 {
@@ -115,11 +115,11 @@ describe('Test videos search', function () {
115 tags: [ 'aaaa', 'bbbb', 'cccc' ], 115 tags: [ 'aaaa', 'bbbb', 'cccc' ],
116 category: 1 116 category: 1
117 } 117 }
118 await server.videosCommand.upload({ attributes: attributes1 }) 118 await server.videos.upload({ attributes: attributes1 })
119 await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } }) 119 await server.videos.upload({ attributes: { ...attributes1, category: 2 } })
120 120
121 await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } }) 121 await server.videos.upload({ attributes: { ...attributes1, tags: [ 'cccc', 'dddd' ] } })
122 await server.videosCommand.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } }) 122 await server.videos.upload({ attributes: { ...attributes1, tags: [ 'eeee', 'ffff' ] } })
123 } 123 }
124 124
125 { 125 {
@@ -127,11 +127,11 @@ describe('Test videos search', function () {
127 name: 'aaaa 2', 127 name: 'aaaa 2',
128 category: 1 128 category: 1
129 } 129 }
130 await server.videosCommand.upload({ attributes: attributes1 }) 130 await server.videos.upload({ attributes: attributes1 })
131 await server.videosCommand.upload({ attributes: { ...attributes1, category: 2 } }) 131 await server.videos.upload({ attributes: { ...attributes1, category: 2 } })
132 } 132 }
133 133
134 command = server.searchCommand 134 command = server.search
135 }) 135 })
136 136
137 it('Should make a simple search and not have results', async function () { 137 it('Should make a simple search and not have results', async function () {
@@ -479,7 +479,7 @@ describe('Test videos search', function () {
479 }, 479 },
480 live: { enabled: true } 480 live: { enabled: true }
481 } 481 }
482 await server.configCommand.updateCustomSubConfig({ newConfig }) 482 await server.config.updateCustomSubConfig({ newConfig })
483 } 483 }
484 484
485 { 485 {
@@ -490,9 +490,9 @@ describe('Test videos search', function () {
490 } 490 }
491 491
492 { 492 {
493 const liveCommand = server.liveCommand 493 const liveCommand = server.live
494 494
495 const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.videoChannel.id } 495 const liveAttributes = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: server.store.channel.id }
496 const live = await liveCommand.create({ fields: liveAttributes }) 496 const live = await liveCommand.create({ fields: liveAttributes })
497 497
498 const ffmpegCommand = await liveCommand.sendRTMPStreamInVideo({ videoId: live.id }) 498 const ffmpegCommand = await liveCommand.sendRTMPStreamInVideo({ videoId: live.id })
diff --git a/server/tests/api/server/auto-follows.ts b/server/tests/api/server/auto-follows.ts
index 34c4f6882..e9fb5b4b1 100644
--- a/server/tests/api/server/auto-follows.ts
+++ b/server/tests/api/server/auto-follows.ts
@@ -16,7 +16,7 @@ const expect = chai.expect
16 16
17async function checkFollow (follower: ServerInfo, following: ServerInfo, exists: boolean) { 17async function checkFollow (follower: ServerInfo, following: ServerInfo, exists: boolean) {
18 { 18 {
19 const body = await following.followsCommand.getFollowers({ start: 0, count: 5, sort: '-createdAt' }) 19 const body = await following.follows.getFollowers({ start: 0, count: 5, sort: '-createdAt' })
20 const follow = body.data.find(f => f.follower.host === follower.host && f.state === 'accepted') 20 const follow = body.data.find(f => f.follower.host === follower.host && f.state === 'accepted')
21 21
22 if (exists === true) expect(follow).to.exist 22 if (exists === true) expect(follow).to.exist
@@ -24,7 +24,7 @@ async function checkFollow (follower: ServerInfo, following: ServerInfo, exists:
24 } 24 }
25 25
26 { 26 {
27 const body = await follower.followsCommand.getFollowings({ start: 0, count: 5, sort: '-createdAt' }) 27 const body = await follower.follows.getFollowings({ start: 0, count: 5, sort: '-createdAt' })
28 const follow = body.data.find(f => f.following.host === following.host && f.state === 'accepted') 28 const follow = body.data.find(f => f.following.host === following.host && f.state === 'accepted')
29 29
30 if (exists === true) expect(follow).to.exist 30 if (exists === true) expect(follow).to.exist
@@ -33,15 +33,15 @@ async function checkFollow (follower: ServerInfo, following: ServerInfo, exists:
33} 33}
34 34
35async function server1Follows2 (servers: ServerInfo[]) { 35async function server1Follows2 (servers: ServerInfo[]) {
36 await servers[0].followsCommand.follow({ targets: [ servers[1].host ] }) 36 await servers[0].follows.follow({ targets: [ servers[1].host ] })
37 37
38 await waitJobs(servers) 38 await waitJobs(servers)
39} 39}
40 40
41async function resetFollows (servers: ServerInfo[]) { 41async function resetFollows (servers: ServerInfo[]) {
42 try { 42 try {
43 await servers[0].followsCommand.unfollow({ target: servers[1] }) 43 await servers[0].follows.unfollow({ target: servers[1] })
44 await servers[1].followsCommand.unfollow({ target: servers[0] }) 44 await servers[1].follows.unfollow({ target: servers[0] })
45 } catch { /* empty */ 45 } catch { /* empty */
46 } 46 }
47 47
@@ -86,7 +86,7 @@ describe('Test auto follows', function () {
86 } 86 }
87 } 87 }
88 } 88 }
89 await servers[1].configCommand.updateCustomSubConfig({ newConfig: config }) 89 await servers[1].config.updateCustomSubConfig({ newConfig: config })
90 90
91 await server1Follows2(servers) 91 await server1Follows2(servers)
92 92
@@ -111,14 +111,14 @@ describe('Test auto follows', function () {
111 } 111 }
112 } 112 }
113 } 113 }
114 await servers[1].configCommand.updateCustomSubConfig({ newConfig: config }) 114 await servers[1].config.updateCustomSubConfig({ newConfig: config })
115 115
116 await server1Follows2(servers) 116 await server1Follows2(servers)
117 117
118 await checkFollow(servers[0], servers[1], false) 118 await checkFollow(servers[0], servers[1], false)
119 await checkFollow(servers[1], servers[0], false) 119 await checkFollow(servers[1], servers[0], false)
120 120
121 await servers[1].followsCommand.acceptFollower({ follower: 'peertube@' + servers[0].host }) 121 await servers[1].follows.acceptFollower({ follower: 'peertube@' + servers[0].host })
122 await waitJobs(servers) 122 await waitJobs(servers)
123 123
124 await checkFollow(servers[0], servers[1], true) 124 await checkFollow(servers[0], servers[1], true)
@@ -128,7 +128,7 @@ describe('Test auto follows', function () {
128 128
129 config.followings.instance.autoFollowBack.enabled = false 129 config.followings.instance.autoFollowBack.enabled = false
130 config.followers.instance.manualApproval = false 130 config.followers.instance.manualApproval = false
131 await servers[1].configCommand.updateCustomSubConfig({ newConfig: config }) 131 await servers[1].config.updateCustomSubConfig({ newConfig: config })
132 }) 132 })
133 }) 133 })
134 134
@@ -165,7 +165,7 @@ describe('Test auto follows', function () {
165 } 165 }
166 } 166 }
167 } 167 }
168 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 168 await servers[0].config.updateCustomSubConfig({ newConfig: config })
169 169
170 await wait(5000) 170 await wait(5000)
171 await waitJobs(servers) 171 await waitJobs(servers)
diff --git a/server/tests/api/server/bulk.ts b/server/tests/api/server/bulk.ts
index c83bcfb22..acc17092d 100644
--- a/server/tests/api/server/bulk.ts
+++ b/server/tests/api/server/bulk.ts
@@ -34,23 +34,23 @@ describe('Test bulk actions', function () {
34 34
35 { 35 {
36 const user = { username: 'user1', password: 'password' } 36 const user = { username: 'user1', password: 'password' }
37 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 37 await servers[0].users.create({ username: user.username, password: user.password })
38 38
39 user1Token = await servers[0].loginCommand.getAccessToken(user) 39 user1Token = await servers[0].login.getAccessToken(user)
40 } 40 }
41 41
42 { 42 {
43 const user = { username: 'user2', password: 'password' } 43 const user = { username: 'user2', password: 'password' }
44 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 44 await servers[0].users.create({ username: user.username, password: user.password })
45 45
46 user2Token = await servers[0].loginCommand.getAccessToken(user) 46 user2Token = await servers[0].login.getAccessToken(user)
47 } 47 }
48 48
49 { 49 {
50 const user = { username: 'user3', password: 'password' } 50 const user = { username: 'user3', password: 'password' }
51 await servers[1].usersCommand.create({ username: user.username, password: user.password }) 51 await servers[1].users.create({ username: user.username, password: user.password })
52 52
53 user3Token = await servers[1].loginCommand.getAccessToken(user) 53 user3Token = await servers[1].login.getAccessToken(user)
54 } 54 }
55 55
56 await doubleFollow(servers[0], servers[1]) 56 await doubleFollow(servers[0], servers[1])
@@ -61,11 +61,11 @@ describe('Test bulk actions', function () {
61 describe('Bulk remove comments', function () { 61 describe('Bulk remove comments', function () {
62 async function checkInstanceCommentsRemoved () { 62 async function checkInstanceCommentsRemoved () {
63 { 63 {
64 const { data } = await servers[0].videosCommand.list() 64 const { data } = await servers[0].videos.list()
65 65
66 // Server 1 should not have these comments anymore 66 // Server 1 should not have these comments anymore
67 for (const video of data) { 67 for (const video of data) {
68 const { data } = await servers[0].commentsCommand.listThreads({ videoId: video.id }) 68 const { data } = await servers[0].comments.listThreads({ videoId: video.id })
69 const comment = data.find(c => c.text === 'comment by user 3') 69 const comment = data.find(c => c.text === 'comment by user 3')
70 70
71 expect(comment).to.not.exist 71 expect(comment).to.not.exist
@@ -73,11 +73,11 @@ describe('Test bulk actions', function () {
73 } 73 }
74 74
75 { 75 {
76 const { data } = await servers[1].videosCommand.list() 76 const { data } = await servers[1].videos.list()
77 77
78 // Server 1 should not have these comments on videos of server 1 78 // Server 1 should not have these comments on videos of server 1
79 for (const video of data) { 79 for (const video of data) {
80 const { data } = await servers[1].commentsCommand.listThreads({ videoId: video.id }) 80 const { data } = await servers[1].comments.listThreads({ videoId: video.id })
81 const comment = data.find(c => c.text === 'comment by user 3') 81 const comment = data.find(c => c.text === 'comment by user 3')
82 82
83 if (video.account.host === 'localhost:' + servers[0].port) { 83 if (video.account.host === 'localhost:' + servers[0].port) {
@@ -92,30 +92,30 @@ describe('Test bulk actions', function () {
92 before(async function () { 92 before(async function () {
93 this.timeout(120000) 93 this.timeout(120000)
94 94
95 await servers[0].videosCommand.upload({ attributes: { name: 'video 1 server 1' } }) 95 await servers[0].videos.upload({ attributes: { name: 'video 1 server 1' } })
96 await servers[0].videosCommand.upload({ attributes: { name: 'video 2 server 1' } }) 96 await servers[0].videos.upload({ attributes: { name: 'video 2 server 1' } })
97 await servers[0].videosCommand.upload({ token: user1Token, attributes: { name: 'video 3 server 1' } }) 97 await servers[0].videos.upload({ token: user1Token, attributes: { name: 'video 3 server 1' } })
98 98
99 await servers[1].videosCommand.upload({ attributes: { name: 'video 1 server 2' } }) 99 await servers[1].videos.upload({ attributes: { name: 'video 1 server 2' } })
100 100
101 await waitJobs(servers) 101 await waitJobs(servers)
102 102
103 { 103 {
104 const { data } = await servers[0].videosCommand.list() 104 const { data } = await servers[0].videos.list()
105 for (const video of data) { 105 for (const video of data) {
106 await servers[0].commentsCommand.createThread({ videoId: video.id, text: 'comment by root server 1' }) 106 await servers[0].comments.createThread({ videoId: video.id, text: 'comment by root server 1' })
107 await servers[0].commentsCommand.createThread({ token: user1Token, videoId: video.id, text: 'comment by user 1' }) 107 await servers[0].comments.createThread({ token: user1Token, videoId: video.id, text: 'comment by user 1' })
108 await servers[0].commentsCommand.createThread({ token: user2Token, videoId: video.id, text: 'comment by user 2' }) 108 await servers[0].comments.createThread({ token: user2Token, videoId: video.id, text: 'comment by user 2' })
109 } 109 }
110 } 110 }
111 111
112 { 112 {
113 const { data } = await servers[1].videosCommand.list() 113 const { data } = await servers[1].videos.list()
114 114
115 for (const video of data) { 115 for (const video of data) {
116 await servers[1].commentsCommand.createThread({ videoId: video.id, text: 'comment by root server 2' }) 116 await servers[1].comments.createThread({ videoId: video.id, text: 'comment by root server 2' })
117 117
118 const comment = await servers[1].commentsCommand.createThread({ token: user3Token, videoId: video.id, text: 'comment by user 3' }) 118 const comment = await servers[1].comments.createThread({ token: user3Token, videoId: video.id, text: 'comment by user 3' })
119 commentsUser3.push({ videoId: video.id, commentId: comment.id }) 119 commentsUser3.push({ videoId: video.id, commentId: comment.id })
120 } 120 }
121 } 121 }
@@ -137,10 +137,10 @@ describe('Test bulk actions', function () {
137 await waitJobs(servers) 137 await waitJobs(servers)
138 138
139 for (const server of servers) { 139 for (const server of servers) {
140 const { data } = await server.videosCommand.list() 140 const { data } = await server.videos.list()
141 141
142 for (const video of data) { 142 for (const video of data) {
143 const { data } = await server.commentsCommand.listThreads({ videoId: video.id }) 143 const { data } = await server.comments.listThreads({ videoId: video.id })
144 const comment = data.find(c => c.text === 'comment by user 2') 144 const comment = data.find(c => c.text === 'comment by user 2')
145 145
146 if (video.name === 'video 3 server 1') expect(comment).to.not.exist 146 if (video.name === 'video 3 server 1') expect(comment).to.not.exist
@@ -168,7 +168,7 @@ describe('Test bulk actions', function () {
168 this.timeout(60000) 168 this.timeout(60000)
169 169
170 for (const obj of commentsUser3) { 170 for (const obj of commentsUser3) {
171 await servers[1].commentsCommand.addReply({ 171 await servers[1].comments.addReply({
172 token: user3Token, 172 token: user3Token,
173 videoId: obj.videoId, 173 videoId: obj.videoId,
174 toCommentId: obj.commentId, 174 toCommentId: obj.commentId,
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index c613511ed..479e177a8 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -214,7 +214,7 @@ describe('Test config', function () {
214 }) 214 })
215 215
216 it('Should have a correct config on a server with registration enabled', async function () { 216 it('Should have a correct config on a server with registration enabled', async function () {
217 const data = await server.configCommand.getConfig() 217 const data = await server.config.getConfig()
218 218
219 expect(data.signup.allowed).to.be.true 219 expect(data.signup.allowed).to.be.true
220 }) 220 })
@@ -223,32 +223,32 @@ describe('Test config', function () {
223 this.timeout(5000) 223 this.timeout(5000)
224 224
225 await Promise.all([ 225 await Promise.all([
226 server.usersCommand.register({ username: 'user1' }), 226 server.users.register({ username: 'user1' }),
227 server.usersCommand.register({ username: 'user2' }), 227 server.users.register({ username: 'user2' }),
228 server.usersCommand.register({ username: 'user3' }) 228 server.users.register({ username: 'user3' })
229 ]) 229 ])
230 230
231 const data = await server.configCommand.getConfig() 231 const data = await server.config.getConfig()
232 232
233 expect(data.signup.allowed).to.be.false 233 expect(data.signup.allowed).to.be.false
234 }) 234 })
235 235
236 it('Should have the correct video allowed extensions', async function () { 236 it('Should have the correct video allowed extensions', async function () {
237 const data = await server.configCommand.getConfig() 237 const data = await server.config.getConfig()
238 238
239 expect(data.video.file.extensions).to.have.lengthOf(3) 239 expect(data.video.file.extensions).to.have.lengthOf(3)
240 expect(data.video.file.extensions).to.contain('.mp4') 240 expect(data.video.file.extensions).to.contain('.mp4')
241 expect(data.video.file.extensions).to.contain('.webm') 241 expect(data.video.file.extensions).to.contain('.webm')
242 expect(data.video.file.extensions).to.contain('.ogv') 242 expect(data.video.file.extensions).to.contain('.ogv')
243 243
244 await server.videosCommand.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 }) 244 await server.videos.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 })
245 await server.videosCommand.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 }) 245 await server.videos.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415 })
246 246
247 expect(data.contactForm.enabled).to.be.true 247 expect(data.contactForm.enabled).to.be.true
248 }) 248 })
249 249
250 it('Should get the customized configuration', async function () { 250 it('Should get the customized configuration', async function () {
251 const data = await server.configCommand.getCustomConfig() 251 const data = await server.config.getCustomConfig()
252 252
253 checkInitialConfig(server, data) 253 checkInitialConfig(server, data)
254 }) 254 })
@@ -425,16 +425,16 @@ describe('Test config', function () {
425 } 425 }
426 } 426 }
427 } 427 }
428 await server.configCommand.updateCustomConfig({ newCustomConfig }) 428 await server.config.updateCustomConfig({ newCustomConfig })
429 429
430 const data = await server.configCommand.getCustomConfig() 430 const data = await server.config.getCustomConfig()
431 checkUpdatedConfig(data) 431 checkUpdatedConfig(data)
432 }) 432 })
433 433
434 it('Should have the correct updated video allowed extensions', async function () { 434 it('Should have the correct updated video allowed extensions', async function () {
435 this.timeout(10000) 435 this.timeout(10000)
436 436
437 const data = await server.configCommand.getConfig() 437 const data = await server.config.getConfig()
438 438
439 expect(data.video.file.extensions).to.have.length.above(4) 439 expect(data.video.file.extensions).to.have.length.above(4)
440 expect(data.video.file.extensions).to.contain('.mp4') 440 expect(data.video.file.extensions).to.contain('.mp4')
@@ -447,8 +447,8 @@ describe('Test config', function () {
447 expect(data.video.file.extensions).to.contain('.ogg') 447 expect(data.video.file.extensions).to.contain('.ogg')
448 expect(data.video.file.extensions).to.contain('.flac') 448 expect(data.video.file.extensions).to.contain('.flac')
449 449
450 await server.videosCommand.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.OK_200 }) 450 await server.videos.upload({ attributes: { fixture: 'video_short.mkv' }, expectedStatus: HttpStatusCode.OK_200 })
451 await server.videosCommand.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.OK_200 }) 451 await server.videos.upload({ attributes: { fixture: 'sample.ogg' }, expectedStatus: HttpStatusCode.OK_200 })
452 }) 452 })
453 453
454 it('Should have the configuration updated after a restart', async function () { 454 it('Should have the configuration updated after a restart', async function () {
@@ -458,13 +458,13 @@ describe('Test config', function () {
458 458
459 await reRunServer(server) 459 await reRunServer(server)
460 460
461 const data = await server.configCommand.getCustomConfig() 461 const data = await server.config.getCustomConfig()
462 462
463 checkUpdatedConfig(data) 463 checkUpdatedConfig(data)
464 }) 464 })
465 465
466 it('Should fetch the about information', async function () { 466 it('Should fetch the about information', async function () {
467 const data = await server.configCommand.getAbout() 467 const data = await server.config.getAbout()
468 468
469 expect(data.instance.name).to.equal('PeerTube updated') 469 expect(data.instance.name).to.equal('PeerTube updated')
470 expect(data.instance.shortDescription).to.equal('my short description') 470 expect(data.instance.shortDescription).to.equal('my short description')
@@ -486,9 +486,9 @@ describe('Test config', function () {
486 it('Should remove the custom configuration', async function () { 486 it('Should remove the custom configuration', async function () {
487 this.timeout(10000) 487 this.timeout(10000)
488 488
489 await server.configCommand.deleteCustomConfig() 489 await server.config.deleteCustomConfig()
490 490
491 const data = await server.configCommand.getCustomConfig() 491 const data = await server.config.getCustomConfig()
492 checkInitialConfig(server, data) 492 checkInitialConfig(server, data)
493 }) 493 })
494 494
diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts
index 79c4c6748..353fed80a 100644
--- a/server/tests/api/server/contact-form.ts
+++ b/server/tests/api/server/contact-form.ts
@@ -27,7 +27,7 @@ describe('Test contact form', function () {
27 server = await flushAndRunServer(1, overrideConfig) 27 server = await flushAndRunServer(1, overrideConfig)
28 await setAccessTokensToServers([ server ]) 28 await setAccessTokensToServers([ server ])
29 29
30 command = server.contactFormCommand 30 command = server.contactForm
31 }) 31 })
32 32
33 it('Should send a contact form', async function () { 33 it('Should send a contact form', async function () {
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index aeda5fddb..258e835e7 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -43,15 +43,15 @@ describe('Test emails', function () {
43 await setAccessTokensToServers([ server ]) 43 await setAccessTokensToServers([ server ])
44 44
45 { 45 {
46 const created = await server.usersCommand.create({ username: user.username, password: user.password }) 46 const created = await server.users.create({ username: user.username, password: user.password })
47 userId = created.id 47 userId = created.id
48 48
49 userAccessToken = await server.loginCommand.getAccessToken(user) 49 userAccessToken = await server.login.getAccessToken(user)
50 } 50 }
51 51
52 { 52 {
53 const attributes = { name: 'my super user video' } 53 const attributes = { name: 'my super user video' }
54 const { uuid } = await server.videosCommand.upload({ token: userAccessToken, attributes }) 54 const { uuid } = await server.videos.upload({ token: userAccessToken, attributes })
55 videoUserUUID = uuid 55 videoUserUUID = uuid
56 } 56 }
57 57
@@ -59,7 +59,7 @@ describe('Test emails', function () {
59 const attributes = { 59 const attributes = {
60 name: 'my super name' 60 name: 'my super name'
61 } 61 }
62 const { uuid, id } = await server.videosCommand.upload({ attributes }) 62 const { uuid, id } = await server.videos.upload({ attributes })
63 videoUUID = uuid 63 videoUUID = uuid
64 videoId = id 64 videoId = id
65 } 65 }
@@ -70,7 +70,7 @@ describe('Test emails', function () {
70 it('Should ask to reset the password', async function () { 70 it('Should ask to reset the password', async function () {
71 this.timeout(10000) 71 this.timeout(10000)
72 72
73 await server.usersCommand.askResetPassword({ email: 'user_1@example.com' }) 73 await server.users.askResetPassword({ email: 'user_1@example.com' })
74 74
75 await waitJobs(server) 75 await waitJobs(server)
76 expect(emails).to.have.lengthOf(1) 76 expect(emails).to.have.lengthOf(1)
@@ -96,7 +96,7 @@ describe('Test emails', function () {
96 }) 96 })
97 97
98 it('Should not reset the password with an invalid verification string', async function () { 98 it('Should not reset the password with an invalid verification string', async function () {
99 await server.usersCommand.resetPassword({ 99 await server.users.resetPassword({
100 userId, 100 userId,
101 verificationString: verificationString + 'b', 101 verificationString: verificationString + 'b',
102 password: 'super_password2', 102 password: 'super_password2',
@@ -105,11 +105,11 @@ describe('Test emails', function () {
105 }) 105 })
106 106
107 it('Should reset the password', async function () { 107 it('Should reset the password', async function () {
108 await server.usersCommand.resetPassword({ userId, verificationString, password: 'super_password2' }) 108 await server.users.resetPassword({ userId, verificationString, password: 'super_password2' })
109 }) 109 })
110 110
111 it('Should not reset the password with the same verification string', async function () { 111 it('Should not reset the password with the same verification string', async function () {
112 await server.usersCommand.resetPassword({ 112 await server.users.resetPassword({
113 userId, 113 userId,
114 verificationString, 114 verificationString,
115 password: 'super_password3', 115 password: 'super_password3',
@@ -120,7 +120,7 @@ describe('Test emails', function () {
120 it('Should login with this new password', async function () { 120 it('Should login with this new password', async function () {
121 user.password = 'super_password2' 121 user.password = 'super_password2'
122 122
123 await server.loginCommand.getAccessToken(user) 123 await server.login.getAccessToken(user)
124 }) 124 })
125 }) 125 })
126 126
@@ -129,7 +129,7 @@ describe('Test emails', function () {
129 it('Should send a create password email', async function () { 129 it('Should send a create password email', async function () {
130 this.timeout(10000) 130 this.timeout(10000)
131 131
132 await server.usersCommand.create({ username: 'create_password', password: '' }) 132 await server.users.create({ username: 'create_password', password: '' })
133 133
134 await waitJobs(server) 134 await waitJobs(server)
135 expect(emails).to.have.lengthOf(2) 135 expect(emails).to.have.lengthOf(2)
@@ -155,7 +155,7 @@ describe('Test emails', function () {
155 }) 155 })
156 156
157 it('Should not reset the password with an invalid verification string', async function () { 157 it('Should not reset the password with an invalid verification string', async function () {
158 await server.usersCommand.resetPassword({ 158 await server.users.resetPassword({
159 userId: userId2, 159 userId: userId2,
160 verificationString: verificationString2 + 'c', 160 verificationString: verificationString2 + 'c',
161 password: 'newly_created_password', 161 password: 'newly_created_password',
@@ -164,7 +164,7 @@ describe('Test emails', function () {
164 }) 164 })
165 165
166 it('Should reset the password', async function () { 166 it('Should reset the password', async function () {
167 await server.usersCommand.resetPassword({ 167 await server.users.resetPassword({
168 userId: userId2, 168 userId: userId2,
169 verificationString: verificationString2, 169 verificationString: verificationString2,
170 password: 'newly_created_password' 170 password: 'newly_created_password'
@@ -172,7 +172,7 @@ describe('Test emails', function () {
172 }) 172 })
173 173
174 it('Should login with this new password', async function () { 174 it('Should login with this new password', async function () {
175 await server.loginCommand.getAccessToken({ 175 await server.login.getAccessToken({
176 username: 'create_password', 176 username: 'create_password',
177 password: 'newly_created_password' 177 password: 'newly_created_password'
178 }) 178 })
@@ -184,7 +184,7 @@ describe('Test emails', function () {
184 this.timeout(10000) 184 this.timeout(10000)
185 185
186 const reason = 'my super bad reason' 186 const reason = 'my super bad reason'
187 await server.abusesCommand.report({ videoId, reason }) 187 await server.abuses.report({ videoId, reason })
188 188
189 await waitJobs(server) 189 await waitJobs(server)
190 expect(emails).to.have.lengthOf(3) 190 expect(emails).to.have.lengthOf(3)
@@ -205,7 +205,7 @@ describe('Test emails', function () {
205 this.timeout(10000) 205 this.timeout(10000)
206 206
207 const reason = 'my super bad reason' 207 const reason = 'my super bad reason'
208 await server.usersCommand.banUser({ userId, reason }) 208 await server.users.banUser({ userId, reason })
209 209
210 await waitJobs(server) 210 await waitJobs(server)
211 expect(emails).to.have.lengthOf(4) 211 expect(emails).to.have.lengthOf(4)
@@ -223,7 +223,7 @@ describe('Test emails', function () {
223 it('Should send the notification email when unblocking a user', async function () { 223 it('Should send the notification email when unblocking a user', async function () {
224 this.timeout(10000) 224 this.timeout(10000)
225 225
226 await server.usersCommand.unbanUser({ userId }) 226 await server.users.unbanUser({ userId })
227 227
228 await waitJobs(server) 228 await waitJobs(server)
229 expect(emails).to.have.lengthOf(5) 229 expect(emails).to.have.lengthOf(5)
@@ -243,7 +243,7 @@ describe('Test emails', function () {
243 this.timeout(10000) 243 this.timeout(10000)
244 244
245 const reason = 'my super reason' 245 const reason = 'my super reason'
246 await server.blacklistCommand.add({ videoId: videoUserUUID, reason }) 246 await server.blacklist.add({ videoId: videoUserUUID, reason })
247 247
248 await waitJobs(server) 248 await waitJobs(server)
249 expect(emails).to.have.lengthOf(6) 249 expect(emails).to.have.lengthOf(6)
@@ -261,7 +261,7 @@ describe('Test emails', function () {
261 it('Should send the notification email', async function () { 261 it('Should send the notification email', async function () {
262 this.timeout(10000) 262 this.timeout(10000)
263 263
264 await server.blacklistCommand.remove({ videoId: videoUserUUID }) 264 await server.blacklist.remove({ videoId: videoUserUUID })
265 265
266 await waitJobs(server) 266 await waitJobs(server)
267 expect(emails).to.have.lengthOf(7) 267 expect(emails).to.have.lengthOf(7)
@@ -286,7 +286,7 @@ describe('Test emails', function () {
286 it('Should ask to send the verification email', async function () { 286 it('Should ask to send the verification email', async function () {
287 this.timeout(10000) 287 this.timeout(10000)
288 288
289 await server.usersCommand.askSendVerifyEmail({ email: 'user_1@example.com' }) 289 await server.users.askSendVerifyEmail({ email: 'user_1@example.com' })
290 290
291 await waitJobs(server) 291 await waitJobs(server)
292 expect(emails).to.have.lengthOf(8) 292 expect(emails).to.have.lengthOf(8)
@@ -312,7 +312,7 @@ describe('Test emails', function () {
312 }) 312 })
313 313
314 it('Should not verify the email with an invalid verification string', async function () { 314 it('Should not verify the email with an invalid verification string', async function () {
315 await server.usersCommand.verifyEmail({ 315 await server.users.verifyEmail({
316 userId, 316 userId,
317 verificationString: verificationString + 'b', 317 verificationString: verificationString + 'b',
318 isPendingEmail: false, 318 isPendingEmail: false,
@@ -321,7 +321,7 @@ describe('Test emails', function () {
321 }) 321 })
322 322
323 it('Should verify the email', async function () { 323 it('Should verify the email', async function () {
324 await server.usersCommand.verifyEmail({ userId, verificationString }) 324 await server.users.verifyEmail({ userId, verificationString })
325 }) 325 })
326 }) 326 })
327 327
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts
index f9014aeee..887e400e9 100644
--- a/server/tests/api/server/follow-constraints.ts
+++ b/server/tests/api/server/follow-constraints.ts
@@ -23,11 +23,11 @@ describe('Test follow constraints', function () {
23 await setAccessTokensToServers(servers) 23 await setAccessTokensToServers(servers)
24 24
25 { 25 {
26 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video server 1' } }) 26 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video server 1' } })
27 video1UUID = uuid 27 video1UUID = uuid
28 } 28 }
29 { 29 {
30 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video server 2' } }) 30 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video server 2' } })
31 video2UUID = uuid 31 video2UUID = uuid
32 } 32 }
33 33
@@ -35,8 +35,8 @@ describe('Test follow constraints', function () {
35 username: 'user1', 35 username: 'user1',
36 password: 'super_password' 36 password: 'super_password'
37 } 37 }
38 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 38 await servers[0].users.create({ username: user.username, password: user.password })
39 userToken = await servers[0].loginCommand.getAccessToken(user) 39 userToken = await servers[0].login.getAccessToken(user)
40 40
41 await doubleFollow(servers[0], servers[1]) 41 await doubleFollow(servers[0], servers[1])
42 }) 42 })
@@ -46,22 +46,22 @@ describe('Test follow constraints', function () {
46 describe('With an unlogged user', function () { 46 describe('With an unlogged user', function () {
47 47
48 it('Should get the local video', async function () { 48 it('Should get the local video', async function () {
49 await servers[0].videosCommand.get({ id: video1UUID }) 49 await servers[0].videos.get({ id: video1UUID })
50 }) 50 })
51 51
52 it('Should get the remote video', async function () { 52 it('Should get the remote video', async function () {
53 await servers[0].videosCommand.get({ id: video2UUID }) 53 await servers[0].videos.get({ id: video2UUID })
54 }) 54 })
55 55
56 it('Should list local account videos', async function () { 56 it('Should list local account videos', async function () {
57 const { total, data } = await servers[0].videosCommand.listByAccount({ accountName: 'root@localhost:' + servers[0].port }) 57 const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[0].port })
58 58
59 expect(total).to.equal(1) 59 expect(total).to.equal(1)
60 expect(data).to.have.lengthOf(1) 60 expect(data).to.have.lengthOf(1)
61 }) 61 })
62 62
63 it('Should list remote account videos', async function () { 63 it('Should list remote account videos', async function () {
64 const { total, data } = await servers[0].videosCommand.listByAccount({ accountName: 'root@localhost:' + servers[1].port }) 64 const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[1].port })
65 65
66 expect(total).to.equal(1) 66 expect(total).to.equal(1)
67 expect(data).to.have.lengthOf(1) 67 expect(data).to.have.lengthOf(1)
@@ -69,7 +69,7 @@ describe('Test follow constraints', function () {
69 69
70 it('Should list local channel videos', async function () { 70 it('Should list local channel videos', async function () {
71 const videoChannelName = 'root_channel@localhost:' + servers[0].port 71 const videoChannelName = 'root_channel@localhost:' + servers[0].port
72 const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName }) 72 const { total, data } = await servers[0].videos.listByChannel({ videoChannelName })
73 73
74 expect(total).to.equal(1) 74 expect(total).to.equal(1)
75 expect(data).to.have.lengthOf(1) 75 expect(data).to.have.lengthOf(1)
@@ -77,7 +77,7 @@ describe('Test follow constraints', function () {
77 77
78 it('Should list remote channel videos', async function () { 78 it('Should list remote channel videos', async function () {
79 const videoChannelName = 'root_channel@localhost:' + servers[1].port 79 const videoChannelName = 'root_channel@localhost:' + servers[1].port
80 const { total, data } = await servers[0].videosCommand.listByChannel({ videoChannelName }) 80 const { total, data } = await servers[0].videos.listByChannel({ videoChannelName })
81 81
82 expect(total).to.equal(1) 82 expect(total).to.equal(1)
83 expect(data).to.have.lengthOf(1) 83 expect(data).to.have.lengthOf(1)
@@ -86,22 +86,22 @@ describe('Test follow constraints', function () {
86 86
87 describe('With a logged user', function () { 87 describe('With a logged user', function () {
88 it('Should get the local video', async function () { 88 it('Should get the local video', async function () {
89 await servers[0].videosCommand.getWithToken({ token: userToken, id: video1UUID }) 89 await servers[0].videos.getWithToken({ token: userToken, id: video1UUID })
90 }) 90 })
91 91
92 it('Should get the remote video', async function () { 92 it('Should get the remote video', async function () {
93 await servers[0].videosCommand.getWithToken({ token: userToken, id: video2UUID }) 93 await servers[0].videos.getWithToken({ token: userToken, id: video2UUID })
94 }) 94 })
95 95
96 it('Should list local account videos', async function () { 96 it('Should list local account videos', async function () {
97 const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port }) 97 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
98 98
99 expect(total).to.equal(1) 99 expect(total).to.equal(1)
100 expect(data).to.have.lengthOf(1) 100 expect(data).to.have.lengthOf(1)
101 }) 101 })
102 102
103 it('Should list remote account videos', async function () { 103 it('Should list remote account videos', async function () {
104 const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port }) 104 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
105 105
106 expect(total).to.equal(1) 106 expect(total).to.equal(1)
107 expect(data).to.have.lengthOf(1) 107 expect(data).to.have.lengthOf(1)
@@ -109,7 +109,7 @@ describe('Test follow constraints', function () {
109 109
110 it('Should list local channel videos', async function () { 110 it('Should list local channel videos', async function () {
111 const videoChannelName = 'root_channel@localhost:' + servers[0].port 111 const videoChannelName = 'root_channel@localhost:' + servers[0].port
112 const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName }) 112 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
113 113
114 expect(total).to.equal(1) 114 expect(total).to.equal(1)
115 expect(data).to.have.lengthOf(1) 115 expect(data).to.have.lengthOf(1)
@@ -117,7 +117,7 @@ describe('Test follow constraints', function () {
117 117
118 it('Should list remote channel videos', async function () { 118 it('Should list remote channel videos', async function () {
119 const videoChannelName = 'root_channel@localhost:' + servers[1].port 119 const videoChannelName = 'root_channel@localhost:' + servers[1].port
120 const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName }) 120 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
121 121
122 expect(total).to.equal(1) 122 expect(total).to.equal(1)
123 expect(data).to.have.lengthOf(1) 123 expect(data).to.have.lengthOf(1)
@@ -130,17 +130,17 @@ describe('Test follow constraints', function () {
130 before(async function () { 130 before(async function () {
131 this.timeout(30000) 131 this.timeout(30000)
132 132
133 await servers[0].followsCommand.unfollow({ target: servers[1] }) 133 await servers[0].follows.unfollow({ target: servers[1] })
134 }) 134 })
135 135
136 describe('With an unlogged user', function () { 136 describe('With an unlogged user', function () {
137 137
138 it('Should get the local video', async function () { 138 it('Should get the local video', async function () {
139 await servers[0].videosCommand.get({ id: video1UUID }) 139 await servers[0].videos.get({ id: video1UUID })
140 }) 140 })
141 141
142 it('Should not get the remote video', async function () { 142 it('Should not get the remote video', async function () {
143 const body = await servers[0].videosCommand.get({ id: video2UUID, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 143 const body = await servers[0].videos.get({ id: video2UUID, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
144 const error = body as unknown as PeerTubeProblemDocument 144 const error = body as unknown as PeerTubeProblemDocument
145 145
146 const doc = 'https://docs.joinpeertube.org/api-rest-reference.html#section/Errors/does_not_respect_follow_constraints' 146 const doc = 'https://docs.joinpeertube.org/api-rest-reference.html#section/Errors/does_not_respect_follow_constraints'
@@ -156,7 +156,7 @@ describe('Test follow constraints', function () {
156 }) 156 })
157 157
158 it('Should list local account videos', async function () { 158 it('Should list local account videos', async function () {
159 const { total, data } = await servers[0].videosCommand.listByAccount({ 159 const { total, data } = await servers[0].videos.listByAccount({
160 token: undefined, 160 token: undefined,
161 accountName: 'root@localhost:' + servers[0].port 161 accountName: 'root@localhost:' + servers[0].port
162 }) 162 })
@@ -166,7 +166,7 @@ describe('Test follow constraints', function () {
166 }) 166 })
167 167
168 it('Should not list remote account videos', async function () { 168 it('Should not list remote account videos', async function () {
169 const { total, data } = await servers[0].videosCommand.listByAccount({ 169 const { total, data } = await servers[0].videos.listByAccount({
170 token: undefined, 170 token: undefined,
171 accountName: 'root@localhost:' + servers[1].port 171 accountName: 'root@localhost:' + servers[1].port
172 }) 172 })
@@ -177,7 +177,7 @@ describe('Test follow constraints', function () {
177 177
178 it('Should list local channel videos', async function () { 178 it('Should list local channel videos', async function () {
179 const videoChannelName = 'root_channel@localhost:' + servers[0].port 179 const videoChannelName = 'root_channel@localhost:' + servers[0].port
180 const { total, data } = await servers[0].videosCommand.listByChannel({ token: undefined, videoChannelName }) 180 const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName })
181 181
182 expect(total).to.equal(1) 182 expect(total).to.equal(1)
183 expect(data).to.have.lengthOf(1) 183 expect(data).to.have.lengthOf(1)
@@ -185,7 +185,7 @@ describe('Test follow constraints', function () {
185 185
186 it('Should not list remote channel videos', async function () { 186 it('Should not list remote channel videos', async function () {
187 const videoChannelName = 'root_channel@localhost:' + servers[1].port 187 const videoChannelName = 'root_channel@localhost:' + servers[1].port
188 const { total, data } = await servers[0].videosCommand.listByChannel({ token: undefined, videoChannelName }) 188 const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName })
189 189
190 expect(total).to.equal(0) 190 expect(total).to.equal(0)
191 expect(data).to.have.lengthOf(0) 191 expect(data).to.have.lengthOf(0)
@@ -194,22 +194,22 @@ describe('Test follow constraints', function () {
194 194
195 describe('With a logged user', function () { 195 describe('With a logged user', function () {
196 it('Should get the local video', async function () { 196 it('Should get the local video', async function () {
197 await servers[0].videosCommand.getWithToken({ token: userToken, id: video1UUID }) 197 await servers[0].videos.getWithToken({ token: userToken, id: video1UUID })
198 }) 198 })
199 199
200 it('Should get the remote video', async function () { 200 it('Should get the remote video', async function () {
201 await servers[0].videosCommand.getWithToken({ token: userToken, id: video2UUID }) 201 await servers[0].videos.getWithToken({ token: userToken, id: video2UUID })
202 }) 202 })
203 203
204 it('Should list local account videos', async function () { 204 it('Should list local account videos', async function () {
205 const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port }) 205 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
206 206
207 expect(total).to.equal(1) 207 expect(total).to.equal(1)
208 expect(data).to.have.lengthOf(1) 208 expect(data).to.have.lengthOf(1)
209 }) 209 })
210 210
211 it('Should list remote account videos', async function () { 211 it('Should list remote account videos', async function () {
212 const { total, data } = await servers[0].videosCommand.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port }) 212 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
213 213
214 expect(total).to.equal(1) 214 expect(total).to.equal(1)
215 expect(data).to.have.lengthOf(1) 215 expect(data).to.have.lengthOf(1)
@@ -217,7 +217,7 @@ describe('Test follow constraints', function () {
217 217
218 it('Should list local channel videos', async function () { 218 it('Should list local channel videos', async function () {
219 const videoChannelName = 'root_channel@localhost:' + servers[0].port 219 const videoChannelName = 'root_channel@localhost:' + servers[0].port
220 const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName }) 220 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
221 221
222 expect(total).to.equal(1) 222 expect(total).to.equal(1)
223 expect(data).to.have.lengthOf(1) 223 expect(data).to.have.lengthOf(1)
@@ -225,7 +225,7 @@ describe('Test follow constraints', function () {
225 225
226 it('Should list remote channel videos', async function () { 226 it('Should list remote channel videos', async function () {
227 const videoChannelName = 'root_channel@localhost:' + servers[1].port 227 const videoChannelName = 'root_channel@localhost:' + servers[1].port
228 const { total, data } = await servers[0].videosCommand.listByChannel({ token: userToken, videoChannelName }) 228 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
229 229
230 expect(total).to.equal(1) 230 expect(total).to.equal(1)
231 expect(data).to.have.lengthOf(1) 231 expect(data).to.have.lengthOf(1)
diff --git a/server/tests/api/server/follows-moderation.ts b/server/tests/api/server/follows-moderation.ts
index 6d6eca9a8..045024544 100644
--- a/server/tests/api/server/follows-moderation.ts
+++ b/server/tests/api/server/follows-moderation.ts
@@ -15,8 +15,8 @@ const expect = chai.expect
15 15
16async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accepted') { 16async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'accepted') {
17 const fns = [ 17 const fns = [
18 servers[0].followsCommand.getFollowings.bind(servers[0].followsCommand), 18 servers[0].follows.getFollowings.bind(servers[0].follows),
19 servers[1].followsCommand.getFollowers.bind(servers[1].followsCommand) 19 servers[1].follows.getFollowers.bind(servers[1].follows)
20 ] 20 ]
21 21
22 for (const fn of fns) { 22 for (const fn of fns) {
@@ -32,8 +32,8 @@ async function checkServer1And2HasFollowers (servers: ServerInfo[], state = 'acc
32 32
33async function checkNoFollowers (servers: ServerInfo[]) { 33async function checkNoFollowers (servers: ServerInfo[]) {
34 const fns = [ 34 const fns = [
35 servers[0].followsCommand.getFollowings.bind(servers[0].followsCommand), 35 servers[0].follows.getFollowings.bind(servers[0].follows),
36 servers[1].followsCommand.getFollowers.bind(servers[1].followsCommand) 36 servers[1].follows.getFollowers.bind(servers[1].follows)
37 ] 37 ]
38 38
39 for (const fn of fns) { 39 for (const fn of fns) {
@@ -54,7 +54,7 @@ describe('Test follows moderation', function () {
54 // Get the access tokens 54 // Get the access tokens
55 await setAccessTokensToServers(servers) 55 await setAccessTokensToServers(servers)
56 56
57 commands = servers.map(s => s.followsCommand) 57 commands = servers.map(s => s.follows)
58 }) 58 })
59 59
60 it('Should have server 1 following server 2', async function () { 60 it('Should have server 1 following server 2', async function () {
@@ -93,7 +93,7 @@ describe('Test follows moderation', function () {
93 } 93 }
94 } 94 }
95 95
96 await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig }) 96 await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
97 97
98 await commands[0].follow({ targets: [ servers[1].url ] }) 98 await commands[0].follow({ targets: [ servers[1].url ] })
99 await waitJobs(servers) 99 await waitJobs(servers)
@@ -113,7 +113,7 @@ describe('Test follows moderation', function () {
113 } 113 }
114 } 114 }
115 115
116 await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig }) 116 await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
117 117
118 await commands[0].follow({ targets: [ servers[1].url ] }) 118 await commands[0].follow({ targets: [ servers[1].url ] })
119 await waitJobs(servers) 119 await waitJobs(servers)
@@ -136,8 +136,8 @@ describe('Test follows moderation', function () {
136 } 136 }
137 } 137 }
138 138
139 await servers[1].configCommand.updateCustomSubConfig({ newConfig: subConfig }) 139 await servers[1].config.updateCustomSubConfig({ newConfig: subConfig })
140 await servers[2].configCommand.updateCustomSubConfig({ newConfig: subConfig }) 140 await servers[2].config.updateCustomSubConfig({ newConfig: subConfig })
141 141
142 await commands[0].follow({ targets: [ servers[1].url ] }) 142 await commands[0].follow({ targets: [ servers[1].url ] })
143 await waitJobs(servers) 143 await waitJobs(servers)
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts
index 5ce8938fa..d43064689 100644
--- a/server/tests/api/server/follows.ts
+++ b/server/tests/api/server/follows.ts
@@ -26,7 +26,7 @@ describe('Test follows', function () {
26 this.timeout(30000) 26 this.timeout(30000)
27 27
28 servers = await flushAndRunMultipleServers(3) 28 servers = await flushAndRunMultipleServers(3)
29 followsCommands = servers.map(s => s.followsCommand) 29 followsCommands = servers.map(s => s.follows)
30 30
31 // Get the access tokens 31 // Get the access tokens
32 await setAccessTokensToServers(servers) 32 await setAccessTokensToServers(servers)
@@ -34,7 +34,7 @@ describe('Test follows', function () {
34 34
35 it('Should not have followers', async function () { 35 it('Should not have followers', async function () {
36 for (const server of servers) { 36 for (const server of servers) {
37 const body = await server.followsCommand.getFollowers({ start: 0, count: 5, sort: 'createdAt' }) 37 const body = await server.follows.getFollowers({ start: 0, count: 5, sort: 'createdAt' })
38 expect(body.total).to.equal(0) 38 expect(body.total).to.equal(0)
39 39
40 const follows = body.data 40 const follows = body.data
@@ -45,7 +45,7 @@ describe('Test follows', function () {
45 45
46 it('Should not have following', async function () { 46 it('Should not have following', async function () {
47 for (const server of servers) { 47 for (const server of servers) {
48 const body = await server.followsCommand.getFollowings({ start: 0, count: 5, sort: 'createdAt' }) 48 const body = await server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
49 expect(body.total).to.equal(0) 49 expect(body.total).to.equal(0)
50 50
51 const follows = body.data 51 const follows = body.data
@@ -141,7 +141,7 @@ describe('Test follows', function () {
141 141
142 it('Should have 0 followings on server 2 and 3', async function () { 142 it('Should have 0 followings on server 2 and 3', async function () {
143 for (const server of [ servers[1], servers[2] ]) { 143 for (const server of [ servers[1], servers[2] ]) {
144 const body = await server.followsCommand.getFollowings({ start: 0, count: 5, sort: 'createdAt' }) 144 const body = await server.follows.getFollowings({ start: 0, count: 5, sort: 'createdAt' })
145 expect(body.total).to.equal(0) 145 expect(body.total).to.equal(0)
146 146
147 const follows = body.data 147 const follows = body.data
@@ -152,7 +152,7 @@ describe('Test follows', function () {
152 152
153 it('Should have 1 followers on server 2 and 3', async function () { 153 it('Should have 1 followers on server 2 and 3', async function () {
154 for (const server of [ servers[1], servers[2] ]) { 154 for (const server of [ servers[1], servers[2] ]) {
155 const body = await server.followsCommand.getFollowers({ start: 0, count: 1, sort: 'createdAt' }) 155 const body = await server.follows.getFollowers({ start: 0, count: 1, sort: 'createdAt' })
156 expect(body.total).to.equal(1) 156 expect(body.total).to.equal(1)
157 157
158 const follows = body.data 158 const follows = body.data
@@ -284,25 +284,25 @@ describe('Test follows', function () {
284 it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () { 284 it('Should upload a video on server 2 and 3 and propagate only the video of server 2', async function () {
285 this.timeout(60000) 285 this.timeout(60000)
286 286
287 await servers[1].videosCommand.upload({ attributes: { name: 'server2' } }) 287 await servers[1].videos.upload({ attributes: { name: 'server2' } })
288 await servers[2].videosCommand.upload({ attributes: { name: 'server3' } }) 288 await servers[2].videos.upload({ attributes: { name: 'server3' } })
289 289
290 await waitJobs(servers) 290 await waitJobs(servers)
291 291
292 { 292 {
293 const { total, data } = await servers[0].videosCommand.list() 293 const { total, data } = await servers[0].videos.list()
294 expect(total).to.equal(1) 294 expect(total).to.equal(1)
295 expect(data[0].name).to.equal('server2') 295 expect(data[0].name).to.equal('server2')
296 } 296 }
297 297
298 { 298 {
299 const { total, data } = await servers[1].videosCommand.list() 299 const { total, data } = await servers[1].videos.list()
300 expect(total).to.equal(1) 300 expect(total).to.equal(1)
301 expect(data[0].name).to.equal('server2') 301 expect(data[0].name).to.equal('server2')
302 } 302 }
303 303
304 { 304 {
305 const { total, data } = await servers[2].videosCommand.list() 305 const { total, data } = await servers[2].videos.list()
306 expect(total).to.equal(1) 306 expect(total).to.equal(1)
307 expect(data[0].name).to.equal('server3') 307 expect(data[0].name).to.equal('server3')
308 } 308 }
@@ -322,60 +322,60 @@ describe('Test follows', function () {
322 tags: [ 'tag1', 'tag2', 'tag3' ] 322 tags: [ 'tag1', 'tag2', 'tag3' ]
323 } 323 }
324 324
325 await servers[2].videosCommand.upload({ attributes: { name: 'server3-2' } }) 325 await servers[2].videos.upload({ attributes: { name: 'server3-2' } })
326 await servers[2].videosCommand.upload({ attributes: { name: 'server3-3' } }) 326 await servers[2].videos.upload({ attributes: { name: 'server3-3' } })
327 await servers[2].videosCommand.upload({ attributes: video4Attributes }) 327 await servers[2].videos.upload({ attributes: video4Attributes })
328 await servers[2].videosCommand.upload({ attributes: { name: 'server3-5' } }) 328 await servers[2].videos.upload({ attributes: { name: 'server3-5' } })
329 await servers[2].videosCommand.upload({ attributes: { name: 'server3-6' } }) 329 await servers[2].videos.upload({ attributes: { name: 'server3-6' } })
330 330
331 { 331 {
332 const userAccessToken = await servers[2].usersCommand.generateUserAndToken('captain') 332 const userAccessToken = await servers[2].users.generateUserAndToken('captain')
333 333
334 const { data } = await servers[2].videosCommand.list() 334 const { data } = await servers[2].videos.list()
335 video4 = data.find(v => v.name === 'server3-4') 335 video4 = data.find(v => v.name === 'server3-4')
336 336
337 { 337 {
338 await servers[2].videosCommand.rate({ id: video4.id, rating: 'like' }) 338 await servers[2].videos.rate({ id: video4.id, rating: 'like' })
339 await servers[2].videosCommand.rate({ token: userAccessToken, id: video4.id, rating: 'dislike' }) 339 await servers[2].videos.rate({ token: userAccessToken, id: video4.id, rating: 'dislike' })
340 } 340 }
341 341
342 { 342 {
343 { 343 {
344 const text = 'my super first comment' 344 const text = 'my super first comment'
345 const created = await servers[2].commentsCommand.createThread({ videoId: video4.id, text }) 345 const created = await servers[2].comments.createThread({ videoId: video4.id, text })
346 const threadId = created.id 346 const threadId = created.id
347 347
348 const text1 = 'my super answer to thread 1' 348 const text1 = 'my super answer to thread 1'
349 const childComment = await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 }) 349 const childComment = await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 })
350 350
351 const text2 = 'my super answer to answer of thread 1' 351 const text2 = 'my super answer to answer of thread 1'
352 await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text2 }) 352 await servers[2].comments.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text2 })
353 353
354 const text3 = 'my second answer to thread 1' 354 const text3 = 'my second answer to thread 1'
355 await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text3 }) 355 await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text3 })
356 } 356 }
357 357
358 { 358 {
359 const text = 'will be deleted' 359 const text = 'will be deleted'
360 const created = await servers[2].commentsCommand.createThread({ videoId: video4.id, text }) 360 const created = await servers[2].comments.createThread({ videoId: video4.id, text })
361 const threadId = created.id 361 const threadId = created.id
362 362
363 const text1 = 'answer to deleted' 363 const text1 = 'answer to deleted'
364 await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 }) 364 await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text1 })
365 365
366 const text2 = 'will also be deleted' 366 const text2 = 'will also be deleted'
367 const childComment = await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: threadId, text: text2 }) 367 const childComment = await servers[2].comments.addReply({ videoId: video4.id, toCommentId: threadId, text: text2 })
368 368
369 const text3 = 'my second answer to deleted' 369 const text3 = 'my second answer to deleted'
370 await servers[2].commentsCommand.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text3 }) 370 await servers[2].comments.addReply({ videoId: video4.id, toCommentId: childComment.id, text: text3 })
371 371
372 await servers[2].commentsCommand.delete({ videoId: video4.id, commentId: threadId }) 372 await servers[2].comments.delete({ videoId: video4.id, commentId: threadId })
373 await servers[2].commentsCommand.delete({ videoId: video4.id, commentId: childComment.id }) 373 await servers[2].comments.delete({ videoId: video4.id, commentId: childComment.id })
374 } 374 }
375 } 375 }
376 376
377 { 377 {
378 await servers[2].captionsCommand.createVideoCaption({ 378 await servers[2].captions.createVideoCaption({
379 language: 'ar', 379 language: 'ar',
380 videoId: video4.id, 380 videoId: video4.id,
381 fixture: 'subtitle-good2.vtt' 381 fixture: 'subtitle-good2.vtt'
@@ -404,7 +404,7 @@ describe('Test follows', function () {
404 }) 404 })
405 405
406 it('Should have propagated videos', async function () { 406 it('Should have propagated videos', async function () {
407 const { total, data } = await servers[0].videosCommand.list() 407 const { total, data } = await servers[0].videos.list()
408 expect(total).to.equal(7) 408 expect(total).to.equal(7)
409 409
410 const video2 = data.find(v => v.name === 'server3-2') 410 const video2 = data.find(v => v.name === 'server3-2')
@@ -454,7 +454,7 @@ describe('Test follows', function () {
454 }) 454 })
455 455
456 it('Should have propagated comments', async function () { 456 it('Should have propagated comments', async function () {
457 const { total, data } = await servers[0].commentsCommand.listThreads({ videoId: video4.id, sort: 'createdAt' }) 457 const { total, data } = await servers[0].comments.listThreads({ videoId: video4.id, sort: 'createdAt' })
458 458
459 expect(total).to.equal(2) 459 expect(total).to.equal(2)
460 expect(data).to.be.an('array') 460 expect(data).to.be.an('array')
@@ -474,7 +474,7 @@ describe('Test follows', function () {
474 474
475 const threadId = comment.threadId 475 const threadId = comment.threadId
476 476
477 const tree = await servers[0].commentsCommand.getThread({ videoId: video4.id, threadId }) 477 const tree = await servers[0].comments.getThread({ videoId: video4.id, threadId })
478 expect(tree.comment.text).equal('my super first comment') 478 expect(tree.comment.text).equal('my super first comment')
479 expect(tree.children).to.have.lengthOf(2) 479 expect(tree.children).to.have.lengthOf(2)
480 480
@@ -502,7 +502,7 @@ describe('Test follows', function () {
502 expect(deletedComment.totalReplies).to.equal(2) 502 expect(deletedComment.totalReplies).to.equal(2)
503 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true 503 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
504 504
505 const tree = await servers[0].commentsCommand.getThread({ videoId: video4.id, threadId: deletedComment.threadId }) 505 const tree = await servers[0].comments.getThread({ videoId: video4.id, threadId: deletedComment.threadId })
506 const [ commentRoot, deletedChildRoot ] = tree.children 506 const [ commentRoot, deletedChildRoot ] = tree.children
507 507
508 expect(deletedChildRoot).to.not.be.undefined 508 expect(deletedChildRoot).to.not.be.undefined
@@ -527,7 +527,7 @@ describe('Test follows', function () {
527 }) 527 })
528 528
529 it('Should have propagated captions', async function () { 529 it('Should have propagated captions', async function () {
530 const body = await servers[0].captionsCommand.listVideoCaptions({ videoId: video4.id }) 530 const body = await servers[0].captions.listVideoCaptions({ videoId: video4.id })
531 expect(body.total).to.equal(1) 531 expect(body.total).to.equal(1)
532 expect(body.data).to.have.lengthOf(1) 532 expect(body.data).to.have.lengthOf(1)
533 533
@@ -545,7 +545,7 @@ describe('Test follows', function () {
545 545
546 await waitJobs(servers) 546 await waitJobs(servers)
547 547
548 const { total } = await servers[0].videosCommand.list() 548 const { total } = await servers[0].videos.list()
549 expect(total).to.equal(1) 549 expect(total).to.equal(1)
550 }) 550 })
551 551
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index 35b905a8c..de3dee826 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -55,7 +55,7 @@ describe('Test handle downs', function () {
55 this.timeout(30000) 55 this.timeout(30000)
56 56
57 servers = await flushAndRunMultipleServers(3) 57 servers = await flushAndRunMultipleServers(3)
58 commentCommands = servers.map(s => s.commentsCommand) 58 commentCommands = servers.map(s => s.comments)
59 59
60 checkAttributes = { 60 checkAttributes = {
61 name: 'my super name for server 1', 61 name: 'my super name for server 1',
@@ -99,19 +99,19 @@ describe('Test handle downs', function () {
99 this.timeout(240000) 99 this.timeout(240000)
100 100
101 // Server 2 and 3 follow server 1 101 // Server 2 and 3 follow server 1
102 await servers[1].followsCommand.follow({ targets: [ servers[0].url ] }) 102 await servers[1].follows.follow({ targets: [ servers[0].url ] })
103 await servers[2].followsCommand.follow({ targets: [ servers[0].url ] }) 103 await servers[2].follows.follow({ targets: [ servers[0].url ] })
104 104
105 await waitJobs(servers) 105 await waitJobs(servers)
106 106
107 // Upload a video to server 1 107 // Upload a video to server 1
108 await servers[0].videosCommand.upload({ attributes: videoAttributes }) 108 await servers[0].videos.upload({ attributes: videoAttributes })
109 109
110 await waitJobs(servers) 110 await waitJobs(servers)
111 111
112 // And check all servers have this video 112 // And check all servers have this video
113 for (const server of servers) { 113 for (const server of servers) {
114 const { data } = await server.videosCommand.list() 114 const { data } = await server.videos.list()
115 expect(data).to.be.an('array') 115 expect(data).to.be.an('array')
116 expect(data).to.have.lengthOf(1) 116 expect(data).to.have.lengthOf(1)
117 } 117 }
@@ -121,7 +121,7 @@ describe('Test handle downs', function () {
121 121
122 // Remove server 2 follower 122 // Remove server 2 follower
123 for (let i = 0; i < 10; i++) { 123 for (let i = 0; i < 10; i++) {
124 await servers[0].videosCommand.upload({ attributes: videoAttributes }) 124 await servers[0].videos.upload({ attributes: videoAttributes })
125 } 125 }
126 126
127 await waitJobs([ servers[0], servers[2] ]) 127 await waitJobs([ servers[0], servers[2] ])
@@ -129,12 +129,12 @@ describe('Test handle downs', function () {
129 // Kill server 3 129 // Kill server 3
130 await killallServers([ servers[2] ]) 130 await killallServers([ servers[2] ])
131 131
132 missedVideo1 = await servers[0].videosCommand.upload({ attributes: videoAttributes }) 132 missedVideo1 = await servers[0].videos.upload({ attributes: videoAttributes })
133 133
134 missedVideo2 = await servers[0].videosCommand.upload({ attributes: videoAttributes }) 134 missedVideo2 = await servers[0].videos.upload({ attributes: videoAttributes })
135 135
136 // Unlisted video 136 // Unlisted video
137 unlistedVideo = await servers[0].videosCommand.upload({ attributes: unlistedVideoAttributes }) 137 unlistedVideo = await servers[0].videos.upload({ attributes: unlistedVideoAttributes })
138 138
139 // Add comments to video 2 139 // Add comments to video 2
140 { 140 {
@@ -153,7 +153,7 @@ describe('Test handle downs', function () {
153 await wait(11000) 153 await wait(11000)
154 154
155 // Only server 3 is still a follower of server 1 155 // Only server 3 is still a follower of server 1
156 const body = await servers[0].followsCommand.getFollowers({ start: 0, count: 2, sort: 'createdAt' }) 156 const body = await servers[0].follows.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
157 expect(body.data).to.be.an('array') 157 expect(body.data).to.be.an('array')
158 expect(body.data).to.have.lengthOf(1) 158 expect(body.data).to.have.lengthOf(1)
159 expect(body.data[0].follower.host).to.equal('localhost:' + servers[2].port) 159 expect(body.data[0].follower.host).to.equal('localhost:' + servers[2].port)
@@ -163,7 +163,7 @@ describe('Test handle downs', function () {
163 const states: JobState[] = [ 'waiting', 'active' ] 163 const states: JobState[] = [ 'waiting', 'active' ]
164 164
165 for (const state of states) { 165 for (const state of states) {
166 const body = await servers[0].jobsCommand.getJobsList({ 166 const body = await servers[0].jobs.getJobsList({
167 state: state, 167 state: state,
168 start: 0, 168 start: 0,
169 count: 50, 169 count: 50,
@@ -179,14 +179,14 @@ describe('Test handle downs', function () {
179 await reRunServer(servers[1]) 179 await reRunServer(servers[1])
180 await reRunServer(servers[2]) 180 await reRunServer(servers[2])
181 181
182 await servers[1].followsCommand.unfollow({ target: servers[0] }) 182 await servers[1].follows.unfollow({ target: servers[0] })
183 await waitJobs(servers) 183 await waitJobs(servers)
184 184
185 await servers[1].followsCommand.follow({ targets: [ servers[0].url ] }) 185 await servers[1].follows.follow({ targets: [ servers[0].url ] })
186 186
187 await waitJobs(servers) 187 await waitJobs(servers)
188 188
189 const body = await servers[0].followsCommand.getFollowers({ start: 0, count: 2, sort: 'createdAt' }) 189 const body = await servers[0].follows.getFollowers({ start: 0, count: 2, sort: 'createdAt' })
190 expect(body.data).to.be.an('array') 190 expect(body.data).to.be.an('array')
191 expect(body.data).to.have.lengthOf(2) 191 expect(body.data).to.have.lengthOf(2)
192 }) 192 })
@@ -195,25 +195,25 @@ describe('Test handle downs', function () {
195 this.timeout(15000) 195 this.timeout(15000)
196 196
197 { 197 {
198 const { data } = await servers[2].videosCommand.list() 198 const { data } = await servers[2].videos.list()
199 expect(data).to.be.an('array') 199 expect(data).to.be.an('array')
200 expect(data).to.have.lengthOf(11) 200 expect(data).to.have.lengthOf(11)
201 } 201 }
202 202
203 await servers[0].videosCommand.update({ id: missedVideo1.uuid }) 203 await servers[0].videos.update({ id: missedVideo1.uuid })
204 await servers[0].videosCommand.update({ id: unlistedVideo.uuid }) 204 await servers[0].videos.update({ id: unlistedVideo.uuid })
205 205
206 await waitJobs(servers) 206 await waitJobs(servers)
207 207
208 { 208 {
209 const { data } = await servers[2].videosCommand.list() 209 const { data } = await servers[2].videos.list()
210 expect(data).to.be.an('array') 210 expect(data).to.be.an('array')
211 // 1 video is unlisted 211 // 1 video is unlisted
212 expect(data).to.have.lengthOf(12) 212 expect(data).to.have.lengthOf(12)
213 } 213 }
214 214
215 // Check unlisted video 215 // Check unlisted video
216 const video = await servers[2].videosCommand.get({ id: unlistedVideo.uuid }) 216 const video = await servers[2].videos.get({ id: unlistedVideo.uuid })
217 await completeVideoCheck(servers[2], video, unlistedCheckAttributes) 217 await completeVideoCheck(servers[2], video, unlistedCheckAttributes)
218 }) 218 })
219 219
@@ -224,16 +224,16 @@ describe('Test handle downs', function () {
224 224
225 await waitJobs(servers) 225 await waitJobs(servers)
226 226
227 await servers[2].videosCommand.get({ id: missedVideo2.uuid }) 227 await servers[2].videos.get({ id: missedVideo2.uuid })
228 228
229 { 229 {
230 const { data } = await servers[2].commentsCommand.listThreads({ videoId: missedVideo2.uuid }) 230 const { data } = await servers[2].comments.listThreads({ videoId: missedVideo2.uuid })
231 expect(data).to.be.an('array') 231 expect(data).to.be.an('array')
232 expect(data).to.have.lengthOf(1) 232 expect(data).to.have.lengthOf(1)
233 233
234 threadIdServer2 = data[0].id 234 threadIdServer2 = data[0].id
235 235
236 const tree = await servers[2].commentsCommand.getThread({ videoId: missedVideo2.uuid, threadId: threadIdServer2 }) 236 const tree = await servers[2].comments.getThread({ videoId: missedVideo2.uuid, threadId: threadIdServer2 })
237 expect(tree.comment.text).equal('thread 1') 237 expect(tree.comment.text).equal('thread 1')
238 expect(tree.children).to.have.lengthOf(1) 238 expect(tree.children).to.have.lengthOf(1)
239 239
@@ -256,7 +256,7 @@ describe('Test handle downs', function () {
256 it('Should correctly reply to the comment', async function () { 256 it('Should correctly reply to the comment', async function () {
257 this.timeout(15000) 257 this.timeout(15000)
258 258
259 await servers[2].commentsCommand.addReply({ videoId: missedVideo2.uuid, toCommentId: commentIdServer2, text: 'comment 1-4' }) 259 await servers[2].comments.addReply({ videoId: missedVideo2.uuid, toCommentId: commentIdServer2, text: 'comment 1-4' })
260 260
261 await waitJobs(servers) 261 await waitJobs(servers)
262 262
@@ -286,24 +286,24 @@ describe('Test handle downs', function () {
286 this.timeout(120000) 286 this.timeout(120000)
287 287
288 for (let i = 0; i < 10; i++) { 288 for (let i = 0; i < 10; i++) {
289 const uuid = (await servers[0].videosCommand.quickUpload({ name: 'video ' + i })).uuid 289 const uuid = (await servers[0].videos.quickUpload({ name: 'video ' + i })).uuid
290 videoIdsServer1.push(uuid) 290 videoIdsServer1.push(uuid)
291 } 291 }
292 292
293 await waitJobs(servers) 293 await waitJobs(servers)
294 294
295 for (const id of videoIdsServer1) { 295 for (const id of videoIdsServer1) {
296 await servers[1].videosCommand.get({ id }) 296 await servers[1].videos.get({ id })
297 } 297 }
298 298
299 await waitJobs(servers) 299 await waitJobs(servers)
300 await servers[1].sqlCommand.setActorFollowScores(20) 300 await servers[1].sql.setActorFollowScores(20)
301 301
302 // Wait video expiration 302 // Wait video expiration
303 await wait(11000) 303 await wait(11000)
304 304
305 // Refresh video -> score + 10 = 30 305 // Refresh video -> score + 10 = 30
306 await servers[1].videosCommand.get({ id: videoIdsServer1[0] }) 306 await servers[1].videos.get({ id: videoIdsServer1[0] })
307 307
308 await waitJobs(servers) 308 await waitJobs(servers)
309 }) 309 })
@@ -318,14 +318,14 @@ describe('Test handle downs', function () {
318 318
319 for (let i = 0; i < 5; i++) { 319 for (let i = 0; i < 5; i++) {
320 try { 320 try {
321 await servers[1].videosCommand.get({ id: videoIdsServer1[i] }) 321 await servers[1].videos.get({ id: videoIdsServer1[i] })
322 await waitJobs([ servers[1] ]) 322 await waitJobs([ servers[1] ])
323 await wait(1500) 323 await wait(1500)
324 } catch {} 324 } catch {}
325 } 325 }
326 326
327 for (const id of videoIdsServer1) { 327 for (const id of videoIdsServer1) {
328 await servers[1].videosCommand.get({ id, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 328 await servers[1].videos.get({ id, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
329 } 329 }
330 }) 330 })
331 331
diff --git a/server/tests/api/server/homepage.ts b/server/tests/api/server/homepage.ts
index 18b9edc31..aac075321 100644
--- a/server/tests/api/server/homepage.ts
+++ b/server/tests/api/server/homepage.ts
@@ -16,7 +16,7 @@ import {
16const expect = chai.expect 16const expect = chai.expect
17 17
18async function getHomepageState (server: ServerInfo) { 18async function getHomepageState (server: ServerInfo) {
19 const config = await server.configCommand.getConfig() 19 const config = await server.config.getConfig()
20 20
21 return config.homepage.enabled 21 return config.homepage.enabled
22} 22}
@@ -31,7 +31,7 @@ describe('Test instance homepage actions', function () {
31 server = await flushAndRunServer(1) 31 server = await flushAndRunServer(1)
32 await setAccessTokensToServers([ server ]) 32 await setAccessTokensToServers([ server ])
33 33
34 command = server.customPageCommand 34 command = server.customPage
35 }) 35 })
36 36
37 it('Should not have a homepage', async function () { 37 it('Should not have a homepage', async function () {
diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts
index aa4c7587b..0c44e4dad 100644
--- a/server/tests/api/server/jobs.ts
+++ b/server/tests/api/server/jobs.ts
@@ -31,21 +31,21 @@ describe('Test jobs', function () {
31 it('Should create some jobs', async function () { 31 it('Should create some jobs', async function () {
32 this.timeout(120000) 32 this.timeout(120000)
33 33
34 await servers[1].videosCommand.upload({ attributes: { name: 'video1' } }) 34 await servers[1].videos.upload({ attributes: { name: 'video1' } })
35 await servers[1].videosCommand.upload({ attributes: { name: 'video2' } }) 35 await servers[1].videos.upload({ attributes: { name: 'video2' } })
36 36
37 await waitJobs(servers) 37 await waitJobs(servers)
38 }) 38 })
39 39
40 it('Should list jobs', async function () { 40 it('Should list jobs', async function () {
41 const body = await servers[1].jobsCommand.getJobsList({ state: 'completed' }) 41 const body = await servers[1].jobs.getJobsList({ state: 'completed' })
42 expect(body.total).to.be.above(2) 42 expect(body.total).to.be.above(2)
43 expect(body.data).to.have.length.above(2) 43 expect(body.data).to.have.length.above(2)
44 }) 44 })
45 45
46 it('Should list jobs with sort, pagination and job type', async function () { 46 it('Should list jobs with sort, pagination and job type', async function () {
47 { 47 {
48 const body = await servers[1].jobsCommand.getJobsList({ 48 const body = await servers[1].jobs.getJobsList({
49 state: 'completed', 49 state: 'completed',
50 start: 1, 50 start: 1,
51 count: 2, 51 count: 2,
@@ -66,7 +66,7 @@ describe('Test jobs', function () {
66 } 66 }
67 67
68 { 68 {
69 const body = await servers[1].jobsCommand.getJobsList({ 69 const body = await servers[1].jobs.getJobsList({
70 state: 'completed', 70 state: 'completed',
71 start: 0, 71 start: 0,
72 count: 100, 72 count: 100,
@@ -82,7 +82,7 @@ describe('Test jobs', function () {
82 }) 82 })
83 83
84 it('Should list all jobs', async function () { 84 it('Should list all jobs', async function () {
85 const body = await servers[1].jobsCommand.getJobsList() 85 const body = await servers[1].jobs.getJobsList()
86 expect(body.total).to.be.above(2) 86 expect(body.total).to.be.above(2)
87 87
88 const jobs = body.data 88 const jobs = body.data
diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.ts
index e7bef5a4a..2d141fd8c 100644
--- a/server/tests/api/server/logs.ts
+++ b/server/tests/api/server/logs.ts
@@ -25,7 +25,7 @@ describe('Test logs', function () {
25 server = await flushAndRunServer(1) 25 server = await flushAndRunServer(1)
26 await setAccessTokensToServers([ server ]) 26 await setAccessTokensToServers([ server ])
27 27
28 logsCommand = server.logsCommand 28 logsCommand = server.logs
29 }) 29 })
30 30
31 describe('With the standard log file', function () { 31 describe('With the standard log file', function () {
@@ -33,12 +33,12 @@ describe('Test logs', function () {
33 it('Should get logs with a start date', async function () { 33 it('Should get logs with a start date', async function () {
34 this.timeout(20000) 34 this.timeout(20000)
35 35
36 await server.videosCommand.upload({ attributes: { name: 'video 1' } }) 36 await server.videos.upload({ attributes: { name: 'video 1' } })
37 await waitJobs([ server ]) 37 await waitJobs([ server ])
38 38
39 const now = new Date() 39 const now = new Date()
40 40
41 await server.videosCommand.upload({ attributes: { name: 'video 2' } }) 41 await server.videos.upload({ attributes: { name: 'video 2' } })
42 await waitJobs([ server ]) 42 await waitJobs([ server ])
43 43
44 const body = await logsCommand.getLogs({ startDate: now }) 44 const body = await logsCommand.getLogs({ startDate: now })
@@ -51,17 +51,17 @@ describe('Test logs', function () {
51 it('Should get logs with an end date', async function () { 51 it('Should get logs with an end date', async function () {
52 this.timeout(30000) 52 this.timeout(30000)
53 53
54 await server.videosCommand.upload({ attributes: { name: 'video 3' } }) 54 await server.videos.upload({ attributes: { name: 'video 3' } })
55 await waitJobs([ server ]) 55 await waitJobs([ server ])
56 56
57 const now1 = new Date() 57 const now1 = new Date()
58 58
59 await server.videosCommand.upload({ attributes: { name: 'video 4' } }) 59 await server.videos.upload({ attributes: { name: 'video 4' } })
60 await waitJobs([ server ]) 60 await waitJobs([ server ])
61 61
62 const now2 = new Date() 62 const now2 = new Date()
63 63
64 await server.videosCommand.upload({ attributes: { name: 'video 5' } }) 64 await server.videos.upload({ attributes: { name: 'video 5' } })
65 await waitJobs([ server ]) 65 await waitJobs([ server ])
66 66
67 const body = await logsCommand.getLogs({ startDate: now1, endDate: now2 }) 67 const body = await logsCommand.getLogs({ startDate: now1, endDate: now2 })
@@ -77,7 +77,7 @@ describe('Test logs', function () {
77 77
78 const now = new Date() 78 const now = new Date()
79 79
80 await server.videosCommand.upload({ attributes: { name: 'video 6' } }) 80 await server.videos.upload({ attributes: { name: 'video 6' } })
81 await waitJobs([ server ]) 81 await waitJobs([ server ])
82 82
83 { 83 {
@@ -100,7 +100,7 @@ describe('Test logs', function () {
100 100
101 const now = new Date() 101 const now = new Date()
102 102
103 await server.serversCommand.ping() 103 await server.servers.ping()
104 104
105 const body = await logsCommand.getLogs({ startDate: now, level: 'info' }) 105 const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
106 const logsString = JSON.stringify(body) 106 const logsString = JSON.stringify(body)
@@ -117,7 +117,7 @@ describe('Test logs', function () {
117 117
118 const now = new Date() 118 const now = new Date()
119 119
120 await server.serversCommand.ping() 120 await server.servers.ping()
121 121
122 const body = await logsCommand.getLogs({ startDate: now, level: 'info' }) 122 const body = await logsCommand.getLogs({ startDate: now, level: 'info' })
123 const logsString = JSON.stringify(body) 123 const logsString = JSON.stringify(body)
@@ -130,12 +130,12 @@ describe('Test logs', function () {
130 it('Should get logs with a start date', async function () { 130 it('Should get logs with a start date', async function () {
131 this.timeout(20000) 131 this.timeout(20000)
132 132
133 await server.videosCommand.upload({ attributes: { name: 'video 7' } }) 133 await server.videos.upload({ attributes: { name: 'video 7' } })
134 await waitJobs([ server ]) 134 await waitJobs([ server ])
135 135
136 const now = new Date() 136 const now = new Date()
137 137
138 await server.videosCommand.upload({ attributes: { name: 'video 8' } }) 138 await server.videos.upload({ attributes: { name: 'video 8' } })
139 await waitJobs([ server ]) 139 await waitJobs([ server ])
140 140
141 const body = await logsCommand.getAuditLogs({ startDate: now }) 141 const body = await logsCommand.getAuditLogs({ startDate: now })
@@ -156,17 +156,17 @@ describe('Test logs', function () {
156 it('Should get logs with an end date', async function () { 156 it('Should get logs with an end date', async function () {
157 this.timeout(30000) 157 this.timeout(30000)
158 158
159 await server.videosCommand.upload({ attributes: { name: 'video 9' } }) 159 await server.videos.upload({ attributes: { name: 'video 9' } })
160 await waitJobs([ server ]) 160 await waitJobs([ server ])
161 161
162 const now1 = new Date() 162 const now1 = new Date()
163 163
164 await server.videosCommand.upload({ attributes: { name: 'video 10' } }) 164 await server.videos.upload({ attributes: { name: 'video 10' } })
165 await waitJobs([ server ]) 165 await waitJobs([ server ])
166 166
167 const now2 = new Date() 167 const now2 = new Date()
168 168
169 await server.videosCommand.upload({ attributes: { name: 'video 11' } }) 169 await server.videos.upload({ attributes: { name: 'video 11' } })
170 await waitJobs([ server ]) 170 await waitJobs([ server ])
171 171
172 const body = await logsCommand.getAuditLogs({ startDate: now1, endDate: now2 }) 172 const body = await logsCommand.getAuditLogs({ startDate: now1, endDate: now2 })
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
index 1fd5e613b..45a22e48d 100644
--- a/server/tests/api/server/plugins.ts
+++ b/server/tests/api/server/plugins.ts
@@ -33,7 +33,7 @@ describe('Test plugins', function () {
33 server = await flushAndRunServer(1, configOverride) 33 server = await flushAndRunServer(1, configOverride)
34 await setAccessTokensToServers([ server ]) 34 await setAccessTokensToServers([ server ])
35 35
36 command = server.pluginsCommand 36 command = server.plugins
37 }) 37 })
38 38
39 it('Should list and search available plugins and themes', async function () { 39 it('Should list and search available plugins and themes', async function () {
@@ -97,7 +97,7 @@ describe('Test plugins', function () {
97 }) 97 })
98 98
99 it('Should have the plugin loaded in the configuration', async function () { 99 it('Should have the plugin loaded in the configuration', async function () {
100 const config = await server.configCommand.getConfig() 100 const config = await server.config.getConfig()
101 101
102 const theme = config.theme.registered.find(r => r.name === 'background-red') 102 const theme = config.theme.registered.find(r => r.name === 'background-red')
103 expect(theme).to.not.be.undefined 103 expect(theme).to.not.be.undefined
@@ -107,20 +107,20 @@ describe('Test plugins', function () {
107 }) 107 })
108 108
109 it('Should update the default theme in the configuration', async function () { 109 it('Should update the default theme in the configuration', async function () {
110 await server.configCommand.updateCustomSubConfig({ 110 await server.config.updateCustomSubConfig({
111 newConfig: { 111 newConfig: {
112 theme: { default: 'background-red' } 112 theme: { default: 'background-red' }
113 } 113 }
114 }) 114 })
115 115
116 const config = await server.configCommand.getConfig() 116 const config = await server.config.getConfig()
117 expect(config.theme.default).to.equal('background-red') 117 expect(config.theme.default).to.equal('background-red')
118 }) 118 })
119 119
120 it('Should update my default theme', async function () { 120 it('Should update my default theme', async function () {
121 await server.usersCommand.updateMe({ theme: 'background-red' }) 121 await server.users.updateMe({ theme: 'background-red' })
122 122
123 const user = await server.usersCommand.getMyInfo() 123 const user = await server.users.getMyInfo()
124 expect(user.theme).to.equal('background-red') 124 expect(user.theme).to.equal('background-red')
125 }) 125 })
126 126
@@ -187,7 +187,7 @@ describe('Test plugins', function () {
187 it('Should have watched settings changes', async function () { 187 it('Should have watched settings changes', async function () {
188 this.timeout(10000) 188 this.timeout(10000)
189 189
190 await server.serversCommand.waitUntilLog('Settings changed!') 190 await server.servers.waitUntilLog('Settings changed!')
191 }) 191 })
192 192
193 it('Should get a plugin and a theme', async function () { 193 it('Should get a plugin and a theme', async function () {
@@ -234,7 +234,7 @@ describe('Test plugins', function () {
234 await wait(6000) 234 await wait(6000)
235 235
236 // Fake update our plugin version 236 // Fake update our plugin version
237 await server.sqlCommand.setPluginVersion('hello-world', '0.0.1') 237 await server.sql.setPluginVersion('hello-world', '0.0.1')
238 238
239 // Fake update package.json 239 // Fake update package.json
240 const packageJSON = await command.getPackageJSON('peertube-plugin-hello-world') 240 const packageJSON = await command.getPackageJSON('peertube-plugin-hello-world')
@@ -293,7 +293,7 @@ describe('Test plugins', function () {
293 }) 293 })
294 294
295 it('Should have updated the configuration', async function () { 295 it('Should have updated the configuration', async function () {
296 const config = await server.configCommand.getConfig() 296 const config = await server.config.getConfig()
297 297
298 expect(config.theme.default).to.equal('default') 298 expect(config.theme.default).to.equal('default')
299 299
@@ -305,7 +305,7 @@ describe('Test plugins', function () {
305 }) 305 })
306 306
307 it('Should have updated the user theme', async function () { 307 it('Should have updated the user theme', async function () {
308 const user = await server.usersCommand.getMyInfo() 308 const user = await server.users.getMyInfo()
309 expect(user.theme).to.equal('instance-default') 309 expect(user.theme).to.equal('instance-default')
310 }) 310 })
311 311
diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts
index 5a6491430..de3cf02f2 100644
--- a/server/tests/api/server/reverse-proxy.ts
+++ b/server/tests/api/server/reverse-proxy.ts
@@ -33,59 +33,59 @@ describe('Test application behind a reverse proxy', function () {
33 server = await flushAndRunServer(1, config) 33 server = await flushAndRunServer(1, config)
34 await setAccessTokensToServers([ server ]) 34 await setAccessTokensToServers([ server ])
35 35
36 const { uuid } = await server.videosCommand.upload() 36 const { uuid } = await server.videos.upload()
37 videoId = uuid 37 videoId = uuid
38 }) 38 })
39 39
40 it('Should view a video only once with the same IP by default', async function () { 40 it('Should view a video only once with the same IP by default', async function () {
41 this.timeout(20000) 41 this.timeout(20000)
42 42
43 await server.videosCommand.view({ id: videoId }) 43 await server.videos.view({ id: videoId })
44 await server.videosCommand.view({ id: videoId }) 44 await server.videos.view({ id: videoId })
45 45
46 // Wait the repeatable job 46 // Wait the repeatable job
47 await wait(8000) 47 await wait(8000)
48 48
49 const video = await server.videosCommand.get({ id: videoId }) 49 const video = await server.videos.get({ id: videoId })
50 expect(video.views).to.equal(1) 50 expect(video.views).to.equal(1)
51 }) 51 })
52 52
53 it('Should view a video 2 times with the X-Forwarded-For header set', async function () { 53 it('Should view a video 2 times with the X-Forwarded-For header set', async function () {
54 this.timeout(20000) 54 this.timeout(20000)
55 55
56 await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.1,127.0.0.1' }) 56 await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.1,127.0.0.1' })
57 await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.2,127.0.0.1' }) 57 await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.2,127.0.0.1' })
58 58
59 // Wait the repeatable job 59 // Wait the repeatable job
60 await wait(8000) 60 await wait(8000)
61 61
62 const video = await server.videosCommand.get({ id: videoId }) 62 const video = await server.videos.get({ id: videoId })
63 expect(video.views).to.equal(3) 63 expect(video.views).to.equal(3)
64 }) 64 })
65 65
66 it('Should view a video only once with the same client IP in the X-Forwarded-For header', async function () { 66 it('Should view a video only once with the same client IP in the X-Forwarded-For header', async function () {
67 this.timeout(20000) 67 this.timeout(20000)
68 68
69 await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.4,0.0.0.3,::ffff:127.0.0.1' }) 69 await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.4,0.0.0.3,::ffff:127.0.0.1' })
70 await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.5,0.0.0.3,127.0.0.1' }) 70 await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.5,0.0.0.3,127.0.0.1' })
71 71
72 // Wait the repeatable job 72 // Wait the repeatable job
73 await wait(8000) 73 await wait(8000)
74 74
75 const video = await server.videosCommand.get({ id: videoId }) 75 const video = await server.videos.get({ id: videoId })
76 expect(video.views).to.equal(4) 76 expect(video.views).to.equal(4)
77 }) 77 })
78 78
79 it('Should view a video two times with a different client IP in the X-Forwarded-For header', async function () { 79 it('Should view a video two times with a different client IP in the X-Forwarded-For header', async function () {
80 this.timeout(20000) 80 this.timeout(20000)
81 81
82 await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.6,127.0.0.1' }) 82 await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.6,127.0.0.1' })
83 await server.videosCommand.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.7,127.0.0.1' }) 83 await server.videos.view({ id: videoId, xForwardedFor: '0.0.0.8,0.0.0.7,127.0.0.1' })
84 84
85 // Wait the repeatable job 85 // Wait the repeatable job
86 await wait(8000) 86 await wait(8000)
87 87
88 const video = await server.videosCommand.get({ id: videoId }) 88 const video = await server.videos.get({ id: videoId })
89 expect(video.views).to.equal(6) 89 expect(video.views).to.equal(6)
90 }) 90 })
91 91
@@ -93,22 +93,22 @@ describe('Test application behind a reverse proxy', function () {
93 const user = { username: 'root', password: 'fail' } 93 const user = { username: 'root', password: 'fail' }
94 94
95 for (let i = 0; i < 19; i++) { 95 for (let i = 0; i < 19; i++) {
96 await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 96 await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
97 } 97 }
98 98
99 await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 }) 99 await server.login.login({ user, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
100 }) 100 })
101 101
102 it('Should rate limit signup', async function () { 102 it('Should rate limit signup', async function () {
103 for (let i = 0; i < 10; i++) { 103 for (let i = 0; i < 10; i++) {
104 try { 104 try {
105 await server.usersCommand.register({ username: 'test' + i }) 105 await server.users.register({ username: 'test' + i })
106 } catch { 106 } catch {
107 // empty 107 // empty
108 } 108 }
109 } 109 }
110 110
111 await server.usersCommand.register({ username: 'test42', expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 }) 111 await server.users.register({ username: 'test42', expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
112 }) 112 })
113 113
114 it('Should not rate limit failed signup', async function () { 114 it('Should not rate limit failed signup', async function () {
@@ -117,10 +117,10 @@ describe('Test application behind a reverse proxy', function () {
117 await wait(7000) 117 await wait(7000)
118 118
119 for (let i = 0; i < 3; i++) { 119 for (let i = 0; i < 3; i++) {
120 await server.usersCommand.register({ username: 'test' + i, expectedStatus: HttpStatusCode.CONFLICT_409 }) 120 await server.users.register({ username: 'test' + i, expectedStatus: HttpStatusCode.CONFLICT_409 })
121 } 121 }
122 122
123 await server.usersCommand.register({ username: 'test43', expectedStatus: HttpStatusCode.NO_CONTENT_204 }) 123 await server.users.register({ username: 'test43', expectedStatus: HttpStatusCode.NO_CONTENT_204 })
124 124
125 }) 125 })
126 126
@@ -131,13 +131,13 @@ describe('Test application behind a reverse proxy', function () {
131 131
132 for (let i = 0; i < 100; i++) { 132 for (let i = 0; i < 100; i++) {
133 try { 133 try {
134 await server.videosCommand.get({ id: videoId }) 134 await server.videos.get({ id: videoId })
135 } catch { 135 } catch {
136 // don't care if it fails 136 // don't care if it fails
137 } 137 }
138 } 138 }
139 139
140 await server.videosCommand.get({ id: videoId, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 }) 140 await server.videos.get({ id: videoId, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
141 }) 141 })
142 142
143 after(async function () { 143 after(async function () {
diff --git a/server/tests/api/server/services.ts b/server/tests/api/server/services.ts
index a62fb3939..28f9ae3b6 100644
--- a/server/tests/api/server/services.ts
+++ b/server/tests/api/server/services.ts
@@ -23,25 +23,25 @@ describe('Test services', function () {
23 23
24 { 24 {
25 const attributes = { name: 'my super name' } 25 const attributes = { name: 'my super name' }
26 await server.videosCommand.upload({ attributes }) 26 await server.videos.upload({ attributes })
27 27
28 const { data } = await server.videosCommand.list() 28 const { data } = await server.videos.list()
29 video = data[0] 29 video = data[0]
30 } 30 }
31 31
32 { 32 {
33 const created = await server.playlistsCommand.create({ 33 const created = await server.playlists.create({
34 attributes: { 34 attributes: {
35 displayName: 'The Life and Times of Scrooge McDuck', 35 displayName: 'The Life and Times of Scrooge McDuck',
36 privacy: VideoPlaylistPrivacy.PUBLIC, 36 privacy: VideoPlaylistPrivacy.PUBLIC,
37 videoChannelId: server.videoChannel.id 37 videoChannelId: server.store.channel.id
38 } 38 }
39 }) 39 })
40 40
41 playlistUUID = created.uuid 41 playlistUUID = created.uuid
42 playlistDisplayName = 'The Life and Times of Scrooge McDuck' 42 playlistDisplayName = 'The Life and Times of Scrooge McDuck'
43 43
44 await server.playlistsCommand.addElement({ 44 await server.playlists.addElement({
45 playlistId: created.id, 45 playlistId: created.id,
46 attributes: { 46 attributes: {
47 videoId: video.id 47 videoId: video.id
@@ -54,7 +54,7 @@ describe('Test services', function () {
54 for (const basePath of [ '/videos/watch/', '/w/' ]) { 54 for (const basePath of [ '/videos/watch/', '/w/' ]) {
55 const oembedUrl = 'http://localhost:' + server.port + basePath + video.uuid 55 const oembedUrl = 'http://localhost:' + server.port + basePath + video.uuid
56 56
57 const res = await server.servicesCommand.getOEmbed({ oembedUrl }) 57 const res = await server.services.getOEmbed({ oembedUrl })
58 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' + 58 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
59 `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` + 59 `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
60 'frameborder="0" allowfullscreen></iframe>' 60 'frameborder="0" allowfullscreen></iframe>'
@@ -62,7 +62,7 @@ describe('Test services', function () {
62 62
63 expect(res.body.html).to.equal(expectedHtml) 63 expect(res.body.html).to.equal(expectedHtml)
64 expect(res.body.title).to.equal(video.name) 64 expect(res.body.title).to.equal(video.name)
65 expect(res.body.author_name).to.equal(server.videoChannel.displayName) 65 expect(res.body.author_name).to.equal(server.store.channel.displayName)
66 expect(res.body.width).to.equal(560) 66 expect(res.body.width).to.equal(560)
67 expect(res.body.height).to.equal(315) 67 expect(res.body.height).to.equal(315)
68 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl) 68 expect(res.body.thumbnail_url).to.equal(expectedThumbnailUrl)
@@ -75,14 +75,14 @@ describe('Test services', function () {
75 for (const basePath of [ '/videos/watch/playlist/', '/w/p/' ]) { 75 for (const basePath of [ '/videos/watch/playlist/', '/w/p/' ]) {
76 const oembedUrl = 'http://localhost:' + server.port + basePath + playlistUUID 76 const oembedUrl = 'http://localhost:' + server.port + basePath + playlistUUID
77 77
78 const res = await server.servicesCommand.getOEmbed({ oembedUrl }) 78 const res = await server.services.getOEmbed({ oembedUrl })
79 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' + 79 const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
80 `title="${playlistDisplayName}" src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` + 80 `title="${playlistDisplayName}" src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` +
81 'frameborder="0" allowfullscreen></iframe>' 81 'frameborder="0" allowfullscreen></iframe>'
82 82
83 expect(res.body.html).to.equal(expectedHtml) 83 expect(res.body.html).to.equal(expectedHtml)
84 expect(res.body.title).to.equal('The Life and Times of Scrooge McDuck') 84 expect(res.body.title).to.equal('The Life and Times of Scrooge McDuck')
85 expect(res.body.author_name).to.equal(server.videoChannel.displayName) 85 expect(res.body.author_name).to.equal(server.store.channel.displayName)
86 expect(res.body.width).to.equal(560) 86 expect(res.body.width).to.equal(560)
87 expect(res.body.height).to.equal(315) 87 expect(res.body.height).to.equal(315)
88 expect(res.body.thumbnail_url).exist 88 expect(res.body.thumbnail_url).exist
@@ -98,14 +98,14 @@ describe('Test services', function () {
98 const maxHeight = 50 98 const maxHeight = 50
99 const maxWidth = 50 99 const maxWidth = 50
100 100
101 const res = await server.servicesCommand.getOEmbed({ oembedUrl, format, maxHeight, maxWidth }) 101 const res = await server.services.getOEmbed({ oembedUrl, format, maxHeight, maxWidth })
102 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' + 102 const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
103 `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` + 103 `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
104 'frameborder="0" allowfullscreen></iframe>' 104 'frameborder="0" allowfullscreen></iframe>'
105 105
106 expect(res.body.html).to.equal(expectedHtml) 106 expect(res.body.html).to.equal(expectedHtml)
107 expect(res.body.title).to.equal(video.name) 107 expect(res.body.title).to.equal(video.name)
108 expect(res.body.author_name).to.equal(server.videoChannel.displayName) 108 expect(res.body.author_name).to.equal(server.store.channel.displayName)
109 expect(res.body.height).to.equal(50) 109 expect(res.body.height).to.equal(50)
110 expect(res.body.width).to.equal(50) 110 expect(res.body.width).to.equal(50)
111 expect(res.body).to.not.have.property('thumbnail_url') 111 expect(res.body).to.not.have.property('thumbnail_url')
diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts
index 3eb1efb94..be5abad52 100644
--- a/server/tests/api/server/stats.ts
+++ b/server/tests/api/server/stats.ts
@@ -32,23 +32,23 @@ describe('Test stats (excluding redundancy)', function () {
32 32
33 await doubleFollow(servers[0], servers[1]) 33 await doubleFollow(servers[0], servers[1])
34 34
35 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 35 await servers[0].users.create({ username: user.username, password: user.password })
36 36
37 const { uuid } = await servers[0].videosCommand.upload({ attributes: { fixture: 'video_short.webm' } }) 37 const { uuid } = await servers[0].videos.upload({ attributes: { fixture: 'video_short.webm' } })
38 38
39 await servers[0].commentsCommand.createThread({ videoId: uuid, text: 'comment' }) 39 await servers[0].comments.createThread({ videoId: uuid, text: 'comment' })
40 40
41 await servers[0].videosCommand.view({ id: uuid }) 41 await servers[0].videos.view({ id: uuid })
42 42
43 // Wait the video views repeatable job 43 // Wait the video views repeatable job
44 await wait(8000) 44 await wait(8000)
45 45
46 await servers[2].followsCommand.follow({ targets: [ servers[0].url ] }) 46 await servers[2].follows.follow({ targets: [ servers[0].url ] })
47 await waitJobs(servers) 47 await waitJobs(servers)
48 }) 48 })
49 49
50 it('Should have the correct stats on instance 1', async function () { 50 it('Should have the correct stats on instance 1', async function () {
51 const data = await servers[0].statsCommand.get() 51 const data = await servers[0].stats.get()
52 52
53 expect(data.totalLocalVideoComments).to.equal(1) 53 expect(data.totalLocalVideoComments).to.equal(1)
54 expect(data.totalLocalVideos).to.equal(1) 54 expect(data.totalLocalVideos).to.equal(1)
@@ -63,7 +63,7 @@ describe('Test stats (excluding redundancy)', function () {
63 }) 63 })
64 64
65 it('Should have the correct stats on instance 2', async function () { 65 it('Should have the correct stats on instance 2', async function () {
66 const data = await servers[1].statsCommand.get() 66 const data = await servers[1].stats.get()
67 67
68 expect(data.totalLocalVideoComments).to.equal(0) 68 expect(data.totalLocalVideoComments).to.equal(0)
69 expect(data.totalLocalVideos).to.equal(0) 69 expect(data.totalLocalVideos).to.equal(0)
@@ -78,7 +78,7 @@ describe('Test stats (excluding redundancy)', function () {
78 }) 78 })
79 79
80 it('Should have the correct stats on instance 3', async function () { 80 it('Should have the correct stats on instance 3', async function () {
81 const data = await servers[2].statsCommand.get() 81 const data = await servers[2].stats.get()
82 82
83 expect(data.totalLocalVideoComments).to.equal(0) 83 expect(data.totalLocalVideoComments).to.equal(0)
84 expect(data.totalLocalVideos).to.equal(0) 84 expect(data.totalLocalVideos).to.equal(0)
@@ -94,10 +94,10 @@ describe('Test stats (excluding redundancy)', function () {
94 it('Should have the correct total videos stats after an unfollow', async function () { 94 it('Should have the correct total videos stats after an unfollow', async function () {
95 this.timeout(15000) 95 this.timeout(15000)
96 96
97 await servers[2].followsCommand.unfollow({ target: servers[0] }) 97 await servers[2].follows.unfollow({ target: servers[0] })
98 await waitJobs(servers) 98 await waitJobs(servers)
99 99
100 const data = await servers[2].statsCommand.get() 100 const data = await servers[2].stats.get()
101 101
102 expect(data.totalVideos).to.equal(0) 102 expect(data.totalVideos).to.equal(0)
103 }) 103 })
@@ -106,7 +106,7 @@ describe('Test stats (excluding redundancy)', function () {
106 const server = servers[0] 106 const server = servers[0]
107 107
108 { 108 {
109 const data = await server.statsCommand.get() 109 const data = await server.stats.get()
110 110
111 expect(data.totalDailyActiveUsers).to.equal(1) 111 expect(data.totalDailyActiveUsers).to.equal(1)
112 expect(data.totalWeeklyActiveUsers).to.equal(1) 112 expect(data.totalWeeklyActiveUsers).to.equal(1)
@@ -114,9 +114,9 @@ describe('Test stats (excluding redundancy)', function () {
114 } 114 }
115 115
116 { 116 {
117 await server.loginCommand.getAccessToken(user) 117 await server.login.getAccessToken(user)
118 118
119 const data = await server.statsCommand.get() 119 const data = await server.stats.get()
120 120
121 expect(data.totalDailyActiveUsers).to.equal(2) 121 expect(data.totalDailyActiveUsers).to.equal(2)
122 expect(data.totalWeeklyActiveUsers).to.equal(2) 122 expect(data.totalWeeklyActiveUsers).to.equal(2)
@@ -128,7 +128,7 @@ describe('Test stats (excluding redundancy)', function () {
128 const server = servers[0] 128 const server = servers[0]
129 129
130 { 130 {
131 const data = await server.statsCommand.get() 131 const data = await server.stats.get()
132 132
133 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1) 133 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
134 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1) 134 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
@@ -140,10 +140,10 @@ describe('Test stats (excluding redundancy)', function () {
140 name: 'stats_channel', 140 name: 'stats_channel',
141 displayName: 'My stats channel' 141 displayName: 'My stats channel'
142 } 142 }
143 const created = await server.channelsCommand.create({ attributes }) 143 const created = await server.channels.create({ attributes })
144 channelId = created.id 144 channelId = created.id
145 145
146 const data = await server.statsCommand.get() 146 const data = await server.stats.get()
147 147
148 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1) 148 expect(data.totalLocalDailyActiveVideoChannels).to.equal(1)
149 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1) 149 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(1)
@@ -151,9 +151,9 @@ describe('Test stats (excluding redundancy)', function () {
151 } 151 }
152 152
153 { 153 {
154 await server.videosCommand.upload({ attributes: { fixture: 'video_short.webm', channelId } }) 154 await server.videos.upload({ attributes: { fixture: 'video_short.webm', channelId } })
155 155
156 const data = await server.statsCommand.get() 156 const data = await server.stats.get()
157 157
158 expect(data.totalLocalDailyActiveVideoChannels).to.equal(2) 158 expect(data.totalLocalDailyActiveVideoChannels).to.equal(2)
159 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(2) 159 expect(data.totalLocalWeeklyActiveVideoChannels).to.equal(2)
@@ -165,12 +165,12 @@ describe('Test stats (excluding redundancy)', function () {
165 const server = servers[0] 165 const server = servers[0]
166 166
167 { 167 {
168 const data = await server.statsCommand.get() 168 const data = await server.stats.get()
169 expect(data.totalLocalPlaylists).to.equal(0) 169 expect(data.totalLocalPlaylists).to.equal(0)
170 } 170 }
171 171
172 { 172 {
173 await server.playlistsCommand.create({ 173 await server.playlists.create({
174 attributes: { 174 attributes: {
175 displayName: 'playlist for count', 175 displayName: 'playlist for count',
176 privacy: VideoPlaylistPrivacy.PUBLIC, 176 privacy: VideoPlaylistPrivacy.PUBLIC,
@@ -178,7 +178,7 @@ describe('Test stats (excluding redundancy)', function () {
178 } 178 }
179 }) 179 })
180 180
181 const data = await server.statsCommand.get() 181 const data = await server.stats.get()
182 expect(data.totalLocalPlaylists).to.equal(1) 182 expect(data.totalLocalPlaylists).to.equal(1)
183 } 183 }
184 }) 184 })
@@ -186,7 +186,7 @@ describe('Test stats (excluding redundancy)', function () {
186 it('Should correctly count video file sizes if transcoding is enabled', async function () { 186 it('Should correctly count video file sizes if transcoding is enabled', async function () {
187 this.timeout(60000) 187 this.timeout(60000)
188 188
189 await servers[0].configCommand.updateCustomSubConfig({ 189 await servers[0].config.updateCustomSubConfig({
190 newConfig: { 190 newConfig: {
191 transcoding: { 191 transcoding: {
192 enabled: true, 192 enabled: true,
@@ -210,17 +210,17 @@ describe('Test stats (excluding redundancy)', function () {
210 } 210 }
211 }) 211 })
212 212
213 await servers[0].videosCommand.upload({ attributes: { name: 'video', fixture: 'video_short.webm' } }) 213 await servers[0].videos.upload({ attributes: { name: 'video', fixture: 'video_short.webm' } })
214 214
215 await waitJobs(servers) 215 await waitJobs(servers)
216 216
217 { 217 {
218 const data = await servers[1].statsCommand.get() 218 const data = await servers[1].stats.get()
219 expect(data.totalLocalVideoFilesSize).to.equal(0) 219 expect(data.totalLocalVideoFilesSize).to.equal(0)
220 } 220 }
221 221
222 { 222 {
223 const data = await servers[0].statsCommand.get() 223 const data = await servers[0].stats.get()
224 expect(data.totalLocalVideoFilesSize).to.be.greaterThan(500000) 224 expect(data.totalLocalVideoFilesSize).to.be.greaterThan(500000)
225 expect(data.totalLocalVideoFilesSize).to.be.lessThan(600000) 225 expect(data.totalLocalVideoFilesSize).to.be.lessThan(600000)
226 } 226 }
@@ -229,7 +229,7 @@ describe('Test stats (excluding redundancy)', function () {
229 it('Should have the correct AP stats', async function () { 229 it('Should have the correct AP stats', async function () {
230 this.timeout(60000) 230 this.timeout(60000)
231 231
232 await servers[0].configCommand.updateCustomSubConfig({ 232 await servers[0].config.updateCustomSubConfig({
233 newConfig: { 233 newConfig: {
234 transcoding: { 234 transcoding: {
235 enabled: false 235 enabled: false
@@ -237,17 +237,17 @@ describe('Test stats (excluding redundancy)', function () {
237 } 237 }
238 }) 238 })
239 239
240 const first = await servers[1].statsCommand.get() 240 const first = await servers[1].stats.get()
241 241
242 for (let i = 0; i < 10; i++) { 242 for (let i = 0; i < 10; i++) {
243 await servers[0].videosCommand.upload({ attributes: { name: 'video' } }) 243 await servers[0].videos.upload({ attributes: { name: 'video' } })
244 } 244 }
245 245
246 await waitJobs(servers) 246 await waitJobs(servers)
247 247
248 await wait(6000) 248 await wait(6000)
249 249
250 const second = await servers[1].statsCommand.get() 250 const second = await servers[1].stats.get()
251 expect(second.totalActivityPubMessagesProcessed).to.be.greaterThan(first.totalActivityPubMessagesProcessed) 251 expect(second.totalActivityPubMessagesProcessed).to.be.greaterThan(first.totalActivityPubMessagesProcessed)
252 252
253 const apTypes: ActivityType[] = [ 253 const apTypes: ActivityType[] = [
@@ -269,7 +269,7 @@ describe('Test stats (excluding redundancy)', function () {
269 269
270 await wait(6000) 270 await wait(6000)
271 271
272 const third = await servers[1].statsCommand.get() 272 const third = await servers[1].stats.get()
273 expect(third.totalActivityPubMessagesWaiting).to.equal(0) 273 expect(third.totalActivityPubMessagesWaiting).to.equal(0)
274 expect(third.activityPubMessagesProcessedPerSecond).to.be.lessThan(second.activityPubMessagesProcessedPerSecond) 274 expect(third.activityPubMessagesProcessedPerSecond).to.be.lessThan(second.activityPubMessagesProcessedPerSecond)
275 }) 275 })
diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts
index 032012edf..d80362fee 100644
--- a/server/tests/api/server/tracker.ts
+++ b/server/tests/api/server/tracker.ts
@@ -16,8 +16,8 @@ describe('Test tracker', function () {
16 await setAccessTokensToServers([ server ]) 16 await setAccessTokensToServers([ server ])
17 17
18 { 18 {
19 const { uuid } = await server.videosCommand.upload() 19 const { uuid } = await server.videos.upload()
20 const video = await server.videosCommand.get({ id: uuid }) 20 const video = await server.videos.get({ id: uuid })
21 goodMagnet = video.files[0].magnetUri 21 goodMagnet = video.files[0].magnetUri
22 22
23 const parsed = magnetUtil.decode(goodMagnet) 23 const parsed = magnetUtil.decode(goodMagnet)
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts
index 622cddb7d..1b15a98dc 100644
--- a/server/tests/api/users/user-subscriptions.ts
+++ b/server/tests/api/users/user-subscriptions.ts
@@ -35,26 +35,26 @@ describe('Test users subscriptions', function () {
35 { 35 {
36 for (const server of servers) { 36 for (const server of servers) {
37 const user = { username: 'user' + server.serverNumber, password: 'password' } 37 const user = { username: 'user' + server.serverNumber, password: 'password' }
38 await server.usersCommand.create({ username: user.username, password: user.password }) 38 await server.users.create({ username: user.username, password: user.password })
39 39
40 const accessToken = await server.loginCommand.getAccessToken(user) 40 const accessToken = await server.login.getAccessToken(user)
41 users.push({ accessToken }) 41 users.push({ accessToken })
42 42
43 const videoName1 = 'video 1-' + server.serverNumber 43 const videoName1 = 'video 1-' + server.serverNumber
44 await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName1 } }) 44 await server.videos.upload({ token: accessToken, attributes: { name: videoName1 } })
45 45
46 const videoName2 = 'video 2-' + server.serverNumber 46 const videoName2 = 'video 2-' + server.serverNumber
47 await server.videosCommand.upload({ token: accessToken, attributes: { name: videoName2 } }) 47 await server.videos.upload({ token: accessToken, attributes: { name: videoName2 } })
48 } 48 }
49 } 49 }
50 50
51 await waitJobs(servers) 51 await waitJobs(servers)
52 52
53 command = servers[0].subscriptionsCommand 53 command = servers[0].subscriptions
54 }) 54 })
55 55
56 it('Should display videos of server 2 on server 1', async function () { 56 it('Should display videos of server 2 on server 1', async function () {
57 const { total } = await servers[0].videosCommand.list() 57 const { total } = await servers[0].videos.list()
58 58
59 expect(total).to.equal(4) 59 expect(total).to.equal(4)
60 }) 60 })
@@ -67,14 +67,14 @@ describe('Test users subscriptions', function () {
67 67
68 await waitJobs(servers) 68 await waitJobs(servers)
69 69
70 const { uuid } = await servers[2].videosCommand.upload({ attributes: { name: 'video server 3 added after follow' } }) 70 const { uuid } = await servers[2].videos.upload({ attributes: { name: 'video server 3 added after follow' } })
71 video3UUID = uuid 71 video3UUID = uuid
72 72
73 await waitJobs(servers) 73 await waitJobs(servers)
74 }) 74 })
75 75
76 it('Should not display videos of server 3 on server 1', async function () { 76 it('Should not display videos of server 3 on server 1', async function () {
77 const { total, data } = await servers[0].videosCommand.list() 77 const { total, data } = await servers[0].videos.list()
78 expect(total).to.equal(4) 78 expect(total).to.equal(4)
79 79
80 for (const video of data) { 80 for (const video of data) {
@@ -183,7 +183,7 @@ describe('Test users subscriptions', function () {
183 this.timeout(60000) 183 this.timeout(60000)
184 184
185 const videoName = 'video server 1 added after follow' 185 const videoName = 'video server 1 added after follow'
186 await servers[0].videosCommand.upload({ attributes: { name: videoName } }) 186 await servers[0].videos.upload({ attributes: { name: videoName } })
187 187
188 await waitJobs(servers) 188 await waitJobs(servers)
189 189
@@ -209,7 +209,7 @@ describe('Test users subscriptions', function () {
209 } 209 }
210 210
211 { 211 {
212 const { data, total } = await servers[0].videosCommand.list() 212 const { data, total } = await servers[0].videos.list()
213 expect(total).to.equal(5) 213 expect(total).to.equal(5)
214 214
215 for (const video of data) { 215 for (const video of data) {
@@ -223,11 +223,11 @@ describe('Test users subscriptions', function () {
223 it('Should have server 1 follow server 3 and display server 3 videos', async function () { 223 it('Should have server 1 follow server 3 and display server 3 videos', async function () {
224 this.timeout(60000) 224 this.timeout(60000)
225 225
226 await servers[0].followsCommand.follow({ targets: [ servers[2].url ] }) 226 await servers[0].follows.follow({ targets: [ servers[2].url ] })
227 227
228 await waitJobs(servers) 228 await waitJobs(servers)
229 229
230 const { data, total } = await servers[0].videosCommand.list() 230 const { data, total } = await servers[0].videos.list()
231 expect(total).to.equal(8) 231 expect(total).to.equal(8)
232 232
233 const names = [ '1-3', '2-3', 'video server 3 added after follow' ] 233 const names = [ '1-3', '2-3', 'video server 3 added after follow' ]
@@ -240,11 +240,11 @@ describe('Test users subscriptions', function () {
240 it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () { 240 it('Should remove follow server 1 -> server 3 and hide server 3 videos', async function () {
241 this.timeout(60000) 241 this.timeout(60000)
242 242
243 await servers[0].followsCommand.unfollow({ target: servers[2] }) 243 await servers[0].follows.unfollow({ target: servers[2] })
244 244
245 await waitJobs(servers) 245 await waitJobs(servers)
246 246
247 const { total, data } = await servers[0].videosCommand.list() 247 const { total, data } = await servers[0].videos.list()
248 expect(total).to.equal(5) 248 expect(total).to.equal(5)
249 249
250 for (const video of data) { 250 for (const video of data) {
@@ -280,7 +280,7 @@ describe('Test users subscriptions', function () {
280 it('Should update a video of server 3 and see the updated video on server 1', async function () { 280 it('Should update a video of server 3 and see the updated video on server 1', async function () {
281 this.timeout(30000) 281 this.timeout(30000)
282 282
283 await servers[2].videosCommand.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } }) 283 await servers[2].videos.update({ id: video3UUID, attributes: { name: 'video server 3 added after follow updated' } })
284 284
285 await waitJobs(servers) 285 await waitJobs(servers)
286 286
@@ -325,7 +325,7 @@ describe('Test users subscriptions', function () {
325 }) 325 })
326 326
327 it('Should correctly display public videos on server 1', async function () { 327 it('Should correctly display public videos on server 1', async function () {
328 const { total, data } = await servers[0].videosCommand.list() 328 const { total, data } = await servers[0].videos.list()
329 expect(total).to.equal(5) 329 expect(total).to.equal(5)
330 330
331 for (const video of data) { 331 for (const video of data) {
@@ -356,7 +356,7 @@ describe('Test users subscriptions', function () {
356 } 356 }
357 357
358 { 358 {
359 const { total, data } = await servers[0].videosCommand.list() 359 const { total, data } = await servers[0].videos.list()
360 expect(total).to.equal(5) 360 expect(total).to.equal(5)
361 361
362 for (const video of data) { 362 for (const video of data) {
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index 3ae105008..f8d7ae88e 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -42,20 +42,20 @@ describe('Test users with multiple servers', function () {
42 await doubleFollow(servers[1], servers[2]) 42 await doubleFollow(servers[1], servers[2])
43 43
44 // The root user of server 1 is propagated to servers 2 and 3 44 // The root user of server 1 is propagated to servers 2 and 3
45 await servers[0].videosCommand.upload() 45 await servers[0].videos.upload()
46 46
47 { 47 {
48 const user = { 48 const user = {
49 username: 'user1', 49 username: 'user1',
50 password: 'password' 50 password: 'password'
51 } 51 }
52 const created = await servers[0].usersCommand.create(user) 52 const created = await servers[0].users.create(user)
53 userId = created.id 53 userId = created.id
54 userAccessToken = await servers[0].loginCommand.getAccessToken(user) 54 userAccessToken = await servers[0].login.getAccessToken(user)
55 } 55 }
56 56
57 { 57 {
58 const { uuid } = await servers[0].videosCommand.upload({ token: userAccessToken }) 58 const { uuid } = await servers[0].videos.upload({ token: userAccessToken })
59 videoUUID = uuid 59 videoUUID = uuid
60 } 60 }
61 61
@@ -65,9 +65,9 @@ describe('Test users with multiple servers', function () {
65 it('Should be able to update my display name', async function () { 65 it('Should be able to update my display name', async function () {
66 this.timeout(10000) 66 this.timeout(10000)
67 67
68 await servers[0].usersCommand.updateMe({ displayName: 'my super display name' }) 68 await servers[0].users.updateMe({ displayName: 'my super display name' })
69 69
70 user = await servers[0].usersCommand.getMyInfo() 70 user = await servers[0].users.getMyInfo()
71 expect(user.account.displayName).to.equal('my super display name') 71 expect(user.account.displayName).to.equal('my super display name')
72 72
73 await waitJobs(servers) 73 await waitJobs(servers)
@@ -76,9 +76,9 @@ describe('Test users with multiple servers', function () {
76 it('Should be able to update my description', async function () { 76 it('Should be able to update my description', async function () {
77 this.timeout(10_000) 77 this.timeout(10_000)
78 78
79 await servers[0].usersCommand.updateMe({ description: 'my super description updated' }) 79 await servers[0].users.updateMe({ description: 'my super description updated' })
80 80
81 user = await servers[0].usersCommand.getMyInfo() 81 user = await servers[0].users.getMyInfo()
82 expect(user.account.displayName).to.equal('my super display name') 82 expect(user.account.displayName).to.equal('my super display name')
83 expect(user.account.description).to.equal('my super description updated') 83 expect(user.account.description).to.equal('my super description updated')
84 84
@@ -90,9 +90,9 @@ describe('Test users with multiple servers', function () {
90 90
91 const fixture = 'avatar2.png' 91 const fixture = 'avatar2.png'
92 92
93 await servers[0].usersCommand.updateMyAvatar({ fixture }) 93 await servers[0].users.updateMyAvatar({ fixture })
94 94
95 user = await servers[0].usersCommand.getMyInfo() 95 user = await servers[0].users.getMyInfo()
96 userAvatarFilename = user.account.avatar.path 96 userAvatarFilename = user.account.avatar.path
97 97
98 await testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png') 98 await testImage(servers[0].url, 'avatar2-resized', userAvatarFilename, '.png')
@@ -104,12 +104,12 @@ describe('Test users with multiple servers', function () {
104 let createdAt: string | Date 104 let createdAt: string | Date
105 105
106 for (const server of servers) { 106 for (const server of servers) {
107 const body = await server.accountsCommand.list({ sort: '-createdAt' }) 107 const body = await server.accounts.list({ sort: '-createdAt' })
108 108
109 const resList = body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port) 109 const resList = body.data.find(a => a.name === 'root' && a.host === 'localhost:' + servers[0].port)
110 expect(resList).not.to.be.undefined 110 expect(resList).not.to.be.undefined
111 111
112 const account = await server.accountsCommand.get({ accountName: resList.name + '@' + resList.host }) 112 const account = await server.accounts.get({ accountName: resList.name + '@' + resList.host })
113 113
114 if (!createdAt) createdAt = account.createdAt 114 if (!createdAt) createdAt = account.createdAt
115 115
@@ -131,7 +131,7 @@ describe('Test users with multiple servers', function () {
131 131
132 it('Should list account videos', async function () { 132 it('Should list account videos', async function () {
133 for (const server of servers) { 133 for (const server of servers) {
134 const { total, data } = await server.videosCommand.listByAccount({ accountName: 'user1@localhost:' + servers[0].port }) 134 const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port })
135 135
136 expect(total).to.equal(1) 136 expect(total).to.equal(1)
137 expect(data).to.be.an('array') 137 expect(data).to.be.an('array')
@@ -143,12 +143,12 @@ describe('Test users with multiple servers', function () {
143 it('Should search through account videos', async function () { 143 it('Should search through account videos', async function () {
144 this.timeout(10_000) 144 this.timeout(10_000)
145 145
146 const created = await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'Kami no chikara' } }) 146 const created = await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'Kami no chikara' } })
147 147
148 await waitJobs(servers) 148 await waitJobs(servers)
149 149
150 for (const server of servers) { 150 for (const server of servers) {
151 const { total, data } = await server.videosCommand.listByAccount({ accountName: 'user1@localhost:' + servers[0].port, search: 'Kami' }) 151 const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port, search: 'Kami' })
152 152
153 expect(total).to.equal(1) 153 expect(total).to.equal(1)
154 expect(data).to.be.an('array') 154 expect(data).to.be.an('array')
@@ -161,27 +161,27 @@ describe('Test users with multiple servers', function () {
161 this.timeout(10_000) 161 this.timeout(10_000)
162 162
163 for (const server of servers) { 163 for (const server of servers) {
164 const body = await server.accountsCommand.list({ sort: '-createdAt' }) 164 const body = await server.accounts.list({ sort: '-createdAt' })
165 165
166 const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) 166 const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port)
167 expect(accountDeleted).not.to.be.undefined 167 expect(accountDeleted).not.to.be.undefined
168 168
169 const { data } = await server.channelsCommand.list() 169 const { data } = await server.channels.list()
170 const videoChannelDeleted = data.find(a => a.displayName === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port) 170 const videoChannelDeleted = data.find(a => a.displayName === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port)
171 expect(videoChannelDeleted).not.to.be.undefined 171 expect(videoChannelDeleted).not.to.be.undefined
172 } 172 }
173 173
174 await servers[0].usersCommand.remove({ userId }) 174 await servers[0].users.remove({ userId })
175 175
176 await waitJobs(servers) 176 await waitJobs(servers)
177 177
178 for (const server of servers) { 178 for (const server of servers) {
179 const body = await server.accountsCommand.list({ sort: '-createdAt' }) 179 const body = await server.accounts.list({ sort: '-createdAt' })
180 180
181 const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port) 181 const accountDeleted = body.data.find(a => a.name === 'user1' && a.host === 'localhost:' + servers[0].port)
182 expect(accountDeleted).to.be.undefined 182 expect(accountDeleted).to.be.undefined
183 183
184 const { data } = await server.channelsCommand.list() 184 const { data } = await server.channels.list()
185 const videoChannelDeleted = data.find(a => a.name === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port) 185 const videoChannelDeleted = data.find(a => a.name === 'Main user1 channel' && a.host === 'localhost:' + servers[0].port)
186 expect(videoChannelDeleted).to.be.undefined 186 expect(videoChannelDeleted).to.be.undefined
187 } 187 }
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts
index 271aa3c7a..c8c226fa8 100644
--- a/server/tests/api/users/users-verification.ts
+++ b/server/tests/api/users/users-verification.ts
@@ -42,7 +42,7 @@ describe('Test users account verification', function () {
42 it('Should register user and send verification email if verification required', async function () { 42 it('Should register user and send verification email if verification required', async function () {
43 this.timeout(30000) 43 this.timeout(30000)
44 44
45 await server.configCommand.updateCustomSubConfig({ 45 await server.config.updateCustomSubConfig({
46 newConfig: { 46 newConfig: {
47 signup: { 47 signup: {
48 enabled: true, 48 enabled: true,
@@ -52,7 +52,7 @@ describe('Test users account verification', function () {
52 } 52 }
53 }) 53 })
54 54
55 await server.usersCommand.register(user1) 55 await server.users.register(user1)
56 56
57 await waitJobs(server) 57 await waitJobs(server)
58 expectedEmailsLength++ 58 expectedEmailsLength++
@@ -71,22 +71,22 @@ describe('Test users account verification', function () {
71 71
72 userId = parseInt(userIdMatches[1], 10) 72 userId = parseInt(userIdMatches[1], 10)
73 73
74 const body = await server.usersCommand.get({ userId }) 74 const body = await server.users.get({ userId })
75 expect(body.emailVerified).to.be.false 75 expect(body.emailVerified).to.be.false
76 }) 76 })
77 77
78 it('Should not allow login for user with unverified email', async function () { 78 it('Should not allow login for user with unverified email', async function () {
79 const { detail } = await server.loginCommand.login({ user: user1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 79 const { detail } = await server.login.login({ user: user1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
80 expect(detail).to.contain('User email is not verified.') 80 expect(detail).to.contain('User email is not verified.')
81 }) 81 })
82 82
83 it('Should verify the user via email and allow login', async function () { 83 it('Should verify the user via email and allow login', async function () {
84 await server.usersCommand.verifyEmail({ userId, verificationString }) 84 await server.users.verifyEmail({ userId, verificationString })
85 85
86 const body = await server.loginCommand.login({ user: user1 }) 86 const body = await server.login.login({ user: user1 })
87 userAccessToken = body.access_token 87 userAccessToken = body.access_token
88 88
89 const user = await server.usersCommand.get({ userId }) 89 const user = await server.users.get({ userId })
90 expect(user.emailVerified).to.be.true 90 expect(user.emailVerified).to.be.true
91 }) 91 })
92 92
@@ -96,7 +96,7 @@ describe('Test users account verification', function () {
96 let updateVerificationString: string 96 let updateVerificationString: string
97 97
98 { 98 {
99 await server.usersCommand.updateMe({ 99 await server.users.updateMe({
100 token: userAccessToken, 100 token: userAccessToken,
101 email: 'updated@example.com', 101 email: 'updated@example.com',
102 currentPassword: user1.password 102 currentPassword: user1.password
@@ -113,15 +113,15 @@ describe('Test users account verification', function () {
113 } 113 }
114 114
115 { 115 {
116 const me = await server.usersCommand.getMyInfo({ token: userAccessToken }) 116 const me = await server.users.getMyInfo({ token: userAccessToken })
117 expect(me.email).to.equal('user_1@example.com') 117 expect(me.email).to.equal('user_1@example.com')
118 expect(me.pendingEmail).to.equal('updated@example.com') 118 expect(me.pendingEmail).to.equal('updated@example.com')
119 } 119 }
120 120
121 { 121 {
122 await server.usersCommand.verifyEmail({ userId, verificationString: updateVerificationString, isPendingEmail: true }) 122 await server.users.verifyEmail({ userId, verificationString: updateVerificationString, isPendingEmail: true })
123 123
124 const me = await server.usersCommand.getMyInfo({ token: userAccessToken }) 124 const me = await server.users.getMyInfo({ token: userAccessToken })
125 expect(me.email).to.equal('updated@example.com') 125 expect(me.email).to.equal('updated@example.com')
126 expect(me.pendingEmail).to.be.null 126 expect(me.pendingEmail).to.be.null
127 } 127 }
@@ -129,7 +129,7 @@ describe('Test users account verification', function () {
129 129
130 it('Should register user not requiring email verification if setting not enabled', async function () { 130 it('Should register user not requiring email verification if setting not enabled', async function () {
131 this.timeout(5000) 131 this.timeout(5000)
132 await server.configCommand.updateCustomSubConfig({ 132 await server.config.updateCustomSubConfig({
133 newConfig: { 133 newConfig: {
134 signup: { 134 signup: {
135 enabled: true, 135 enabled: true,
@@ -139,19 +139,19 @@ describe('Test users account verification', function () {
139 } 139 }
140 }) 140 })
141 141
142 await server.usersCommand.register(user2) 142 await server.users.register(user2)
143 143
144 await waitJobs(server) 144 await waitJobs(server)
145 expect(emails).to.have.lengthOf(expectedEmailsLength) 145 expect(emails).to.have.lengthOf(expectedEmailsLength)
146 146
147 const accessToken = await server.loginCommand.getAccessToken(user2) 147 const accessToken = await server.login.getAccessToken(user2)
148 148
149 const user = await server.usersCommand.getMyInfo({ token: accessToken }) 149 const user = await server.users.getMyInfo({ token: accessToken })
150 expect(user.emailVerified).to.be.null 150 expect(user.emailVerified).to.be.null
151 }) 151 })
152 152
153 it('Should allow login for user with unverified email when setting later enabled', async function () { 153 it('Should allow login for user with unverified email when setting later enabled', async function () {
154 await server.configCommand.updateCustomSubConfig({ 154 await server.config.updateCustomSubConfig({
155 newConfig: { 155 newConfig: {
156 signup: { 156 signup: {
157 enabled: true, 157 enabled: true,
@@ -161,7 +161,7 @@ describe('Test users account verification', function () {
161 } 161 }
162 }) 162 })
163 163
164 await server.loginCommand.getAccessToken(user2) 164 await server.login.getAccessToken(user2)
165 }) 165 })
166 166
167 after(async function () { 167 after(async function () {
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 6f3873939..310136a37 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -42,7 +42,7 @@ describe('Test users', function () {
42 42
43 await setAccessTokensToServers([ server ]) 43 await setAccessTokensToServers([ server ])
44 44
45 await server.pluginsCommand.install({ npmName: 'peertube-theme-background-red' }) 45 await server.plugins.install({ npmName: 'peertube-theme-background-red' })
46 }) 46 })
47 47
48 describe('OAuth client', function () { 48 describe('OAuth client', function () {
@@ -53,8 +53,8 @@ describe('Test users', function () {
53 it('Should remove the last client') 53 it('Should remove the last client')
54 54
55 it('Should not login with an invalid client id', async function () { 55 it('Should not login with an invalid client id', async function () {
56 const client = { id: 'client', secret: server.client.secret } 56 const client = { id: 'client', secret: server.store.client.secret }
57 const body = await server.loginCommand.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 57 const body = await server.login.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
58 58
59 expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT) 59 expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
60 expect(body.error).to.contain('client is invalid') 60 expect(body.error).to.contain('client is invalid')
@@ -63,8 +63,8 @@ describe('Test users', function () {
63 }) 63 })
64 64
65 it('Should not login with an invalid client secret', async function () { 65 it('Should not login with an invalid client secret', async function () {
66 const client = { id: server.client.id, secret: 'coucou' } 66 const client = { id: server.store.client.id, secret: 'coucou' }
67 const body = await server.loginCommand.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 67 const body = await server.login.login({ client, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
68 68
69 expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT) 69 expect(body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
70 expect(body.error).to.contain('client is invalid') 70 expect(body.error).to.contain('client is invalid')
@@ -76,8 +76,8 @@ describe('Test users', function () {
76 describe('Login', function () { 76 describe('Login', function () {
77 77
78 it('Should not login with an invalid username', async function () { 78 it('Should not login with an invalid username', async function () {
79 const user = { username: 'captain crochet', password: server.user.password } 79 const user = { username: 'captain crochet', password: server.store.user.password }
80 const body = await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 80 const body = await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
81 81
82 expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT) 82 expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
83 expect(body.error).to.contain('credentials are invalid') 83 expect(body.error).to.contain('credentials are invalid')
@@ -86,8 +86,8 @@ describe('Test users', function () {
86 }) 86 })
87 87
88 it('Should not login with an invalid password', async function () { 88 it('Should not login with an invalid password', async function () {
89 const user = { username: server.user.username, password: 'mew_three' } 89 const user = { username: server.store.user.username, password: 'mew_three' }
90 const body = await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 90 const body = await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
91 91
92 expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT) 92 expect(body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
93 expect(body.error).to.contain('credentials are invalid') 93 expect(body.error).to.contain('credentials are invalid')
@@ -98,13 +98,13 @@ describe('Test users', function () {
98 it('Should not be able to upload a video', async function () { 98 it('Should not be able to upload a video', async function () {
99 token = 'my_super_token' 99 token = 'my_super_token'
100 100
101 await server.videosCommand.upload({ token, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 101 await server.videos.upload({ token, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
102 }) 102 })
103 103
104 it('Should not be able to follow', async function () { 104 it('Should not be able to follow', async function () {
105 token = 'my_super_token' 105 token = 'my_super_token'
106 106
107 await server.followsCommand.follow({ 107 await server.follows.follow({
108 targets: [ 'http://example.com' ], 108 targets: [ 'http://example.com' ],
109 token, 109 token,
110 expectedStatus: HttpStatusCode.UNAUTHORIZED_401 110 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
@@ -114,28 +114,28 @@ describe('Test users', function () {
114 it('Should not be able to unfollow') 114 it('Should not be able to unfollow')
115 115
116 it('Should be able to login', async function () { 116 it('Should be able to login', async function () {
117 const body = await server.loginCommand.login({ expectedStatus: HttpStatusCode.OK_200 }) 117 const body = await server.login.login({ expectedStatus: HttpStatusCode.OK_200 })
118 118
119 token = body.access_token 119 token = body.access_token
120 }) 120 })
121 121
122 it('Should be able to login with an insensitive username', async function () { 122 it('Should be able to login with an insensitive username', async function () {
123 const user = { username: 'RoOt', password: server.user.password } 123 const user = { username: 'RoOt', password: server.store.user.password }
124 await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.OK_200 }) 124 await server.login.login({ user, expectedStatus: HttpStatusCode.OK_200 })
125 125
126 const user2 = { username: 'rOoT', password: server.user.password } 126 const user2 = { username: 'rOoT', password: server.store.user.password }
127 await server.loginCommand.login({ user: user2, expectedStatus: HttpStatusCode.OK_200 }) 127 await server.login.login({ user: user2, expectedStatus: HttpStatusCode.OK_200 })
128 128
129 const user3 = { username: 'ROOt', password: server.user.password } 129 const user3 = { username: 'ROOt', password: server.store.user.password }
130 await server.loginCommand.login({ user: user3, expectedStatus: HttpStatusCode.OK_200 }) 130 await server.login.login({ user: user3, expectedStatus: HttpStatusCode.OK_200 })
131 }) 131 })
132 }) 132 })
133 133
134 describe('Upload', function () { 134 describe('Upload', function () {
135 135
136 it('Should upload the video with the correct token', async function () { 136 it('Should upload the video with the correct token', async function () {
137 await server.videosCommand.upload({ token }) 137 await server.videos.upload({ token })
138 const { data } = await server.videosCommand.list() 138 const { data } = await server.videos.list()
139 const video = data[0] 139 const video = data[0]
140 140
141 expect(video.account.name).to.equal('root') 141 expect(video.account.name).to.equal('root')
@@ -143,24 +143,24 @@ describe('Test users', function () {
143 }) 143 })
144 144
145 it('Should upload the video again with the correct token', async function () { 145 it('Should upload the video again with the correct token', async function () {
146 await server.videosCommand.upload({ token }) 146 await server.videos.upload({ token })
147 }) 147 })
148 }) 148 })
149 149
150 describe('Ratings', function () { 150 describe('Ratings', function () {
151 151
152 it('Should retrieve a video rating', async function () { 152 it('Should retrieve a video rating', async function () {
153 await server.videosCommand.rate({ id: videoId, rating: 'like' }) 153 await server.videos.rate({ id: videoId, rating: 'like' })
154 const rating = await server.usersCommand.getMyRating({ token, videoId }) 154 const rating = await server.users.getMyRating({ token, videoId })
155 155
156 expect(rating.videoId).to.equal(videoId) 156 expect(rating.videoId).to.equal(videoId)
157 expect(rating.rating).to.equal('like') 157 expect(rating.rating).to.equal('like')
158 }) 158 })
159 159
160 it('Should retrieve ratings list', async function () { 160 it('Should retrieve ratings list', async function () {
161 await server.videosCommand.rate({ id: videoId, rating: 'like' }) 161 await server.videos.rate({ id: videoId, rating: 'like' })
162 162
163 const body = await server.accountsCommand.listRatings({ accountName: server.user.username }) 163 const body = await server.accounts.listRatings({ accountName: server.store.user.username })
164 164
165 expect(body.total).to.equal(1) 165 expect(body.total).to.equal(1)
166 expect(body.data[0].video.id).to.equal(videoId) 166 expect(body.data[0].video.id).to.equal(videoId)
@@ -169,12 +169,12 @@ describe('Test users', function () {
169 169
170 it('Should retrieve ratings list by rating type', async function () { 170 it('Should retrieve ratings list by rating type', async function () {
171 { 171 {
172 const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'like' }) 172 const body = await server.accounts.listRatings({ accountName: server.store.user.username, rating: 'like' })
173 expect(body.data.length).to.equal(1) 173 expect(body.data.length).to.equal(1)
174 } 174 }
175 175
176 { 176 {
177 const body = await server.accountsCommand.listRatings({ accountName: server.user.username, rating: 'dislike' }) 177 const body = await server.accounts.listRatings({ accountName: server.store.user.username, rating: 'dislike' })
178 expect(body.data.length).to.equal(0) 178 expect(body.data.length).to.equal(0)
179 } 179 }
180 }) 180 })
@@ -182,27 +182,27 @@ describe('Test users', function () {
182 182
183 describe('Remove video', function () { 183 describe('Remove video', function () {
184 it('Should not be able to remove the video with an incorrect token', async function () { 184 it('Should not be able to remove the video with an incorrect token', async function () {
185 await server.videosCommand.remove({ token: 'bad_token', id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 185 await server.videos.remove({ token: 'bad_token', id: videoId, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
186 }) 186 })
187 187
188 it('Should not be able to remove the video with the token of another account') 188 it('Should not be able to remove the video with the token of another account')
189 189
190 it('Should be able to remove the video with the correct token', async function () { 190 it('Should be able to remove the video with the correct token', async function () {
191 await server.videosCommand.remove({ token, id: videoId }) 191 await server.videos.remove({ token, id: videoId })
192 }) 192 })
193 }) 193 })
194 194
195 describe('Logout', function () { 195 describe('Logout', function () {
196 it('Should logout (revoke token)', async function () { 196 it('Should logout (revoke token)', async function () {
197 await server.loginCommand.logout({ token: server.accessToken }) 197 await server.login.logout({ token: server.accessToken })
198 }) 198 })
199 199
200 it('Should not be able to get the user information', async function () { 200 it('Should not be able to get the user information', async function () {
201 await server.usersCommand.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 201 await server.users.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
202 }) 202 })
203 203
204 it('Should not be able to upload a video', async function () { 204 it('Should not be able to upload a video', async function () {
205 await server.videosCommand.upload({ attributes: { name: 'video' }, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 205 await server.videos.upload({ attributes: { name: 'video' }, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
206 }) 206 })
207 207
208 it('Should not be able to rate a video', async function () { 208 it('Should not be able to rate a video', async function () {
@@ -222,64 +222,64 @@ describe('Test users', function () {
222 }) 222 })
223 223
224 it('Should be able to login again', async function () { 224 it('Should be able to login again', async function () {
225 const body = await server.loginCommand.login() 225 const body = await server.login.login()
226 server.accessToken = body.access_token 226 server.accessToken = body.access_token
227 server.refreshToken = body.refresh_token 227 server.refreshToken = body.refresh_token
228 }) 228 })
229 229
230 it('Should be able to get my user information again', async function () { 230 it('Should be able to get my user information again', async function () {
231 await server.usersCommand.getMyInfo() 231 await server.users.getMyInfo()
232 }) 232 })
233 233
234 it('Should have an expired access token', async function () { 234 it('Should have an expired access token', async function () {
235 this.timeout(15000) 235 this.timeout(15000)
236 236
237 await server.sqlCommand.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString()) 237 await server.sql.setTokenField(server.accessToken, 'accessTokenExpiresAt', new Date().toISOString())
238 await server.sqlCommand.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString()) 238 await server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', new Date().toISOString())
239 239
240 await killallServers([ server ]) 240 await killallServers([ server ])
241 await reRunServer(server) 241 await reRunServer(server)
242 242
243 await server.usersCommand.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 243 await server.users.getMyInfo({ expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
244 }) 244 })
245 245
246 it('Should not be able to refresh an access token with an expired refresh token', async function () { 246 it('Should not be able to refresh an access token with an expired refresh token', async function () {
247 await server.loginCommand.refreshToken({ refreshToken: server.refreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 247 await server.login.refreshToken({ refreshToken: server.refreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
248 }) 248 })
249 249
250 it('Should refresh the token', async function () { 250 it('Should refresh the token', async function () {
251 this.timeout(15000) 251 this.timeout(15000)
252 252
253 const futureDate = new Date(new Date().getTime() + 1000 * 60).toISOString() 253 const futureDate = new Date(new Date().getTime() + 1000 * 60).toISOString()
254 await server.sqlCommand.setTokenField(server.accessToken, 'refreshTokenExpiresAt', futureDate) 254 await server.sql.setTokenField(server.accessToken, 'refreshTokenExpiresAt', futureDate)
255 255
256 await killallServers([ server ]) 256 await killallServers([ server ])
257 await reRunServer(server) 257 await reRunServer(server)
258 258
259 const res = await server.loginCommand.refreshToken({ refreshToken: server.refreshToken }) 259 const res = await server.login.refreshToken({ refreshToken: server.refreshToken })
260 server.accessToken = res.body.access_token 260 server.accessToken = res.body.access_token
261 server.refreshToken = res.body.refresh_token 261 server.refreshToken = res.body.refresh_token
262 }) 262 })
263 263
264 it('Should be able to get my user information again', async function () { 264 it('Should be able to get my user information again', async function () {
265 await server.usersCommand.getMyInfo() 265 await server.users.getMyInfo()
266 }) 266 })
267 }) 267 })
268 268
269 describe('Creating a user', function () { 269 describe('Creating a user', function () {
270 270
271 it('Should be able to create a new user', async function () { 271 it('Should be able to create a new user', async function () {
272 await server.usersCommand.create({ ...user, videoQuota: 2 * 1024 * 1024, adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST }) 272 await server.users.create({ ...user, videoQuota: 2 * 1024 * 1024, adminFlags: UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST })
273 }) 273 })
274 274
275 it('Should be able to login with this user', async function () { 275 it('Should be able to login with this user', async function () {
276 userToken = await server.loginCommand.getAccessToken(user) 276 userToken = await server.login.getAccessToken(user)
277 }) 277 })
278 278
279 it('Should be able to get user information', async function () { 279 it('Should be able to get user information', async function () {
280 const userMe = await server.usersCommand.getMyInfo({ token: userToken }) 280 const userMe = await server.users.getMyInfo({ token: userToken })
281 281
282 const userGet = await server.usersCommand.get({ userId: userMe.id, withStats: true }) 282 const userGet = await server.users.get({ userId: userMe.id, withStats: true })
283 283
284 for (const user of [ userMe, userGet ]) { 284 for (const user of [ userMe, userGet ]) {
285 expect(user.username).to.equal('user_1') 285 expect(user.username).to.equal('user_1')
@@ -319,20 +319,20 @@ describe('Test users', function () {
319 name: 'super user video', 319 name: 'super user video',
320 fixture: 'video_short.webm' 320 fixture: 'video_short.webm'
321 } 321 }
322 await server.videosCommand.upload({ token: userToken, attributes }) 322 await server.videos.upload({ token: userToken, attributes })
323 }) 323 })
324 324
325 it('Should have video quota updated', async function () { 325 it('Should have video quota updated', async function () {
326 const quota = await server.usersCommand.getMyQuotaUsed({ token: userToken }) 326 const quota = await server.users.getMyQuotaUsed({ token: userToken })
327 expect(quota.videoQuotaUsed).to.equal(218910) 327 expect(quota.videoQuotaUsed).to.equal(218910)
328 328
329 const { data } = await server.usersCommand.list() 329 const { data } = await server.users.list()
330 const tmpUser = data.find(u => u.username === user.username) 330 const tmpUser = data.find(u => u.username === user.username)
331 expect(tmpUser.videoQuotaUsed).to.equal(218910) 331 expect(tmpUser.videoQuotaUsed).to.equal(218910)
332 }) 332 })
333 333
334 it('Should be able to list my videos', async function () { 334 it('Should be able to list my videos', async function () {
335 const { total, data } = await server.videosCommand.listMyVideos({ token: userToken }) 335 const { total, data } = await server.videos.listMyVideos({ token: userToken })
336 expect(total).to.equal(1) 336 expect(total).to.equal(1)
337 expect(data).to.have.lengthOf(1) 337 expect(data).to.have.lengthOf(1)
338 338
@@ -344,13 +344,13 @@ describe('Test users', function () {
344 344
345 it('Should be able to search in my videos', async function () { 345 it('Should be able to search in my videos', async function () {
346 { 346 {
347 const { total, data } = await server.videosCommand.listMyVideos({ token: userToken, sort: '-createdAt', search: 'user video' }) 347 const { total, data } = await server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'user video' })
348 expect(total).to.equal(1) 348 expect(total).to.equal(1)
349 expect(data).to.have.lengthOf(1) 349 expect(data).to.have.lengthOf(1)
350 } 350 }
351 351
352 { 352 {
353 const { total, data } = await server.videosCommand.listMyVideos({ token: userToken, sort: '-createdAt', search: 'toto' }) 353 const { total, data } = await server.videos.listMyVideos({ token: userToken, sort: '-createdAt', search: 'toto' })
354 expect(total).to.equal(0) 354 expect(total).to.equal(0)
355 expect(data).to.have.lengthOf(0) 355 expect(data).to.have.lengthOf(0)
356 } 356 }
@@ -360,11 +360,11 @@ describe('Test users', function () {
360 this.timeout(60000) 360 this.timeout(60000)
361 361
362 { 362 {
363 const config = await server.configCommand.getCustomConfig() 363 const config = await server.config.getCustomConfig()
364 config.transcoding.webtorrent.enabled = false 364 config.transcoding.webtorrent.enabled = false
365 config.transcoding.hls.enabled = true 365 config.transcoding.hls.enabled = true
366 config.transcoding.enabled = true 366 config.transcoding.enabled = true
367 await server.configCommand.updateCustomSubConfig({ newConfig: config }) 367 await server.config.updateCustomSubConfig({ newConfig: config })
368 } 368 }
369 369
370 { 370 {
@@ -372,13 +372,13 @@ describe('Test users', function () {
372 name: 'super user video 2', 372 name: 'super user video 2',
373 fixture: 'video_short.webm' 373 fixture: 'video_short.webm'
374 } 374 }
375 await server.videosCommand.upload({ token: userToken, attributes }) 375 await server.videos.upload({ token: userToken, attributes })
376 376
377 await waitJobs([ server ]) 377 await waitJobs([ server ])
378 } 378 }
379 379
380 { 380 {
381 const data = await server.usersCommand.getMyQuotaUsed({ token: userToken }) 381 const data = await server.users.getMyQuotaUsed({ token: userToken })
382 expect(data.videoQuotaUsed).to.be.greaterThan(220000) 382 expect(data.videoQuotaUsed).to.be.greaterThan(220000)
383 } 383 }
384 }) 384 })
@@ -387,7 +387,7 @@ describe('Test users', function () {
387 describe('Users listing', function () { 387 describe('Users listing', function () {
388 388
389 it('Should list all the users', async function () { 389 it('Should list all the users', async function () {
390 const { data, total } = await server.usersCommand.list() 390 const { data, total } = await server.users.list()
391 391
392 expect(total).to.equal(2) 392 expect(total).to.equal(2)
393 expect(data).to.be.an('array') 393 expect(data).to.be.an('array')
@@ -410,7 +410,7 @@ describe('Test users', function () {
410 }) 410 })
411 411
412 it('Should list only the first user by username asc', async function () { 412 it('Should list only the first user by username asc', async function () {
413 const { total, data } = await server.usersCommand.list({ start: 0, count: 1, sort: 'username' }) 413 const { total, data } = await server.users.list({ start: 0, count: 1, sort: 'username' })
414 414
415 expect(total).to.equal(2) 415 expect(total).to.equal(2)
416 expect(data.length).to.equal(1) 416 expect(data.length).to.equal(1)
@@ -423,7 +423,7 @@ describe('Test users', function () {
423 }) 423 })
424 424
425 it('Should list only the first user by username desc', async function () { 425 it('Should list only the first user by username desc', async function () {
426 const { total, data } = await server.usersCommand.list({ start: 0, count: 1, sort: '-username' }) 426 const { total, data } = await server.users.list({ start: 0, count: 1, sort: '-username' })
427 427
428 expect(total).to.equal(2) 428 expect(total).to.equal(2)
429 expect(data.length).to.equal(1) 429 expect(data.length).to.equal(1)
@@ -435,7 +435,7 @@ describe('Test users', function () {
435 }) 435 })
436 436
437 it('Should list only the second user by createdAt desc', async function () { 437 it('Should list only the second user by createdAt desc', async function () {
438 const { data, total } = await server.usersCommand.list({ start: 0, count: 1, sort: '-createdAt' }) 438 const { data, total } = await server.users.list({ start: 0, count: 1, sort: '-createdAt' })
439 expect(total).to.equal(2) 439 expect(total).to.equal(2)
440 440
441 expect(data.length).to.equal(1) 441 expect(data.length).to.equal(1)
@@ -447,7 +447,7 @@ describe('Test users', function () {
447 }) 447 })
448 448
449 it('Should list all the users by createdAt asc', async function () { 449 it('Should list all the users by createdAt asc', async function () {
450 const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt' }) 450 const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt' })
451 451
452 expect(total).to.equal(2) 452 expect(total).to.equal(2)
453 expect(data.length).to.equal(2) 453 expect(data.length).to.equal(2)
@@ -462,7 +462,7 @@ describe('Test users', function () {
462 }) 462 })
463 463
464 it('Should search user by username', async function () { 464 it('Should search user by username', async function () {
465 const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'oot' }) 465 const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'oot' })
466 expect(total).to.equal(1) 466 expect(total).to.equal(1)
467 expect(data.length).to.equal(1) 467 expect(data.length).to.equal(1)
468 expect(data[0].username).to.equal('root') 468 expect(data[0].username).to.equal('root')
@@ -470,7 +470,7 @@ describe('Test users', function () {
470 470
471 it('Should search user by email', async function () { 471 it('Should search user by email', async function () {
472 { 472 {
473 const { total, data } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'r_1@exam' }) 473 const { total, data } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'r_1@exam' })
474 expect(total).to.equal(1) 474 expect(total).to.equal(1)
475 expect(data.length).to.equal(1) 475 expect(data.length).to.equal(1)
476 expect(data[0].username).to.equal('user_1') 476 expect(data[0].username).to.equal('user_1')
@@ -478,7 +478,7 @@ describe('Test users', function () {
478 } 478 }
479 479
480 { 480 {
481 const { total, data } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', search: 'example' }) 481 const { total, data } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', search: 'example' })
482 expect(total).to.equal(2) 482 expect(total).to.equal(2)
483 expect(data.length).to.equal(2) 483 expect(data.length).to.equal(2)
484 expect(data[0].username).to.equal('root') 484 expect(data[0].username).to.equal('root')
@@ -490,23 +490,23 @@ describe('Test users', function () {
490 describe('Update my account', function () { 490 describe('Update my account', function () {
491 491
492 it('Should update my password', async function () { 492 it('Should update my password', async function () {
493 await server.usersCommand.updateMe({ 493 await server.users.updateMe({
494 token: userToken, 494 token: userToken,
495 currentPassword: 'super password', 495 currentPassword: 'super password',
496 password: 'new password' 496 password: 'new password'
497 }) 497 })
498 user.password = 'new password' 498 user.password = 'new password'
499 499
500 await server.loginCommand.login({ user }) 500 await server.login.login({ user })
501 }) 501 })
502 502
503 it('Should be able to change the NSFW display attribute', async function () { 503 it('Should be able to change the NSFW display attribute', async function () {
504 await server.usersCommand.updateMe({ 504 await server.users.updateMe({
505 token: userToken, 505 token: userToken,
506 nsfwPolicy: 'do_not_list' 506 nsfwPolicy: 'do_not_list'
507 }) 507 })
508 508
509 const user = await server.usersCommand.getMyInfo({ token: userToken }) 509 const user = await server.users.getMyInfo({ token: userToken })
510 expect(user.username).to.equal('user_1') 510 expect(user.username).to.equal('user_1')
511 expect(user.email).to.equal('user_1@example.com') 511 expect(user.email).to.equal('user_1@example.com')
512 expect(user.nsfwPolicy).to.equal('do_not_list') 512 expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -517,33 +517,33 @@ describe('Test users', function () {
517 }) 517 })
518 518
519 it('Should be able to change the autoPlayVideo attribute', async function () { 519 it('Should be able to change the autoPlayVideo attribute', async function () {
520 await server.usersCommand.updateMe({ 520 await server.users.updateMe({
521 token: userToken, 521 token: userToken,
522 autoPlayVideo: false 522 autoPlayVideo: false
523 }) 523 })
524 524
525 const user = await server.usersCommand.getMyInfo({ token: userToken }) 525 const user = await server.users.getMyInfo({ token: userToken })
526 expect(user.autoPlayVideo).to.be.false 526 expect(user.autoPlayVideo).to.be.false
527 }) 527 })
528 528
529 it('Should be able to change the autoPlayNextVideo attribute', async function () { 529 it('Should be able to change the autoPlayNextVideo attribute', async function () {
530 await server.usersCommand.updateMe({ 530 await server.users.updateMe({
531 token: userToken, 531 token: userToken,
532 autoPlayNextVideo: true 532 autoPlayNextVideo: true
533 }) 533 })
534 534
535 const user = await server.usersCommand.getMyInfo({ token: userToken }) 535 const user = await server.users.getMyInfo({ token: userToken })
536 expect(user.autoPlayNextVideo).to.be.true 536 expect(user.autoPlayNextVideo).to.be.true
537 }) 537 })
538 538
539 it('Should be able to change the email attribute', async function () { 539 it('Should be able to change the email attribute', async function () {
540 await server.usersCommand.updateMe({ 540 await server.users.updateMe({
541 token: userToken, 541 token: userToken,
542 currentPassword: 'new password', 542 currentPassword: 'new password',
543 email: 'updated@example.com' 543 email: 'updated@example.com'
544 }) 544 })
545 545
546 const user = await server.usersCommand.getMyInfo({ token: userToken }) 546 const user = await server.users.getMyInfo({ token: userToken })
547 expect(user.username).to.equal('user_1') 547 expect(user.username).to.equal('user_1')
548 expect(user.email).to.equal('updated@example.com') 548 expect(user.email).to.equal('updated@example.com')
549 expect(user.nsfwPolicy).to.equal('do_not_list') 549 expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -556,9 +556,9 @@ describe('Test users', function () {
556 it('Should be able to update my avatar with a gif', async function () { 556 it('Should be able to update my avatar with a gif', async function () {
557 const fixture = 'avatar.gif' 557 const fixture = 'avatar.gif'
558 558
559 await server.usersCommand.updateMyAvatar({ token: userToken, fixture }) 559 await server.users.updateMyAvatar({ token: userToken, fixture })
560 560
561 const user = await server.usersCommand.getMyInfo({ token: userToken }) 561 const user = await server.users.getMyInfo({ token: userToken })
562 await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.gif') 562 await testImage(server.url, 'avatar-resized', user.account.avatar.path, '.gif')
563 }) 563 })
564 564
@@ -566,17 +566,17 @@ describe('Test users', function () {
566 for (const extension of [ '.png', '.gif' ]) { 566 for (const extension of [ '.png', '.gif' ]) {
567 const fixture = 'avatar' + extension 567 const fixture = 'avatar' + extension
568 568
569 await server.usersCommand.updateMyAvatar({ token: userToken, fixture }) 569 await server.users.updateMyAvatar({ token: userToken, fixture })
570 570
571 const user = await server.usersCommand.getMyInfo({ token: userToken }) 571 const user = await server.users.getMyInfo({ token: userToken })
572 await testImage(server.url, 'avatar-resized', user.account.avatar.path, extension) 572 await testImage(server.url, 'avatar-resized', user.account.avatar.path, extension)
573 } 573 }
574 }) 574 })
575 575
576 it('Should be able to update my display name', async function () { 576 it('Should be able to update my display name', async function () {
577 await server.usersCommand.updateMe({ token: userToken, displayName: 'new display name' }) 577 await server.users.updateMe({ token: userToken, displayName: 'new display name' })
578 578
579 const user = await server.usersCommand.getMyInfo({ token: userToken }) 579 const user = await server.users.getMyInfo({ token: userToken })
580 expect(user.username).to.equal('user_1') 580 expect(user.username).to.equal('user_1')
581 expect(user.email).to.equal('updated@example.com') 581 expect(user.email).to.equal('updated@example.com')
582 expect(user.nsfwPolicy).to.equal('do_not_list') 582 expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -587,9 +587,9 @@ describe('Test users', function () {
587 }) 587 })
588 588
589 it('Should be able to update my description', async function () { 589 it('Should be able to update my description', async function () {
590 await server.usersCommand.updateMe({ token: userToken, description: 'my super description updated' }) 590 await server.users.updateMe({ token: userToken, description: 'my super description updated' })
591 591
592 const user = await server.usersCommand.getMyInfo({ token: userToken }) 592 const user = await server.users.getMyInfo({ token: userToken })
593 expect(user.username).to.equal('user_1') 593 expect(user.username).to.equal('user_1')
594 expect(user.email).to.equal('updated@example.com') 594 expect(user.email).to.equal('updated@example.com')
595 expect(user.nsfwPolicy).to.equal('do_not_list') 595 expect(user.nsfwPolicy).to.equal('do_not_list')
@@ -603,21 +603,21 @@ describe('Test users', function () {
603 603
604 it('Should be able to update my theme', async function () { 604 it('Should be able to update my theme', async function () {
605 for (const theme of [ 'background-red', 'default', 'instance-default' ]) { 605 for (const theme of [ 'background-red', 'default', 'instance-default' ]) {
606 await server.usersCommand.updateMe({ token: userToken, theme }) 606 await server.users.updateMe({ token: userToken, theme })
607 607
608 const user = await server.usersCommand.getMyInfo({ token: userToken }) 608 const user = await server.users.getMyInfo({ token: userToken })
609 expect(user.theme).to.equal(theme) 609 expect(user.theme).to.equal(theme)
610 } 610 }
611 }) 611 })
612 612
613 it('Should be able to update my modal preferences', async function () { 613 it('Should be able to update my modal preferences', async function () {
614 await server.usersCommand.updateMe({ 614 await server.users.updateMe({
615 token: userToken, 615 token: userToken,
616 noInstanceConfigWarningModal: true, 616 noInstanceConfigWarningModal: true,
617 noWelcomeModal: true 617 noWelcomeModal: true
618 }) 618 })
619 619
620 const user = await server.usersCommand.getMyInfo({ token: userToken }) 620 const user = await server.users.getMyInfo({ token: userToken })
621 expect(user.noWelcomeModal).to.be.true 621 expect(user.noWelcomeModal).to.be.true
622 expect(user.noInstanceConfigWarningModal).to.be.true 622 expect(user.noInstanceConfigWarningModal).to.be.true
623 }) 623 })
@@ -625,7 +625,7 @@ describe('Test users', function () {
625 625
626 describe('Updating another user', function () { 626 describe('Updating another user', function () {
627 it('Should be able to update another user', async function () { 627 it('Should be able to update another user', async function () {
628 await server.usersCommand.update({ 628 await server.users.update({
629 userId, 629 userId,
630 token, 630 token,
631 email: 'updated2@example.com', 631 email: 'updated2@example.com',
@@ -636,7 +636,7 @@ describe('Test users', function () {
636 pluginAuth: 'toto' 636 pluginAuth: 'toto'
637 }) 637 })
638 638
639 const user = await server.usersCommand.get({ token, userId }) 639 const user = await server.users.get({ token, userId })
640 640
641 expect(user.username).to.equal('user_1') 641 expect(user.username).to.equal('user_1')
642 expect(user.email).to.equal('updated2@example.com') 642 expect(user.email).to.equal('updated2@example.com')
@@ -650,47 +650,47 @@ describe('Test users', function () {
650 }) 650 })
651 651
652 it('Should reset the auth plugin', async function () { 652 it('Should reset the auth plugin', async function () {
653 await server.usersCommand.update({ userId, token, pluginAuth: null }) 653 await server.users.update({ userId, token, pluginAuth: null })
654 654
655 const user = await server.usersCommand.get({ token, userId }) 655 const user = await server.users.get({ token, userId })
656 expect(user.pluginAuth).to.be.null 656 expect(user.pluginAuth).to.be.null
657 }) 657 })
658 658
659 it('Should have removed the user token', async function () { 659 it('Should have removed the user token', async function () {
660 await server.usersCommand.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 660 await server.users.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
661 661
662 userToken = await server.loginCommand.getAccessToken(user) 662 userToken = await server.login.getAccessToken(user)
663 }) 663 })
664 664
665 it('Should be able to update another user password', async function () { 665 it('Should be able to update another user password', async function () {
666 await server.usersCommand.update({ userId, token, password: 'password updated' }) 666 await server.users.update({ userId, token, password: 'password updated' })
667 667
668 await server.usersCommand.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 668 await server.users.getMyQuotaUsed({ token: userToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
669 669
670 await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 670 await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
671 671
672 user.password = 'password updated' 672 user.password = 'password updated'
673 userToken = await server.loginCommand.getAccessToken(user) 673 userToken = await server.login.getAccessToken(user)
674 }) 674 })
675 }) 675 })
676 676
677 describe('Video blacklists', function () { 677 describe('Video blacklists', function () {
678 it('Should be able to list video blacklist by a moderator', async function () { 678 it('Should be able to list video blacklist by a moderator', async function () {
679 await server.blacklistCommand.list({ token: userToken }) 679 await server.blacklist.list({ token: userToken })
680 }) 680 })
681 }) 681 })
682 682
683 describe('Remove a user', function () { 683 describe('Remove a user', function () {
684 it('Should be able to remove this user', async function () { 684 it('Should be able to remove this user', async function () {
685 await server.usersCommand.remove({ userId, token }) 685 await server.users.remove({ userId, token })
686 }) 686 })
687 687
688 it('Should not be able to login with this user', async function () { 688 it('Should not be able to login with this user', async function () {
689 await server.loginCommand.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 689 await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
690 }) 690 })
691 691
692 it('Should not have videos of this user', async function () { 692 it('Should not have videos of this user', async function () {
693 const { data, total } = await server.videosCommand.list() 693 const { data, total } = await server.videos.list()
694 expect(total).to.equal(1) 694 expect(total).to.equal(1)
695 695
696 const video = data[0] 696 const video = data[0]
@@ -705,7 +705,7 @@ describe('Test users', function () {
705 const user = { displayName: 'super user 15', username: 'user_15', password: 'my super password' } 705 const user = { displayName: 'super user 15', username: 'user_15', password: 'my super password' }
706 const channel = { name: 'my_user_15_channel', displayName: 'my channel rocks' } 706 const channel = { name: 'my_user_15_channel', displayName: 'my channel rocks' }
707 707
708 await server.usersCommand.register({ ...user, channel }) 708 await server.users.register({ ...user, channel })
709 }) 709 })
710 710
711 it('Should be able to login with this registered user', async function () { 711 it('Should be able to login with this registered user', async function () {
@@ -714,35 +714,35 @@ describe('Test users', function () {
714 password: 'my super password' 714 password: 'my super password'
715 } 715 }
716 716
717 user15AccessToken = await server.loginCommand.getAccessToken(user15) 717 user15AccessToken = await server.login.getAccessToken(user15)
718 }) 718 })
719 719
720 it('Should have the correct display name', async function () { 720 it('Should have the correct display name', async function () {
721 const user = await server.usersCommand.getMyInfo({ token: user15AccessToken }) 721 const user = await server.users.getMyInfo({ token: user15AccessToken })
722 expect(user.account.displayName).to.equal('super user 15') 722 expect(user.account.displayName).to.equal('super user 15')
723 }) 723 })
724 724
725 it('Should have the correct video quota', async function () { 725 it('Should have the correct video quota', async function () {
726 const user = await server.usersCommand.getMyInfo({ token: user15AccessToken }) 726 const user = await server.users.getMyInfo({ token: user15AccessToken })
727 expect(user.videoQuota).to.equal(5 * 1024 * 1024) 727 expect(user.videoQuota).to.equal(5 * 1024 * 1024)
728 }) 728 })
729 729
730 it('Should have created the channel', async function () { 730 it('Should have created the channel', async function () {
731 const { displayName } = await server.channelsCommand.get({ channelName: 'my_user_15_channel' }) 731 const { displayName } = await server.channels.get({ channelName: 'my_user_15_channel' })
732 732
733 expect(displayName).to.equal('my channel rocks') 733 expect(displayName).to.equal('my channel rocks')
734 }) 734 })
735 735
736 it('Should remove me', async function () { 736 it('Should remove me', async function () {
737 { 737 {
738 const { data } = await server.usersCommand.list() 738 const { data } = await server.users.list()
739 expect(data.find(u => u.username === 'user_15')).to.not.be.undefined 739 expect(data.find(u => u.username === 'user_15')).to.not.be.undefined
740 } 740 }
741 741
742 await server.usersCommand.deleteMe({ token: user15AccessToken }) 742 await server.users.deleteMe({ token: user15AccessToken })
743 743
744 { 744 {
745 const { data } = await server.usersCommand.list() 745 const { data } = await server.users.list()
746 expect(data.find(u => u.username === 'user_15')).to.be.undefined 746 expect(data.find(u => u.username === 'user_15')).to.be.undefined
747 } 747 }
748 }) 748 })
@@ -757,21 +757,21 @@ describe('Test users', function () {
757 } 757 }
758 758
759 it('Should block a user', async function () { 759 it('Should block a user', async function () {
760 const user = await server.usersCommand.create({ ...user16 }) 760 const user = await server.users.create({ ...user16 })
761 user16Id = user.id 761 user16Id = user.id
762 762
763 user16AccessToken = await server.loginCommand.getAccessToken(user16) 763 user16AccessToken = await server.login.getAccessToken(user16)
764 764
765 await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 }) 765 await server.users.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
766 await server.usersCommand.banUser({ userId: user16Id }) 766 await server.users.banUser({ userId: user16Id })
767 767
768 await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 768 await server.users.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
769 await server.loginCommand.login({ user: user16, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 769 await server.login.login({ user: user16, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
770 }) 770 })
771 771
772 it('Should search user by banned status', async function () { 772 it('Should search user by banned status', async function () {
773 { 773 {
774 const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', blocked: true }) 774 const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', blocked: true })
775 expect(total).to.equal(1) 775 expect(total).to.equal(1)
776 expect(data.length).to.equal(1) 776 expect(data.length).to.equal(1)
777 777
@@ -779,7 +779,7 @@ describe('Test users', function () {
779 } 779 }
780 780
781 { 781 {
782 const { data, total } = await server.usersCommand.list({ start: 0, count: 2, sort: 'createdAt', blocked: false }) 782 const { data, total } = await server.users.list({ start: 0, count: 2, sort: 'createdAt', blocked: false })
783 expect(total).to.equal(1) 783 expect(total).to.equal(1)
784 expect(data.length).to.equal(1) 784 expect(data.length).to.equal(1)
785 785
@@ -788,9 +788,9 @@ describe('Test users', function () {
788 }) 788 })
789 789
790 it('Should unblock a user', async function () { 790 it('Should unblock a user', async function () {
791 await server.usersCommand.unbanUser({ userId: user16Id }) 791 await server.users.unbanUser({ userId: user16Id })
792 user16AccessToken = await server.loginCommand.getAccessToken(user16) 792 user16AccessToken = await server.login.getAccessToken(user16)
793 await server.usersCommand.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 }) 793 await server.users.getMyInfo({ token: user16AccessToken, expectedStatus: HttpStatusCode.OK_200 })
794 }) 794 })
795 }) 795 })
796 796
@@ -803,12 +803,12 @@ describe('Test users', function () {
803 username: 'user_17', 803 username: 'user_17',
804 password: 'my super password' 804 password: 'my super password'
805 } 805 }
806 const created = await server.usersCommand.create({ ...user17 }) 806 const created = await server.users.create({ ...user17 })
807 807
808 user17Id = created.id 808 user17Id = created.id
809 user17AccessToken = await server.loginCommand.getAccessToken(user17) 809 user17AccessToken = await server.login.getAccessToken(user17)
810 810
811 const user = await server.usersCommand.get({ userId: user17Id, withStats: true }) 811 const user = await server.users.get({ userId: user17Id, withStats: true })
812 expect(user.videosCount).to.equal(0) 812 expect(user.videosCount).to.equal(0)
813 expect(user.videoCommentsCount).to.equal(0) 813 expect(user.videoCommentsCount).to.equal(0)
814 expect(user.abusesCount).to.equal(0) 814 expect(user.abusesCount).to.equal(0)
@@ -818,37 +818,37 @@ describe('Test users', function () {
818 818
819 it('Should report correct videos count', async function () { 819 it('Should report correct videos count', async function () {
820 const attributes = { name: 'video to test user stats' } 820 const attributes = { name: 'video to test user stats' }
821 await server.videosCommand.upload({ token: user17AccessToken, attributes }) 821 await server.videos.upload({ token: user17AccessToken, attributes })
822 822
823 const { data } = await server.videosCommand.list() 823 const { data } = await server.videos.list()
824 videoId = data.find(video => video.name === attributes.name).id 824 videoId = data.find(video => video.name === attributes.name).id
825 825
826 const user = await server.usersCommand.get({ userId: user17Id, withStats: true }) 826 const user = await server.users.get({ userId: user17Id, withStats: true })
827 expect(user.videosCount).to.equal(1) 827 expect(user.videosCount).to.equal(1)
828 }) 828 })
829 829
830 it('Should report correct video comments for user', async function () { 830 it('Should report correct video comments for user', async function () {
831 const text = 'super comment' 831 const text = 'super comment'
832 await server.commentsCommand.createThread({ token: user17AccessToken, videoId, text }) 832 await server.comments.createThread({ token: user17AccessToken, videoId, text })
833 833
834 const user = await server.usersCommand.get({ userId: user17Id, withStats: true }) 834 const user = await server.users.get({ userId: user17Id, withStats: true })
835 expect(user.videoCommentsCount).to.equal(1) 835 expect(user.videoCommentsCount).to.equal(1)
836 }) 836 })
837 837
838 it('Should report correct abuses counts', async function () { 838 it('Should report correct abuses counts', async function () {
839 const reason = 'my super bad reason' 839 const reason = 'my super bad reason'
840 await server.abusesCommand.report({ token: user17AccessToken, videoId, reason }) 840 await server.abuses.report({ token: user17AccessToken, videoId, reason })
841 841
842 const body1 = await server.abusesCommand.getAdminList() 842 const body1 = await server.abuses.getAdminList()
843 const abuseId = body1.data[0].id 843 const abuseId = body1.data[0].id
844 844
845 const user2 = await server.usersCommand.get({ userId: user17Id, withStats: true }) 845 const user2 = await server.users.get({ userId: user17Id, withStats: true })
846 expect(user2.abusesCount).to.equal(1) // number of incriminations 846 expect(user2.abusesCount).to.equal(1) // number of incriminations
847 expect(user2.abusesCreatedCount).to.equal(1) // number of reports created 847 expect(user2.abusesCreatedCount).to.equal(1) // number of reports created
848 848
849 await server.abusesCommand.update({ abuseId, body: { state: AbuseState.ACCEPTED } }) 849 await server.abuses.update({ abuseId, body: { state: AbuseState.ACCEPTED } })
850 850
851 const user3 = await server.usersCommand.get({ userId: user17Id, withStats: true }) 851 const user3 = await server.users.get({ userId: user17Id, withStats: true })
852 expect(user3.abusesAcceptedCount).to.equal(1) // number of reports created accepted 852 expect(user3.abusesAcceptedCount).to.equal(1) // number of reports created accepted
853 }) 853 })
854 }) 854 })
diff --git a/server/tests/api/videos/audio-only.ts b/server/tests/api/videos/audio-only.ts
index e31905b36..b2952e38b 100644
--- a/server/tests/api/videos/audio-only.ts
+++ b/server/tests/api/videos/audio-only.ts
@@ -48,13 +48,13 @@ describe('Test audio only video transcoding', function () {
48 it('Should upload a video and transcode it', async function () { 48 it('Should upload a video and transcode it', async function () {
49 this.timeout(120000) 49 this.timeout(120000)
50 50
51 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'audio only' } }) 51 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'audio only' } })
52 videoUUID = uuid 52 videoUUID = uuid
53 53
54 await waitJobs(servers) 54 await waitJobs(servers)
55 55
56 for (const server of servers) { 56 for (const server of servers) {
57 const video = await server.videosCommand.get({ id: videoUUID }) 57 const video = await server.videos.get({ id: videoUUID })
58 expect(video.streamingPlaylists).to.have.lengthOf(1) 58 expect(video.streamingPlaylists).to.have.lengthOf(1)
59 59
60 for (const files of [ video.files, video.streamingPlaylists[0].files ]) { 60 for (const files of [ video.files, video.streamingPlaylists[0].files ]) {
@@ -68,8 +68,8 @@ describe('Test audio only video transcoding', function () {
68 68
69 it('0p transcoded video should not have video', async function () { 69 it('0p transcoded video should not have video', async function () {
70 const paths = [ 70 const paths = [
71 servers[0].serversCommand.buildDirectory(join('videos', videoUUID + '-0.mp4')), 71 servers[0].servers.buildDirectory(join('videos', videoUUID + '-0.mp4')),
72 servers[0].serversCommand.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4')) 72 servers[0].servers.buildDirectory(join('streaming-playlists', 'hls', videoUUID, videoUUID + '-0-fragmented.mp4'))
73 ] 73 ]
74 74
75 for (const path of paths) { 75 for (const path of paths) {
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 5c13ac629..89d842307 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -44,8 +44,8 @@ describe('Test multiple servers', function () {
44 displayName: 'my channel', 44 displayName: 'my channel',
45 description: 'super channel' 45 description: 'super channel'
46 } 46 }
47 await servers[0].channelsCommand.create({ attributes: videoChannel }) 47 await servers[0].channels.create({ attributes: videoChannel })
48 const { data } = await servers[0].channelsCommand.list({ start: 0, count: 1 }) 48 const { data } = await servers[0].channels.list({ start: 0, count: 1 })
49 videoChannelId = data[0].id 49 videoChannelId = data[0].id
50 } 50 }
51 51
@@ -59,7 +59,7 @@ describe('Test multiple servers', function () {
59 59
60 it('Should not have videos for all servers', async function () { 60 it('Should not have videos for all servers', async function () {
61 for (const server of servers) { 61 for (const server of servers) {
62 const { data } = await server.videosCommand.list() 62 const { data } = await server.videos.list()
63 expect(data).to.be.an('array') 63 expect(data).to.be.an('array')
64 expect(data.length).to.equal(0) 64 expect(data.length).to.equal(0)
65 } 65 }
@@ -82,7 +82,7 @@ describe('Test multiple servers', function () {
82 channelId: videoChannelId, 82 channelId: videoChannelId,
83 fixture: 'video_short1.webm' 83 fixture: 'video_short1.webm'
84 } 84 }
85 await servers[0].videosCommand.upload({ attributes }) 85 await servers[0].videos.upload({ attributes })
86 86
87 await waitJobs(servers) 87 await waitJobs(servers)
88 88
@@ -125,7 +125,7 @@ describe('Test multiple servers', function () {
125 ] 125 ]
126 } 126 }
127 127
128 const { data } = await server.videosCommand.list() 128 const { data } = await server.videos.list()
129 expect(data).to.be.an('array') 129 expect(data).to.be.an('array')
130 expect(data.length).to.equal(1) 130 expect(data.length).to.equal(1)
131 const video = data[0] 131 const video = data[0]
@@ -142,8 +142,8 @@ describe('Test multiple servers', function () {
142 username: 'user1', 142 username: 'user1',
143 password: 'super_password' 143 password: 'super_password'
144 } 144 }
145 await servers[1].usersCommand.create({ username: user.username, password: user.password }) 145 await servers[1].users.create({ username: user.username, password: user.password })
146 const userAccessToken = await servers[1].loginCommand.getAccessToken(user) 146 const userAccessToken = await servers[1].login.getAccessToken(user)
147 147
148 const attributes = { 148 const attributes = {
149 name: 'my super name for server 2', 149 name: 'my super name for server 2',
@@ -158,7 +158,7 @@ describe('Test multiple servers', function () {
158 thumbnailfile: 'thumbnail.jpg', 158 thumbnailfile: 'thumbnail.jpg',
159 previewfile: 'preview.jpg' 159 previewfile: 'preview.jpg'
160 } 160 }
161 await servers[1].videosCommand.upload({ token: userAccessToken, attributes, mode: 'resumable' }) 161 await servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' })
162 162
163 // Transcoding 163 // Transcoding
164 await waitJobs(servers) 164 await waitJobs(servers)
@@ -213,7 +213,7 @@ describe('Test multiple servers', function () {
213 previewfile: 'preview' 213 previewfile: 'preview'
214 } 214 }
215 215
216 const { data } = await server.videosCommand.list() 216 const { data } = await server.videos.list()
217 expect(data).to.be.an('array') 217 expect(data).to.be.an('array')
218 expect(data.length).to.equal(2) 218 expect(data.length).to.equal(2)
219 const video = data[1] 219 const video = data[1]
@@ -237,7 +237,7 @@ describe('Test multiple servers', function () {
237 tags: [ 'tag1p3' ], 237 tags: [ 'tag1p3' ],
238 fixture: 'video_short3.webm' 238 fixture: 'video_short3.webm'
239 } 239 }
240 await servers[2].videosCommand.upload({ attributes }) 240 await servers[2].videos.upload({ attributes })
241 } 241 }
242 242
243 { 243 {
@@ -252,7 +252,7 @@ describe('Test multiple servers', function () {
252 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ], 252 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
253 fixture: 'video_short.webm' 253 fixture: 'video_short.webm'
254 } 254 }
255 await servers[2].videosCommand.upload({ attributes }) 255 await servers[2].videos.upload({ attributes })
256 } 256 }
257 257
258 await waitJobs(servers) 258 await waitJobs(servers)
@@ -260,7 +260,7 @@ describe('Test multiple servers', function () {
260 // All servers should have this video 260 // All servers should have this video
261 for (const server of servers) { 261 for (const server of servers) {
262 const isLocal = server.url === 'http://localhost:' + servers[2].port 262 const isLocal = server.url === 'http://localhost:' + servers[2].port
263 const { data } = await server.videosCommand.list() 263 const { data } = await server.videos.list()
264 264
265 expect(data).to.be.an('array') 265 expect(data).to.be.an('array')
266 expect(data.length).to.equal(4) 266 expect(data.length).to.equal(4)
@@ -349,7 +349,7 @@ describe('Test multiple servers', function () {
349 349
350 describe('It should list local videos', function () { 350 describe('It should list local videos', function () {
351 it('Should list only local videos on server 1', async function () { 351 it('Should list only local videos on server 1', async function () {
352 const { data, total } = await servers[0].videosCommand.list({ filter: 'local' }) 352 const { data, total } = await servers[0].videos.list({ filter: 'local' })
353 353
354 expect(total).to.equal(1) 354 expect(total).to.equal(1)
355 expect(data).to.be.an('array') 355 expect(data).to.be.an('array')
@@ -358,7 +358,7 @@ describe('Test multiple servers', function () {
358 }) 358 })
359 359
360 it('Should list only local videos on server 2', async function () { 360 it('Should list only local videos on server 2', async function () {
361 const { data, total } = await servers[1].videosCommand.list({ filter: 'local' }) 361 const { data, total } = await servers[1].videos.list({ filter: 'local' })
362 362
363 expect(total).to.equal(1) 363 expect(total).to.equal(1)
364 expect(data).to.be.an('array') 364 expect(data).to.be.an('array')
@@ -367,7 +367,7 @@ describe('Test multiple servers', function () {
367 }) 367 })
368 368
369 it('Should list only local videos on server 3', async function () { 369 it('Should list only local videos on server 3', async function () {
370 const { data, total } = await servers[2].videosCommand.list({ filter: 'local' }) 370 const { data, total } = await servers[2].videos.list({ filter: 'local' })
371 371
372 expect(total).to.equal(2) 372 expect(total).to.equal(2)
373 expect(data).to.be.an('array') 373 expect(data).to.be.an('array')
@@ -381,13 +381,13 @@ describe('Test multiple servers', function () {
381 it('Should add the file 1 by asking server 3', async function () { 381 it('Should add the file 1 by asking server 3', async function () {
382 this.timeout(10000) 382 this.timeout(10000)
383 383
384 const { data } = await servers[2].videosCommand.list() 384 const { data } = await servers[2].videos.list()
385 385
386 const video = data[0] 386 const video = data[0]
387 toRemove.push(data[2]) 387 toRemove.push(data[2])
388 toRemove.push(data[3]) 388 toRemove.push(data[3])
389 389
390 const videoDetails = await servers[2].videosCommand.get({ id: video.id }) 390 const videoDetails = await servers[2].videos.get({ id: video.id })
391 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) 391 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
392 expect(torrent.files).to.be.an('array') 392 expect(torrent.files).to.be.an('array')
393 expect(torrent.files.length).to.equal(1) 393 expect(torrent.files.length).to.equal(1)
@@ -397,10 +397,10 @@ describe('Test multiple servers', function () {
397 it('Should add the file 2 by asking server 1', async function () { 397 it('Should add the file 2 by asking server 1', async function () {
398 this.timeout(10000) 398 this.timeout(10000)
399 399
400 const { data } = await servers[0].videosCommand.list() 400 const { data } = await servers[0].videos.list()
401 401
402 const video = data[1] 402 const video = data[1]
403 const videoDetails = await servers[0].videosCommand.get({ id: video.id }) 403 const videoDetails = await servers[0].videos.get({ id: video.id })
404 404
405 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) 405 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
406 expect(torrent.files).to.be.an('array') 406 expect(torrent.files).to.be.an('array')
@@ -411,10 +411,10 @@ describe('Test multiple servers', function () {
411 it('Should add the file 3 by asking server 2', async function () { 411 it('Should add the file 3 by asking server 2', async function () {
412 this.timeout(10000) 412 this.timeout(10000)
413 413
414 const { data } = await servers[1].videosCommand.list() 414 const { data } = await servers[1].videos.list()
415 415
416 const video = data[2] 416 const video = data[2]
417 const videoDetails = await servers[1].videosCommand.get({ id: video.id }) 417 const videoDetails = await servers[1].videos.get({ id: video.id })
418 418
419 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true) 419 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
420 expect(torrent.files).to.be.an('array') 420 expect(torrent.files).to.be.an('array')
@@ -425,10 +425,10 @@ describe('Test multiple servers', function () {
425 it('Should add the file 3-2 by asking server 1', async function () { 425 it('Should add the file 3-2 by asking server 1', async function () {
426 this.timeout(10000) 426 this.timeout(10000)
427 427
428 const { data } = await servers[0].videosCommand.list() 428 const { data } = await servers[0].videos.list()
429 429
430 const video = data[3] 430 const video = data[3]
431 const videoDetails = await servers[0].videosCommand.get({ id: video.id }) 431 const videoDetails = await servers[0].videos.get({ id: video.id })
432 432
433 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri) 433 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
434 expect(torrent.files).to.be.an('array') 434 expect(torrent.files).to.be.an('array')
@@ -439,10 +439,10 @@ describe('Test multiple servers', function () {
439 it('Should add the file 2 in 360p by asking server 1', async function () { 439 it('Should add the file 2 in 360p by asking server 1', async function () {
440 this.timeout(10000) 440 this.timeout(10000)
441 441
442 const { data } = await servers[0].videosCommand.list() 442 const { data } = await servers[0].videos.list()
443 443
444 const video = data.find(v => v.name === 'my super name for server 2') 444 const video = data.find(v => v.name === 'my super name for server 2')
445 const videoDetails = await servers[0].videosCommand.get({ id: video.id }) 445 const videoDetails = await servers[0].videos.get({ id: video.id })
446 446
447 const file = videoDetails.files.find(f => f.resolution.id === 360) 447 const file = videoDetails.files.find(f => f.resolution.id === 360)
448 expect(file).not.to.be.undefined 448 expect(file).not.to.be.undefined
@@ -462,17 +462,17 @@ describe('Test multiple servers', function () {
462 462
463 before(async function () { 463 before(async function () {
464 { 464 {
465 const { data } = await servers[0].videosCommand.list() 465 const { data } = await servers[0].videos.list()
466 remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid) 466 remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid)
467 } 467 }
468 468
469 { 469 {
470 const { data } = await servers[1].videosCommand.list() 470 const { data } = await servers[1].videos.list()
471 remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid) 471 remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid)
472 } 472 }
473 473
474 { 474 {
475 const { data } = await servers[2].videosCommand.list() 475 const { data } = await servers[2].videos.list()
476 localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid) 476 localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid)
477 remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid) 477 remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid)
478 } 478 }
@@ -481,16 +481,16 @@ describe('Test multiple servers', function () {
481 it('Should view multiple videos on owned servers', async function () { 481 it('Should view multiple videos on owned servers', async function () {
482 this.timeout(30000) 482 this.timeout(30000)
483 483
484 await servers[2].videosCommand.view({ id: localVideosServer3[0] }) 484 await servers[2].videos.view({ id: localVideosServer3[0] })
485 await wait(1000) 485 await wait(1000)
486 486
487 await servers[2].videosCommand.view({ id: localVideosServer3[0] }) 487 await servers[2].videos.view({ id: localVideosServer3[0] })
488 await servers[2].videosCommand.view({ id: localVideosServer3[1] }) 488 await servers[2].videos.view({ id: localVideosServer3[1] })
489 489
490 await wait(1000) 490 await wait(1000)
491 491
492 await servers[2].videosCommand.view({ id: localVideosServer3[0] }) 492 await servers[2].videos.view({ id: localVideosServer3[0] })
493 await servers[2].videosCommand.view({ id: localVideosServer3[0] }) 493 await servers[2].videos.view({ id: localVideosServer3[0] })
494 494
495 await waitJobs(servers) 495 await waitJobs(servers)
496 496
@@ -500,7 +500,7 @@ describe('Test multiple servers', function () {
500 await waitJobs(servers) 500 await waitJobs(servers)
501 501
502 for (const server of servers) { 502 for (const server of servers) {
503 const { data } = await server.videosCommand.list() 503 const { data } = await server.videos.list()
504 504
505 const video0 = data.find(v => v.uuid === localVideosServer3[0]) 505 const video0 = data.find(v => v.uuid === localVideosServer3[0])
506 const video1 = data.find(v => v.uuid === localVideosServer3[1]) 506 const video1 = data.find(v => v.uuid === localVideosServer3[1])
@@ -514,16 +514,16 @@ describe('Test multiple servers', function () {
514 this.timeout(45000) 514 this.timeout(45000)
515 515
516 const tasks: Promise<any>[] = [] 516 const tasks: Promise<any>[] = []
517 tasks.push(servers[0].videosCommand.view({ id: remoteVideosServer1[0] })) 517 tasks.push(servers[0].videos.view({ id: remoteVideosServer1[0] }))
518 tasks.push(servers[1].videosCommand.view({ id: remoteVideosServer2[0] })) 518 tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
519 tasks.push(servers[1].videosCommand.view({ id: remoteVideosServer2[0] })) 519 tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
520 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[0] })) 520 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[0] }))
521 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] })) 521 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
522 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] })) 522 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
523 tasks.push(servers[2].videosCommand.view({ id: remoteVideosServer3[1] })) 523 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
524 tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] })) 524 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
525 tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] })) 525 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
526 tasks.push(servers[2].videosCommand.view({ id: localVideosServer3[1] })) 526 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
527 527
528 await Promise.all(tasks) 528 await Promise.all(tasks)
529 529
@@ -537,7 +537,7 @@ describe('Test multiple servers', function () {
537 let baseVideos = null 537 let baseVideos = null
538 538
539 for (const server of servers) { 539 for (const server of servers) {
540 const { data } = await server.videosCommand.list() 540 const { data } = await server.videos.list()
541 541
542 // Initialize base videos for future comparisons 542 // Initialize base videos for future comparisons
543 if (baseVideos === null) { 543 if (baseVideos === null) {
@@ -555,17 +555,17 @@ describe('Test multiple servers', function () {
555 it('Should like and dislikes videos on different services', async function () { 555 it('Should like and dislikes videos on different services', async function () {
556 this.timeout(50000) 556 this.timeout(50000)
557 557
558 await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'like' }) 558 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
559 await wait(500) 559 await wait(500)
560 await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'dislike' }) 560 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
561 await wait(500) 561 await wait(500)
562 await servers[0].videosCommand.rate({ id: remoteVideosServer1[0], rating: 'like' }) 562 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
563 await servers[2].videosCommand.rate({ id: localVideosServer3[1], rating: 'like' }) 563 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' })
564 await wait(500) 564 await wait(500)
565 await servers[2].videosCommand.rate({ id: localVideosServer3[1], rating: 'dislike' }) 565 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' })
566 await servers[2].videosCommand.rate({ id: remoteVideosServer3[1], rating: 'dislike' }) 566 await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
567 await wait(500) 567 await wait(500)
568 await servers[2].videosCommand.rate({ id: remoteVideosServer3[0], rating: 'like' }) 568 await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' })
569 569
570 await waitJobs(servers) 570 await waitJobs(servers)
571 await wait(5000) 571 await wait(5000)
@@ -573,7 +573,7 @@ describe('Test multiple servers', function () {
573 573
574 let baseVideos = null 574 let baseVideos = null
575 for (const server of servers) { 575 for (const server of servers) {
576 const { data } = await server.videosCommand.list() 576 const { data } = await server.videos.list()
577 577
578 // Initialize base videos for future comparisons 578 // Initialize base videos for future comparisons
579 if (baseVideos === null) { 579 if (baseVideos === null) {
@@ -608,7 +608,7 @@ describe('Test multiple servers', function () {
608 previewfile: 'preview.jpg' 608 previewfile: 'preview.jpg'
609 } 609 }
610 610
611 await servers[2].videosCommand.update({ id: toRemove[0].id, attributes }) 611 await servers[2].videos.update({ id: toRemove[0].id, attributes })
612 612
613 await waitJobs(servers) 613 await waitJobs(servers)
614 }) 614 })
@@ -617,7 +617,7 @@ describe('Test multiple servers', function () {
617 this.timeout(10000) 617 this.timeout(10000)
618 618
619 for (const server of servers) { 619 for (const server of servers) {
620 const { data } = await server.videosCommand.list() 620 const { data } = await server.videos.list()
621 621
622 const videoUpdated = data.find(video => video.name === 'my super video updated') 622 const videoUpdated = data.find(video => video.name === 'my super video updated')
623 expect(!!videoUpdated).to.be.true 623 expect(!!videoUpdated).to.be.true
@@ -665,8 +665,8 @@ describe('Test multiple servers', function () {
665 it('Should remove the videos 3 and 3-2 by asking server 3', async function () { 665 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
666 this.timeout(10000) 666 this.timeout(10000)
667 667
668 await servers[2].videosCommand.remove({ id: toRemove[0].id }) 668 await servers[2].videos.remove({ id: toRemove[0].id })
669 await servers[2].videosCommand.remove({ id: toRemove[1].id }) 669 await servers[2].videos.remove({ id: toRemove[1].id })
670 670
671 await waitJobs(servers) 671 await waitJobs(servers)
672 }) 672 })
@@ -680,7 +680,7 @@ describe('Test multiple servers', function () {
680 680
681 it('Should have videos 1 and 3 on each server', async function () { 681 it('Should have videos 1 and 3 on each server', async function () {
682 for (const server of servers) { 682 for (const server of servers) {
683 const { data } = await server.videosCommand.list() 683 const { data } = await server.videos.list()
684 684
685 expect(data).to.be.an('array') 685 expect(data).to.be.an('array')
686 expect(data.length).to.equal(2) 686 expect(data.length).to.equal(2)
@@ -697,7 +697,7 @@ describe('Test multiple servers', function () {
697 it('Should get the same video by UUID on each server', async function () { 697 it('Should get the same video by UUID on each server', async function () {
698 let baseVideo = null 698 let baseVideo = null
699 for (const server of servers) { 699 for (const server of servers) {
700 const video = await server.videosCommand.get({ id: videoUUID }) 700 const video = await server.videos.get({ id: videoUUID })
701 701
702 if (baseVideo === null) { 702 if (baseVideo === null) {
703 baseVideo = video 703 baseVideo = video
@@ -720,7 +720,7 @@ describe('Test multiple servers', function () {
720 720
721 it('Should get the preview from each server', async function () { 721 it('Should get the preview from each server', async function () {
722 for (const server of servers) { 722 for (const server of servers) {
723 const video = await server.videosCommand.get({ id: videoUUID }) 723 const video = await server.videos.get({ id: videoUUID })
724 724
725 await testImage(server.url, 'video_short1-preview.webm', video.previewPath) 725 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
726 } 726 }
@@ -735,36 +735,36 @@ describe('Test multiple servers', function () {
735 735
736 { 736 {
737 const text = 'my super first comment' 737 const text = 'my super first comment'
738 await servers[0].commentsCommand.createThread({ videoId: videoUUID, text }) 738 await servers[0].comments.createThread({ videoId: videoUUID, text })
739 } 739 }
740 740
741 { 741 {
742 const text = 'my super second comment' 742 const text = 'my super second comment'
743 await servers[2].commentsCommand.createThread({ videoId: videoUUID, text }) 743 await servers[2].comments.createThread({ videoId: videoUUID, text })
744 } 744 }
745 745
746 await waitJobs(servers) 746 await waitJobs(servers)
747 747
748 { 748 {
749 const threadId = await servers[1].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) 749 const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
750 750
751 const text = 'my super answer to thread 1' 751 const text = 'my super answer to thread 1'
752 await servers[1].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text }) 752 await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text })
753 } 753 }
754 754
755 await waitJobs(servers) 755 await waitJobs(servers)
756 756
757 { 757 {
758 const threadId = await servers[2].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' }) 758 const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
759 759
760 const body = await servers[2].commentsCommand.getThread({ videoId: videoUUID, threadId }) 760 const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId })
761 const childCommentId = body.children[0].comment.id 761 const childCommentId = body.children[0].comment.id
762 762
763 const text3 = 'my second answer to thread 1' 763 const text3 = 'my second answer to thread 1'
764 await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 }) 764 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
765 765
766 const text2 = 'my super answer to answer of thread 1' 766 const text2 = 'my super answer to answer of thread 1'
767 await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 }) 767 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
768 } 768 }
769 769
770 await waitJobs(servers) 770 await waitJobs(servers)
@@ -772,7 +772,7 @@ describe('Test multiple servers', function () {
772 772
773 it('Should have these threads', async function () { 773 it('Should have these threads', async function () {
774 for (const server of servers) { 774 for (const server of servers) {
775 const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) 775 const body = await server.comments.listThreads({ videoId: videoUUID })
776 776
777 expect(body.total).to.equal(2) 777 expect(body.total).to.equal(2)
778 expect(body.data).to.be.an('array') 778 expect(body.data).to.be.an('array')
@@ -804,10 +804,10 @@ describe('Test multiple servers', function () {
804 804
805 it('Should have these comments', async function () { 805 it('Should have these comments', async function () {
806 for (const server of servers) { 806 for (const server of servers) {
807 const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) 807 const body = await server.comments.listThreads({ videoId: videoUUID })
808 const threadId = body.data.find(c => c.text === 'my super first comment').id 808 const threadId = body.data.find(c => c.text === 'my super first comment').id
809 809
810 const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId }) 810 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
811 811
812 expect(tree.comment.text).equal('my super first comment') 812 expect(tree.comment.text).equal('my super first comment')
813 expect(tree.comment.account.name).equal('root') 813 expect(tree.comment.account.name).equal('root')
@@ -837,17 +837,17 @@ describe('Test multiple servers', function () {
837 it('Should delete a reply', async function () { 837 it('Should delete a reply', async function () {
838 this.timeout(10000) 838 this.timeout(10000)
839 839
840 await servers[2].commentsCommand.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id }) 840 await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
841 841
842 await waitJobs(servers) 842 await waitJobs(servers)
843 }) 843 })
844 844
845 it('Should have this comment marked as deleted', async function () { 845 it('Should have this comment marked as deleted', async function () {
846 for (const server of servers) { 846 for (const server of servers) {
847 const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID }) 847 const { data } = await server.comments.listThreads({ videoId: videoUUID })
848 const threadId = data.find(c => c.text === 'my super first comment').id 848 const threadId = data.find(c => c.text === 'my super first comment').id
849 849
850 const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId }) 850 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
851 expect(tree.comment.text).equal('my super first comment') 851 expect(tree.comment.text).equal('my super first comment')
852 852
853 const firstChild = tree.children[0] 853 const firstChild = tree.children[0]
@@ -868,16 +868,16 @@ describe('Test multiple servers', function () {
868 it('Should delete the thread comments', async function () { 868 it('Should delete the thread comments', async function () {
869 this.timeout(10000) 869 this.timeout(10000)
870 870
871 const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID }) 871 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
872 const commentId = data.find(c => c.text === 'my super first comment').id 872 const commentId = data.find(c => c.text === 'my super first comment').id
873 await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId }) 873 await servers[0].comments.delete({ videoId: videoUUID, commentId })
874 874
875 await waitJobs(servers) 875 await waitJobs(servers)
876 }) 876 })
877 877
878 it('Should have the threads marked as deleted on other servers too', async function () { 878 it('Should have the threads marked as deleted on other servers too', async function () {
879 for (const server of servers) { 879 for (const server of servers) {
880 const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) 880 const body = await server.comments.listThreads({ videoId: videoUUID })
881 881
882 expect(body.total).to.equal(2) 882 expect(body.total).to.equal(2)
883 expect(body.data).to.be.an('array') 883 expect(body.data).to.be.an('array')
@@ -913,16 +913,16 @@ describe('Test multiple servers', function () {
913 it('Should delete a remote thread by the origin server', async function () { 913 it('Should delete a remote thread by the origin server', async function () {
914 this.timeout(5000) 914 this.timeout(5000)
915 915
916 const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID }) 916 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
917 const commentId = data.find(c => c.text === 'my super second comment').id 917 const commentId = data.find(c => c.text === 'my super second comment').id
918 await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId }) 918 await servers[0].comments.delete({ videoId: videoUUID, commentId })
919 919
920 await waitJobs(servers) 920 await waitJobs(servers)
921 }) 921 })
922 922
923 it('Should have the threads marked as deleted on other servers too', async function () { 923 it('Should have the threads marked as deleted on other servers too', async function () {
924 for (const server of servers) { 924 for (const server of servers) {
925 const body = await server.commentsCommand.listThreads({ videoId: videoUUID }) 925 const body = await server.comments.listThreads({ videoId: videoUUID })
926 926
927 expect(body.total).to.equal(2) 927 expect(body.total).to.equal(2)
928 expect(body.data).to.have.lengthOf(2) 928 expect(body.data).to.have.lengthOf(2)
@@ -957,17 +957,17 @@ describe('Test multiple servers', function () {
957 downloadEnabled: false 957 downloadEnabled: false
958 } 958 }
959 959
960 await servers[0].videosCommand.update({ id: videoUUID, attributes }) 960 await servers[0].videos.update({ id: videoUUID, attributes })
961 961
962 await waitJobs(servers) 962 await waitJobs(servers)
963 963
964 for (const server of servers) { 964 for (const server of servers) {
965 const video = await server.videosCommand.get({ id: videoUUID }) 965 const video = await server.videos.get({ id: videoUUID })
966 expect(video.commentsEnabled).to.be.false 966 expect(video.commentsEnabled).to.be.false
967 expect(video.downloadEnabled).to.be.false 967 expect(video.downloadEnabled).to.be.false
968 968
969 const text = 'my super forbidden comment' 969 const text = 'my super forbidden comment'
970 await server.commentsCommand.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 }) 970 await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
971 } 971 }
972 }) 972 })
973 }) 973 })
@@ -992,7 +992,7 @@ describe('Test multiple servers', function () {
992 await waitJobs(servers) 992 await waitJobs(servers)
993 993
994 for (const server of servers) { 994 for (const server of servers) {
995 const { data } = await server.videosCommand.list() 995 const { data } = await server.videos.list()
996 const video = data.find(v => v.name === 'minimum parameters') 996 const video = data.find(v => v.name === 'minimum parameters')
997 997
998 const isLocal = server.url === 'http://localhost:' + servers[1].port 998 const isLocal = server.url === 'http://localhost:' + servers[1].port
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index b7756a4a8..2f1cf8a55 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -36,14 +36,14 @@ describe('Test resumable upload', function () {
36 36
37 const attributes = { 37 const attributes = {
38 name: 'video', 38 name: 'video',
39 channelId: server.videoChannel.id, 39 channelId: server.store.channel.id,
40 privacy: VideoPrivacy.PUBLIC, 40 privacy: VideoPrivacy.PUBLIC,
41 fixture: defaultFixture 41 fixture: defaultFixture
42 } 42 }
43 43
44 const mimetype = 'video/mp4' 44 const mimetype = 'video/mp4'
45 45
46 const res = await server.videosCommand.prepareResumableUpload({ attributes, size, mimetype }) 46 const res = await server.videos.prepareResumableUpload({ attributes, size, mimetype })
47 47
48 return res.header['location'].split('?')[1] 48 return res.header['location'].split('?')[1]
49 } 49 }
@@ -61,7 +61,7 @@ describe('Test resumable upload', function () {
61 const size = await buildSize(defaultFixture, options.size) 61 const size = await buildSize(defaultFixture, options.size)
62 const absoluteFilePath = buildAbsoluteFixturePath(defaultFixture) 62 const absoluteFilePath = buildAbsoluteFixturePath(defaultFixture)
63 63
64 return server.videosCommand.sendResumableChunks({ 64 return server.videos.sendResumableChunks({
65 pathUploadId, 65 pathUploadId,
66 videoFilePath: absoluteFilePath, 66 videoFilePath: absoluteFilePath,
67 size, 67 size,
@@ -75,7 +75,7 @@ describe('Test resumable upload', function () {
75 const uploadId = uploadIdArg.replace(/^upload_id=/, '') 75 const uploadId = uploadIdArg.replace(/^upload_id=/, '')
76 76
77 const subPath = join('tmp', 'resumable-uploads', uploadId) 77 const subPath = join('tmp', 'resumable-uploads', uploadId)
78 const filePath = server.serversCommand.buildDirectory(subPath) 78 const filePath = server.servers.buildDirectory(subPath)
79 const exists = await pathExists(filePath) 79 const exists = await pathExists(filePath)
80 80
81 if (expectedSize === null) { 81 if (expectedSize === null) {
@@ -90,7 +90,7 @@ describe('Test resumable upload', function () {
90 90
91 async function countResumableUploads () { 91 async function countResumableUploads () {
92 const subPath = join('tmp', 'resumable-uploads') 92 const subPath = join('tmp', 'resumable-uploads')
93 const filePath = server.serversCommand.buildDirectory(subPath) 93 const filePath = server.servers.buildDirectory(subPath)
94 94
95 const files = await readdir(filePath) 95 const files = await readdir(filePath)
96 return files.length 96 return files.length
@@ -103,10 +103,10 @@ describe('Test resumable upload', function () {
103 await setAccessTokensToServers([ server ]) 103 await setAccessTokensToServers([ server ])
104 await setDefaultVideoChannel([ server ]) 104 await setDefaultVideoChannel([ server ])
105 105
106 const body = await server.usersCommand.getMyInfo() 106 const body = await server.users.getMyInfo()
107 rootId = body.id 107 rootId = body.id
108 108
109 await server.usersCommand.update({ userId: rootId, videoQuota: 10_000_000 }) 109 await server.users.update({ userId: rootId, videoQuota: 10_000_000 })
110 }) 110 })
111 111
112 describe('Directory cleaning', function () { 112 describe('Directory cleaning', function () {
@@ -125,13 +125,13 @@ describe('Test resumable upload', function () {
125 }) 125 })
126 126
127 it('Should not delete recent uploads', async function () { 127 it('Should not delete recent uploads', async function () {
128 await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }) 128 await server.debug.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } })
129 129
130 expect(await countResumableUploads()).to.equal(2) 130 expect(await countResumableUploads()).to.equal(2)
131 }) 131 })
132 132
133 it('Should delete old uploads', async function () { 133 it('Should delete old uploads', async function () {
134 await server.debugCommand.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } }) 134 await server.debug.sendCommand({ body: { command: 'remove-dandling-resumable-uploads' } })
135 135
136 expect(await countResumableUploads()).to.equal(0) 136 expect(await countResumableUploads()).to.equal(0)
137 }) 137 })
diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts
index da0b2011e..12c1f7b2f 100644
--- a/server/tests/api/videos/single-server.ts
+++ b/server/tests/api/videos/single-server.ts
@@ -100,35 +100,35 @@ describe('Test a single server', function () {
100 }) 100 })
101 101
102 it('Should list video categories', async function () { 102 it('Should list video categories', async function () {
103 const categories = await server.videosCommand.getCategories() 103 const categories = await server.videos.getCategories()
104 expect(Object.keys(categories)).to.have.length.above(10) 104 expect(Object.keys(categories)).to.have.length.above(10)
105 105
106 expect(categories[11]).to.equal('News & Politics') 106 expect(categories[11]).to.equal('News & Politics')
107 }) 107 })
108 108
109 it('Should list video licences', async function () { 109 it('Should list video licences', async function () {
110 const licences = await server.videosCommand.getLicences() 110 const licences = await server.videos.getLicences()
111 expect(Object.keys(licences)).to.have.length.above(5) 111 expect(Object.keys(licences)).to.have.length.above(5)
112 112
113 expect(licences[3]).to.equal('Attribution - No Derivatives') 113 expect(licences[3]).to.equal('Attribution - No Derivatives')
114 }) 114 })
115 115
116 it('Should list video languages', async function () { 116 it('Should list video languages', async function () {
117 const languages = await server.videosCommand.getLanguages() 117 const languages = await server.videos.getLanguages()
118 expect(Object.keys(languages)).to.have.length.above(5) 118 expect(Object.keys(languages)).to.have.length.above(5)
119 119
120 expect(languages['ru']).to.equal('Russian') 120 expect(languages['ru']).to.equal('Russian')
121 }) 121 })
122 122
123 it('Should list video privacies', async function () { 123 it('Should list video privacies', async function () {
124 const privacies = await server.videosCommand.getPrivacies() 124 const privacies = await server.videos.getPrivacies()
125 expect(Object.keys(privacies)).to.have.length.at.least(3) 125 expect(Object.keys(privacies)).to.have.length.at.least(3)
126 126
127 expect(privacies[3]).to.equal('Private') 127 expect(privacies[3]).to.equal('Private')
128 }) 128 })
129 129
130 it('Should not have videos', async function () { 130 it('Should not have videos', async function () {
131 const { data, total } = await server.videosCommand.list() 131 const { data, total } = await server.videos.list()
132 132
133 expect(total).to.equal(0) 133 expect(total).to.equal(0)
134 expect(data).to.be.an('array') 134 expect(data).to.be.an('array')
@@ -145,7 +145,7 @@ describe('Test a single server', function () {
145 licence: 6, 145 licence: 6,
146 tags: [ 'tag1', 'tag2', 'tag3' ] 146 tags: [ 'tag1', 'tag2', 'tag3' ]
147 } 147 }
148 const video = await server.videosCommand.upload({ attributes, mode }) 148 const video = await server.videos.upload({ attributes, mode })
149 expect(video).to.not.be.undefined 149 expect(video).to.not.be.undefined
150 expect(video.id).to.equal(1) 150 expect(video.id).to.equal(1)
151 expect(video.uuid).to.have.length.above(5) 151 expect(video.uuid).to.have.length.above(5)
@@ -157,7 +157,7 @@ describe('Test a single server', function () {
157 it('Should get and seed the uploaded video', async function () { 157 it('Should get and seed the uploaded video', async function () {
158 this.timeout(5000) 158 this.timeout(5000)
159 159
160 const { data, total } = await server.videosCommand.list() 160 const { data, total } = await server.videos.list()
161 161
162 expect(total).to.equal(1) 162 expect(total).to.equal(1)
163 expect(data).to.be.an('array') 163 expect(data).to.be.an('array')
@@ -170,42 +170,42 @@ describe('Test a single server', function () {
170 it('Should get the video by UUID', async function () { 170 it('Should get the video by UUID', async function () {
171 this.timeout(5000) 171 this.timeout(5000)
172 172
173 const video = await server.videosCommand.get({ id: videoUUID }) 173 const video = await server.videos.get({ id: videoUUID })
174 await completeVideoCheck(server, video, getCheckAttributes()) 174 await completeVideoCheck(server, video, getCheckAttributes())
175 }) 175 })
176 176
177 it('Should have the views updated', async function () { 177 it('Should have the views updated', async function () {
178 this.timeout(20000) 178 this.timeout(20000)
179 179
180 await server.videosCommand.view({ id: videoId }) 180 await server.videos.view({ id: videoId })
181 await server.videosCommand.view({ id: videoId }) 181 await server.videos.view({ id: videoId })
182 await server.videosCommand.view({ id: videoId }) 182 await server.videos.view({ id: videoId })
183 183
184 await wait(1500) 184 await wait(1500)
185 185
186 await server.videosCommand.view({ id: videoId }) 186 await server.videos.view({ id: videoId })
187 await server.videosCommand.view({ id: videoId }) 187 await server.videos.view({ id: videoId })
188 188
189 await wait(1500) 189 await wait(1500)
190 190
191 await server.videosCommand.view({ id: videoId }) 191 await server.videos.view({ id: videoId })
192 await server.videosCommand.view({ id: videoId }) 192 await server.videos.view({ id: videoId })
193 193
194 // Wait the repeatable job 194 // Wait the repeatable job
195 await wait(8000) 195 await wait(8000)
196 196
197 const video = await server.videosCommand.get({ id: videoId }) 197 const video = await server.videos.get({ id: videoId })
198 expect(video.views).to.equal(3) 198 expect(video.views).to.equal(3)
199 }) 199 })
200 200
201 it('Should remove the video', async function () { 201 it('Should remove the video', async function () {
202 await server.videosCommand.remove({ id: videoId }) 202 await server.videos.remove({ id: videoId })
203 203
204 await checkVideoFilesWereRemoved(videoUUID, server) 204 await checkVideoFilesWereRemoved(videoUUID, server)
205 }) 205 })
206 206
207 it('Should not have videos', async function () { 207 it('Should not have videos', async function () {
208 const { total, data } = await server.videosCommand.list() 208 const { total, data } = await server.videos.list()
209 209
210 expect(total).to.equal(0) 210 expect(total).to.equal(0)
211 expect(data).to.be.an('array') 211 expect(data).to.be.an('array')
@@ -232,12 +232,12 @@ describe('Test a single server', function () {
232 fixture: video 232 fixture: video
233 } 233 }
234 234
235 await server.videosCommand.upload({ attributes, mode }) 235 await server.videos.upload({ attributes, mode })
236 } 236 }
237 }) 237 })
238 238
239 it('Should have the correct durations', async function () { 239 it('Should have the correct durations', async function () {
240 const { total, data } = await server.videosCommand.list() 240 const { total, data } = await server.videos.list()
241 241
242 expect(total).to.equal(6) 242 expect(total).to.equal(6)
243 expect(data).to.be.an('array') 243 expect(data).to.be.an('array')
@@ -255,7 +255,7 @@ describe('Test a single server', function () {
255 }) 255 })
256 256
257 it('Should have the correct thumbnails', async function () { 257 it('Should have the correct thumbnails', async function () {
258 const { data } = await server.videosCommand.list() 258 const { data } = await server.videos.list()
259 259
260 // For the next test 260 // For the next test
261 videosListBase = data 261 videosListBase = data
@@ -267,7 +267,7 @@ describe('Test a single server', function () {
267 }) 267 })
268 268
269 it('Should list only the two first videos', async function () { 269 it('Should list only the two first videos', async function () {
270 const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: 'name' }) 270 const { total, data } = await server.videos.list({ start: 0, count: 2, sort: 'name' })
271 271
272 expect(total).to.equal(6) 272 expect(total).to.equal(6)
273 expect(data.length).to.equal(2) 273 expect(data.length).to.equal(2)
@@ -276,7 +276,7 @@ describe('Test a single server', function () {
276 }) 276 })
277 277
278 it('Should list only the next three videos', async function () { 278 it('Should list only the next three videos', async function () {
279 const { total, data } = await server.videosCommand.list({ start: 2, count: 3, sort: 'name' }) 279 const { total, data } = await server.videos.list({ start: 2, count: 3, sort: 'name' })
280 280
281 expect(total).to.equal(6) 281 expect(total).to.equal(6)
282 expect(data.length).to.equal(3) 282 expect(data.length).to.equal(3)
@@ -286,7 +286,7 @@ describe('Test a single server', function () {
286 }) 286 })
287 287
288 it('Should list the last video', async function () { 288 it('Should list the last video', async function () {
289 const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name' }) 289 const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name' })
290 290
291 expect(total).to.equal(6) 291 expect(total).to.equal(6)
292 expect(data.length).to.equal(1) 292 expect(data.length).to.equal(1)
@@ -294,7 +294,7 @@ describe('Test a single server', function () {
294 }) 294 })
295 295
296 it('Should not have the total field', async function () { 296 it('Should not have the total field', async function () {
297 const { total, data } = await server.videosCommand.list({ start: 5, count: 6, sort: 'name', skipCount: true }) 297 const { total, data } = await server.videos.list({ start: 5, count: 6, sort: 'name', skipCount: true })
298 298
299 expect(total).to.not.exist 299 expect(total).to.not.exist
300 expect(data.length).to.equal(1) 300 expect(data.length).to.equal(1)
@@ -302,7 +302,7 @@ describe('Test a single server', function () {
302 }) 302 })
303 303
304 it('Should list and sort by name in descending order', async function () { 304 it('Should list and sort by name in descending order', async function () {
305 const { total, data } = await server.videosCommand.list({ sort: '-name' }) 305 const { total, data } = await server.videos.list({ sort: '-name' })
306 306
307 expect(total).to.equal(6) 307 expect(total).to.equal(6)
308 expect(data.length).to.equal(6) 308 expect(data.length).to.equal(6)
@@ -318,21 +318,21 @@ describe('Test a single server', function () {
318 }) 318 })
319 319
320 it('Should list and sort by trending in descending order', async function () { 320 it('Should list and sort by trending in descending order', async function () {
321 const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-trending' }) 321 const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-trending' })
322 322
323 expect(total).to.equal(6) 323 expect(total).to.equal(6)
324 expect(data.length).to.equal(2) 324 expect(data.length).to.equal(2)
325 }) 325 })
326 326
327 it('Should list and sort by hotness in descending order', async function () { 327 it('Should list and sort by hotness in descending order', async function () {
328 const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-hot' }) 328 const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-hot' })
329 329
330 expect(total).to.equal(6) 330 expect(total).to.equal(6)
331 expect(data.length).to.equal(2) 331 expect(data.length).to.equal(2)
332 }) 332 })
333 333
334 it('Should list and sort by best in descending order', async function () { 334 it('Should list and sort by best in descending order', async function () {
335 const { total, data } = await server.videosCommand.list({ start: 0, count: 2, sort: '-best' }) 335 const { total, data } = await server.videos.list({ start: 0, count: 2, sort: '-best' })
336 336
337 expect(total).to.equal(6) 337 expect(total).to.equal(6)
338 expect(data.length).to.equal(2) 338 expect(data.length).to.equal(2)
@@ -350,18 +350,18 @@ describe('Test a single server', function () {
350 downloadEnabled: false, 350 downloadEnabled: false,
351 tags: [ 'tagup1', 'tagup2' ] 351 tags: [ 'tagup1', 'tagup2' ]
352 } 352 }
353 await server.videosCommand.update({ id: videoId, attributes }) 353 await server.videos.update({ id: videoId, attributes })
354 }) 354 })
355 355
356 it('Should filter by tags and category', async function () { 356 it('Should filter by tags and category', async function () {
357 { 357 {
358 const { data, total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] }) 358 const { data, total } = await server.videos.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 4 ] })
359 expect(total).to.equal(1) 359 expect(total).to.equal(1)
360 expect(data[0].name).to.equal('my super video updated') 360 expect(data[0].name).to.equal('my super video updated')
361 } 361 }
362 362
363 { 363 {
364 const { total } = await server.videosCommand.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] }) 364 const { total } = await server.videos.list({ tagsAllOf: [ 'tagup1', 'tagup2' ], categoryOneOf: [ 3 ] })
365 expect(total).to.equal(0) 365 expect(total).to.equal(0)
366 } 366 }
367 }) 367 })
@@ -369,7 +369,7 @@ describe('Test a single server', function () {
369 it('Should have the video updated', async function () { 369 it('Should have the video updated', async function () {
370 this.timeout(60000) 370 this.timeout(60000)
371 371
372 const video = await server.videosCommand.get({ id: videoId }) 372 const video = await server.videos.get({ id: videoId })
373 373
374 await completeVideoCheck(server, video, updateCheckAttributes()) 374 await completeVideoCheck(server, video, updateCheckAttributes())
375 }) 375 })
@@ -378,9 +378,9 @@ describe('Test a single server', function () {
378 const attributes = { 378 const attributes = {
379 tags: [ 'supertag', 'tag1', 'tag2' ] 379 tags: [ 'supertag', 'tag1', 'tag2' ]
380 } 380 }
381 await server.videosCommand.update({ id: videoId, attributes }) 381 await server.videos.update({ id: videoId, attributes })
382 382
383 const video = await server.videosCommand.get({ id: videoId }) 383 const video = await server.videos.get({ id: videoId })
384 384
385 await completeVideoCheck(server, video, Object.assign(updateCheckAttributes(), attributes)) 385 await completeVideoCheck(server, video, Object.assign(updateCheckAttributes(), attributes))
386 }) 386 })
@@ -389,27 +389,27 @@ describe('Test a single server', function () {
389 const attributes = { 389 const attributes = {
390 description: 'hello everybody' 390 description: 'hello everybody'
391 } 391 }
392 await server.videosCommand.update({ id: videoId, attributes }) 392 await server.videos.update({ id: videoId, attributes })
393 393
394 const video = await server.videosCommand.get({ id: videoId }) 394 const video = await server.videos.get({ id: videoId })
395 395
396 const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes) 396 const expectedAttributes = Object.assign(updateCheckAttributes(), { tags: [ 'supertag', 'tag1', 'tag2' ] }, attributes)
397 await completeVideoCheck(server, video, expectedAttributes) 397 await completeVideoCheck(server, video, expectedAttributes)
398 }) 398 })
399 399
400 it('Should like a video', async function () { 400 it('Should like a video', async function () {
401 await server.videosCommand.rate({ id: videoId, rating: 'like' }) 401 await server.videos.rate({ id: videoId, rating: 'like' })
402 402
403 const video = await server.videosCommand.get({ id: videoId }) 403 const video = await server.videos.get({ id: videoId })
404 404
405 expect(video.likes).to.equal(1) 405 expect(video.likes).to.equal(1)
406 expect(video.dislikes).to.equal(0) 406 expect(video.dislikes).to.equal(0)
407 }) 407 })
408 408
409 it('Should dislike the same video', async function () { 409 it('Should dislike the same video', async function () {
410 await server.videosCommand.rate({ id: videoId, rating: 'dislike' }) 410 await server.videos.rate({ id: videoId, rating: 'dislike' })
411 411
412 const video = await server.videosCommand.get({ id: videoId }) 412 const video = await server.videos.get({ id: videoId })
413 413
414 expect(video.likes).to.equal(0) 414 expect(video.likes).to.equal(0)
415 expect(video.dislikes).to.equal(1) 415 expect(video.dislikes).to.equal(1)
@@ -419,9 +419,9 @@ describe('Test a single server', function () {
419 { 419 {
420 const now = new Date() 420 const now = new Date()
421 const attributes = { originallyPublishedAt: now.toISOString() } 421 const attributes = { originallyPublishedAt: now.toISOString() }
422 await server.videosCommand.update({ id: videoId, attributes }) 422 await server.videos.update({ id: videoId, attributes })
423 423
424 const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' }) 424 const { data } = await server.videos.list({ sort: '-originallyPublishedAt' })
425 const names = data.map(v => v.name) 425 const names = data.map(v => v.name)
426 426
427 expect(names[0]).to.equal('my super video updated') 427 expect(names[0]).to.equal('my super video updated')
@@ -435,9 +435,9 @@ describe('Test a single server', function () {
435 { 435 {
436 const now = new Date() 436 const now = new Date()
437 const attributes = { originallyPublishedAt: now.toISOString() } 437 const attributes = { originallyPublishedAt: now.toISOString() }
438 await server.videosCommand.update({ id: videoId2, attributes }) 438 await server.videos.update({ id: videoId2, attributes })
439 439
440 const { data } = await server.videosCommand.list({ sort: '-originallyPublishedAt' }) 440 const { data } = await server.videos.list({ sort: '-originallyPublishedAt' })
441 const names = data.map(v => v.name) 441 const names = data.map(v => v.name)
442 442
443 expect(names[0]).to.equal('video_short1.webm name') 443 expect(names[0]).to.equal('video_short1.webm name')
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts
index 4c67e96f7..abc07194d 100644
--- a/server/tests/api/videos/video-captions.ts
+++ b/server/tests/api/videos/video-captions.ts
@@ -32,7 +32,7 @@ describe('Test video captions', function () {
32 32
33 await waitJobs(servers) 33 await waitJobs(servers)
34 34
35 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'my video name' } }) 35 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'my video name' } })
36 videoUUID = uuid 36 videoUUID = uuid
37 37
38 await waitJobs(servers) 38 await waitJobs(servers)
@@ -40,7 +40,7 @@ describe('Test video captions', function () {
40 40
41 it('Should list the captions and return an empty list', async function () { 41 it('Should list the captions and return an empty list', async function () {
42 for (const server of servers) { 42 for (const server of servers) {
43 const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) 43 const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
44 expect(body.total).to.equal(0) 44 expect(body.total).to.equal(0)
45 expect(body.data).to.have.lengthOf(0) 45 expect(body.data).to.have.lengthOf(0)
46 } 46 }
@@ -49,13 +49,13 @@ describe('Test video captions', function () {
49 it('Should create two new captions', async function () { 49 it('Should create two new captions', async function () {
50 this.timeout(30000) 50 this.timeout(30000)
51 51
52 await servers[0].captionsCommand.createVideoCaption({ 52 await servers[0].captions.createVideoCaption({
53 language: 'ar', 53 language: 'ar',
54 videoId: videoUUID, 54 videoId: videoUUID,
55 fixture: 'subtitle-good1.vtt' 55 fixture: 'subtitle-good1.vtt'
56 }) 56 })
57 57
58 await servers[0].captionsCommand.createVideoCaption({ 58 await servers[0].captions.createVideoCaption({
59 language: 'zh', 59 language: 'zh',
60 videoId: videoUUID, 60 videoId: videoUUID,
61 fixture: 'subtitle-good2.vtt', 61 fixture: 'subtitle-good2.vtt',
@@ -67,7 +67,7 @@ describe('Test video captions', function () {
67 67
68 it('Should list these uploaded captions', async function () { 68 it('Should list these uploaded captions', async function () {
69 for (const server of servers) { 69 for (const server of servers) {
70 const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) 70 const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
71 expect(body.total).to.equal(2) 71 expect(body.total).to.equal(2)
72 expect(body.data).to.have.lengthOf(2) 72 expect(body.data).to.have.lengthOf(2)
73 73
@@ -88,7 +88,7 @@ describe('Test video captions', function () {
88 it('Should replace an existing caption', async function () { 88 it('Should replace an existing caption', async function () {
89 this.timeout(30000) 89 this.timeout(30000)
90 90
91 await servers[0].captionsCommand.createVideoCaption({ 91 await servers[0].captions.createVideoCaption({
92 language: 'ar', 92 language: 'ar',
93 videoId: videoUUID, 93 videoId: videoUUID,
94 fixture: 'subtitle-good2.vtt' 94 fixture: 'subtitle-good2.vtt'
@@ -99,7 +99,7 @@ describe('Test video captions', function () {
99 99
100 it('Should have this caption updated', async function () { 100 it('Should have this caption updated', async function () {
101 for (const server of servers) { 101 for (const server of servers) {
102 const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) 102 const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
103 expect(body.total).to.equal(2) 103 expect(body.total).to.equal(2)
104 expect(body.data).to.have.lengthOf(2) 104 expect(body.data).to.have.lengthOf(2)
105 105
@@ -114,7 +114,7 @@ describe('Test video captions', function () {
114 it('Should replace an existing caption with a srt file and convert it', async function () { 114 it('Should replace an existing caption with a srt file and convert it', async function () {
115 this.timeout(30000) 115 this.timeout(30000)
116 116
117 await servers[0].captionsCommand.createVideoCaption({ 117 await servers[0].captions.createVideoCaption({
118 language: 'ar', 118 language: 'ar',
119 videoId: videoUUID, 119 videoId: videoUUID,
120 fixture: 'subtitle-good.srt' 120 fixture: 'subtitle-good.srt'
@@ -128,7 +128,7 @@ describe('Test video captions', function () {
128 128
129 it('Should have this caption updated and converted', async function () { 129 it('Should have this caption updated and converted', async function () {
130 for (const server of servers) { 130 for (const server of servers) {
131 const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) 131 const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
132 expect(body.total).to.equal(2) 132 expect(body.total).to.equal(2)
133 expect(body.data).to.have.lengthOf(2) 133 expect(body.data).to.have.lengthOf(2)
134 134
@@ -157,14 +157,14 @@ describe('Test video captions', function () {
157 it('Should remove one caption', async function () { 157 it('Should remove one caption', async function () {
158 this.timeout(30000) 158 this.timeout(30000)
159 159
160 await servers[0].captionsCommand.deleteVideoCaption({ videoId: videoUUID, language: 'ar' }) 160 await servers[0].captions.deleteVideoCaption({ videoId: videoUUID, language: 'ar' })
161 161
162 await waitJobs(servers) 162 await waitJobs(servers)
163 }) 163 })
164 164
165 it('Should only list the caption that was not deleted', async function () { 165 it('Should only list the caption that was not deleted', async function () {
166 for (const server of servers) { 166 for (const server of servers) {
167 const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID }) 167 const body = await server.captions.listVideoCaptions({ videoId: videoUUID })
168 expect(body.total).to.equal(1) 168 expect(body.total).to.equal(1)
169 expect(body.data).to.have.lengthOf(1) 169 expect(body.data).to.have.lengthOf(1)
170 170
@@ -178,7 +178,7 @@ describe('Test video captions', function () {
178 }) 178 })
179 179
180 it('Should remove the video, and thus all video captions', async function () { 180 it('Should remove the video, and thus all video captions', async function () {
181 await servers[0].videosCommand.remove({ id: videoUUID }) 181 await servers[0].videos.remove({ id: videoUUID })
182 182
183 await checkVideoFilesWereRemoved(videoUUID, servers[0]) 183 await checkVideoFilesWereRemoved(videoUUID, servers[0])
184 }) 184 })
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index b85edd920..352eb5ea3 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -43,7 +43,7 @@ describe('Test video change ownership - nominal', function () {
43 await setAccessTokensToServers(servers) 43 await setAccessTokensToServers(servers)
44 await setDefaultVideoChannel(servers) 44 await setDefaultVideoChannel(servers)
45 45
46 await servers[0].configCommand.updateCustomSubConfig({ 46 await servers[0].config.updateCustomSubConfig({
47 newConfig: { 47 newConfig: {
48 transcoding: { 48 transcoding: {
49 enabled: false 49 enabled: false
@@ -54,16 +54,16 @@ describe('Test video change ownership - nominal', function () {
54 } 54 }
55 }) 55 })
56 56
57 firstUserToken = await servers[0].usersCommand.generateUserAndToken(firstUser) 57 firstUserToken = await servers[0].users.generateUserAndToken(firstUser)
58 secondUserToken = await servers[0].usersCommand.generateUserAndToken(secondUser) 58 secondUserToken = await servers[0].users.generateUserAndToken(secondUser)
59 59
60 { 60 {
61 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: firstUserToken }) 61 const { videoChannels } = await servers[0].users.getMyInfo({ token: firstUserToken })
62 firstUserChannelId = videoChannels[0].id 62 firstUserChannelId = videoChannels[0].id
63 } 63 }
64 64
65 { 65 {
66 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: secondUserToken }) 66 const { videoChannels } = await servers[0].users.getMyInfo({ token: secondUserToken })
67 secondUserChannelId = videoChannels[0].id 67 secondUserChannelId = videoChannels[0].id
68 } 68 }
69 69
@@ -72,19 +72,19 @@ describe('Test video change ownership - nominal', function () {
72 name: 'my super name', 72 name: 'my super name',
73 description: 'my super description' 73 description: 'my super description'
74 } 74 }
75 const { id } = await servers[0].videosCommand.upload({ token: firstUserToken, attributes }) 75 const { id } = await servers[0].videos.upload({ token: firstUserToken, attributes })
76 76
77 servers[0].video = await servers[0].videosCommand.get({ id }) 77 servers[0].store.video = await servers[0].videos.get({ id })
78 } 78 }
79 79
80 { 80 {
81 const attributes = { name: 'live', channelId: firstUserChannelId, privacy: VideoPrivacy.PUBLIC } 81 const attributes = { name: 'live', channelId: firstUserChannelId, privacy: VideoPrivacy.PUBLIC }
82 const video = await servers[0].liveCommand.create({ token: firstUserToken, fields: attributes }) 82 const video = await servers[0].live.create({ token: firstUserToken, fields: attributes })
83 83
84 liveId = video.id 84 liveId = video.id
85 } 85 }
86 86
87 command = servers[0].changeOwnershipCommand 87 command = servers[0].changeOwnership
88 88
89 await doubleFollow(servers[0], servers[1]) 89 await doubleFollow(servers[0], servers[1])
90 }) 90 })
@@ -110,7 +110,7 @@ describe('Test video change ownership - nominal', function () {
110 it('Should send a request to change ownership of a video', async function () { 110 it('Should send a request to change ownership of a video', async function () {
111 this.timeout(15000) 111 this.timeout(15000)
112 112
113 await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser }) 113 await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser })
114 }) 114 })
115 115
116 it('Should only return a request to change ownership for the second user', async function () { 116 it('Should only return a request to change ownership for the second user', async function () {
@@ -136,7 +136,7 @@ describe('Test video change ownership - nominal', function () {
136 it('Should accept the same change ownership request without crashing', async function () { 136 it('Should accept the same change ownership request without crashing', async function () {
137 this.timeout(10000) 137 this.timeout(10000)
138 138
139 await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser }) 139 await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser })
140 }) 140 })
141 141
142 it('Should not create multiple change ownership requests while one is waiting', async function () { 142 it('Should not create multiple change ownership requests while one is waiting', async function () {
@@ -164,7 +164,7 @@ describe('Test video change ownership - nominal', function () {
164 it('Should send a new request to change ownership of a video', async function () { 164 it('Should send a new request to change ownership of a video', async function () {
165 this.timeout(15000) 165 this.timeout(15000)
166 166
167 await command.create({ token: firstUserToken, videoId: servers[0].video.id, username: secondUser }) 167 await command.create({ token: firstUserToken, videoId: servers[0].store.video.id, username: secondUser })
168 }) 168 })
169 169
170 it('Should return two requests to change ownership for the second user', async function () { 170 it('Should return two requests to change ownership for the second user', async function () {
@@ -208,7 +208,7 @@ describe('Test video change ownership - nominal', function () {
208 208
209 it('Should have the channel of the video updated', async function () { 209 it('Should have the channel of the video updated', async function () {
210 for (const server of servers) { 210 for (const server of servers) {
211 const video = await server.videosCommand.get({ id: servers[0].video.uuid }) 211 const video = await server.videos.get({ id: servers[0].store.video.uuid })
212 212
213 expect(video.name).to.equal('my super name') 213 expect(video.name).to.equal('my super name')
214 expect(video.channel.displayName).to.equal('Main second channel') 214 expect(video.channel.displayName).to.equal('Main second channel')
@@ -237,7 +237,7 @@ describe('Test video change ownership - nominal', function () {
237 await waitJobs(servers) 237 await waitJobs(servers)
238 238
239 for (const server of servers) { 239 for (const server of servers) {
240 const video = await server.videosCommand.get({ id: servers[0].video.uuid }) 240 const video = await server.videos.get({ id: servers[0].store.video.uuid })
241 241
242 expect(video.name).to.equal('my super name') 242 expect(video.name).to.equal('my super name')
243 expect(video.channel.displayName).to.equal('Main second channel') 243 expect(video.channel.displayName).to.equal('Main second channel')
@@ -266,35 +266,35 @@ describe('Test video change ownership - quota too small', function () {
266 server = await flushAndRunServer(1) 266 server = await flushAndRunServer(1)
267 await setAccessTokensToServers([ server ]) 267 await setAccessTokensToServers([ server ])
268 268
269 await server.usersCommand.create({ username: secondUser, videoQuota: 10 }) 269 await server.users.create({ username: secondUser, videoQuota: 10 })
270 270
271 firstUserToken = await server.usersCommand.generateUserAndToken(firstUser) 271 firstUserToken = await server.users.generateUserAndToken(firstUser)
272 secondUserToken = await server.loginCommand.getAccessToken(secondUser) 272 secondUserToken = await server.login.getAccessToken(secondUser)
273 273
274 // Upload some videos on the server 274 // Upload some videos on the server
275 const attributes = { 275 const attributes = {
276 name: 'my super name', 276 name: 'my super name',
277 description: 'my super description' 277 description: 'my super description'
278 } 278 }
279 await server.videosCommand.upload({ token: firstUserToken, attributes }) 279 await server.videos.upload({ token: firstUserToken, attributes })
280 280
281 await waitJobs(server) 281 await waitJobs(server)
282 282
283 const { data } = await server.videosCommand.list() 283 const { data } = await server.videos.list()
284 expect(data.length).to.equal(1) 284 expect(data.length).to.equal(1)
285 285
286 server.video = data.find(video => video.name === 'my super name') 286 server.store.video = data.find(video => video.name === 'my super name')
287 }) 287 })
288 288
289 it('Should send a request to change ownership of a video', async function () { 289 it('Should send a request to change ownership of a video', async function () {
290 this.timeout(15000) 290 this.timeout(15000)
291 291
292 await server.changeOwnershipCommand.create({ token: firstUserToken, videoId: server.video.id, username: secondUser }) 292 await server.changeOwnership.create({ token: firstUserToken, videoId: server.store.video.id, username: secondUser })
293 }) 293 })
294 294
295 it('Should only return a request to change ownership for the second user', async function () { 295 it('Should only return a request to change ownership for the second user', async function () {
296 { 296 {
297 const body = await server.changeOwnershipCommand.list({ token: firstUserToken }) 297 const body = await server.changeOwnership.list({ token: firstUserToken })
298 298
299 expect(body.total).to.equal(0) 299 expect(body.total).to.equal(0)
300 expect(body.data).to.be.an('array') 300 expect(body.data).to.be.an('array')
@@ -302,7 +302,7 @@ describe('Test video change ownership - quota too small', function () {
302 } 302 }
303 303
304 { 304 {
305 const body = await server.changeOwnershipCommand.list({ token: secondUserToken }) 305 const body = await server.changeOwnership.list({ token: secondUserToken })
306 306
307 expect(body.total).to.equal(1) 307 expect(body.total).to.equal(1)
308 expect(body.data).to.be.an('array') 308 expect(body.data).to.be.an('array')
@@ -315,10 +315,10 @@ describe('Test video change ownership - quota too small', function () {
315 it('Should not be possible to accept the change of ownership from second user because of exceeded quota', async function () { 315 it('Should not be possible to accept the change of ownership from second user because of exceeded quota', async function () {
316 this.timeout(10000) 316 this.timeout(10000)
317 317
318 const { videoChannels } = await server.usersCommand.getMyInfo({ token: secondUserToken }) 318 const { videoChannels } = await server.users.getMyInfo({ token: secondUserToken })
319 const channelId = videoChannels[0].id 319 const channelId = videoChannels[0].id
320 320
321 await server.changeOwnershipCommand.accept({ 321 await server.changeOwnership.accept({
322 token: secondUserToken, 322 token: secondUserToken,
323 ownershipId: lastRequestId, 323 ownershipId: lastRequestId,
324 channelId, 324 channelId,
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 170cc942e..1efef932c 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -21,7 +21,7 @@ import { User, VideoChannel } from '@shared/models'
21const expect = chai.expect 21const expect = chai.expect
22 22
23async function findChannel (server: ServerInfo, channelId: number) { 23async function findChannel (server: ServerInfo, channelId: number) {
24 const body = await server.channelsCommand.list({ sort: '-name' }) 24 const body = await server.channels.list({ sort: '-name' })
25 25
26 return body.data.find(c => c.id === channelId) 26 return body.data.find(c => c.id === channelId)
27} 27}
@@ -49,7 +49,7 @@ describe('Test video channels', function () {
49 }) 49 })
50 50
51 it('Should have one video channel (created with root)', async () => { 51 it('Should have one video channel (created with root)', async () => {
52 const body = await servers[0].channelsCommand.list({ start: 0, count: 2 }) 52 const body = await servers[0].channels.list({ start: 0, count: 2 })
53 53
54 expect(body.total).to.equal(1) 54 expect(body.total).to.equal(1)
55 expect(body.data).to.be.an('array') 55 expect(body.data).to.be.an('array')
@@ -66,14 +66,14 @@ describe('Test video channels', function () {
66 description: 'super video channel description', 66 description: 'super video channel description',
67 support: 'super video channel support text' 67 support: 'super video channel support text'
68 } 68 }
69 const created = await servers[0].channelsCommand.create({ attributes: videoChannel }) 69 const created = await servers[0].channels.create({ attributes: videoChannel })
70 secondVideoChannelId = created.id 70 secondVideoChannelId = created.id
71 } 71 }
72 72
73 // The channel is 1 is propagated to servers 2 73 // The channel is 1 is propagated to servers 2
74 { 74 {
75 const attributes = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' } 75 const attributes = { name: 'my video name', channelId: secondVideoChannelId, support: 'video support field' }
76 const { uuid } = await servers[0].videosCommand.upload({ attributes }) 76 const { uuid } = await servers[0].videos.upload({ attributes })
77 videoUUID = uuid 77 videoUUID = uuid
78 } 78 }
79 79
@@ -81,7 +81,7 @@ describe('Test video channels', function () {
81 }) 81 })
82 82
83 it('Should have two video channels when getting my information', async () => { 83 it('Should have two video channels when getting my information', async () => {
84 userInfo = await servers[0].usersCommand.getMyInfo() 84 userInfo = await servers[0].users.getMyInfo()
85 85
86 expect(userInfo.videoChannels).to.be.an('array') 86 expect(userInfo.videoChannels).to.be.an('array')
87 expect(userInfo.videoChannels).to.have.lengthOf(2) 87 expect(userInfo.videoChannels).to.have.lengthOf(2)
@@ -99,7 +99,7 @@ describe('Test video channels', function () {
99 }) 99 })
100 100
101 it('Should have two video channels when getting account channels on server 1', async function () { 101 it('Should have two video channels when getting account channels on server 1', async function () {
102 const body = await servers[0].channelsCommand.listByAccount({ accountName }) 102 const body = await servers[0].channels.listByAccount({ accountName })
103 expect(body.total).to.equal(2) 103 expect(body.total).to.equal(2)
104 104
105 const videoChannels = body.data 105 const videoChannels = body.data
@@ -118,7 +118,7 @@ describe('Test video channels', function () {
118 118
119 it('Should paginate and sort account channels', async function () { 119 it('Should paginate and sort account channels', async function () {
120 { 120 {
121 const body = await servers[0].channelsCommand.listByAccount({ 121 const body = await servers[0].channels.listByAccount({
122 accountName, 122 accountName,
123 start: 0, 123 start: 0,
124 count: 1, 124 count: 1,
@@ -133,7 +133,7 @@ describe('Test video channels', function () {
133 } 133 }
134 134
135 { 135 {
136 const body = await servers[0].channelsCommand.listByAccount({ 136 const body = await servers[0].channels.listByAccount({
137 accountName, 137 accountName,
138 start: 0, 138 start: 0,
139 count: 1, 139 count: 1,
@@ -146,7 +146,7 @@ describe('Test video channels', function () {
146 } 146 }
147 147
148 { 148 {
149 const body = await servers[0].channelsCommand.listByAccount({ 149 const body = await servers[0].channels.listByAccount({
150 accountName, 150 accountName,
151 start: 1, 151 start: 1,
152 count: 1, 152 count: 1,
@@ -160,7 +160,7 @@ describe('Test video channels', function () {
160 }) 160 })
161 161
162 it('Should have one video channel when getting account channels on server 2', async function () { 162 it('Should have one video channel when getting account channels on server 2', async function () {
163 const body = await servers[1].channelsCommand.listByAccount({ accountName }) 163 const body = await servers[1].channels.listByAccount({ accountName })
164 164
165 expect(body.total).to.equal(1) 165 expect(body.total).to.equal(1)
166 expect(body.data).to.be.an('array') 166 expect(body.data).to.be.an('array')
@@ -174,7 +174,7 @@ describe('Test video channels', function () {
174 }) 174 })
175 175
176 it('Should list video channels', async function () { 176 it('Should list video channels', async function () {
177 const body = await servers[0].channelsCommand.list({ start: 1, count: 1, sort: '-name' }) 177 const body = await servers[0].channels.list({ start: 1, count: 1, sort: '-name' })
178 178
179 expect(body.total).to.equal(2) 179 expect(body.total).to.equal(2)
180 expect(body.data).to.be.an('array') 180 expect(body.data).to.be.an('array')
@@ -192,14 +192,14 @@ describe('Test video channels', function () {
192 support: 'support updated' 192 support: 'support updated'
193 } 193 }
194 194
195 await servers[0].channelsCommand.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes }) 195 await servers[0].channels.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes })
196 196
197 await waitJobs(servers) 197 await waitJobs(servers)
198 }) 198 })
199 199
200 it('Should have video channel updated', async function () { 200 it('Should have video channel updated', async function () {
201 for (const server of servers) { 201 for (const server of servers) {
202 const body = await server.channelsCommand.list({ start: 0, count: 1, sort: '-name' }) 202 const body = await server.channels.list({ start: 0, count: 1, sort: '-name' })
203 203
204 expect(body.total).to.equal(2) 204 expect(body.total).to.equal(2)
205 expect(body.data).to.be.an('array') 205 expect(body.data).to.be.an('array')
@@ -214,7 +214,7 @@ describe('Test video channels', function () {
214 214
215 it('Should not have updated the video support field', async function () { 215 it('Should not have updated the video support field', async function () {
216 for (const server of servers) { 216 for (const server of servers) {
217 const video = await server.videosCommand.get({ id: videoUUID }) 217 const video = await server.videos.get({ id: videoUUID })
218 expect(video.support).to.equal('video support field') 218 expect(video.support).to.equal('video support field')
219 } 219 }
220 }) 220 })
@@ -227,12 +227,12 @@ describe('Test video channels', function () {
227 bulkVideosSupportUpdate: true 227 bulkVideosSupportUpdate: true
228 } 228 }
229 229
230 await servers[0].channelsCommand.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes }) 230 await servers[0].channels.update({ channelName: 'second_video_channel', attributes: videoChannelAttributes })
231 231
232 await waitJobs(servers) 232 await waitJobs(servers)
233 233
234 for (const server of servers) { 234 for (const server of servers) {
235 const video = await server.videosCommand.get({ id: videoUUID }) 235 const video = await server.videos.get({ id: videoUUID })
236 expect(video.support).to.equal(videoChannelAttributes.support) 236 expect(video.support).to.equal(videoChannelAttributes.support)
237 } 237 }
238 }) 238 })
@@ -242,7 +242,7 @@ describe('Test video channels', function () {
242 242
243 const fixture = 'avatar.png' 243 const fixture = 'avatar.png'
244 244
245 await servers[0].channelsCommand.updateImage({ 245 await servers[0].channels.updateImage({
246 channelName: 'second_video_channel', 246 channelName: 'second_video_channel',
247 fixture, 247 fixture,
248 type: 'avatar' 248 type: 'avatar'
@@ -257,7 +257,7 @@ describe('Test video channels', function () {
257 await testImage(server.url, 'avatar-resized', avatarPaths[server.port], '.png') 257 await testImage(server.url, 'avatar-resized', avatarPaths[server.port], '.png')
258 await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), true) 258 await testFileExistsOrNot(server, 'avatars', basename(avatarPaths[server.port]), true)
259 259
260 const row = await server.sqlCommand.getActorImage(basename(avatarPaths[server.port])) 260 const row = await server.sql.getActorImage(basename(avatarPaths[server.port]))
261 expect(row.height).to.equal(ACTOR_IMAGES_SIZE.AVATARS.height) 261 expect(row.height).to.equal(ACTOR_IMAGES_SIZE.AVATARS.height)
262 expect(row.width).to.equal(ACTOR_IMAGES_SIZE.AVATARS.width) 262 expect(row.width).to.equal(ACTOR_IMAGES_SIZE.AVATARS.width)
263 } 263 }
@@ -268,7 +268,7 @@ describe('Test video channels', function () {
268 268
269 const fixture = 'banner.jpg' 269 const fixture = 'banner.jpg'
270 270
271 await servers[0].channelsCommand.updateImage({ 271 await servers[0].channels.updateImage({
272 channelName: 'second_video_channel', 272 channelName: 'second_video_channel',
273 fixture, 273 fixture,
274 type: 'banner' 274 type: 'banner'
@@ -277,13 +277,13 @@ describe('Test video channels', function () {
277 await waitJobs(servers) 277 await waitJobs(servers)
278 278
279 for (const server of servers) { 279 for (const server of servers) {
280 const videoChannel = await server.channelsCommand.get({ channelName: 'second_video_channel@' + servers[0].host }) 280 const videoChannel = await server.channels.get({ channelName: 'second_video_channel@' + servers[0].host })
281 281
282 bannerPaths[server.port] = videoChannel.banner.path 282 bannerPaths[server.port] = videoChannel.banner.path
283 await testImage(server.url, 'banner-resized', bannerPaths[server.port]) 283 await testImage(server.url, 'banner-resized', bannerPaths[server.port])
284 await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), true) 284 await testFileExistsOrNot(server, 'avatars', basename(bannerPaths[server.port]), true)
285 285
286 const row = await server.sqlCommand.getActorImage(basename(bannerPaths[server.port])) 286 const row = await server.sql.getActorImage(basename(bannerPaths[server.port]))
287 expect(row.height).to.equal(ACTOR_IMAGES_SIZE.BANNERS.height) 287 expect(row.height).to.equal(ACTOR_IMAGES_SIZE.BANNERS.height)
288 expect(row.width).to.equal(ACTOR_IMAGES_SIZE.BANNERS.width) 288 expect(row.width).to.equal(ACTOR_IMAGES_SIZE.BANNERS.width)
289 } 289 }
@@ -292,7 +292,7 @@ describe('Test video channels', function () {
292 it('Should delete the video channel avatar', async function () { 292 it('Should delete the video channel avatar', async function () {
293 this.timeout(15000) 293 this.timeout(15000)
294 294
295 await servers[0].channelsCommand.deleteImage({ channelName: 'second_video_channel', type: 'avatar' }) 295 await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'avatar' })
296 296
297 await waitJobs(servers) 297 await waitJobs(servers)
298 298
@@ -307,7 +307,7 @@ describe('Test video channels', function () {
307 it('Should delete the video channel banner', async function () { 307 it('Should delete the video channel banner', async function () {
308 this.timeout(15000) 308 this.timeout(15000)
309 309
310 await servers[0].channelsCommand.deleteImage({ channelName: 'second_video_channel', type: 'banner' }) 310 await servers[0].channels.deleteImage({ channelName: 'second_video_channel', type: 'banner' })
311 311
312 await waitJobs(servers) 312 await waitJobs(servers)
313 313
@@ -324,7 +324,7 @@ describe('Test video channels', function () {
324 324
325 for (const server of servers) { 325 for (const server of servers) {
326 const channelURI = 'second_video_channel@localhost:' + servers[0].port 326 const channelURI = 'second_video_channel@localhost:' + servers[0].port
327 const { total, data } = await server.videosCommand.listByChannel({ videoChannelName: channelURI }) 327 const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI })
328 328
329 expect(total).to.equal(1) 329 expect(total).to.equal(1)
330 expect(data).to.be.an('array') 330 expect(data).to.be.an('array')
@@ -336,7 +336,7 @@ describe('Test video channels', function () {
336 it('Should change the video channel of a video', async function () { 336 it('Should change the video channel of a video', async function () {
337 this.timeout(10000) 337 this.timeout(10000)
338 338
339 await servers[0].videosCommand.update({ id: videoUUID, attributes: { channelId: servers[0].videoChannel.id } }) 339 await servers[0].videos.update({ id: videoUUID, attributes: { channelId: servers[0].store.channel.id } })
340 340
341 await waitJobs(servers) 341 await waitJobs(servers)
342 }) 342 })
@@ -347,13 +347,13 @@ describe('Test video channels', function () {
347 for (const server of servers) { 347 for (const server of servers) {
348 { 348 {
349 const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port 349 const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port
350 const { total } = await server.videosCommand.listByChannel({ videoChannelName: secondChannelURI }) 350 const { total } = await server.videos.listByChannel({ videoChannelName: secondChannelURI })
351 expect(total).to.equal(0) 351 expect(total).to.equal(0)
352 } 352 }
353 353
354 { 354 {
355 const channelURI = 'root_channel@localhost:' + servers[0].port 355 const channelURI = 'root_channel@localhost:' + servers[0].port
356 const { total, data } = await server.videosCommand.listByChannel({ videoChannelName: channelURI }) 356 const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI })
357 expect(total).to.equal(1) 357 expect(total).to.equal(1)
358 358
359 expect(data).to.be.an('array') 359 expect(data).to.be.an('array')
@@ -364,11 +364,11 @@ describe('Test video channels', function () {
364 }) 364 })
365 365
366 it('Should delete video channel', async function () { 366 it('Should delete video channel', async function () {
367 await servers[0].channelsCommand.delete({ channelName: 'second_video_channel' }) 367 await servers[0].channels.delete({ channelName: 'second_video_channel' })
368 }) 368 })
369 369
370 it('Should have video channel deleted', async function () { 370 it('Should have video channel deleted', async function () {
371 const body = await servers[0].channelsCommand.list({ start: 0, count: 10 }) 371 const body = await servers[0].channels.list({ start: 0, count: 10 })
372 372
373 expect(body.total).to.equal(1) 373 expect(body.total).to.equal(1)
374 expect(body.data).to.be.an('array') 374 expect(body.data).to.be.an('array')
@@ -379,15 +379,15 @@ describe('Test video channels', function () {
379 it('Should create the main channel with an uuid if there is a conflict', async function () { 379 it('Should create the main channel with an uuid if there is a conflict', async function () {
380 { 380 {
381 const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' } 381 const videoChannel = { name: 'toto_channel', displayName: 'My toto channel' }
382 const created = await servers[0].channelsCommand.create({ attributes: videoChannel }) 382 const created = await servers[0].channels.create({ attributes: videoChannel })
383 totoChannel = created.id 383 totoChannel = created.id
384 } 384 }
385 385
386 { 386 {
387 await servers[0].usersCommand.create({ username: 'toto', password: 'password' }) 387 await servers[0].users.create({ username: 'toto', password: 'password' })
388 const accessToken = await servers[0].loginCommand.getAccessToken({ username: 'toto', password: 'password' }) 388 const accessToken = await servers[0].login.getAccessToken({ username: 'toto', password: 'password' })
389 389
390 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token: accessToken }) 390 const { videoChannels } = await servers[0].users.getMyInfo({ token: accessToken })
391 const videoChannel = videoChannels[0] 391 const videoChannel = videoChannels[0]
392 expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/) 392 expect(videoChannel.name).to.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)
393 } 393 }
@@ -397,7 +397,7 @@ describe('Test video channels', function () {
397 this.timeout(10000) 397 this.timeout(10000)
398 398
399 { 399 {
400 const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true }) 400 const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true })
401 401
402 for (const channel of data) { 402 for (const channel of data) {
403 expect(channel).to.haveOwnProperty('viewsPerDay') 403 expect(channel).to.haveOwnProperty('viewsPerDay')
@@ -411,21 +411,21 @@ describe('Test video channels', function () {
411 } 411 }
412 412
413 { 413 {
414 // video has been posted on channel servers[0].videoChannel.id since last update 414 // video has been posted on channel servers[0].store.videoChannel.id since last update
415 await servers[0].videosCommand.view({ id: videoUUID, xForwardedFor: '0.0.0.1,127.0.0.1' }) 415 await servers[0].videos.view({ id: videoUUID, xForwardedFor: '0.0.0.1,127.0.0.1' })
416 await servers[0].videosCommand.view({ id: videoUUID, xForwardedFor: '0.0.0.2,127.0.0.1' }) 416 await servers[0].videos.view({ id: videoUUID, xForwardedFor: '0.0.0.2,127.0.0.1' })
417 417
418 // Wait the repeatable job 418 // Wait the repeatable job
419 await wait(8000) 419 await wait(8000)
420 420
421 const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true }) 421 const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true })
422 const channelWithView = data.find(channel => channel.id === servers[0].videoChannel.id) 422 const channelWithView = data.find(channel => channel.id === servers[0].store.channel.id)
423 expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2) 423 expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2)
424 } 424 }
425 }) 425 })
426 426
427 it('Should report correct videos count', async function () { 427 it('Should report correct videos count', async function () {
428 const { data } = await servers[0].channelsCommand.listByAccount({ accountName, withStats: true }) 428 const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true })
429 429
430 const totoChannel = data.find(c => c.name === 'toto_channel') 430 const totoChannel = data.find(c => c.name === 'toto_channel')
431 const rootChannel = data.find(c => c.name === 'root_channel') 431 const rootChannel = data.find(c => c.name === 'root_channel')
@@ -436,7 +436,7 @@ describe('Test video channels', function () {
436 436
437 it('Should search among account video channels', async function () { 437 it('Should search among account video channels', async function () {
438 { 438 {
439 const body = await servers[0].channelsCommand.listByAccount({ accountName, search: 'root' }) 439 const body = await servers[0].channels.listByAccount({ accountName, search: 'root' })
440 expect(body.total).to.equal(1) 440 expect(body.total).to.equal(1)
441 441
442 const channels = body.data 442 const channels = body.data
@@ -444,7 +444,7 @@ describe('Test video channels', function () {
444 } 444 }
445 445
446 { 446 {
447 const body = await servers[0].channelsCommand.listByAccount({ accountName, search: 'does not exist' }) 447 const body = await servers[0].channels.listByAccount({ accountName, search: 'does not exist' })
448 expect(body.total).to.equal(0) 448 expect(body.total).to.equal(0)
449 449
450 const channels = body.data 450 const channels = body.data
@@ -455,21 +455,21 @@ describe('Test video channels', function () {
455 it('Should list channels by updatedAt desc if a video has been uploaded', async function () { 455 it('Should list channels by updatedAt desc if a video has been uploaded', async function () {
456 this.timeout(30000) 456 this.timeout(30000)
457 457
458 await servers[0].videosCommand.upload({ attributes: { channelId: totoChannel } }) 458 await servers[0].videos.upload({ attributes: { channelId: totoChannel } })
459 await waitJobs(servers) 459 await waitJobs(servers)
460 460
461 for (const server of servers) { 461 for (const server of servers) {
462 const { data } = await server.channelsCommand.listByAccount({ accountName, sort: '-updatedAt' }) 462 const { data } = await server.channels.listByAccount({ accountName, sort: '-updatedAt' })
463 463
464 expect(data[0].name).to.equal('toto_channel') 464 expect(data[0].name).to.equal('toto_channel')
465 expect(data[1].name).to.equal('root_channel') 465 expect(data[1].name).to.equal('root_channel')
466 } 466 }
467 467
468 await servers[0].videosCommand.upload({ attributes: { channelId: servers[0].videoChannel.id } }) 468 await servers[0].videos.upload({ attributes: { channelId: servers[0].store.channel.id } })
469 await waitJobs(servers) 469 await waitJobs(servers)
470 470
471 for (const server of servers) { 471 for (const server of servers) {
472 const { data } = await server.channelsCommand.listByAccount({ accountName, sort: '-updatedAt' }) 472 const { data } = await server.channels.listByAccount({ accountName, sort: '-updatedAt' })
473 473
474 expect(data[0].name).to.equal('root_channel') 474 expect(data[0].name).to.equal('root_channel')
475 expect(data[1].name).to.equal('toto_channel') 475 expect(data[1].name).to.equal('toto_channel')
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index 41be54c81..adb59bd74 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -32,15 +32,15 @@ describe('Test video comments', function () {
32 32
33 await setAccessTokensToServers([ server ]) 33 await setAccessTokensToServers([ server ])
34 34
35 const { id, uuid } = await server.videosCommand.upload() 35 const { id, uuid } = await server.videos.upload()
36 videoUUID = uuid 36 videoUUID = uuid
37 videoId = id 37 videoId = id
38 38
39 await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' }) 39 await server.users.updateMyAvatar({ fixture: 'avatar.png' })
40 40
41 userAccessTokenServer1 = await server.usersCommand.generateUserAndToken('user1') 41 userAccessTokenServer1 = await server.users.generateUserAndToken('user1')
42 42
43 command = server.commentsCommand 43 command = server.comments
44 }) 44 })
45 45
46 describe('User comments', function () { 46 describe('User comments', function () {
diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.ts
index 6ac9206f5..b89247288 100644
--- a/server/tests/api/videos/video-description.ts
+++ b/server/tests/api/videos/video-description.ts
@@ -31,11 +31,11 @@ describe('Test video description', function () {
31 const attributes = { 31 const attributes = {
32 description: longDescription 32 description: longDescription
33 } 33 }
34 await servers[0].videosCommand.upload({ attributes }) 34 await servers[0].videos.upload({ attributes })
35 35
36 await waitJobs(servers) 36 await waitJobs(servers)
37 37
38 const { data } = await servers[0].videosCommand.list() 38 const { data } = await servers[0].videos.list()
39 39
40 videoId = data[0].id 40 videoId = data[0].id
41 videoUUID = data[0].uuid 41 videoUUID = data[0].uuid
@@ -43,7 +43,7 @@ describe('Test video description', function () {
43 43
44 it('Should have a truncated description on each server', async function () { 44 it('Should have a truncated description on each server', async function () {
45 for (const server of servers) { 45 for (const server of servers) {
46 const video = await server.videosCommand.get({ id: videoUUID }) 46 const video = await server.videos.get({ id: videoUUID })
47 47
48 // 30 characters * 6 -> 240 characters 48 // 30 characters * 6 -> 240 characters
49 const truncatedDescription = 'my super description for server 1'.repeat(7) + 49 const truncatedDescription = 'my super description for server 1'.repeat(7) +
@@ -55,9 +55,9 @@ describe('Test video description', function () {
55 55
56 it('Should fetch long description on each server', async function () { 56 it('Should fetch long description on each server', async function () {
57 for (const server of servers) { 57 for (const server of servers) {
58 const video = await server.videosCommand.get({ id: videoUUID }) 58 const video = await server.videos.get({ id: videoUUID })
59 59
60 const { description } = await server.videosCommand.getDescription({ descriptionPath: video.descriptionPath }) 60 const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
61 expect(description).to.equal(longDescription) 61 expect(description).to.equal(longDescription)
62 } 62 }
63 }) 63 })
@@ -68,18 +68,18 @@ describe('Test video description', function () {
68 const attributes = { 68 const attributes = {
69 description: 'short description' 69 description: 'short description'
70 } 70 }
71 await servers[0].videosCommand.update({ id: videoId, attributes }) 71 await servers[0].videos.update({ id: videoId, attributes })
72 72
73 await waitJobs(servers) 73 await waitJobs(servers)
74 }) 74 })
75 75
76 it('Should have a small description on each server', async function () { 76 it('Should have a small description on each server', async function () {
77 for (const server of servers) { 77 for (const server of servers) {
78 const video = await server.videosCommand.get({ id: videoUUID }) 78 const video = await server.videos.get({ id: videoUUID })
79 79
80 expect(video.description).to.equal('short description') 80 expect(video.description).to.equal('short description')
81 81
82 const { description } = await server.videosCommand.getDescription({ descriptionPath: video.descriptionPath }) 82 const { description } = await server.videos.getDescription({ descriptionPath: video.descriptionPath })
83 expect(description).to.equal('short description') 83 expect(description).to.equal('short description')
84 } 84 }
85 }) 85 })
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index d63b81694..9d79f2683 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -25,7 +25,7 @@ const expect = chai.expect
25 25
26async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) { 26async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOnly: boolean, resolutions = [ 240, 360, 480, 720 ]) {
27 for (const server of servers) { 27 for (const server of servers) {
28 const videoDetails = await server.videosCommand.get({ id: videoUUID }) 28 const videoDetails = await server.videos.get({ id: videoUUID })
29 const baseUrl = `http://${videoDetails.account.host}` 29 const baseUrl = `http://${videoDetails.account.host}`
30 30
31 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 31 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
@@ -62,7 +62,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn
62 { 62 {
63 await checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions }) 63 await checkResolutionsInMasterPlaylist({ server, playlistUrl: hlsPlaylist.playlistUrl, resolutions })
64 64
65 const masterPlaylist = await server.streamingPlaylistsCommand.get({ url: hlsPlaylist.playlistUrl }) 65 const masterPlaylist = await server.streamingPlaylists.get({ url: hlsPlaylist.playlistUrl })
66 66
67 for (const resolution of resolutions) { 67 for (const resolution of resolutions) {
68 expect(masterPlaylist).to.contain(`${resolution}.m3u8`) 68 expect(masterPlaylist).to.contain(`${resolution}.m3u8`)
@@ -72,7 +72,7 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn
72 72
73 { 73 {
74 for (const resolution of resolutions) { 74 for (const resolution of resolutions) {
75 const subPlaylist = await server.streamingPlaylistsCommand.get({ 75 const subPlaylist = await server.streamingPlaylists.get({
76 url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8` 76 url: `${baseUrl}/static/streaming-playlists/hls/${videoUUID}/${resolution}.m3u8`
77 }) 77 })
78 78
@@ -107,7 +107,7 @@ describe('Test HLS videos', function () {
107 it('Should upload a video and transcode it to HLS', async function () { 107 it('Should upload a video and transcode it to HLS', async function () {
108 this.timeout(120000) 108 this.timeout(120000)
109 109
110 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } }) 110 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video 1', fixture: 'video_short.webm' } })
111 videoUUID = uuid 111 videoUUID = uuid
112 112
113 await waitJobs(servers) 113 await waitJobs(servers)
@@ -118,7 +118,7 @@ describe('Test HLS videos', function () {
118 it('Should upload an audio file and transcode it to HLS', async function () { 118 it('Should upload an audio file and transcode it to HLS', async function () {
119 this.timeout(120000) 119 this.timeout(120000)
120 120
121 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } }) 121 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video audio', fixture: 'sample.ogg' } })
122 videoAudioUUID = uuid 122 videoAudioUUID = uuid
123 123
124 await waitJobs(servers) 124 await waitJobs(servers)
@@ -129,7 +129,7 @@ describe('Test HLS videos', function () {
129 it('Should update the video', async function () { 129 it('Should update the video', async function () {
130 this.timeout(10000) 130 this.timeout(10000)
131 131
132 await servers[0].videosCommand.update({ id: videoUUID, attributes: { name: 'video 1 updated' } }) 132 await servers[0].videos.update({ id: videoUUID, attributes: { name: 'video 1 updated' } })
133 133
134 await waitJobs(servers) 134 await waitJobs(servers)
135 135
@@ -139,14 +139,14 @@ describe('Test HLS videos', function () {
139 it('Should delete videos', async function () { 139 it('Should delete videos', async function () {
140 this.timeout(10000) 140 this.timeout(10000)
141 141
142 await servers[0].videosCommand.remove({ id: videoUUID }) 142 await servers[0].videos.remove({ id: videoUUID })
143 await servers[0].videosCommand.remove({ id: videoAudioUUID }) 143 await servers[0].videos.remove({ id: videoAudioUUID })
144 144
145 await waitJobs(servers) 145 await waitJobs(servers)
146 146
147 for (const server of servers) { 147 for (const server of servers) {
148 await server.videosCommand.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 148 await server.videos.get({ id: videoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
149 await server.videosCommand.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 149 await server.videos.get({ id: videoAudioUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
150 } 150 }
151 }) 151 })
152 152
@@ -192,7 +192,7 @@ describe('Test HLS videos', function () {
192 describe('With only HLS enabled', function () { 192 describe('With only HLS enabled', function () {
193 193
194 before(async function () { 194 before(async function () {
195 await servers[0].configCommand.updateCustomSubConfig({ 195 await servers[0].config.updateCustomSubConfig({
196 newConfig: { 196 newConfig: {
197 transcoding: { 197 transcoding: {
198 enabled: true, 198 enabled: true,
diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts
index 31fdfe12e..8b6542aa4 100644
--- a/server/tests/api/videos/video-imports.ts
+++ b/server/tests/api/videos/video-imports.ts
@@ -26,7 +26,7 @@ describe('Test video imports', function () {
26 if (areHttpImportTestsDisabled()) return 26 if (areHttpImportTestsDisabled()) return
27 27
28 async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) { 28 async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) {
29 const videoHttp = await server.videosCommand.get({ id: idHttp }) 29 const videoHttp = await server.videos.get({ id: idHttp })
30 30
31 expect(videoHttp.name).to.equal('small video - youtube') 31 expect(videoHttp.name).to.equal('small video - youtube')
32 // FIXME: youtube-dl seems broken 32 // FIXME: youtube-dl seems broken
@@ -43,8 +43,8 @@ describe('Test video imports', function () {
43 expect(originallyPublishedAt.getMonth()).to.equal(0) 43 expect(originallyPublishedAt.getMonth()).to.equal(0)
44 expect(originallyPublishedAt.getFullYear()).to.equal(2019) 44 expect(originallyPublishedAt.getFullYear()).to.equal(2019)
45 45
46 const videoMagnet = await server.videosCommand.get({ id: idMagnet }) 46 const videoMagnet = await server.videos.get({ id: idMagnet })
47 const videoTorrent = await server.videosCommand.get({ id: idTorrent }) 47 const videoTorrent = await server.videos.get({ id: idTorrent })
48 48
49 for (const video of [ videoMagnet, videoTorrent ]) { 49 for (const video of [ videoMagnet, videoTorrent ]) {
50 expect(video.category.label).to.equal('Misc') 50 expect(video.category.label).to.equal('Misc')
@@ -59,12 +59,12 @@ describe('Test video imports', function () {
59 expect(videoTorrent.name).to.contain('你好 世界 720p.mp4') 59 expect(videoTorrent.name).to.contain('你好 世界 720p.mp4')
60 expect(videoMagnet.name).to.contain('super peertube2 video') 60 expect(videoMagnet.name).to.contain('super peertube2 video')
61 61
62 const bodyCaptions = await server.captionsCommand.listVideoCaptions({ videoId: idHttp }) 62 const bodyCaptions = await server.captions.listVideoCaptions({ videoId: idHttp })
63 expect(bodyCaptions.total).to.equal(2) 63 expect(bodyCaptions.total).to.equal(2)
64 } 64 }
65 65
66 async function checkVideoServer2 (server: ServerInfo, id: number | string) { 66 async function checkVideoServer2 (server: ServerInfo, id: number | string) {
67 const video = await server.videosCommand.get({ id }) 67 const video = await server.videos.get({ id })
68 68
69 expect(video.name).to.equal('my super name') 69 expect(video.name).to.equal('my super name')
70 expect(video.category.label).to.equal('Entertainment') 70 expect(video.category.label).to.equal('Entertainment')
@@ -76,7 +76,7 @@ describe('Test video imports', function () {
76 76
77 expect(video.files).to.have.lengthOf(1) 77 expect(video.files).to.have.lengthOf(1)
78 78
79 const bodyCaptions = await server.captionsCommand.listVideoCaptions({ videoId: id }) 79 const bodyCaptions = await server.captions.listVideoCaptions({ videoId: id })
80 expect(bodyCaptions.total).to.equal(2) 80 expect(bodyCaptions.total).to.equal(2)
81 } 81 }
82 82
@@ -89,12 +89,12 @@ describe('Test video imports', function () {
89 await setAccessTokensToServers(servers) 89 await setAccessTokensToServers(servers)
90 90
91 { 91 {
92 const { videoChannels } = await servers[0].usersCommand.getMyInfo() 92 const { videoChannels } = await servers[0].users.getMyInfo()
93 channelIdServer1 = videoChannels[0].id 93 channelIdServer1 = videoChannels[0].id
94 } 94 }
95 95
96 { 96 {
97 const { videoChannels } = await servers[1].usersCommand.getMyInfo() 97 const { videoChannels } = await servers[1].users.getMyInfo()
98 channelIdServer2 = videoChannels[0].id 98 channelIdServer2 = videoChannels[0].id
99 } 99 }
100 100
@@ -111,7 +111,7 @@ describe('Test video imports', function () {
111 111
112 { 112 {
113 const attributes = { ...baseAttributes, targetUrl: ImportsCommand.getYoutubeVideoUrl() } 113 const attributes = { ...baseAttributes, targetUrl: ImportsCommand.getYoutubeVideoUrl() }
114 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 114 const { video } = await servers[0].imports.importVideo({ attributes })
115 expect(video.name).to.equal('small video - youtube') 115 expect(video.name).to.equal('small video - youtube')
116 116
117 expect(video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`)) 117 expect(video.thumbnailPath).to.match(new RegExp(`^/static/thumbnails/.+.jpg$`))
@@ -120,7 +120,7 @@ describe('Test video imports', function () {
120 await testImage(servers[0].url, 'video_import_thumbnail', video.thumbnailPath) 120 await testImage(servers[0].url, 'video_import_thumbnail', video.thumbnailPath)
121 await testImage(servers[0].url, 'video_import_preview', video.previewPath) 121 await testImage(servers[0].url, 'video_import_preview', video.previewPath)
122 122
123 const bodyCaptions = await servers[0].captionsCommand.listVideoCaptions({ videoId: video.id }) 123 const bodyCaptions = await servers[0].captions.listVideoCaptions({ videoId: video.id })
124 const videoCaptions = bodyCaptions.data 124 const videoCaptions = bodyCaptions.data
125 expect(videoCaptions).to.have.lengthOf(2) 125 expect(videoCaptions).to.have.lengthOf(2)
126 126
@@ -166,7 +166,7 @@ Ajouter un sous-titre est vraiment facile`)
166 description: 'this is a super torrent description', 166 description: 'this is a super torrent description',
167 tags: [ 'tag_torrent1', 'tag_torrent2' ] 167 tags: [ 'tag_torrent1', 'tag_torrent2' ]
168 } 168 }
169 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 169 const { video } = await servers[0].imports.importVideo({ attributes })
170 expect(video.name).to.equal('super peertube2 video') 170 expect(video.name).to.equal('super peertube2 video')
171 } 171 }
172 172
@@ -177,13 +177,13 @@ Ajouter un sous-titre est vraiment facile`)
177 description: 'this is a super torrent description', 177 description: 'this is a super torrent description',
178 tags: [ 'tag_torrent1', 'tag_torrent2' ] 178 tags: [ 'tag_torrent1', 'tag_torrent2' ]
179 } 179 }
180 const { video } = await servers[0].importsCommand.importVideo({ attributes }) 180 const { video } = await servers[0].imports.importVideo({ attributes })
181 expect(video.name).to.equal('你好 世界 720p.mp4') 181 expect(video.name).to.equal('你好 世界 720p.mp4')
182 } 182 }
183 }) 183 })
184 184
185 it('Should list the videos to import in my videos on server 1', async function () { 185 it('Should list the videos to import in my videos on server 1', async function () {
186 const { total, data } = await servers[0].videosCommand.listMyVideos({ sort: 'createdAt' }) 186 const { total, data } = await servers[0].videos.listMyVideos({ sort: 'createdAt' })
187 187
188 expect(total).to.equal(3) 188 expect(total).to.equal(3)
189 189
@@ -194,7 +194,7 @@ Ajouter un sous-titre est vraiment facile`)
194 }) 194 })
195 195
196 it('Should list the videos to import in my imports on server 1', async function () { 196 it('Should list the videos to import in my imports on server 1', async function () {
197 const { total, data: videoImports } = await servers[0].importsCommand.getMyVideoImports({ sort: '-createdAt' }) 197 const { total, data: videoImports } = await servers[0].imports.getMyVideoImports({ sort: '-createdAt' })
198 expect(total).to.equal(3) 198 expect(total).to.equal(3)
199 199
200 expect(videoImports).to.have.lengthOf(3) 200 expect(videoImports).to.have.lengthOf(3)
@@ -221,7 +221,7 @@ Ajouter un sous-titre est vraiment facile`)
221 await waitJobs(servers) 221 await waitJobs(servers)
222 222
223 for (const server of servers) { 223 for (const server of servers) {
224 const { total, data } = await server.videosCommand.list() 224 const { total, data } = await server.videos.list()
225 expect(total).to.equal(3) 225 expect(total).to.equal(3)
226 expect(data).to.have.lengthOf(3) 226 expect(data).to.have.lengthOf(3)
227 227
@@ -244,7 +244,7 @@ Ajouter un sous-titre est vraiment facile`)
244 description: 'my super description', 244 description: 'my super description',
245 tags: [ 'supertag1', 'supertag2' ] 245 tags: [ 'supertag1', 'supertag2' ]
246 } 246 }
247 const { video } = await servers[1].importsCommand.importVideo({ attributes }) 247 const { video } = await servers[1].imports.importVideo({ attributes })
248 expect(video.name).to.equal('my super name') 248 expect(video.name).to.equal('my super name')
249 }) 249 })
250 250
@@ -254,7 +254,7 @@ Ajouter un sous-titre est vraiment facile`)
254 await waitJobs(servers) 254 await waitJobs(servers)
255 255
256 for (const server of servers) { 256 for (const server of servers) {
257 const { total, data } = await server.videosCommand.list() 257 const { total, data } = await server.videos.list()
258 expect(total).to.equal(4) 258 expect(total).to.equal(4)
259 expect(data).to.have.lengthOf(4) 259 expect(data).to.have.lengthOf(4)
260 260
@@ -274,13 +274,13 @@ Ajouter un sous-titre est vraiment facile`)
274 channelId: channelIdServer2, 274 channelId: channelIdServer2,
275 privacy: VideoPrivacy.PUBLIC 275 privacy: VideoPrivacy.PUBLIC
276 } 276 }
277 const { video } = await servers[1].importsCommand.importVideo({ attributes }) 277 const { video } = await servers[1].imports.importVideo({ attributes })
278 const videoUUID = video.uuid 278 const videoUUID = video.uuid
279 279
280 await waitJobs(servers) 280 await waitJobs(servers)
281 281
282 for (const server of servers) { 282 for (const server of servers) {
283 const video = await server.videosCommand.get({ id: videoUUID }) 283 const video = await server.videos.get({ id: videoUUID })
284 284
285 expect(video.name).to.equal('transcoded video') 285 expect(video.name).to.equal('transcoded video')
286 expect(video.files).to.have.lengthOf(4) 286 expect(video.files).to.have.lengthOf(4)
@@ -316,7 +316,7 @@ Ajouter un sous-titre est vraiment facile`)
316 } 316 }
317 } 317 }
318 } 318 }
319 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 319 await servers[0].config.updateCustomSubConfig({ newConfig: config })
320 320
321 const attributes = { 321 const attributes = {
322 name: 'hdr video', 322 name: 'hdr video',
@@ -324,13 +324,13 @@ Ajouter un sous-titre est vraiment facile`)
324 channelId: channelIdServer1, 324 channelId: channelIdServer1,
325 privacy: VideoPrivacy.PUBLIC 325 privacy: VideoPrivacy.PUBLIC
326 } 326 }
327 const { video: videoImported } = await servers[0].importsCommand.importVideo({ attributes }) 327 const { video: videoImported } = await servers[0].imports.importVideo({ attributes })
328 const videoUUID = videoImported.uuid 328 const videoUUID = videoImported.uuid
329 329
330 await waitJobs(servers) 330 await waitJobs(servers)
331 331
332 // test resolution 332 // test resolution
333 const video = await servers[0].videosCommand.get({ id: videoUUID }) 333 const video = await servers[0].videos.get({ id: videoUUID })
334 expect(video.name).to.equal('hdr video') 334 expect(video.name).to.equal('hdr video')
335 const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id })) 335 const maxResolution = Math.max.apply(Math, video.files.map(function (o) { return o.resolution.id }))
336 expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P) 336 expect(maxResolution, 'expected max resolution not met').to.equals(VideoResolution.H_1080P)
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index b8fff096d..95395a582 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -18,7 +18,7 @@ describe('Test video NSFW policy', function () {
18 let customConfig: CustomConfig 18 let customConfig: CustomConfig
19 19
20 async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) { 20 async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) {
21 const user = await server.usersCommand.getMyInfo() 21 const user = await server.users.getMyInfo()
22 const videoChannelName = user.videoChannels[0].name 22 const videoChannelName = user.videoChannels[0].name
23 const accountName = user.account.name + '@' + user.account.host 23 const accountName = user.account.name + '@' + user.account.host
24 const hasQuery = Object.keys(query).length !== 0 24 const hasQuery = Object.keys(query).length !== 0
@@ -26,15 +26,15 @@ describe('Test video NSFW policy', function () {
26 26
27 if (token) { 27 if (token) {
28 promises = [ 28 promises = [
29 server.searchCommand.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }), 29 server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }),
30 server.videosCommand.listWithToken({ token, ...query }), 30 server.videos.listWithToken({ token, ...query }),
31 server.videosCommand.listByAccount({ token, accountName, ...query }), 31 server.videos.listByAccount({ token, accountName, ...query }),
32 server.videosCommand.listByChannel({ token, videoChannelName, ...query }) 32 server.videos.listByChannel({ token, videoChannelName, ...query })
33 ] 33 ]
34 34
35 // Overviews do not support video filters 35 // Overviews do not support video filters
36 if (!hasQuery) { 36 if (!hasQuery) {
37 const p = server.overviewsCommand.getVideos({ page: 1, token }) 37 const p = server.overviews.getVideos({ page: 1, token })
38 .then(res => createOverviewRes(res)) 38 .then(res => createOverviewRes(res))
39 promises.push(p) 39 promises.push(p)
40 } 40 }
@@ -43,15 +43,15 @@ describe('Test video NSFW policy', function () {
43 } 43 }
44 44
45 promises = [ 45 promises = [
46 server.searchCommand.searchVideos({ search: 'n', sort: '-publishedAt' }), 46 server.search.searchVideos({ search: 'n', sort: '-publishedAt' }),
47 server.videosCommand.list(), 47 server.videos.list(),
48 server.videosCommand.listByAccount({ accountName }), 48 server.videos.listByAccount({ accountName }),
49 server.videosCommand.listByChannel({ videoChannelName }) 49 server.videos.listByChannel({ videoChannelName })
50 ] 50 ]
51 51
52 // Overviews do not support video filters 52 // Overviews do not support video filters
53 if (!hasQuery) { 53 if (!hasQuery) {
54 const p = server.overviewsCommand.getVideos({ page: 1 }) 54 const p = server.overviews.getVideos({ page: 1 })
55 .then(res => createOverviewRes(res)) 55 .then(res => createOverviewRes(res))
56 promises.push(p) 56 promises.push(p)
57 } 57 }
@@ -68,20 +68,20 @@ describe('Test video NSFW policy', function () {
68 68
69 { 69 {
70 const attributes = { name: 'nsfw', nsfw: true, category: 1 } 70 const attributes = { name: 'nsfw', nsfw: true, category: 1 }
71 await server.videosCommand.upload({ attributes }) 71 await server.videos.upload({ attributes })
72 } 72 }
73 73
74 { 74 {
75 const attributes = { name: 'normal', nsfw: false, category: 1 } 75 const attributes = { name: 'normal', nsfw: false, category: 1 }
76 await server.videosCommand.upload({ attributes }) 76 await server.videos.upload({ attributes })
77 } 77 }
78 78
79 customConfig = await server.configCommand.getCustomConfig() 79 customConfig = await server.config.getCustomConfig()
80 }) 80 })
81 81
82 describe('Instance default NSFW policy', function () { 82 describe('Instance default NSFW policy', function () {
83 it('Should display NSFW videos with display default NSFW policy', async function () { 83 it('Should display NSFW videos with display default NSFW policy', async function () {
84 const serverConfig = await server.configCommand.getConfig() 84 const serverConfig = await server.config.getConfig()
85 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display') 85 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('display')
86 86
87 for (const body of await getVideosFunctions()) { 87 for (const body of await getVideosFunctions()) {
@@ -96,9 +96,9 @@ describe('Test video NSFW policy', function () {
96 96
97 it('Should not display NSFW videos with do_not_list default NSFW policy', async function () { 97 it('Should not display NSFW videos with do_not_list default NSFW policy', async function () {
98 customConfig.instance.defaultNSFWPolicy = 'do_not_list' 98 customConfig.instance.defaultNSFWPolicy = 'do_not_list'
99 await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig }) 99 await server.config.updateCustomConfig({ newCustomConfig: customConfig })
100 100
101 const serverConfig = await server.configCommand.getConfig() 101 const serverConfig = await server.config.getConfig()
102 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('do_not_list') 102 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('do_not_list')
103 103
104 for (const body of await getVideosFunctions()) { 104 for (const body of await getVideosFunctions()) {
@@ -112,9 +112,9 @@ describe('Test video NSFW policy', function () {
112 112
113 it('Should display NSFW videos with blur default NSFW policy', async function () { 113 it('Should display NSFW videos with blur default NSFW policy', async function () {
114 customConfig.instance.defaultNSFWPolicy = 'blur' 114 customConfig.instance.defaultNSFWPolicy = 'blur'
115 await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig }) 115 await server.config.updateCustomConfig({ newCustomConfig: customConfig })
116 116
117 const serverConfig = await server.configCommand.getConfig() 117 const serverConfig = await server.config.getConfig()
118 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('blur') 118 expect(serverConfig.instance.defaultNSFWPolicy).to.equal('blur')
119 119
120 for (const body of await getVideosFunctions()) { 120 for (const body of await getVideosFunctions()) {
@@ -133,17 +133,17 @@ describe('Test video NSFW policy', function () {
133 it('Should create a user having the default nsfw policy', async function () { 133 it('Should create a user having the default nsfw policy', async function () {
134 const username = 'user1' 134 const username = 'user1'
135 const password = 'my super password' 135 const password = 'my super password'
136 await server.usersCommand.create({ username: username, password: password }) 136 await server.users.create({ username: username, password: password })
137 137
138 userAccessToken = await server.loginCommand.getAccessToken({ username, password }) 138 userAccessToken = await server.login.getAccessToken({ username, password })
139 139
140 const user = await server.usersCommand.getMyInfo({ token: userAccessToken }) 140 const user = await server.users.getMyInfo({ token: userAccessToken })
141 expect(user.nsfwPolicy).to.equal('blur') 141 expect(user.nsfwPolicy).to.equal('blur')
142 }) 142 })
143 143
144 it('Should display NSFW videos with blur user NSFW policy', async function () { 144 it('Should display NSFW videos with blur user NSFW policy', async function () {
145 customConfig.instance.defaultNSFWPolicy = 'do_not_list' 145 customConfig.instance.defaultNSFWPolicy = 'do_not_list'
146 await server.configCommand.updateCustomConfig({ newCustomConfig: customConfig }) 146 await server.config.updateCustomConfig({ newCustomConfig: customConfig })
147 147
148 for (const body of await getVideosFunctions(userAccessToken)) { 148 for (const body of await getVideosFunctions(userAccessToken)) {
149 expect(body.total).to.equal(2) 149 expect(body.total).to.equal(2)
@@ -156,7 +156,7 @@ describe('Test video NSFW policy', function () {
156 }) 156 })
157 157
158 it('Should display NSFW videos with display user NSFW policy', async function () { 158 it('Should display NSFW videos with display user NSFW policy', async function () {
159 await server.usersCommand.updateMe({ nsfwPolicy: 'display' }) 159 await server.users.updateMe({ nsfwPolicy: 'display' })
160 160
161 for (const body of await getVideosFunctions(server.accessToken)) { 161 for (const body of await getVideosFunctions(server.accessToken)) {
162 expect(body.total).to.equal(2) 162 expect(body.total).to.equal(2)
@@ -169,7 +169,7 @@ describe('Test video NSFW policy', function () {
169 }) 169 })
170 170
171 it('Should not display NSFW videos with do_not_list user NSFW policy', async function () { 171 it('Should not display NSFW videos with do_not_list user NSFW policy', async function () {
172 await server.usersCommand.updateMe({ nsfwPolicy: 'do_not_list' }) 172 await server.users.updateMe({ nsfwPolicy: 'do_not_list' })
173 173
174 for (const body of await getVideosFunctions(server.accessToken)) { 174 for (const body of await getVideosFunctions(server.accessToken)) {
175 expect(body.total).to.equal(1) 175 expect(body.total).to.equal(1)
@@ -181,7 +181,7 @@ describe('Test video NSFW policy', function () {
181 }) 181 })
182 182
183 it('Should be able to see my NSFW videos even with do_not_list user NSFW policy', async function () { 183 it('Should be able to see my NSFW videos even with do_not_list user NSFW policy', async function () {
184 const { total, data } = await server.videosCommand.listMyVideos() 184 const { total, data } = await server.videos.listMyVideos()
185 expect(total).to.equal(2) 185 expect(total).to.equal(2)
186 186
187 expect(data).to.have.lengthOf(2) 187 expect(data).to.have.lengthOf(2)
diff --git a/server/tests/api/videos/video-playlist-thumbnails.ts b/server/tests/api/videos/video-playlist-thumbnails.ts
index 14739af20..709f64c4d 100644
--- a/server/tests/api/videos/video-playlist-thumbnails.ts
+++ b/server/tests/api/videos/video-playlist-thumbnails.ts
@@ -31,13 +31,13 @@ describe('Playlist thumbnail', function () {
31 let video2: number 31 let video2: number
32 32
33 async function getPlaylistWithoutThumbnail (server: ServerInfo) { 33 async function getPlaylistWithoutThumbnail (server: ServerInfo) {
34 const body = await server.playlistsCommand.list({ start: 0, count: 10 }) 34 const body = await server.playlists.list({ start: 0, count: 10 })
35 35
36 return body.data.find(p => p.displayName === 'playlist without thumbnail') 36 return body.data.find(p => p.displayName === 'playlist without thumbnail')
37 } 37 }
38 38
39 async function getPlaylistWithThumbnail (server: ServerInfo) { 39 async function getPlaylistWithThumbnail (server: ServerInfo) {
40 const body = await server.playlistsCommand.list({ start: 0, count: 10 }) 40 const body = await server.playlists.list({ start: 0, count: 10 })
41 41
42 return body.data.find(p => p.displayName === 'playlist with thumbnail') 42 return body.data.find(p => p.displayName === 'playlist with thumbnail')
43 } 43 }
@@ -54,8 +54,8 @@ describe('Playlist thumbnail', function () {
54 // Server 1 and server 2 follow each other 54 // Server 1 and server 2 follow each other
55 await doubleFollow(servers[0], servers[1]) 55 await doubleFollow(servers[0], servers[1])
56 56
57 video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).id 57 video1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).id
58 video2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).id 58 video2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).id
59 59
60 await waitJobs(servers) 60 await waitJobs(servers)
61 }) 61 })
@@ -63,16 +63,16 @@ describe('Playlist thumbnail', function () {
63 it('Should automatically update the thumbnail when adding an element', async function () { 63 it('Should automatically update the thumbnail when adding an element', async function () {
64 this.timeout(30000) 64 this.timeout(30000)
65 65
66 const created = await servers[1].playlistsCommand.create({ 66 const created = await servers[1].playlists.create({
67 attributes: { 67 attributes: {
68 displayName: 'playlist without thumbnail', 68 displayName: 'playlist without thumbnail',
69 privacy: VideoPlaylistPrivacy.PUBLIC, 69 privacy: VideoPlaylistPrivacy.PUBLIC,
70 videoChannelId: servers[1].videoChannel.id 70 videoChannelId: servers[1].store.channel.id
71 } 71 }
72 }) 72 })
73 playlistWithoutThumbnailId = created.id 73 playlistWithoutThumbnailId = created.id
74 74
75 const added = await servers[1].playlistsCommand.addElement({ 75 const added = await servers[1].playlists.addElement({
76 playlistId: playlistWithoutThumbnailId, 76 playlistId: playlistWithoutThumbnailId,
77 attributes: { videoId: video1 } 77 attributes: { videoId: video1 }
78 }) 78 })
@@ -89,17 +89,17 @@ describe('Playlist thumbnail', function () {
89 it('Should not update the thumbnail if we explicitly uploaded a thumbnail', async function () { 89 it('Should not update the thumbnail if we explicitly uploaded a thumbnail', async function () {
90 this.timeout(30000) 90 this.timeout(30000)
91 91
92 const created = await servers[1].playlistsCommand.create({ 92 const created = await servers[1].playlists.create({
93 attributes: { 93 attributes: {
94 displayName: 'playlist with thumbnail', 94 displayName: 'playlist with thumbnail',
95 privacy: VideoPlaylistPrivacy.PUBLIC, 95 privacy: VideoPlaylistPrivacy.PUBLIC,
96 videoChannelId: servers[1].videoChannel.id, 96 videoChannelId: servers[1].store.channel.id,
97 thumbnailfile: 'thumbnail.jpg' 97 thumbnailfile: 'thumbnail.jpg'
98 } 98 }
99 }) 99 })
100 playlistWithThumbnailId = created.id 100 playlistWithThumbnailId = created.id
101 101
102 const added = await servers[1].playlistsCommand.addElement({ 102 const added = await servers[1].playlists.addElement({
103 playlistId: playlistWithThumbnailId, 103 playlistId: playlistWithThumbnailId,
104 attributes: { videoId: video1 } 104 attributes: { videoId: video1 }
105 }) 105 })
@@ -116,13 +116,13 @@ describe('Playlist thumbnail', function () {
116 it('Should automatically update the thumbnail when moving the first element', async function () { 116 it('Should automatically update the thumbnail when moving the first element', async function () {
117 this.timeout(30000) 117 this.timeout(30000)
118 118
119 const added = await servers[1].playlistsCommand.addElement({ 119 const added = await servers[1].playlists.addElement({
120 playlistId: playlistWithoutThumbnailId, 120 playlistId: playlistWithoutThumbnailId,
121 attributes: { videoId: video2 } 121 attributes: { videoId: video2 }
122 }) 122 })
123 withoutThumbnailE2 = added.id 123 withoutThumbnailE2 = added.id
124 124
125 await servers[1].playlistsCommand.reorderElements({ 125 await servers[1].playlists.reorderElements({
126 playlistId: playlistWithoutThumbnailId, 126 playlistId: playlistWithoutThumbnailId,
127 attributes: { 127 attributes: {
128 startPosition: 1, 128 startPosition: 1,
@@ -141,13 +141,13 @@ describe('Playlist thumbnail', function () {
141 it('Should not update the thumbnail when moving the first element if we explicitly uploaded a thumbnail', async function () { 141 it('Should not update the thumbnail when moving the first element if we explicitly uploaded a thumbnail', async function () {
142 this.timeout(30000) 142 this.timeout(30000)
143 143
144 const added = await servers[1].playlistsCommand.addElement({ 144 const added = await servers[1].playlists.addElement({
145 playlistId: playlistWithThumbnailId, 145 playlistId: playlistWithThumbnailId,
146 attributes: { videoId: video2 } 146 attributes: { videoId: video2 }
147 }) 147 })
148 withThumbnailE2 = added.id 148 withThumbnailE2 = added.id
149 149
150 await servers[1].playlistsCommand.reorderElements({ 150 await servers[1].playlists.reorderElements({
151 playlistId: playlistWithThumbnailId, 151 playlistId: playlistWithThumbnailId,
152 attributes: { 152 attributes: {
153 startPosition: 1, 153 startPosition: 1,
@@ -166,7 +166,7 @@ describe('Playlist thumbnail', function () {
166 it('Should automatically update the thumbnail when deleting the first element', async function () { 166 it('Should automatically update the thumbnail when deleting the first element', async function () {
167 this.timeout(30000) 167 this.timeout(30000)
168 168
169 await servers[1].playlistsCommand.removeElement({ 169 await servers[1].playlists.removeElement({
170 playlistId: playlistWithoutThumbnailId, 170 playlistId: playlistWithoutThumbnailId,
171 elementId: withoutThumbnailE1 171 elementId: withoutThumbnailE1
172 }) 172 })
@@ -182,7 +182,7 @@ describe('Playlist thumbnail', function () {
182 it('Should not update the thumbnail when deleting the first element if we explicitly uploaded a thumbnail', async function () { 182 it('Should not update the thumbnail when deleting the first element if we explicitly uploaded a thumbnail', async function () {
183 this.timeout(30000) 183 this.timeout(30000)
184 184
185 await servers[1].playlistsCommand.removeElement({ 185 await servers[1].playlists.removeElement({
186 playlistId: playlistWithThumbnailId, 186 playlistId: playlistWithThumbnailId,
187 elementId: withThumbnailE1 187 elementId: withThumbnailE1
188 }) 188 })
@@ -198,7 +198,7 @@ describe('Playlist thumbnail', function () {
198 it('Should the thumbnail when we delete the last element', async function () { 198 it('Should the thumbnail when we delete the last element', async function () {
199 this.timeout(30000) 199 this.timeout(30000)
200 200
201 await servers[1].playlistsCommand.removeElement({ 201 await servers[1].playlists.removeElement({
202 playlistId: playlistWithoutThumbnailId, 202 playlistId: playlistWithoutThumbnailId,
203 elementId: withoutThumbnailE2 203 elementId: withoutThumbnailE2
204 }) 204 })
@@ -214,7 +214,7 @@ describe('Playlist thumbnail', function () {
214 it('Should not update the thumbnail when we delete the last element if we explicitly uploaded a thumbnail', async function () { 214 it('Should not update the thumbnail when we delete the last element if we explicitly uploaded a thumbnail', async function () {
215 this.timeout(30000) 215 this.timeout(30000)
216 216
217 await servers[1].playlistsCommand.removeElement({ 217 await servers[1].playlists.removeElement({
218 playlistId: playlistWithThumbnailId, 218 playlistId: playlistWithThumbnailId,
219 elementId: withThumbnailE2 219 elementId: withThumbnailE2
220 }) 220 })
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 40f61ca19..0dc53d4c0 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -36,7 +36,7 @@ async function checkPlaylistElementType (
36 total: number 36 total: number
37) { 37) {
38 for (const server of servers) { 38 for (const server of servers) {
39 const body = await server.playlistsCommand.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 }) 39 const body = await server.playlists.listVideos({ token: server.accessToken, playlistId, start: 0, count: 10 })
40 expect(body.total).to.equal(total) 40 expect(body.total).to.equal(total)
41 41
42 const videoElement = body.data.find(e => e.position === position) 42 const videoElement = body.data.find(e => e.position === position)
@@ -86,26 +86,26 @@ describe('Test video playlists', function () {
86 // Server 1 and server 3 follow each other 86 // Server 1 and server 3 follow each other
87 await doubleFollow(servers[0], servers[2]) 87 await doubleFollow(servers[0], servers[2])
88 88
89 commands = servers.map(s => s.playlistsCommand) 89 commands = servers.map(s => s.playlists)
90 90
91 { 91 {
92 servers[0].videos = [] 92 servers[0].store.videos = []
93 servers[1].videos = [] 93 servers[1].store.videos = []
94 servers[2].videos = [] 94 servers[2].store.videos = []
95 95
96 for (const server of servers) { 96 for (const server of servers) {
97 for (let i = 0; i < 7; i++) { 97 for (let i = 0; i < 7; i++) {
98 const name = `video ${i} server ${server.serverNumber}` 98 const name = `video ${i} server ${server.serverNumber}`
99 const video = await server.videosCommand.upload({ attributes: { name, nsfw: false } }) 99 const video = await server.videos.upload({ attributes: { name, nsfw: false } })
100 100
101 server.videos.push(video) 101 server.store.videos.push(video)
102 } 102 }
103 } 103 }
104 } 104 }
105 105
106 nsfwVideoServer1 = (await servers[0].videosCommand.quickUpload({ name: 'NSFW video', nsfw: true })).id 106 nsfwVideoServer1 = (await servers[0].videos.quickUpload({ name: 'NSFW video', nsfw: true })).id
107 107
108 userTokenServer1 = await servers[0].usersCommand.generateUserAndToken('user1') 108 userTokenServer1 = await servers[0].users.generateUserAndToken('user1')
109 109
110 await waitJobs(servers) 110 await waitJobs(servers)
111 }) 111 })
@@ -149,7 +149,7 @@ describe('Test video playlists', function () {
149 }) 149 })
150 150
151 it('Should get private playlist for a classic user', async function () { 151 it('Should get private playlist for a classic user', async function () {
152 const token = await servers[0].usersCommand.generateUserAndToken('toto') 152 const token = await servers[0].users.generateUserAndToken('toto')
153 153
154 const body = await commands[0].listByAccount({ token, handle: 'toto' }) 154 const body = await commands[0].listByAccount({ token, handle: 'toto' })
155 155
@@ -172,7 +172,7 @@ describe('Test video playlists', function () {
172 privacy: VideoPlaylistPrivacy.PUBLIC, 172 privacy: VideoPlaylistPrivacy.PUBLIC,
173 description: 'my super description', 173 description: 'my super description',
174 thumbnailfile: 'thumbnail.jpg', 174 thumbnailfile: 'thumbnail.jpg',
175 videoChannelId: servers[0].videoChannel.id 175 videoChannelId: servers[0].store.channel.id
176 } 176 }
177 }) 177 })
178 178
@@ -181,13 +181,13 @@ describe('Test video playlists', function () {
181 await wait(3000) 181 await wait(3000)
182 182
183 for (const server of servers) { 183 for (const server of servers) {
184 const body = await server.playlistsCommand.list({ start: 0, count: 5 }) 184 const body = await server.playlists.list({ start: 0, count: 5 })
185 expect(body.total).to.equal(1) 185 expect(body.total).to.equal(1)
186 expect(body.data).to.have.lengthOf(1) 186 expect(body.data).to.have.lengthOf(1)
187 187
188 const playlistFromList = body.data[0] 188 const playlistFromList = body.data[0]
189 189
190 const playlistFromGet = await server.playlistsCommand.get({ playlistId: playlistFromList.uuid }) 190 const playlistFromGet = await server.playlists.get({ playlistId: playlistFromList.uuid })
191 191
192 for (const playlist of [ playlistFromGet, playlistFromList ]) { 192 for (const playlist of [ playlistFromGet, playlistFromList ]) {
193 expect(playlist.id).to.be.a('number') 193 expect(playlist.id).to.be.a('number')
@@ -217,23 +217,23 @@ describe('Test video playlists', function () {
217 this.timeout(30000) 217 this.timeout(30000)
218 218
219 { 219 {
220 const playlist = await servers[1].playlistsCommand.create({ 220 const playlist = await servers[1].playlists.create({
221 attributes: { 221 attributes: {
222 displayName: 'playlist 2', 222 displayName: 'playlist 2',
223 privacy: VideoPlaylistPrivacy.PUBLIC, 223 privacy: VideoPlaylistPrivacy.PUBLIC,
224 videoChannelId: servers[1].videoChannel.id 224 videoChannelId: servers[1].store.channel.id
225 } 225 }
226 }) 226 })
227 playlistServer2Id1 = playlist.id 227 playlistServer2Id1 = playlist.id
228 } 228 }
229 229
230 { 230 {
231 const playlist = await servers[1].playlistsCommand.create({ 231 const playlist = await servers[1].playlists.create({
232 attributes: { 232 attributes: {
233 displayName: 'playlist 3', 233 displayName: 'playlist 3',
234 privacy: VideoPlaylistPrivacy.PUBLIC, 234 privacy: VideoPlaylistPrivacy.PUBLIC,
235 thumbnailfile: 'thumbnail.jpg', 235 thumbnailfile: 'thumbnail.jpg',
236 videoChannelId: servers[1].videoChannel.id 236 videoChannelId: servers[1].store.channel.id
237 } 237 }
238 }) 238 })
239 239
@@ -242,13 +242,13 @@ describe('Test video playlists', function () {
242 } 242 }
243 243
244 for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) { 244 for (const id of [ playlistServer2Id1, playlistServer2Id2 ]) {
245 await servers[1].playlistsCommand.addElement({ 245 await servers[1].playlists.addElement({
246 playlistId: id, 246 playlistId: id,
247 attributes: { videoId: servers[1].videos[0].id, startTimestamp: 1, stopTimestamp: 2 } 247 attributes: { videoId: servers[1].store.videos[0].id, startTimestamp: 1, stopTimestamp: 2 }
248 }) 248 })
249 await servers[1].playlistsCommand.addElement({ 249 await servers[1].playlists.addElement({
250 playlistId: id, 250 playlistId: id,
251 attributes: { videoId: servers[1].videos[1].id } 251 attributes: { videoId: servers[1].store.videos[1].id }
252 }) 252 })
253 } 253 }
254 254
@@ -256,7 +256,7 @@ describe('Test video playlists', function () {
256 await wait(3000) 256 await wait(3000)
257 257
258 for (const server of [ servers[0], servers[1] ]) { 258 for (const server of [ servers[0], servers[1] ]) {
259 const body = await server.playlistsCommand.list({ start: 0, count: 5 }) 259 const body = await server.playlists.list({ start: 0, count: 5 })
260 260
261 const playlist2 = body.data.find(p => p.displayName === 'playlist 2') 261 const playlist2 = body.data.find(p => p.displayName === 'playlist 2')
262 expect(playlist2).to.not.be.undefined 262 expect(playlist2).to.not.be.undefined
@@ -267,7 +267,7 @@ describe('Test video playlists', function () {
267 await testImage(server.url, 'thumbnail', playlist3.thumbnailPath) 267 await testImage(server.url, 'thumbnail', playlist3.thumbnailPath)
268 } 268 }
269 269
270 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) 270 const body = await servers[2].playlists.list({ start: 0, count: 5 })
271 expect(body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined 271 expect(body.data.find(p => p.displayName === 'playlist 2')).to.be.undefined
272 expect(body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined 272 expect(body.data.find(p => p.displayName === 'playlist 3')).to.be.undefined
273 }) 273 })
@@ -278,7 +278,7 @@ describe('Test video playlists', function () {
278 // Server 2 and server 3 follow each other 278 // Server 2 and server 3 follow each other
279 await doubleFollow(servers[1], servers[2]) 279 await doubleFollow(servers[1], servers[2])
280 280
281 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) 281 const body = await servers[2].playlists.list({ start: 0, count: 5 })
282 282
283 const playlist2 = body.data.find(p => p.displayName === 'playlist 2') 283 const playlist2 = body.data.find(p => p.displayName === 'playlist 2')
284 expect(playlist2).to.not.be.undefined 284 expect(playlist2).to.not.be.undefined
@@ -294,7 +294,7 @@ describe('Test video playlists', function () {
294 this.timeout(30000) 294 this.timeout(30000)
295 295
296 { 296 {
297 const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: 'createdAt' }) 297 const body = await servers[2].playlists.list({ start: 1, count: 2, sort: 'createdAt' })
298 expect(body.total).to.equal(3) 298 expect(body.total).to.equal(3)
299 299
300 const data = body.data 300 const data = body.data
@@ -304,7 +304,7 @@ describe('Test video playlists', function () {
304 } 304 }
305 305
306 { 306 {
307 const body = await servers[2].playlistsCommand.list({ start: 1, count: 2, sort: '-createdAt' }) 307 const body = await servers[2].playlists.list({ start: 1, count: 2, sort: '-createdAt' })
308 expect(body.total).to.equal(3) 308 expect(body.total).to.equal(3)
309 309
310 const data = body.data 310 const data = body.data
@@ -331,7 +331,7 @@ describe('Test video playlists', function () {
331 this.timeout(30000) 331 this.timeout(30000)
332 332
333 { 333 {
334 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' }) 334 const body = await servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: '-createdAt' })
335 expect(body.total).to.equal(2) 335 expect(body.total).to.equal(2)
336 336
337 const data = body.data 337 const data = body.data
@@ -340,7 +340,7 @@ describe('Test video playlists', function () {
340 } 340 }
341 341
342 { 342 {
343 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' }) 343 const body = await servers[1].playlists.listByAccount({ handle: 'root', start: 1, count: 2, sort: 'createdAt' })
344 expect(body.total).to.equal(2) 344 expect(body.total).to.equal(2)
345 345
346 const data = body.data 346 const data = body.data
@@ -349,7 +349,7 @@ describe('Test video playlists', function () {
349 } 349 }
350 350
351 { 351 {
352 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' }) 352 const body = await servers[1].playlists.listByAccount({ handle: 'root', sort: 'createdAt', search: '3' })
353 expect(body.total).to.equal(1) 353 expect(body.total).to.equal(1)
354 354
355 const data = body.data 355 const data = body.data
@@ -358,7 +358,7 @@ describe('Test video playlists', function () {
358 } 358 }
359 359
360 { 360 {
361 const body = await servers[1].playlistsCommand.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' }) 361 const body = await servers[1].playlists.listByAccount({ handle: 'root', sort: 'createdAt', search: '4' })
362 expect(body.total).to.equal(0) 362 expect(body.total).to.equal(0)
363 363
364 const data = body.data 364 const data = body.data
@@ -375,17 +375,17 @@ describe('Test video playlists', function () {
375 this.timeout(30000) 375 this.timeout(30000)
376 376
377 { 377 {
378 unlistedPlaylist = await servers[1].playlistsCommand.create({ 378 unlistedPlaylist = await servers[1].playlists.create({
379 attributes: { 379 attributes: {
380 displayName: 'playlist unlisted', 380 displayName: 'playlist unlisted',
381 privacy: VideoPlaylistPrivacy.UNLISTED, 381 privacy: VideoPlaylistPrivacy.UNLISTED,
382 videoChannelId: servers[1].videoChannel.id 382 videoChannelId: servers[1].store.channel.id
383 } 383 }
384 }) 384 })
385 } 385 }
386 386
387 { 387 {
388 privatePlaylist = await servers[1].playlistsCommand.create({ 388 privatePlaylist = await servers[1].playlists.create({
389 attributes: { 389 attributes: {
390 displayName: 'playlist private', 390 displayName: 'playlist private',
391 privacy: VideoPlaylistPrivacy.PRIVATE 391 privacy: VideoPlaylistPrivacy.PRIVATE
@@ -400,8 +400,8 @@ describe('Test video playlists', function () {
400 it('Should not list unlisted or private playlists', async function () { 400 it('Should not list unlisted or private playlists', async function () {
401 for (const server of servers) { 401 for (const server of servers) {
402 const results = [ 402 const results = [
403 await server.playlistsCommand.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }), 403 await server.playlists.listByAccount({ handle: 'root@localhost:' + servers[1].port, sort: '-createdAt' }),
404 await server.playlistsCommand.list({ start: 0, count: 2, sort: '-createdAt' }) 404 await server.playlists.list({ start: 0, count: 2, sort: '-createdAt' })
405 ] 405 ]
406 406
407 expect(results[0].total).to.equal(2) 407 expect(results[0].total).to.equal(2)
@@ -417,23 +417,23 @@ describe('Test video playlists', function () {
417 }) 417 })
418 418
419 it('Should not get unlisted playlist using only the id', async function () { 419 it('Should not get unlisted playlist using only the id', async function () {
420 await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 }) 420 await servers[1].playlists.get({ playlistId: unlistedPlaylist.id, expectedStatus: 404 })
421 }) 421 })
422 422
423 it('Should get unlisted plyaylist using uuid or shortUUID', async function () { 423 it('Should get unlisted plyaylist using uuid or shortUUID', async function () {
424 await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.uuid }) 424 await servers[1].playlists.get({ playlistId: unlistedPlaylist.uuid })
425 await servers[1].playlistsCommand.get({ playlistId: unlistedPlaylist.shortUUID }) 425 await servers[1].playlists.get({ playlistId: unlistedPlaylist.shortUUID })
426 }) 426 })
427 427
428 it('Should not get private playlist without token', async function () { 428 it('Should not get private playlist without token', async function () {
429 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { 429 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) {
430 await servers[1].playlistsCommand.get({ playlistId: id, expectedStatus: 401 }) 430 await servers[1].playlists.get({ playlistId: id, expectedStatus: 401 })
431 } 431 }
432 }) 432 })
433 433
434 it('Should get private playlist with a token', async function () { 434 it('Should get private playlist with a token', async function () {
435 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) { 435 for (const id of [ privatePlaylist.id, privatePlaylist.uuid, privatePlaylist.shortUUID ]) {
436 await servers[1].playlistsCommand.get({ token: servers[1].accessToken, playlistId: id }) 436 await servers[1].playlists.get({ token: servers[1].accessToken, playlistId: id })
437 } 437 }
438 }) 438 })
439 }) 439 })
@@ -443,13 +443,13 @@ describe('Test video playlists', function () {
443 it('Should update a playlist', async function () { 443 it('Should update a playlist', async function () {
444 this.timeout(30000) 444 this.timeout(30000)
445 445
446 await servers[1].playlistsCommand.update({ 446 await servers[1].playlists.update({
447 attributes: { 447 attributes: {
448 displayName: 'playlist 3 updated', 448 displayName: 'playlist 3 updated',
449 description: 'description updated', 449 description: 'description updated',
450 privacy: VideoPlaylistPrivacy.UNLISTED, 450 privacy: VideoPlaylistPrivacy.UNLISTED,
451 thumbnailfile: 'thumbnail.jpg', 451 thumbnailfile: 'thumbnail.jpg',
452 videoChannelId: servers[1].videoChannel.id 452 videoChannelId: servers[1].store.channel.id
453 }, 453 },
454 playlistId: playlistServer2Id2 454 playlistId: playlistServer2Id2
455 }) 455 })
@@ -457,7 +457,7 @@ describe('Test video playlists', function () {
457 await waitJobs(servers) 457 await waitJobs(servers)
458 458
459 for (const server of servers) { 459 for (const server of servers) {
460 const playlist = await server.playlistsCommand.get({ playlistId: playlistServer2UUID2 }) 460 const playlist = await server.playlists.get({ playlistId: playlistServer2UUID2 })
461 461
462 expect(playlist.displayName).to.equal('playlist 3 updated') 462 expect(playlist.displayName).to.equal('playlist 3 updated')
463 expect(playlist.description).to.equal('description updated') 463 expect(playlist.description).to.equal('description updated')
@@ -491,23 +491,23 @@ describe('Test video playlists', function () {
491 attributes: { 491 attributes: {
492 displayName: 'playlist 4', 492 displayName: 'playlist 4',
493 privacy: VideoPlaylistPrivacy.PUBLIC, 493 privacy: VideoPlaylistPrivacy.PUBLIC,
494 videoChannelId: servers[0].videoChannel.id 494 videoChannelId: servers[0].store.channel.id
495 } 495 }
496 }) 496 })
497 497
498 playlistServer1Id = playlist.id 498 playlistServer1Id = playlist.id
499 playlistServer1UUID = playlist.uuid 499 playlistServer1UUID = playlist.uuid
500 500
501 await addVideo({ videoId: servers[0].videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 }) 501 await addVideo({ videoId: servers[0].store.videos[0].uuid, startTimestamp: 15, stopTimestamp: 28 })
502 await addVideo({ videoId: servers[2].videos[1].uuid, startTimestamp: 35 }) 502 await addVideo({ videoId: servers[2].store.videos[1].uuid, startTimestamp: 35 })
503 await addVideo({ videoId: servers[2].videos[2].uuid }) 503 await addVideo({ videoId: servers[2].store.videos[2].uuid })
504 { 504 {
505 const element = await addVideo({ videoId: servers[0].videos[3].uuid, stopTimestamp: 35 }) 505 const element = await addVideo({ videoId: servers[0].store.videos[3].uuid, stopTimestamp: 35 })
506 playlistElementServer1Video4 = element.id 506 playlistElementServer1Video4 = element.id
507 } 507 }
508 508
509 { 509 {
510 const element = await addVideo({ videoId: servers[0].videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 }) 510 const element = await addVideo({ videoId: servers[0].store.videos[4].uuid, startTimestamp: 45, stopTimestamp: 60 })
511 playlistElementServer1Video5 = element.id 511 playlistElementServer1Video5 = element.id
512 } 512 }
513 513
@@ -527,7 +527,7 @@ describe('Test video playlists', function () {
527 527
528 for (const server of servers) { 528 for (const server of servers) {
529 { 529 {
530 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 530 const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
531 531
532 expect(body.total).to.equal(8) 532 expect(body.total).to.equal(8)
533 533
@@ -576,7 +576,7 @@ describe('Test video playlists', function () {
576 } 576 }
577 577
578 { 578 {
579 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 }) 579 const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 2 })
580 expect(body.data).to.have.lengthOf(2) 580 expect(body.data).to.have.lengthOf(2)
581 } 581 }
582 } 582 }
@@ -606,7 +606,7 @@ describe('Test video playlists', function () {
606 attributes: { 606 attributes: {
607 displayName: 'playlist 56', 607 displayName: 'playlist 56',
608 privacy: VideoPlaylistPrivacy.PUBLIC, 608 privacy: VideoPlaylistPrivacy.PUBLIC,
609 videoChannelId: servers[0].videoChannel.id 609 videoChannelId: servers[0].store.channel.id
610 } 610 }
611 }) 611 })
612 612
@@ -617,9 +617,9 @@ describe('Test video playlists', function () {
617 return commands[0].addElement({ token: userTokenServer1, playlistId: playlistServer1Id2, attributes }) 617 return commands[0].addElement({ token: userTokenServer1, playlistId: playlistServer1Id2, attributes })
618 } 618 }
619 619
620 video1 = (await servers[0].videosCommand.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid 620 video1 = (await servers[0].videos.quickUpload({ name: 'video 89', token: userTokenServer1 })).uuid
621 video2 = (await servers[1].videosCommand.quickUpload({ name: 'video 90' })).uuid 621 video2 = (await servers[1].videos.quickUpload({ name: 'video 90' })).uuid
622 video3 = (await servers[0].videosCommand.quickUpload({ name: 'video 91', nsfw: true })).uuid 622 video3 = (await servers[0].videos.quickUpload({ name: 'video 91', nsfw: true })).uuid
623 623
624 await waitJobs(servers) 624 await waitJobs(servers)
625 625
@@ -637,7 +637,7 @@ describe('Test video playlists', function () {
637 const position = 1 637 const position = 1
638 638
639 { 639 {
640 await servers[0].videosCommand.update({ id: video1, attributes: { privacy: VideoPrivacy.PRIVATE } }) 640 await servers[0].videos.update({ id: video1, attributes: { privacy: VideoPrivacy.PRIVATE } })
641 await waitJobs(servers) 641 await waitJobs(servers)
642 642
643 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 643 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -647,7 +647,7 @@ describe('Test video playlists', function () {
647 } 647 }
648 648
649 { 649 {
650 await servers[0].videosCommand.update({ id: video1, attributes: { privacy: VideoPrivacy.PUBLIC } }) 650 await servers[0].videos.update({ id: video1, attributes: { privacy: VideoPrivacy.PUBLIC } })
651 await waitJobs(servers) 651 await waitJobs(servers)
652 652
653 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 653 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -665,7 +665,7 @@ describe('Test video playlists', function () {
665 const position = 1 665 const position = 1
666 666
667 { 667 {
668 await servers[0].blacklistCommand.add({ videoId: video1, reason: 'reason', unfederate: true }) 668 await servers[0].blacklist.add({ videoId: video1, reason: 'reason', unfederate: true })
669 await waitJobs(servers) 669 await waitJobs(servers)
670 670
671 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 671 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -675,7 +675,7 @@ describe('Test video playlists', function () {
675 } 675 }
676 676
677 { 677 {
678 await servers[0].blacklistCommand.remove({ videoId: video1 }) 678 await servers[0].blacklist.remove({ videoId: video1 })
679 await waitJobs(servers) 679 await waitJobs(servers)
680 680
681 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3) 681 await checkPlaylistElementType(groupUser1, playlistServer1UUID2, VideoPlaylistElementType.REGULAR, position, name, 3)
@@ -689,7 +689,7 @@ describe('Test video playlists', function () {
689 it('Should update the element type if the account or server of the video is blocked', async function () { 689 it('Should update the element type if the account or server of the video is blocked', async function () {
690 this.timeout(90000) 690 this.timeout(90000)
691 691
692 const command = servers[0].blocklistCommand 692 const command = servers[0].blocklist
693 693
694 const name = 'video 90' 694 const name = 'video 90'
695 const position = 2 695 const position = 2
@@ -778,7 +778,7 @@ describe('Test video playlists', function () {
778 await waitJobs(servers) 778 await waitJobs(servers)
779 779
780 for (const server of servers) { 780 for (const server of servers) {
781 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 781 const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
782 const names = body.data.map(v => v.video.name) 782 const names = body.data.map(v => v.video.name)
783 783
784 expect(names).to.deep.equal([ 784 expect(names).to.deep.equal([
@@ -807,7 +807,7 @@ describe('Test video playlists', function () {
807 await waitJobs(servers) 807 await waitJobs(servers)
808 808
809 for (const server of servers) { 809 for (const server of servers) {
810 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 810 const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
811 const names = body.data.map(v => v.video.name) 811 const names = body.data.map(v => v.video.name)
812 812
813 expect(names).to.deep.equal([ 813 expect(names).to.deep.equal([
@@ -835,7 +835,7 @@ describe('Test video playlists', function () {
835 await waitJobs(servers) 835 await waitJobs(servers)
836 836
837 for (const server of servers) { 837 for (const server of servers) {
838 const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 838 const { data: elements } = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
839 const names = elements.map(v => v.video.name) 839 const names = elements.map(v => v.video.name)
840 840
841 expect(names).to.deep.equal([ 841 expect(names).to.deep.equal([
@@ -878,7 +878,7 @@ describe('Test video playlists', function () {
878 await waitJobs(servers) 878 await waitJobs(servers)
879 879
880 for (const server of servers) { 880 for (const server of servers) {
881 const { data: elements } = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 881 const { data: elements } = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
882 882
883 expect(elements[0].video.name).to.equal('video 3 server 1') 883 expect(elements[0].video.name).to.equal('video 3 server 1')
884 expect(elements[0].position).to.equal(1) 884 expect(elements[0].position).to.equal(1)
@@ -894,16 +894,16 @@ describe('Test video playlists', function () {
894 894
895 it('Should check videos existence in my playlist', async function () { 895 it('Should check videos existence in my playlist', async function () {
896 const videoIds = [ 896 const videoIds = [
897 servers[0].videos[0].id, 897 servers[0].store.videos[0].id,
898 42000, 898 42000,
899 servers[0].videos[3].id, 899 servers[0].store.videos[3].id,
900 43000, 900 43000,
901 servers[0].videos[4].id 901 servers[0].store.videos[4].id
902 ] 902 ]
903 const obj = await commands[0].videosExist({ videoIds }) 903 const obj = await commands[0].videosExist({ videoIds })
904 904
905 { 905 {
906 const elem = obj[servers[0].videos[0].id] 906 const elem = obj[servers[0].store.videos[0].id]
907 expect(elem).to.have.lengthOf(1) 907 expect(elem).to.have.lengthOf(1)
908 expect(elem[0].playlistElementId).to.exist 908 expect(elem[0].playlistElementId).to.exist
909 expect(elem[0].playlistId).to.equal(playlistServer1Id) 909 expect(elem[0].playlistId).to.equal(playlistServer1Id)
@@ -912,7 +912,7 @@ describe('Test video playlists', function () {
912 } 912 }
913 913
914 { 914 {
915 const elem = obj[servers[0].videos[3].id] 915 const elem = obj[servers[0].store.videos[3].id]
916 expect(elem).to.have.lengthOf(1) 916 expect(elem).to.have.lengthOf(1)
917 expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4) 917 expect(elem[0].playlistElementId).to.equal(playlistElementServer1Video4)
918 expect(elem[0].playlistId).to.equal(playlistServer1Id) 918 expect(elem[0].playlistId).to.equal(playlistServer1Id)
@@ -921,7 +921,7 @@ describe('Test video playlists', function () {
921 } 921 }
922 922
923 { 923 {
924 const elem = obj[servers[0].videos[4].id] 924 const elem = obj[servers[0].store.videos[4].id]
925 expect(elem).to.have.lengthOf(1) 925 expect(elem).to.have.lengthOf(1)
926 expect(elem[0].playlistId).to.equal(playlistServer1Id) 926 expect(elem[0].playlistId).to.equal(playlistServer1Id)
927 expect(elem[0].startTimestamp).to.equal(45) 927 expect(elem[0].startTimestamp).to.equal(45)
@@ -934,29 +934,29 @@ describe('Test video playlists', function () {
934 934
935 it('Should automatically update updatedAt field of playlists', async function () { 935 it('Should automatically update updatedAt field of playlists', async function () {
936 const server = servers[1] 936 const server = servers[1]
937 const videoId = servers[1].videos[5].id 937 const videoId = servers[1].store.videos[5].id
938 938
939 async function getPlaylistNames () { 939 async function getPlaylistNames () {
940 const { data } = await server.playlistsCommand.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' }) 940 const { data } = await server.playlists.listByAccount({ token: server.accessToken, handle: 'root', sort: '-updatedAt' })
941 941
942 return data.map(p => p.displayName) 942 return data.map(p => p.displayName)
943 } 943 }
944 944
945 const attributes = { videoId } 945 const attributes = { videoId }
946 const element1 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id1, attributes }) 946 const element1 = await server.playlists.addElement({ playlistId: playlistServer2Id1, attributes })
947 const element2 = await server.playlistsCommand.addElement({ playlistId: playlistServer2Id2, attributes }) 947 const element2 = await server.playlists.addElement({ playlistId: playlistServer2Id2, attributes })
948 948
949 const names1 = await getPlaylistNames() 949 const names1 = await getPlaylistNames()
950 expect(names1[0]).to.equal('playlist 3 updated') 950 expect(names1[0]).to.equal('playlist 3 updated')
951 expect(names1[1]).to.equal('playlist 2') 951 expect(names1[1]).to.equal('playlist 2')
952 952
953 await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id }) 953 await server.playlists.removeElement({ playlistId: playlistServer2Id1, elementId: element1.id })
954 954
955 const names2 = await getPlaylistNames() 955 const names2 = await getPlaylistNames()
956 expect(names2[0]).to.equal('playlist 2') 956 expect(names2[0]).to.equal('playlist 2')
957 expect(names2[1]).to.equal('playlist 3 updated') 957 expect(names2[1]).to.equal('playlist 3 updated')
958 958
959 await server.playlistsCommand.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id }) 959 await server.playlists.removeElement({ playlistId: playlistServer2Id2, elementId: element2.id })
960 960
961 const names3 = await getPlaylistNames() 961 const names3 = await getPlaylistNames()
962 expect(names3[0]).to.equal('playlist 3 updated') 962 expect(names3[0]).to.equal('playlist 3 updated')
@@ -972,7 +972,7 @@ describe('Test video playlists', function () {
972 await waitJobs(servers) 972 await waitJobs(servers)
973 973
974 for (const server of servers) { 974 for (const server of servers) {
975 const body = await server.playlistsCommand.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 }) 975 const body = await server.playlists.listVideos({ playlistId: playlistServer1UUID, start: 0, count: 10 })
976 expect(body.total).to.equal(6) 976 expect(body.total).to.equal(6)
977 977
978 const elements = body.data 978 const elements = body.data
@@ -1005,14 +1005,14 @@ describe('Test video playlists', function () {
1005 attributes: { 1005 attributes: {
1006 displayName: 'my super public playlist', 1006 displayName: 'my super public playlist',
1007 privacy: VideoPlaylistPrivacy.PUBLIC, 1007 privacy: VideoPlaylistPrivacy.PUBLIC,
1008 videoChannelId: servers[0].videoChannel.id 1008 videoChannelId: servers[0].store.channel.id
1009 } 1009 }
1010 }) 1010 })
1011 1011
1012 await waitJobs(servers) 1012 await waitJobs(servers)
1013 1013
1014 for (const server of servers) { 1014 for (const server of servers) {
1015 await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 }) 1015 await server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.OK_200 })
1016 } 1016 }
1017 1017
1018 const attributes = { privacy: VideoPlaylistPrivacy.PRIVATE } 1018 const attributes = { privacy: VideoPlaylistPrivacy.PRIVATE }
@@ -1021,7 +1021,7 @@ describe('Test video playlists', function () {
1021 await waitJobs(servers) 1021 await waitJobs(servers)
1022 1022
1023 for (const server of [ servers[1], servers[2] ]) { 1023 for (const server of [ servers[1], servers[2] ]) {
1024 await server.playlistsCommand.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 1024 await server.playlists.get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
1025 } 1025 }
1026 1026
1027 await commands[0].get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 1027 await commands[0].get({ playlistId: videoPlaylistIds.uuid, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
@@ -1039,7 +1039,7 @@ describe('Test video playlists', function () {
1039 await waitJobs(servers) 1039 await waitJobs(servers)
1040 1040
1041 for (const server of servers) { 1041 for (const server of servers) {
1042 await server.playlistsCommand.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 1042 await server.playlists.get({ playlistId: playlistServer1UUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
1043 } 1043 }
1044 }) 1044 })
1045 1045
@@ -1057,16 +1057,16 @@ describe('Test video playlists', function () {
1057 const finder = (data: VideoPlaylist[]) => data.find(p => p.displayName === 'my super playlist') 1057 const finder = (data: VideoPlaylist[]) => data.find(p => p.displayName === 'my super playlist')
1058 1058
1059 { 1059 {
1060 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) 1060 const body = await servers[2].playlists.list({ start: 0, count: 5 })
1061 expect(body.total).to.equal(3) 1061 expect(body.total).to.equal(3)
1062 1062
1063 expect(finder(body.data)).to.not.be.undefined 1063 expect(finder(body.data)).to.not.be.undefined
1064 } 1064 }
1065 1065
1066 await servers[2].followsCommand.unfollow({ target: servers[0] }) 1066 await servers[2].follows.unfollow({ target: servers[0] })
1067 1067
1068 { 1068 {
1069 const body = await servers[2].playlistsCommand.list({ start: 0, count: 5 }) 1069 const body = await servers[2].playlists.list({ start: 0, count: 5 })
1070 expect(body.total).to.equal(1) 1070 expect(body.total).to.equal(1)
1071 1071
1072 expect(finder(body.data)).to.be.undefined 1072 expect(finder(body.data)).to.be.undefined
@@ -1076,7 +1076,7 @@ describe('Test video playlists', function () {
1076 it('Should delete a channel and put the associated playlist in private mode', async function () { 1076 it('Should delete a channel and put the associated playlist in private mode', async function () {
1077 this.timeout(30000) 1077 this.timeout(30000)
1078 1078
1079 const channel = await servers[0].channelsCommand.create({ attributes: { name: 'super_channel', displayName: 'super channel' } }) 1079 const channel = await servers[0].channels.create({ attributes: { name: 'super_channel', displayName: 'super channel' } })
1080 1080
1081 const playlistCreated = await commands[0].create({ 1081 const playlistCreated = await commands[0].create({
1082 attributes: { 1082 attributes: {
@@ -1088,7 +1088,7 @@ describe('Test video playlists', function () {
1088 1088
1089 await waitJobs(servers) 1089 await waitJobs(servers)
1090 1090
1091 await servers[0].channelsCommand.delete({ channelName: 'super_channel' }) 1091 await servers[0].channels.delete({ channelName: 'super_channel' })
1092 1092
1093 await waitJobs(servers) 1093 await waitJobs(servers)
1094 1094
@@ -1096,15 +1096,15 @@ describe('Test video playlists', function () {
1096 expect(body.displayName).to.equal('channel playlist') 1096 expect(body.displayName).to.equal('channel playlist')
1097 expect(body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE) 1097 expect(body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
1098 1098
1099 await servers[1].playlistsCommand.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 1099 await servers[1].playlists.get({ playlistId: playlistCreated.uuid, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
1100 }) 1100 })
1101 1101
1102 it('Should delete an account and delete its playlists', async function () { 1102 it('Should delete an account and delete its playlists', async function () {
1103 this.timeout(30000) 1103 this.timeout(30000)
1104 1104
1105 const { userId, token } = await servers[0].usersCommand.generate('user_1') 1105 const { userId, token } = await servers[0].users.generate('user_1')
1106 1106
1107 const { videoChannels } = await servers[0].usersCommand.getMyInfo({ token }) 1107 const { videoChannels } = await servers[0].users.getMyInfo({ token })
1108 const userChannel = videoChannels[0] 1108 const userChannel = videoChannels[0]
1109 1109
1110 await commands[0].create({ 1110 await commands[0].create({
@@ -1121,18 +1121,18 @@ describe('Test video playlists', function () {
1121 1121
1122 { 1122 {
1123 for (const server of [ servers[0], servers[1] ]) { 1123 for (const server of [ servers[0], servers[1] ]) {
1124 const body = await server.playlistsCommand.list({ start: 0, count: 15 }) 1124 const body = await server.playlists.list({ start: 0, count: 15 })
1125 1125
1126 expect(finder(body.data)).to.not.be.undefined 1126 expect(finder(body.data)).to.not.be.undefined
1127 } 1127 }
1128 } 1128 }
1129 1129
1130 await servers[0].usersCommand.remove({ userId }) 1130 await servers[0].users.remove({ userId })
1131 await waitJobs(servers) 1131 await waitJobs(servers)
1132 1132
1133 { 1133 {
1134 for (const server of [ servers[0], servers[1] ]) { 1134 for (const server of [ servers[0], servers[1] ]) {
1135 const body = await server.playlistsCommand.list({ start: 0, count: 15 }) 1135 const body = await server.playlists.list({ start: 0, count: 15 })
1136 1136
1137 expect(finder(body.data)).to.be.undefined 1137 expect(finder(body.data)).to.be.undefined
1138 } 1138 }
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
index bcf431edb..de08a9e7b 100644
--- a/server/tests/api/videos/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -52,28 +52,28 @@ describe('Test video privacy', function () {
52 52
53 for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) { 53 for (const privacy of [ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]) {
54 const attributes = { privacy } 54 const attributes = { privacy }
55 await servers[0].videosCommand.upload({ attributes }) 55 await servers[0].videos.upload({ attributes })
56 } 56 }
57 57
58 await waitJobs(servers) 58 await waitJobs(servers)
59 }) 59 })
60 60
61 it('Should not have these private and internal videos on server 2', async function () { 61 it('Should not have these private and internal videos on server 2', async function () {
62 const { total, data } = await servers[1].videosCommand.list() 62 const { total, data } = await servers[1].videos.list()
63 63
64 expect(total).to.equal(0) 64 expect(total).to.equal(0)
65 expect(data).to.have.lengthOf(0) 65 expect(data).to.have.lengthOf(0)
66 }) 66 })
67 67
68 it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () { 68 it('Should not list the private and internal videos for an unauthenticated user on server 1', async function () {
69 const { total, data } = await servers[0].videosCommand.list() 69 const { total, data } = await servers[0].videos.list()
70 70
71 expect(total).to.equal(0) 71 expect(total).to.equal(0)
72 expect(data).to.have.lengthOf(0) 72 expect(data).to.have.lengthOf(0)
73 }) 73 })
74 74
75 it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () { 75 it('Should not list the private video and list the internal video for an authenticated user on server 1', async function () {
76 const { total, data } = await servers[0].videosCommand.listWithToken() 76 const { total, data } = await servers[0].videos.listWithToken()
77 77
78 expect(total).to.equal(1) 78 expect(total).to.equal(1)
79 expect(data).to.have.lengthOf(1) 79 expect(data).to.have.lengthOf(1)
@@ -82,7 +82,7 @@ describe('Test video privacy', function () {
82 }) 82 })
83 83
84 it('Should list my (private and internal) videos', async function () { 84 it('Should list my (private and internal) videos', async function () {
85 const { total, data } = await servers[0].videosCommand.listMyVideos() 85 const { total, data } = await servers[0].videos.listMyVideos()
86 86
87 expect(total).to.equal(2) 87 expect(total).to.equal(2)
88 expect(data).to.have.lengthOf(2) 88 expect(data).to.have.lengthOf(2)
@@ -97,8 +97,8 @@ describe('Test video privacy', function () {
97 }) 97 })
98 98
99 it('Should not be able to watch the private/internal video with non authenticated user', async function () { 99 it('Should not be able to watch the private/internal video with non authenticated user', async function () {
100 await servers[0].videosCommand.get({ id: privateVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 100 await servers[0].videos.get({ id: privateVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
101 await servers[0].videosCommand.get({ id: internalVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 101 await servers[0].videos.get({ id: internalVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
102 }) 102 })
103 103
104 it('Should not be able to watch the private video with another user', async function () { 104 it('Should not be able to watch the private video with another user', async function () {
@@ -108,11 +108,11 @@ describe('Test video privacy', function () {
108 username: 'hello', 108 username: 'hello',
109 password: 'super password' 109 password: 'super password'
110 } 110 }
111 await servers[0].usersCommand.create({ username: user.username, password: user.password }) 111 await servers[0].users.create({ username: user.username, password: user.password })
112 112
113 anotherUserToken = await servers[0].loginCommand.getAccessToken(user) 113 anotherUserToken = await servers[0].login.getAccessToken(user)
114 114
115 await servers[0].videosCommand.getWithToken({ 115 await servers[0].videos.getWithToken({
116 token: anotherUserToken, 116 token: anotherUserToken,
117 id: privateVideoUUID, 117 id: privateVideoUUID,
118 expectedStatus: HttpStatusCode.FORBIDDEN_403 118 expectedStatus: HttpStatusCode.FORBIDDEN_403
@@ -120,11 +120,11 @@ describe('Test video privacy', function () {
120 }) 120 })
121 121
122 it('Should be able to watch the internal video with another user', async function () { 122 it('Should be able to watch the internal video with another user', async function () {
123 await servers[0].videosCommand.getWithToken({ token: anotherUserToken, id: internalVideoUUID }) 123 await servers[0].videos.getWithToken({ token: anotherUserToken, id: internalVideoUUID })
124 }) 124 })
125 125
126 it('Should be able to watch the private video with the correct user', async function () { 126 it('Should be able to watch the private video with the correct user', async function () {
127 await servers[0].videosCommand.getWithToken({ id: privateVideoUUID }) 127 await servers[0].videos.getWithToken({ id: privateVideoUUID })
128 }) 128 })
129 }) 129 })
130 130
@@ -137,7 +137,7 @@ describe('Test video privacy', function () {
137 name: 'unlisted video', 137 name: 'unlisted video',
138 privacy: VideoPrivacy.UNLISTED 138 privacy: VideoPrivacy.UNLISTED
139 } 139 }
140 await servers[1].videosCommand.upload({ attributes }) 140 await servers[1].videos.upload({ attributes })
141 141
142 // Server 2 has transcoding enabled 142 // Server 2 has transcoding enabled
143 await waitJobs(servers) 143 await waitJobs(servers)
@@ -145,7 +145,7 @@ describe('Test video privacy', function () {
145 145
146 it('Should not have this unlisted video listed on server 1 and 2', async function () { 146 it('Should not have this unlisted video listed on server 1 and 2', async function () {
147 for (const server of servers) { 147 for (const server of servers) {
148 const { total, data } = await server.videosCommand.list() 148 const { total, data } = await server.videos.list()
149 149
150 expect(total).to.equal(0) 150 expect(total).to.equal(0)
151 expect(data).to.have.lengthOf(0) 151 expect(data).to.have.lengthOf(0)
@@ -153,7 +153,7 @@ describe('Test video privacy', function () {
153 }) 153 })
154 154
155 it('Should list my (unlisted) videos', async function () { 155 it('Should list my (unlisted) videos', async function () {
156 const { total, data } = await servers[1].videosCommand.listMyVideos() 156 const { total, data } = await servers[1].videos.listMyVideos()
157 157
158 expect(total).to.equal(1) 158 expect(total).to.equal(1)
159 expect(data).to.have.lengthOf(1) 159 expect(data).to.have.lengthOf(1)
@@ -162,13 +162,13 @@ describe('Test video privacy', function () {
162 }) 162 })
163 163
164 it('Should not be able to get this unlisted video using its id', async function () { 164 it('Should not be able to get this unlisted video using its id', async function () {
165 await servers[1].videosCommand.get({ id: unlistedVideo.id, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 165 await servers[1].videos.get({ id: unlistedVideo.id, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
166 }) 166 })
167 167
168 it('Should be able to get this unlisted video using its uuid/shortUUID', async function () { 168 it('Should be able to get this unlisted video using its uuid/shortUUID', async function () {
169 for (const server of servers) { 169 for (const server of servers) {
170 for (const id of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) { 170 for (const id of [ unlistedVideo.uuid, unlistedVideo.shortUUID ]) {
171 const video = await server.videosCommand.get({ id }) 171 const video = await server.videos.get({ id })
172 172
173 expect(video.name).to.equal('unlisted video') 173 expect(video.name).to.equal('unlisted video')
174 } 174 }
@@ -182,13 +182,13 @@ describe('Test video privacy', function () {
182 name: 'unlisted video', 182 name: 'unlisted video',
183 privacy: VideoPrivacy.UNLISTED 183 privacy: VideoPrivacy.UNLISTED
184 } 184 }
185 await servers[0].videosCommand.upload({ attributes }) 185 await servers[0].videos.upload({ attributes })
186 186
187 await waitJobs(servers) 187 await waitJobs(servers)
188 }) 188 })
189 189
190 it('Should list my new unlisted video', async function () { 190 it('Should list my new unlisted video', async function () {
191 const { total, data } = await servers[0].videosCommand.listMyVideos() 191 const { total, data } = await servers[0].videos.listMyVideos()
192 192
193 expect(total).to.equal(3) 193 expect(total).to.equal(3)
194 expect(data).to.have.lengthOf(3) 194 expect(data).to.have.lengthOf(3)
@@ -197,13 +197,13 @@ describe('Test video privacy', function () {
197 }) 197 })
198 198
199 it('Should be able to get non-federated unlisted video from origin', async function () { 199 it('Should be able to get non-federated unlisted video from origin', async function () {
200 const video = await servers[0].videosCommand.get({ id: nonFederatedUnlistedVideoUUID }) 200 const video = await servers[0].videos.get({ id: nonFederatedUnlistedVideoUUID })
201 201
202 expect(video.name).to.equal('unlisted video') 202 expect(video.name).to.equal('unlisted video')
203 }) 203 })
204 204
205 it('Should not be able to get non-federated unlisted video from federated server', async function () { 205 it('Should not be able to get non-federated unlisted video from federated server', async function () {
206 await servers[1].videosCommand.get({ id: nonFederatedUnlistedVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 206 await servers[1].videos.get({ id: nonFederatedUnlistedVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
207 }) 207 })
208 }) 208 })
209 209
@@ -220,7 +220,7 @@ describe('Test video privacy', function () {
220 privacy: VideoPrivacy.PUBLIC 220 privacy: VideoPrivacy.PUBLIC
221 } 221 }
222 222
223 await servers[0].videosCommand.update({ id: privateVideoId, attributes }) 223 await servers[0].videos.update({ id: privateVideoId, attributes })
224 } 224 }
225 225
226 { 226 {
@@ -228,7 +228,7 @@ describe('Test video privacy', function () {
228 name: 'internal video becomes public', 228 name: 'internal video becomes public',
229 privacy: VideoPrivacy.PUBLIC 229 privacy: VideoPrivacy.PUBLIC
230 } 230 }
231 await servers[0].videosCommand.update({ id: internalVideoId, attributes }) 231 await servers[0].videos.update({ id: internalVideoId, attributes })
232 } 232 }
233 233
234 await waitJobs(servers) 234 await waitJobs(servers)
@@ -236,7 +236,7 @@ describe('Test video privacy', function () {
236 236
237 it('Should have this new public video listed on server 1 and 2', async function () { 237 it('Should have this new public video listed on server 1 and 2', async function () {
238 for (const server of servers) { 238 for (const server of servers) {
239 const { total, data } = await server.videosCommand.list() 239 const { total, data } = await server.videos.list()
240 expect(total).to.equal(2) 240 expect(total).to.equal(2)
241 expect(data).to.have.lengthOf(2) 241 expect(data).to.have.lengthOf(2)
242 242
@@ -258,20 +258,20 @@ describe('Test video privacy', function () {
258 it('Should set these videos as private and internal', async function () { 258 it('Should set these videos as private and internal', async function () {
259 this.timeout(10000) 259 this.timeout(10000)
260 260
261 await servers[0].videosCommand.update({ id: internalVideoId, attributes: { privacy: VideoPrivacy.PRIVATE } }) 261 await servers[0].videos.update({ id: internalVideoId, attributes: { privacy: VideoPrivacy.PRIVATE } })
262 await servers[0].videosCommand.update({ id: privateVideoId, attributes: { privacy: VideoPrivacy.INTERNAL } }) 262 await servers[0].videos.update({ id: privateVideoId, attributes: { privacy: VideoPrivacy.INTERNAL } })
263 263
264 await waitJobs(servers) 264 await waitJobs(servers)
265 265
266 for (const server of servers) { 266 for (const server of servers) {
267 const { total, data } = await server.videosCommand.list() 267 const { total, data } = await server.videos.list()
268 268
269 expect(total).to.equal(0) 269 expect(total).to.equal(0)
270 expect(data).to.have.lengthOf(0) 270 expect(data).to.have.lengthOf(0)
271 } 271 }
272 272
273 { 273 {
274 const { total, data } = await servers[0].videosCommand.listMyVideos() 274 const { total, data } = await servers[0].videos.listMyVideos()
275 expect(total).to.equal(3) 275 expect(total).to.equal(3)
276 expect(data).to.have.lengthOf(3) 276 expect(data).to.have.lengthOf(3)
277 277
diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts
index 635ae6ff1..3938b47c8 100644
--- a/server/tests/api/videos/video-schedule-update.ts
+++ b/server/tests/api/videos/video-schedule-update.ts
@@ -49,25 +49,25 @@ describe('Test video update scheduler', function () {
49 } 49 }
50 } 50 }
51 51
52 await servers[0].videosCommand.upload({ attributes }) 52 await servers[0].videos.upload({ attributes })
53 53
54 await waitJobs(servers) 54 await waitJobs(servers)
55 }) 55 })
56 56
57 it('Should not list the video (in privacy mode)', async function () { 57 it('Should not list the video (in privacy mode)', async function () {
58 for (const server of servers) { 58 for (const server of servers) {
59 const { total } = await server.videosCommand.list() 59 const { total } = await server.videos.list()
60 60
61 expect(total).to.equal(0) 61 expect(total).to.equal(0)
62 } 62 }
63 }) 63 })
64 64
65 it('Should have my scheduled video in my account videos', async function () { 65 it('Should have my scheduled video in my account videos', async function () {
66 const { total, data } = await servers[0].videosCommand.listMyVideos() 66 const { total, data } = await servers[0].videos.listMyVideos()
67 expect(total).to.equal(1) 67 expect(total).to.equal(1)
68 68
69 const videoFromList = data[0] 69 const videoFromList = data[0]
70 const videoFromGet = await servers[0].videosCommand.getWithToken({ id: videoFromList.uuid }) 70 const videoFromGet = await servers[0].videos.getWithToken({ id: videoFromList.uuid })
71 71
72 for (const video of [ videoFromList, videoFromGet ]) { 72 for (const video of [ videoFromList, videoFromGet ]) {
73 expect(video.name).to.equal('video 1') 73 expect(video.name).to.equal('video 1')
@@ -84,7 +84,7 @@ describe('Test video update scheduler', function () {
84 await waitJobs(servers) 84 await waitJobs(servers)
85 85
86 for (const server of servers) { 86 for (const server of servers) {
87 const { total, data } = await server.videosCommand.list() 87 const { total, data } = await server.videos.list()
88 88
89 expect(total).to.equal(1) 89 expect(total).to.equal(1)
90 expect(data[0].name).to.equal('video 1') 90 expect(data[0].name).to.equal('video 1')
@@ -99,7 +99,7 @@ describe('Test video update scheduler', function () {
99 privacy: VideoPrivacy.PRIVATE 99 privacy: VideoPrivacy.PRIVATE
100 } 100 }
101 101
102 const { uuid } = await servers[0].videosCommand.upload({ attributes }) 102 const { uuid } = await servers[0].videos.upload({ attributes })
103 video2UUID = uuid 103 video2UUID = uuid
104 104
105 await waitJobs(servers) 105 await waitJobs(servers)
@@ -116,20 +116,20 @@ describe('Test video update scheduler', function () {
116 } 116 }
117 } 117 }
118 118
119 await servers[0].videosCommand.update({ id: video2UUID, attributes }) 119 await servers[0].videos.update({ id: video2UUID, attributes })
120 await waitJobs(servers) 120 await waitJobs(servers)
121 }) 121 })
122 122
123 it('Should not display the updated video', async function () { 123 it('Should not display the updated video', async function () {
124 for (const server of servers) { 124 for (const server of servers) {
125 const { total } = await server.videosCommand.list() 125 const { total } = await server.videos.list()
126 126
127 expect(total).to.equal(1) 127 expect(total).to.equal(1)
128 } 128 }
129 }) 129 })
130 130
131 it('Should have my scheduled updated video in my account videos', async function () { 131 it('Should have my scheduled updated video in my account videos', async function () {
132 const { total, data } = await servers[0].videosCommand.listMyVideos() 132 const { total, data } = await servers[0].videos.listMyVideos()
133 expect(total).to.equal(2) 133 expect(total).to.equal(2)
134 134
135 const video = data.find(v => v.uuid === video2UUID) 135 const video = data.find(v => v.uuid === video2UUID)
@@ -149,7 +149,7 @@ describe('Test video update scheduler', function () {
149 await waitJobs(servers) 149 await waitJobs(servers)
150 150
151 for (const server of servers) { 151 for (const server of servers) {
152 const { total, data } = await server.videosCommand.list() 152 const { total, data } = await server.videos.list()
153 expect(total).to.equal(2) 153 expect(total).to.equal(2)
154 154
155 const video = data.find(v => v.uuid === video2UUID) 155 const video = data.find(v => v.uuid === video2UUID)
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index b41c68283..37450eeeb 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -32,7 +32,7 @@ import {
32const expect = chai.expect 32const expect = chai.expect
33 33
34function updateConfigForTranscoding (server: ServerInfo) { 34function updateConfigForTranscoding (server: ServerInfo) {
35 return server.configCommand.updateCustomSubConfig({ 35 return server.config.updateCustomSubConfig({
36 newConfig: { 36 newConfig: {
37 transcoding: { 37 transcoding: {
38 enabled: true, 38 enabled: true,
@@ -82,15 +82,15 @@ describe('Test video transcoding', function () {
82 description: 'my super description for server 1', 82 description: 'my super description for server 1',
83 fixture: 'video_short.webm' 83 fixture: 'video_short.webm'
84 } 84 }
85 await servers[0].videosCommand.upload({ attributes }) 85 await servers[0].videos.upload({ attributes })
86 86
87 await waitJobs(servers) 87 await waitJobs(servers)
88 88
89 for (const server of servers) { 89 for (const server of servers) {
90 const { data } = await server.videosCommand.list() 90 const { data } = await server.videos.list()
91 const video = data[0] 91 const video = data[0]
92 92
93 const videoDetails = await server.videosCommand.get({ id: video.id }) 93 const videoDetails = await server.videos.get({ id: video.id })
94 expect(videoDetails.files).to.have.lengthOf(1) 94 expect(videoDetails.files).to.have.lengthOf(1)
95 95
96 const magnetUri = videoDetails.files[0].magnetUri 96 const magnetUri = videoDetails.files[0].magnetUri
@@ -111,15 +111,15 @@ describe('Test video transcoding', function () {
111 description: 'my super description for server 2', 111 description: 'my super description for server 2',
112 fixture: 'video_short.webm' 112 fixture: 'video_short.webm'
113 } 113 }
114 await servers[1].videosCommand.upload({ attributes }) 114 await servers[1].videos.upload({ attributes })
115 115
116 await waitJobs(servers) 116 await waitJobs(servers)
117 117
118 for (const server of servers) { 118 for (const server of servers) {
119 const { data } = await server.videosCommand.list() 119 const { data } = await server.videos.list()
120 120
121 const video = data.find(v => v.name === attributes.name) 121 const video = data.find(v => v.name === attributes.name)
122 const videoDetails = await server.videosCommand.get({ id: video.id }) 122 const videoDetails = await server.videos.get({ id: video.id })
123 123
124 expect(videoDetails.files).to.have.lengthOf(4) 124 expect(videoDetails.files).to.have.lengthOf(4)
125 125
@@ -143,11 +143,11 @@ describe('Test video transcoding', function () {
143 fixture: 'video_short1.webm', 143 fixture: 'video_short1.webm',
144 waitTranscoding: true 144 waitTranscoding: true
145 } 145 }
146 const { uuid } = await servers[1].videosCommand.upload({ attributes }) 146 const { uuid } = await servers[1].videos.upload({ attributes })
147 const videoId = uuid 147 const videoId = uuid
148 148
149 // Should be in transcode state 149 // Should be in transcode state
150 const body = await servers[1].videosCommand.get({ id: videoId }) 150 const body = await servers[1].videos.get({ id: videoId })
151 expect(body.name).to.equal('waiting video') 151 expect(body.name).to.equal('waiting video')
152 expect(body.state.id).to.equal(VideoState.TO_TRANSCODE) 152 expect(body.state.id).to.equal(VideoState.TO_TRANSCODE)
153 expect(body.state.label).to.equal('To transcode') 153 expect(body.state.label).to.equal('To transcode')
@@ -155,7 +155,7 @@ describe('Test video transcoding', function () {
155 155
156 { 156 {
157 // Should have my video 157 // Should have my video
158 const { data } = await servers[1].videosCommand.listMyVideos() 158 const { data } = await servers[1].videos.listMyVideos()
159 const videoToFindInMine = data.find(v => v.name === attributes.name) 159 const videoToFindInMine = data.find(v => v.name === attributes.name)
160 expect(videoToFindInMine).not.to.be.undefined 160 expect(videoToFindInMine).not.to.be.undefined
161 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE) 161 expect(videoToFindInMine.state.id).to.equal(VideoState.TO_TRANSCODE)
@@ -165,23 +165,23 @@ describe('Test video transcoding', function () {
165 165
166 { 166 {
167 // Should not list this video 167 // Should not list this video
168 const { data } = await servers[1].videosCommand.list() 168 const { data } = await servers[1].videos.list()
169 const videoToFindInList = data.find(v => v.name === attributes.name) 169 const videoToFindInList = data.find(v => v.name === attributes.name)
170 expect(videoToFindInList).to.be.undefined 170 expect(videoToFindInList).to.be.undefined
171 } 171 }
172 172
173 // Server 1 should not have the video yet 173 // Server 1 should not have the video yet
174 await servers[0].videosCommand.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 174 await servers[0].videos.get({ id: videoId, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
175 } 175 }
176 176
177 await waitJobs(servers) 177 await waitJobs(servers)
178 178
179 for (const server of servers) { 179 for (const server of servers) {
180 const { data } = await server.videosCommand.list() 180 const { data } = await server.videos.list()
181 const videoToFind = data.find(v => v.name === 'waiting video') 181 const videoToFind = data.find(v => v.name === 'waiting video')
182 expect(videoToFind).not.to.be.undefined 182 expect(videoToFind).not.to.be.undefined
183 183
184 const videoDetails = await server.videosCommand.get({ id: videoToFind.id }) 184 const videoDetails = await server.videos.get({ id: videoToFind.id })
185 185
186 expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED) 186 expect(videoDetails.state.id).to.equal(VideoState.PUBLISHED)
187 expect(videoDetails.state.label).to.equal('Published') 187 expect(videoDetails.state.label).to.equal('Published')
@@ -207,15 +207,15 @@ describe('Test video transcoding', function () {
207 fixture 207 fixture
208 } 208 }
209 209
210 await servers[1].videosCommand.upload({ attributes }) 210 await servers[1].videos.upload({ attributes })
211 211
212 await waitJobs(servers) 212 await waitJobs(servers)
213 213
214 for (const server of servers) { 214 for (const server of servers) {
215 const { data } = await server.videosCommand.list() 215 const { data } = await server.videos.list()
216 216
217 const video = data.find(v => v.name === attributes.name) 217 const video = data.find(v => v.name === attributes.name)
218 const videoDetails = await server.videosCommand.get({ id: video.id }) 218 const videoDetails = await server.videos.get({ id: video.id })
219 expect(videoDetails.files).to.have.lengthOf(4) 219 expect(videoDetails.files).to.have.lengthOf(4)
220 220
221 const magnetUri = videoDetails.files[0].magnetUri 221 const magnetUri = videoDetails.files[0].magnetUri
@@ -232,7 +232,7 @@ describe('Test video transcoding', function () {
232 fixture: 'video_short_4k.mp4' 232 fixture: 'video_short_4k.mp4'
233 } 233 }
234 234
235 const { uuid } = await servers[1].videosCommand.upload({ attributes }) 235 const { uuid } = await servers[1].videos.upload({ attributes })
236 video4k = uuid 236 video4k = uuid
237 237
238 await waitJobs(servers) 238 await waitJobs(servers)
@@ -240,7 +240,7 @@ describe('Test video transcoding', function () {
240 const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ] 240 const resolutions = [ 240, 360, 480, 720, 1080, 1440, 2160 ]
241 241
242 for (const server of servers) { 242 for (const server of servers) {
243 const videoDetails = await server.videosCommand.get({ id: video4k }) 243 const videoDetails = await server.videos.get({ id: video4k })
244 expect(videoDetails.files).to.have.lengthOf(resolutions.length) 244 expect(videoDetails.files).to.have.lengthOf(resolutions.length)
245 245
246 for (const r of resolutions) { 246 for (const r of resolutions) {
@@ -260,19 +260,19 @@ describe('Test video transcoding', function () {
260 name: 'mp3_256k', 260 name: 'mp3_256k',
261 fixture: 'video_short_mp3_256k.mp4' 261 fixture: 'video_short_mp3_256k.mp4'
262 } 262 }
263 await servers[1].videosCommand.upload({ attributes }) 263 await servers[1].videos.upload({ attributes })
264 264
265 await waitJobs(servers) 265 await waitJobs(servers)
266 266
267 for (const server of servers) { 267 for (const server of servers) {
268 const { data } = await server.videosCommand.list() 268 const { data } = await server.videos.list()
269 269
270 const video = data.find(v => v.name === attributes.name) 270 const video = data.find(v => v.name === attributes.name)
271 const videoDetails = await server.videosCommand.get({ id: video.id }) 271 const videoDetails = await server.videos.get({ id: video.id })
272 272
273 expect(videoDetails.files).to.have.lengthOf(4) 273 expect(videoDetails.files).to.have.lengthOf(4)
274 274
275 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) 275 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
276 const probe = await getAudioStream(path) 276 const probe = await getAudioStream(path)
277 277
278 if (probe.audioStream) { 278 if (probe.audioStream) {
@@ -291,18 +291,18 @@ describe('Test video transcoding', function () {
291 name: 'no_audio', 291 name: 'no_audio',
292 fixture: 'video_short_no_audio.mp4' 292 fixture: 'video_short_no_audio.mp4'
293 } 293 }
294 await servers[1].videosCommand.upload({ attributes }) 294 await servers[1].videos.upload({ attributes })
295 295
296 await waitJobs(servers) 296 await waitJobs(servers)
297 297
298 for (const server of servers) { 298 for (const server of servers) {
299 const { data } = await server.videosCommand.list() 299 const { data } = await server.videos.list()
300 300
301 const video = data.find(v => v.name === attributes.name) 301 const video = data.find(v => v.name === attributes.name)
302 const videoDetails = await server.videosCommand.get({ id: video.id }) 302 const videoDetails = await server.videos.get({ id: video.id })
303 303
304 expect(videoDetails.files).to.have.lengthOf(4) 304 expect(videoDetails.files).to.have.lengthOf(4)
305 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) 305 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
306 const probe = await getAudioStream(path) 306 const probe = await getAudioStream(path)
307 expect(probe).to.not.have.property('audioStream') 307 expect(probe).to.not.have.property('audioStream')
308 } 308 }
@@ -315,21 +315,21 @@ describe('Test video transcoding', function () {
315 name: 'untouched_audio', 315 name: 'untouched_audio',
316 fixture: 'video_short.mp4' 316 fixture: 'video_short.mp4'
317 } 317 }
318 await servers[1].videosCommand.upload({ attributes }) 318 await servers[1].videos.upload({ attributes })
319 319
320 await waitJobs(servers) 320 await waitJobs(servers)
321 321
322 for (const server of servers) { 322 for (const server of servers) {
323 const { data } = await server.videosCommand.list() 323 const { data } = await server.videos.list()
324 324
325 const video = data.find(v => v.name === attributes.name) 325 const video = data.find(v => v.name === attributes.name)
326 const videoDetails = await server.videosCommand.get({ id: video.id }) 326 const videoDetails = await server.videos.get({ id: video.id })
327 327
328 expect(videoDetails.files).to.have.lengthOf(4) 328 expect(videoDetails.files).to.have.lengthOf(4)
329 329
330 const fixturePath = buildAbsoluteFixturePath(attributes.fixture) 330 const fixturePath = buildAbsoluteFixturePath(attributes.fixture)
331 const fixtureVideoProbe = await getAudioStream(fixturePath) 331 const fixtureVideoProbe = await getAudioStream(fixturePath)
332 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) 332 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
333 333
334 const videoProbe = await getAudioStream(path) 334 const videoProbe = await getAudioStream(path)
335 335
@@ -348,7 +348,7 @@ describe('Test video transcoding', function () {
348 function runSuite (mode: 'legacy' | 'resumable') { 348 function runSuite (mode: 'legacy' | 'resumable') {
349 349
350 before(async function () { 350 before(async function () {
351 await servers[1].configCommand.updateCustomSubConfig({ 351 await servers[1].config.updateCustomSubConfig({
352 newConfig: { 352 newConfig: {
353 transcoding: { 353 transcoding: {
354 hls: { enabled: true }, 354 hls: { enabled: true },
@@ -372,15 +372,15 @@ describe('Test video transcoding', function () {
372 this.timeout(60_000) 372 this.timeout(60_000)
373 373
374 const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } 374 const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
375 await servers[1].videosCommand.upload({ attributes, mode }) 375 await servers[1].videos.upload({ attributes, mode })
376 376
377 await waitJobs(servers) 377 await waitJobs(servers)
378 378
379 for (const server of servers) { 379 for (const server of servers) {
380 const { data } = await server.videosCommand.list() 380 const { data } = await server.videos.list()
381 381
382 const video = data.find(v => v.name === 'audio_with_preview') 382 const video = data.find(v => v.name === 'audio_with_preview')
383 const videoDetails = await server.videosCommand.get({ id: video.id }) 383 const videoDetails = await server.videos.get({ id: video.id })
384 384
385 expect(videoDetails.files).to.have.lengthOf(1) 385 expect(videoDetails.files).to.have.lengthOf(1)
386 386
@@ -396,15 +396,15 @@ describe('Test video transcoding', function () {
396 this.timeout(60_000) 396 this.timeout(60_000)
397 397
398 const attributes = { name: 'audio_without_preview', fixture: 'sample.ogg' } 398 const attributes = { name: 'audio_without_preview', fixture: 'sample.ogg' }
399 await servers[1].videosCommand.upload({ attributes, mode }) 399 await servers[1].videos.upload({ attributes, mode })
400 400
401 await waitJobs(servers) 401 await waitJobs(servers)
402 402
403 for (const server of servers) { 403 for (const server of servers) {
404 const { data } = await server.videosCommand.list() 404 const { data } = await server.videos.list()
405 405
406 const video = data.find(v => v.name === 'audio_without_preview') 406 const video = data.find(v => v.name === 'audio_without_preview')
407 const videoDetails = await server.videosCommand.get({ id: video.id }) 407 const videoDetails = await server.videos.get({ id: video.id })
408 408
409 expect(videoDetails.files).to.have.lengthOf(1) 409 expect(videoDetails.files).to.have.lengthOf(1)
410 410
@@ -419,7 +419,7 @@ describe('Test video transcoding', function () {
419 it('Should upload an audio file and create an audio version only', async function () { 419 it('Should upload an audio file and create an audio version only', async function () {
420 this.timeout(60_000) 420 this.timeout(60_000)
421 421
422 await servers[1].configCommand.updateCustomSubConfig({ 422 await servers[1].config.updateCustomSubConfig({
423 newConfig: { 423 newConfig: {
424 transcoding: { 424 transcoding: {
425 hls: { enabled: true }, 425 hls: { enabled: true },
@@ -434,12 +434,12 @@ describe('Test video transcoding', function () {
434 }) 434 })
435 435
436 const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' } 436 const attributes = { name: 'audio_with_preview', previewfile: 'preview.jpg', fixture: 'sample.ogg' }
437 const { id } = await servers[1].videosCommand.upload({ attributes, mode }) 437 const { id } = await servers[1].videos.upload({ attributes, mode })
438 438
439 await waitJobs(servers) 439 await waitJobs(servers)
440 440
441 for (const server of servers) { 441 for (const server of servers) {
442 const videoDetails = await server.videosCommand.get({ id }) 442 const videoDetails = await server.videos.get({ id })
443 443
444 for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) { 444 for (const files of [ videoDetails.files, videoDetails.streamingPlaylists[0].files ]) {
445 expect(files).to.have.lengthOf(2) 445 expect(files).to.have.lengthOf(2)
@@ -470,15 +470,15 @@ describe('Test video transcoding', function () {
470 description: 'my super 30fps description for server 2', 470 description: 'my super 30fps description for server 2',
471 fixture: '60fps_720p_small.mp4' 471 fixture: '60fps_720p_small.mp4'
472 } 472 }
473 await servers[1].videosCommand.upload({ attributes }) 473 await servers[1].videos.upload({ attributes })
474 474
475 await waitJobs(servers) 475 await waitJobs(servers)
476 476
477 for (const server of servers) { 477 for (const server of servers) {
478 const { data } = await server.videosCommand.list() 478 const { data } = await server.videos.list()
479 479
480 const video = data.find(v => v.name === attributes.name) 480 const video = data.find(v => v.name === attributes.name)
481 const videoDetails = await server.videosCommand.get({ id: video.id }) 481 const videoDetails = await server.videos.get({ id: video.id })
482 482
483 expect(videoDetails.files).to.have.lengthOf(4) 483 expect(videoDetails.files).to.have.lengthOf(4)
484 expect(videoDetails.files[0].fps).to.be.above(58).and.below(62) 484 expect(videoDetails.files[0].fps).to.be.above(58).and.below(62)
@@ -487,13 +487,13 @@ describe('Test video transcoding', function () {
487 expect(videoDetails.files[3].fps).to.be.below(31) 487 expect(videoDetails.files[3].fps).to.be.below(31)
488 488
489 for (const resolution of [ '240', '360', '480' ]) { 489 for (const resolution of [ '240', '360', '480' ]) {
490 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4')) 490 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
491 const fps = await getVideoFileFPS(path) 491 const fps = await getVideoFileFPS(path)
492 492
493 expect(fps).to.be.below(31) 493 expect(fps).to.be.below(31)
494 } 494 }
495 495
496 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4')) 496 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-720.mp4'))
497 const fps = await getVideoFileFPS(path) 497 const fps = await getVideoFileFPS(path)
498 498
499 expect(fps).to.be.above(58).and.below(62) 499 expect(fps).to.be.above(58).and.below(62)
@@ -518,23 +518,23 @@ describe('Test video transcoding', function () {
518 fixture: tempFixturePath 518 fixture: tempFixturePath
519 } 519 }
520 520
521 await servers[1].videosCommand.upload({ attributes }) 521 await servers[1].videos.upload({ attributes })
522 522
523 await waitJobs(servers) 523 await waitJobs(servers)
524 524
525 for (const server of servers) { 525 for (const server of servers) {
526 const { data } = await server.videosCommand.list() 526 const { data } = await server.videos.list()
527 527
528 const video = data.find(v => v.name === attributes.name) 528 const video = data.find(v => v.name === attributes.name)
529 529
530 { 530 {
531 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-240.mp4')) 531 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-240.mp4'))
532 const fps = await getVideoFileFPS(path) 532 const fps = await getVideoFileFPS(path)
533 expect(fps).to.be.equal(25) 533 expect(fps).to.be.equal(25)
534 } 534 }
535 535
536 { 536 {
537 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-720.mp4')) 537 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-720.mp4'))
538 const fps = await getVideoFileFPS(path) 538 const fps = await getVideoFileFPS(path)
539 expect(fps).to.be.equal(59) 539 expect(fps).to.be.equal(59)
540 } 540 }
@@ -561,17 +561,17 @@ describe('Test video transcoding', function () {
561 fixture: tempFixturePath 561 fixture: tempFixturePath
562 } 562 }
563 563
564 await servers[1].videosCommand.upload({ attributes }) 564 await servers[1].videos.upload({ attributes })
565 565
566 await waitJobs(servers) 566 await waitJobs(servers)
567 567
568 for (const server of servers) { 568 for (const server of servers) {
569 const { data } = await server.videosCommand.list() 569 const { data } = await server.videos.list()
570 570
571 const video = data.find(v => v.name === attributes.name) 571 const video = data.find(v => v.name === attributes.name)
572 572
573 for (const resolution of [ '240', '360', '480', '720', '1080' ]) { 573 for (const resolution of [ '240', '360', '480', '720', '1080' ]) {
574 const path = servers[1].serversCommand.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4')) 574 const path = servers[1].servers.buildDirectory(join('videos', video.uuid + '-' + resolution + '.mp4'))
575 575
576 const bitrate = await getVideoFileBitrate(path) 576 const bitrate = await getVideoFileBitrate(path)
577 const fps = await getVideoFileFPS(path) 577 const fps = await getVideoFileFPS(path)
@@ -602,21 +602,21 @@ describe('Test video transcoding', function () {
602 hls: { enabled: true } 602 hls: { enabled: true }
603 } 603 }
604 } 604 }
605 await servers[1].configCommand.updateCustomSubConfig({ newConfig }) 605 await servers[1].config.updateCustomSubConfig({ newConfig })
606 606
607 const attributes = { 607 const attributes = {
608 name: 'low bitrate', 608 name: 'low bitrate',
609 fixture: 'low-bitrate.mp4' 609 fixture: 'low-bitrate.mp4'
610 } 610 }
611 611
612 const { uuid } = await servers[1].videosCommand.upload({ attributes }) 612 const { uuid } = await servers[1].videos.upload({ attributes })
613 613
614 await waitJobs(servers) 614 await waitJobs(servers)
615 615
616 const resolutions = [ 240, 360, 480, 720, 1080 ] 616 const resolutions = [ 240, 360, 480, 720, 1080 ]
617 for (const r of resolutions) { 617 for (const r of resolutions) {
618 const path = `videos/${uuid}-${r}.mp4` 618 const path = `videos/${uuid}-${r}.mp4`
619 const size = await servers[1].serversCommand.getServerFileSize(path) 619 const size = await servers[1].servers.getServerFileSize(path)
620 expect(size, `${path} not below ${60_000}`).to.be.below(60_000) 620 expect(size, `${path} not below ${60_000}`).to.be.below(60_000)
621 } 621 }
622 }) 622 })
@@ -627,11 +627,11 @@ describe('Test video transcoding', function () {
627 it('Should provide valid ffprobe data', async function () { 627 it('Should provide valid ffprobe data', async function () {
628 this.timeout(160_000) 628 this.timeout(160_000)
629 629
630 const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'ffprobe data' })).uuid 630 const videoUUID = (await servers[1].videos.quickUpload({ name: 'ffprobe data' })).uuid
631 await waitJobs(servers) 631 await waitJobs(servers)
632 632
633 { 633 {
634 const path = servers[1].serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4')) 634 const path = servers[1].servers.buildDirectory(join('videos', videoUUID + '-240.mp4'))
635 const metadata = await getMetadataFromFile(path) 635 const metadata = await getMetadataFromFile(path)
636 636
637 // expected format properties 637 // expected format properties
@@ -661,7 +661,7 @@ describe('Test video transcoding', function () {
661 } 661 }
662 662
663 for (const server of servers) { 663 for (const server of servers) {
664 const videoDetails = await server.videosCommand.get({ id: videoUUID }) 664 const videoDetails = await server.videos.get({ id: videoUUID })
665 665
666 const videoFiles = videoDetails.files 666 const videoFiles = videoDetails.files
667 .concat(videoDetails.streamingPlaylists[0].files) 667 .concat(videoDetails.streamingPlaylists[0].files)
@@ -673,7 +673,7 @@ describe('Test video transcoding', function () {
673 expect(file.metadataUrl).to.contain(servers[1].url) 673 expect(file.metadataUrl).to.contain(servers[1].url)
674 expect(file.metadataUrl).to.contain(videoUUID) 674 expect(file.metadataUrl).to.contain(videoUUID)
675 675
676 const metadata = await server.videosCommand.getFileMetadata({ url: file.metadataUrl }) 676 const metadata = await server.videos.getFileMetadata({ url: file.metadataUrl })
677 expect(metadata).to.have.nested.property('format.size') 677 expect(metadata).to.have.nested.property('format.size')
678 } 678 }
679 } 679 }
@@ -690,7 +690,7 @@ describe('Test video transcoding', function () {
690 describe('Transcoding job queue', function () { 690 describe('Transcoding job queue', function () {
691 691
692 it('Should have the appropriate priorities for transcoding jobs', async function () { 692 it('Should have the appropriate priorities for transcoding jobs', async function () {
693 const body = await servers[1].jobsCommand.getJobsList({ 693 const body = await servers[1].jobs.getJobsList({
694 start: 0, 694 start: 0,
695 count: 100, 695 count: 100,
696 sort: '-createdAt', 696 sort: '-createdAt',
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts
index 4a5a83ee6..af1541dbd 100644
--- a/server/tests/api/videos/videos-filter.ts
+++ b/server/tests/api/videos/videos-filter.ts
@@ -55,19 +55,19 @@ describe('Test videos filter', function () {
55 55
56 for (const server of servers) { 56 for (const server of servers) {
57 const moderator = { username: 'moderator', password: 'my super password' } 57 const moderator = { username: 'moderator', password: 'my super password' }
58 await server.usersCommand.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR }) 58 await server.users.create({ username: moderator.username, password: moderator.password, role: UserRole.MODERATOR })
59 server['moderatorAccessToken'] = await server.loginCommand.getAccessToken(moderator) 59 server['moderatorAccessToken'] = await server.login.getAccessToken(moderator)
60 60
61 await server.videosCommand.upload({ attributes: { name: 'public ' + server.serverNumber } }) 61 await server.videos.upload({ attributes: { name: 'public ' + server.serverNumber } })
62 62
63 { 63 {
64 const attributes = { name: 'unlisted ' + server.serverNumber, privacy: VideoPrivacy.UNLISTED } 64 const attributes = { name: 'unlisted ' + server.serverNumber, privacy: VideoPrivacy.UNLISTED }
65 await server.videosCommand.upload({ attributes }) 65 await server.videos.upload({ attributes })
66 } 66 }
67 67
68 { 68 {
69 const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE } 69 const attributes = { name: 'private ' + server.serverNumber, privacy: VideoPrivacy.PRIVATE }
70 await server.videosCommand.upload({ attributes }) 70 await server.videos.upload({ attributes })
71 } 71 }
72 } 72 }
73 73
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index 8614078f1..4b5e581d1 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -33,20 +33,20 @@ describe('Test videos history', function () {
33 33
34 await setAccessTokensToServers([ server ]) 34 await setAccessTokensToServers([ server ])
35 35
36 command = server.historyCommand 36 command = server.history
37 37
38 { 38 {
39 const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 1' } }) 39 const { uuid } = await server.videos.upload({ attributes: { name: 'video 1' } })
40 video1UUID = uuid 40 video1UUID = uuid
41 } 41 }
42 42
43 { 43 {
44 const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 2' } }) 44 const { uuid } = await server.videos.upload({ attributes: { name: 'video 2' } })
45 video2UUID = uuid 45 video2UUID = uuid
46 } 46 }
47 47
48 { 48 {
49 const { uuid } = await server.videosCommand.upload({ attributes: { name: 'video 3' } }) 49 const { uuid } = await server.videos.upload({ attributes: { name: 'video 3' } })
50 video3UUID = uuid 50 video3UUID = uuid
51 } 51 }
52 52
@@ -54,15 +54,15 @@ describe('Test videos history', function () {
54 username: 'user_1', 54 username: 'user_1',
55 password: 'super password' 55 password: 'super password'
56 } 56 }
57 await server.usersCommand.create({ username: user.username, password: user.password }) 57 await server.users.create({ username: user.username, password: user.password })
58 userAccessToken = await server.loginCommand.getAccessToken(user) 58 userAccessToken = await server.login.getAccessToken(user)
59 }) 59 })
60 60
61 it('Should get videos, without watching history', async function () { 61 it('Should get videos, without watching history', async function () {
62 const { data } = await server.videosCommand.listWithToken() 62 const { data } = await server.videos.listWithToken()
63 63
64 for (const video of data) { 64 for (const video of data) {
65 const videoDetails = await server.videosCommand.getWithToken({ id: video.id }) 65 const videoDetails = await server.videos.getWithToken({ id: video.id })
66 66
67 expect(video.userHistory).to.be.undefined 67 expect(video.userHistory).to.be.undefined
68 expect(videoDetails.userHistory).to.be.undefined 68 expect(videoDetails.userHistory).to.be.undefined
@@ -78,12 +78,12 @@ describe('Test videos history', function () {
78 const videosOfVideos: Video[][] = [] 78 const videosOfVideos: Video[][] = []
79 79
80 { 80 {
81 const { data } = await server.videosCommand.listWithToken() 81 const { data } = await server.videos.listWithToken()
82 videosOfVideos.push(data) 82 videosOfVideos.push(data)
83 } 83 }
84 84
85 { 85 {
86 const body = await server.searchCommand.searchVideos({ token: server.accessToken, search: 'video' }) 86 const body = await server.search.searchVideos({ token: server.accessToken, search: 'video' })
87 videosOfVideos.push(body.data) 87 videosOfVideos.push(body.data)
88 } 88 }
89 89
@@ -102,21 +102,21 @@ describe('Test videos history', function () {
102 } 102 }
103 103
104 { 104 {
105 const videoDetails = await server.videosCommand.getWithToken({ id: video1UUID }) 105 const videoDetails = await server.videos.getWithToken({ id: video1UUID })
106 106
107 expect(videoDetails.userHistory).to.not.be.undefined 107 expect(videoDetails.userHistory).to.not.be.undefined
108 expect(videoDetails.userHistory.currentTime).to.equal(3) 108 expect(videoDetails.userHistory.currentTime).to.equal(3)
109 } 109 }
110 110
111 { 111 {
112 const videoDetails = await server.videosCommand.getWithToken({ id: video2UUID }) 112 const videoDetails = await server.videos.getWithToken({ id: video2UUID })
113 113
114 expect(videoDetails.userHistory).to.not.be.undefined 114 expect(videoDetails.userHistory).to.not.be.undefined
115 expect(videoDetails.userHistory.currentTime).to.equal(8) 115 expect(videoDetails.userHistory.currentTime).to.equal(8)
116 } 116 }
117 117
118 { 118 {
119 const videoDetails = await server.videosCommand.getWithToken({ id: video3UUID }) 119 const videoDetails = await server.videos.getWithToken({ id: video3UUID })
120 120
121 expect(videoDetails.userHistory).to.be.undefined 121 expect(videoDetails.userHistory).to.be.undefined
122 } 122 }
@@ -164,7 +164,7 @@ describe('Test videos history', function () {
164 }) 164 })
165 165
166 it('Should disable videos history', async function () { 166 it('Should disable videos history', async function () {
167 await server.usersCommand.updateMe({ 167 await server.users.updateMe({
168 videosHistoryEnabled: false 168 videosHistoryEnabled: false
169 }) 169 })
170 170
@@ -172,7 +172,7 @@ describe('Test videos history', function () {
172 }) 172 })
173 173
174 it('Should re-enable videos history', async function () { 174 it('Should re-enable videos history', async function () {
175 await server.usersCommand.updateMe({ 175 await server.users.updateMe({
176 videosHistoryEnabled: true 176 videosHistoryEnabled: true
177 }) 177 })
178 178
diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts
index 969393842..f0657b334 100644
--- a/server/tests/api/videos/videos-overview.ts
+++ b/server/tests/api/videos/videos-overview.ts
@@ -25,7 +25,7 @@ describe('Test a videos overview', function () {
25 }) 25 })
26 26
27 it('Should send empty overview', async function () { 27 it('Should send empty overview', async function () {
28 const body = await server.overviewsCommand.getVideos({ page: 1 }) 28 const body = await server.overviews.getVideos({ page: 1 })
29 29
30 testOverviewCount(body, 0) 30 testOverviewCount(body, 0)
31 }) 31 })
@@ -35,7 +35,7 @@ describe('Test a videos overview', function () {
35 35
36 await wait(3000) 36 await wait(3000)
37 37
38 await server.videosCommand.upload({ 38 await server.videos.upload({
39 attributes: { 39 attributes: {
40 name: 'video 0', 40 name: 'video 0',
41 category: 3, 41 category: 3,
@@ -43,7 +43,7 @@ describe('Test a videos overview', function () {
43 } 43 }
44 }) 44 })
45 45
46 const body = await server.overviewsCommand.getVideos({ page: 1 }) 46 const body = await server.overviews.getVideos({ page: 1 })
47 47
48 testOverviewCount(body, 0) 48 testOverviewCount(body, 0)
49 }) 49 })
@@ -53,7 +53,7 @@ describe('Test a videos overview', function () {
53 53
54 { 54 {
55 for (let i = 1; i < 6; i++) { 55 for (let i = 1; i < 6; i++) {
56 await server.videosCommand.upload({ 56 await server.videos.upload({
57 attributes: { 57 attributes: {
58 name: 'video ' + i, 58 name: 'video ' + i,
59 category: 3, 59 category: 3,
@@ -66,13 +66,13 @@ describe('Test a videos overview', function () {
66 } 66 }
67 67
68 { 68 {
69 const body = await server.overviewsCommand.getVideos({ page: 1 }) 69 const body = await server.overviews.getVideos({ page: 1 })
70 70
71 testOverviewCount(body, 1) 71 testOverviewCount(body, 1)
72 } 72 }
73 73
74 { 74 {
75 const overview = await server.overviewsCommand.getVideos({ page: 2 }) 75 const overview = await server.overviews.getVideos({ page: 2 })
76 76
77 expect(overview.tags).to.have.lengthOf(1) 77 expect(overview.tags).to.have.lengthOf(1)
78 expect(overview.categories).to.have.lengthOf(0) 78 expect(overview.categories).to.have.lengthOf(0)
@@ -81,8 +81,8 @@ describe('Test a videos overview', function () {
81 }) 81 })
82 82
83 it('Should have the correct overview', async function () { 83 it('Should have the correct overview', async function () {
84 const overview1 = await server.overviewsCommand.getVideos({ page: 1 }) 84 const overview1 = await server.overviews.getVideos({ page: 1 })
85 const overview2 = await server.overviewsCommand.getVideos({ page: 2 }) 85 const overview2 = await server.overviews.getVideos({ page: 2 })
86 86
87 for (const arr of [ overview1.tags, overview1.categories, overview1.channels, overview2.tags ]) { 87 for (const arr of [ overview1.tags, overview1.categories, overview1.channels, overview2.tags ]) {
88 expect(arr).to.have.lengthOf(1) 88 expect(arr).to.have.lengthOf(1)
@@ -108,18 +108,18 @@ describe('Test a videos overview', function () {
108 }) 108 })
109 109
110 it('Should hide muted accounts', async function () { 110 it('Should hide muted accounts', async function () {
111 const token = await server.usersCommand.generateUserAndToken('choco') 111 const token = await server.users.generateUserAndToken('choco')
112 112
113 await server.blocklistCommand.addToMyBlocklist({ token, account: 'root@' + server.host }) 113 await server.blocklist.addToMyBlocklist({ token, account: 'root@' + server.host })
114 114
115 { 115 {
116 const body = await server.overviewsCommand.getVideos({ page: 1 }) 116 const body = await server.overviews.getVideos({ page: 1 })
117 117
118 testOverviewCount(body, 1) 118 testOverviewCount(body, 1)
119 } 119 }
120 120
121 { 121 {
122 const body = await server.overviewsCommand.getVideos({ page: 1, token }) 122 const body = await server.overviews.getVideos({ page: 1, token })
123 123
124 testOverviewCount(body, 0) 124 testOverviewCount(body, 0)
125 } 125 }
diff --git a/server/tests/api/videos/videos-views-cleaner.ts b/server/tests/api/videos/videos-views-cleaner.ts
index 7ded1bf38..238662cf3 100644
--- a/server/tests/api/videos/videos-views-cleaner.ts
+++ b/server/tests/api/videos/videos-views-cleaner.ts
@@ -30,15 +30,15 @@ describe('Test video views cleaner', function () {
30 30
31 await doubleFollow(servers[0], servers[1]) 31 await doubleFollow(servers[0], servers[1])
32 32
33 videoIdServer1 = (await servers[0].videosCommand.quickUpload({ name: 'video server 1' })).uuid 33 videoIdServer1 = (await servers[0].videos.quickUpload({ name: 'video server 1' })).uuid
34 videoIdServer2 = (await servers[1].videosCommand.quickUpload({ name: 'video server 2' })).uuid 34 videoIdServer2 = (await servers[1].videos.quickUpload({ name: 'video server 2' })).uuid
35 35
36 await waitJobs(servers) 36 await waitJobs(servers)
37 37
38 await servers[0].videosCommand.view({ id: videoIdServer1 }) 38 await servers[0].videos.view({ id: videoIdServer1 })
39 await servers[1].videosCommand.view({ id: videoIdServer1 }) 39 await servers[1].videos.view({ id: videoIdServer1 })
40 await servers[0].videosCommand.view({ id: videoIdServer2 }) 40 await servers[0].videos.view({ id: videoIdServer2 })
41 await servers[1].videosCommand.view({ id: videoIdServer2 }) 41 await servers[1].videos.view({ id: videoIdServer2 })
42 42
43 await waitJobs(servers) 43 await waitJobs(servers)
44 }) 44 })
@@ -56,14 +56,14 @@ describe('Test video views cleaner', function () {
56 56
57 { 57 {
58 for (const server of servers) { 58 for (const server of servers) {
59 const total = await server.sqlCommand.countVideoViewsOf(videoIdServer1) 59 const total = await server.sql.countVideoViewsOf(videoIdServer1)
60 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') 60 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
61 } 61 }
62 } 62 }
63 63
64 { 64 {
65 for (const server of servers) { 65 for (const server of servers) {
66 const total = await server.sqlCommand.countVideoViewsOf(videoIdServer2) 66 const total = await server.sql.countVideoViewsOf(videoIdServer2)
67 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views') 67 expect(total).to.equal(2, 'Server ' + server.serverNumber + ' does not have the correct amount of views')
68 } 68 }
69 } 69 }
@@ -82,16 +82,16 @@ describe('Test video views cleaner', function () {
82 82
83 { 83 {
84 for (const server of servers) { 84 for (const server of servers) {
85 const total = await server.sqlCommand.countVideoViewsOf(videoIdServer1) 85 const total = await server.sql.countVideoViewsOf(videoIdServer1)
86 expect(total).to.equal(2) 86 expect(total).to.equal(2)
87 } 87 }
88 } 88 }
89 89
90 { 90 {
91 const totalServer1 = await servers[0].sqlCommand.countVideoViewsOf(videoIdServer2) 91 const totalServer1 = await servers[0].sql.countVideoViewsOf(videoIdServer2)
92 expect(totalServer1).to.equal(0) 92 expect(totalServer1).to.equal(0)
93 93
94 const totalServer2 = await servers[1].sqlCommand.countVideoViewsOf(videoIdServer2) 94 const totalServer2 = await servers[1].sql.countVideoViewsOf(videoIdServer2)
95 expect(totalServer2).to.equal(2) 95 expect(totalServer2).to.equal(2)
96 } 96 }
97 }) 97 })
diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts
index b1d9da242..26f4bdc8d 100644
--- a/server/tests/cli/create-import-video-file-job.ts
+++ b/server/tests/cli/create-import-video-file-job.ts
@@ -35,12 +35,12 @@ describe('Test create import video jobs', function () {
35 35
36 // Upload two videos for our needs 36 // Upload two videos for our needs
37 { 37 {
38 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video1' } }) 38 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video1' } })
39 video1UUID = uuid 39 video1UUID = uuid
40 } 40 }
41 41
42 { 42 {
43 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video2' } }) 43 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video2' } })
44 video2UUID = uuid 44 video2UUID = uuid
45 } 45 }
46 46
@@ -50,16 +50,16 @@ describe('Test create import video jobs', function () {
50 50
51 it('Should run a import job on video 1 with a lower resolution', async function () { 51 it('Should run a import job on video 1 with a lower resolution', async function () {
52 const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm` 52 const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short-480.webm`
53 await servers[0].cliCommand.execWithEnv(command) 53 await servers[0].cli.execWithEnv(command)
54 54
55 await waitJobs(servers) 55 await waitJobs(servers)
56 56
57 for (const server of servers) { 57 for (const server of servers) {
58 const { data: videos } = await server.videosCommand.list() 58 const { data: videos } = await server.videos.list()
59 expect(videos).to.have.lengthOf(2) 59 expect(videos).to.have.lengthOf(2)
60 60
61 const video = videos.find(({ uuid }) => uuid === video1UUID) 61 const video = videos.find(({ uuid }) => uuid === video1UUID)
62 const videoDetails = await server.videosCommand.get({ id: video.uuid }) 62 const videoDetails = await server.videos.get({ id: video.uuid })
63 63
64 expect(videoDetails.files).to.have.lengthOf(2) 64 expect(videoDetails.files).to.have.lengthOf(2)
65 const [ originalVideo, transcodedVideo ] = videoDetails.files 65 const [ originalVideo, transcodedVideo ] = videoDetails.files
@@ -70,16 +70,16 @@ describe('Test create import video jobs', function () {
70 70
71 it('Should run a import job on video 2 with the same resolution and a different extension', async function () { 71 it('Should run a import job on video 2 with the same resolution and a different extension', async function () {
72 const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv` 72 const command = `npm run create-import-video-file-job -- -v ${video2UUID} -i server/tests/fixtures/video_short.ogv`
73 await servers[1].cliCommand.execWithEnv(command) 73 await servers[1].cli.execWithEnv(command)
74 74
75 await waitJobs(servers) 75 await waitJobs(servers)
76 76
77 for (const server of servers) { 77 for (const server of servers) {
78 const { data: videos } = await server.videosCommand.list() 78 const { data: videos } = await server.videos.list()
79 expect(videos).to.have.lengthOf(2) 79 expect(videos).to.have.lengthOf(2)
80 80
81 const video = videos.find(({ uuid }) => uuid === video2UUID) 81 const video = videos.find(({ uuid }) => uuid === video2UUID)
82 const videoDetails = await server.videosCommand.get({ id: video.uuid }) 82 const videoDetails = await server.videos.get({ id: video.uuid })
83 83
84 expect(videoDetails.files).to.have.lengthOf(4) 84 expect(videoDetails.files).to.have.lengthOf(4)
85 const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetails.files 85 const [ originalVideo, transcodedVideo420, transcodedVideo320, transcodedVideo240 ] = videoDetails.files
@@ -92,16 +92,16 @@ describe('Test create import video jobs', function () {
92 92
93 it('Should run a import job on video 2 with the same resolution and the same extension', async function () { 93 it('Should run a import job on video 2 with the same resolution and the same extension', async function () {
94 const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm` 94 const command = `npm run create-import-video-file-job -- -v ${video1UUID} -i server/tests/fixtures/video_short2.webm`
95 await servers[0].cliCommand.execWithEnv(command) 95 await servers[0].cli.execWithEnv(command)
96 96
97 await waitJobs(servers) 97 await waitJobs(servers)
98 98
99 for (const server of servers) { 99 for (const server of servers) {
100 const { data: videos } = await server.videosCommand.list() 100 const { data: videos } = await server.videos.list()
101 expect(videos).to.have.lengthOf(2) 101 expect(videos).to.have.lengthOf(2)
102 102
103 const video = videos.find(({ uuid }) => uuid === video1UUID) 103 const video = videos.find(({ uuid }) => uuid === video1UUID)
104 const videoDetails = await server.videosCommand.get({ id: video.uuid }) 104 const videoDetails = await server.videos.get({ id: video.uuid })
105 105
106 expect(videoDetails.files).to.have.lengthOf(2) 106 expect(videoDetails.files).to.have.lengthOf(2)
107 const [ video720, video480 ] = videoDetails.files 107 const [ video720, video480 ] = videoDetails.files
diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts
index f629306e6..c9bbab802 100644
--- a/server/tests/cli/create-transcoding-job.ts
+++ b/server/tests/cli/create-transcoding-job.ts
@@ -42,12 +42,12 @@ describe('Test create transcoding jobs', function () {
42 servers = await flushAndRunMultipleServers(2) 42 servers = await flushAndRunMultipleServers(2)
43 await setAccessTokensToServers(servers) 43 await setAccessTokensToServers(servers)
44 44
45 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 45 await servers[0].config.updateCustomSubConfig({ newConfig: config })
46 46
47 await doubleFollow(servers[0], servers[1]) 47 await doubleFollow(servers[0], servers[1])
48 48
49 for (let i = 1; i <= 5; i++) { 49 for (let i = 1; i <= 5; i++) {
50 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' + i } }) 50 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' + i } })
51 videosUUID.push(uuid) 51 videosUUID.push(uuid)
52 } 52 }
53 53
@@ -58,11 +58,11 @@ describe('Test create transcoding jobs', function () {
58 this.timeout(30000) 58 this.timeout(30000)
59 59
60 for (const server of servers) { 60 for (const server of servers) {
61 const { data } = await server.videosCommand.list() 61 const { data } = await server.videos.list()
62 expect(data).to.have.lengthOf(videosUUID.length) 62 expect(data).to.have.lengthOf(videosUUID.length)
63 63
64 for (const video of data) { 64 for (const video of data) {
65 const videoDetail = await server.videosCommand.get({ id: video.uuid }) 65 const videoDetail = await server.videos.get({ id: video.uuid })
66 expect(videoDetail.files).to.have.lengthOf(1) 66 expect(videoDetail.files).to.have.lengthOf(1)
67 expect(videoDetail.streamingPlaylists).to.have.lengthOf(0) 67 expect(videoDetail.streamingPlaylists).to.have.lengthOf(0)
68 } 68 }
@@ -72,16 +72,16 @@ describe('Test create transcoding jobs', function () {
72 it('Should run a transcoding job on video 2', async function () { 72 it('Should run a transcoding job on video 2', async function () {
73 this.timeout(60000) 73 this.timeout(60000)
74 74
75 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`) 75 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[1]}`)
76 await waitJobs(servers) 76 await waitJobs(servers)
77 77
78 for (const server of servers) { 78 for (const server of servers) {
79 const { data } = await server.videosCommand.list() 79 const { data } = await server.videos.list()
80 80
81 let infoHashes: { [id: number]: string } 81 let infoHashes: { [id: number]: string }
82 82
83 for (const video of data) { 83 for (const video of data) {
84 const videoDetail = await server.videosCommand.get({ id: video.uuid }) 84 const videoDetail = await server.videos.get({ id: video.uuid })
85 85
86 if (video.uuid === videosUUID[1]) { 86 if (video.uuid === videosUUID[1]) {
87 expect(videoDetail.files).to.have.lengthOf(4) 87 expect(videoDetail.files).to.have.lengthOf(4)
@@ -110,15 +110,15 @@ describe('Test create transcoding jobs', function () {
110 it('Should run a transcoding job on video 1 with resolution', async function () { 110 it('Should run a transcoding job on video 1 with resolution', async function () {
111 this.timeout(60000) 111 this.timeout(60000)
112 112
113 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`) 113 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[0]} -r 480`)
114 114
115 await waitJobs(servers) 115 await waitJobs(servers)
116 116
117 for (const server of servers) { 117 for (const server of servers) {
118 const { data } = await server.videosCommand.list() 118 const { data } = await server.videos.list()
119 expect(data).to.have.lengthOf(videosUUID.length) 119 expect(data).to.have.lengthOf(videosUUID.length)
120 120
121 const videoDetails = await server.videosCommand.get({ id: videosUUID[0] }) 121 const videoDetails = await server.videos.get({ id: videosUUID[0] })
122 122
123 expect(videoDetails.files).to.have.lengthOf(2) 123 expect(videoDetails.files).to.have.lengthOf(2)
124 expect(videoDetails.files[0].resolution.id).to.equal(720) 124 expect(videoDetails.files[0].resolution.id).to.equal(720)
@@ -131,12 +131,12 @@ describe('Test create transcoding jobs', function () {
131 it('Should generate an HLS resolution', async function () { 131 it('Should generate an HLS resolution', async function () {
132 this.timeout(120000) 132 this.timeout(120000)
133 133
134 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`) 134 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
135 135
136 await waitJobs(servers) 136 await waitJobs(servers)
137 137
138 for (const server of servers) { 138 for (const server of servers) {
139 const videoDetails = await server.videosCommand.get({ id: videosUUID[2] }) 139 const videoDetails = await server.videos.get({ id: videosUUID[2] })
140 140
141 expect(videoDetails.files).to.have.lengthOf(1) 141 expect(videoDetails.files).to.have.lengthOf(1)
142 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 142 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
@@ -150,12 +150,12 @@ describe('Test create transcoding jobs', function () {
150 it('Should not duplicate an HLS resolution', async function () { 150 it('Should not duplicate an HLS resolution', async function () {
151 this.timeout(120000) 151 this.timeout(120000)
152 152
153 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`) 153 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[2]} --generate-hls -r 480`)
154 154
155 await waitJobs(servers) 155 await waitJobs(servers)
156 156
157 for (const server of servers) { 157 for (const server of servers) {
158 const videoDetails = await server.videosCommand.get({ id: videosUUID[2] }) 158 const videoDetails = await server.videos.get({ id: videosUUID[2] })
159 159
160 const files = videoDetails.streamingPlaylists[0].files 160 const files = videoDetails.streamingPlaylists[0].files
161 expect(files).to.have.lengthOf(1) 161 expect(files).to.have.lengthOf(1)
@@ -166,12 +166,12 @@ describe('Test create transcoding jobs', function () {
166 it('Should generate all HLS resolutions', async function () { 166 it('Should generate all HLS resolutions', async function () {
167 this.timeout(120000) 167 this.timeout(120000)
168 168
169 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`) 169 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[3]} --generate-hls`)
170 170
171 await waitJobs(servers) 171 await waitJobs(servers)
172 172
173 for (const server of servers) { 173 for (const server of servers) {
174 const videoDetails = await server.videosCommand.get({ id: videosUUID[3] }) 174 const videoDetails = await server.videos.get({ id: videosUUID[3] })
175 175
176 expect(videoDetails.files).to.have.lengthOf(1) 176 expect(videoDetails.files).to.have.lengthOf(1)
177 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 177 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
@@ -185,14 +185,14 @@ describe('Test create transcoding jobs', function () {
185 this.timeout(120000) 185 this.timeout(120000)
186 186
187 config.transcoding.hls.enabled = true 187 config.transcoding.hls.enabled = true
188 await servers[0].configCommand.updateCustomSubConfig({ newConfig: config }) 188 await servers[0].config.updateCustomSubConfig({ newConfig: config })
189 189
190 await servers[0].cliCommand.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`) 190 await servers[0].cli.execWithEnv(`npm run create-transcoding-job -- -v ${videosUUID[4]}`)
191 191
192 await waitJobs(servers) 192 await waitJobs(servers)
193 193
194 for (const server of servers) { 194 for (const server of servers) {
195 const videoDetails = await server.videosCommand.get({ id: videosUUID[4] }) 195 const videoDetails = await server.videos.get({ id: videosUUID[4] })
196 196
197 expect(videoDetails.files).to.have.lengthOf(4) 197 expect(videoDetails.files).to.have.lengthOf(4)
198 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 198 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts
index ef8603a33..eefc95a6d 100644
--- a/server/tests/cli/optimize-old-videos.ts
+++ b/server/tests/cli/optimize-old-videos.ts
@@ -41,8 +41,8 @@ describe('Test optimize old videos', function () {
41 } 41 }
42 42
43 // Upload two videos for our needs 43 // Upload two videos for our needs
44 await servers[0].videosCommand.upload({ attributes: { name: 'video1', fixture: tempFixturePath } }) 44 await servers[0].videos.upload({ attributes: { name: 'video1', fixture: tempFixturePath } })
45 await servers[0].videosCommand.upload({ attributes: { name: 'video2', fixture: tempFixturePath } }) 45 await servers[0].videos.upload({ attributes: { name: 'video2', fixture: tempFixturePath } })
46 46
47 await waitJobs(servers) 47 await waitJobs(servers)
48 }) 48 })
@@ -51,11 +51,11 @@ describe('Test optimize old videos', function () {
51 this.timeout(30000) 51 this.timeout(30000)
52 52
53 for (const server of servers) { 53 for (const server of servers) {
54 const { data } = await server.videosCommand.list() 54 const { data } = await server.videos.list()
55 expect(data).to.have.lengthOf(2) 55 expect(data).to.have.lengthOf(2)
56 56
57 for (const video of data) { 57 for (const video of data) {
58 const videoDetails = await server.videosCommand.get({ id: video.uuid }) 58 const videoDetails = await server.videos.get({ id: video.uuid })
59 expect(videoDetails.files).to.have.lengthOf(1) 59 expect(videoDetails.files).to.have.lengthOf(1)
60 } 60 }
61 } 61 }
@@ -64,29 +64,29 @@ describe('Test optimize old videos', function () {
64 it('Should run optimize script', async function () { 64 it('Should run optimize script', async function () {
65 this.timeout(200000) 65 this.timeout(200000)
66 66
67 await servers[0].cliCommand.execWithEnv('npm run optimize-old-videos') 67 await servers[0].cli.execWithEnv('npm run optimize-old-videos')
68 await waitJobs(servers) 68 await waitJobs(servers)
69 69
70 for (const server of servers) { 70 for (const server of servers) {
71 const { data } = await server.videosCommand.list() 71 const { data } = await server.videos.list()
72 expect(data).to.have.lengthOf(2) 72 expect(data).to.have.lengthOf(2)
73 73
74 for (const video of data) { 74 for (const video of data) {
75 await server.videosCommand.view({ id: video.uuid }) 75 await server.videos.view({ id: video.uuid })
76 76
77 // Refresh video 77 // Refresh video
78 await waitJobs(servers) 78 await waitJobs(servers)
79 await wait(5000) 79 await wait(5000)
80 await waitJobs(servers) 80 await waitJobs(servers)
81 81
82 const videoDetails = await server.videosCommand.get({ id: video.uuid }) 82 const videoDetails = await server.videos.get({ id: video.uuid })
83 83
84 expect(videoDetails.files).to.have.lengthOf(1) 84 expect(videoDetails.files).to.have.lengthOf(1)
85 const file = videoDetails.files[0] 85 const file = videoDetails.files[0]
86 86
87 expect(file.size).to.be.below(8000000) 87 expect(file.size).to.be.below(8000000)
88 88
89 const path = servers[0].serversCommand.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4')) 89 const path = servers[0].servers.buildDirectory(join('videos', video.uuid + '-' + file.resolution.id + '.mp4'))
90 const bitrate = await getVideoFileBitrate(path) 90 const bitrate = await getVideoFileBitrate(path)
91 const fps = await getVideoFileFPS(path) 91 const fps = await getVideoFileFPS(path)
92 const resolution = await getVideoFileResolution(path) 92 const resolution = await getVideoFileResolution(path)
diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts
index fe5f63191..a83aa7724 100644
--- a/server/tests/cli/peertube.ts
+++ b/server/tests/cli/peertube.ts
@@ -30,16 +30,16 @@ describe('Test CLI wrapper', function () {
30 server = await flushAndRunServer(1) 30 server = await flushAndRunServer(1)
31 await setAccessTokensToServers([ server ]) 31 await setAccessTokensToServers([ server ])
32 32
33 await server.usersCommand.create({ username: 'user_1', password: 'super_password' }) 33 await server.users.create({ username: 'user_1', password: 'super_password' })
34 34
35 userAccessToken = await server.loginCommand.getAccessToken({ username: 'user_1', password: 'super_password' }) 35 userAccessToken = await server.login.getAccessToken({ username: 'user_1', password: 'super_password' })
36 36
37 { 37 {
38 const attributes = { name: 'user_channel', displayName: 'User channel', support: 'super support text' } 38 const attributes = { name: 'user_channel', displayName: 'User channel', support: 'super support text' }
39 await server.channelsCommand.create({ token: userAccessToken, attributes }) 39 await server.channels.create({ token: userAccessToken, attributes })
40 } 40 }
41 41
42 cliCommand = server.cliCommand 42 cliCommand = server.cli
43 }) 43 })
44 44
45 describe('Authentication and instance selection', function () { 45 describe('Authentication and instance selection', function () {
@@ -48,7 +48,7 @@ describe('Test CLI wrapper', function () {
48 const stdout = await cliCommand.execWithEnv(`${cmd} token --url ${server.url} --username user_1 --password super_password`) 48 const stdout = await cliCommand.execWithEnv(`${cmd} token --url ${server.url} --username user_1 --password super_password`)
49 const token = stdout.trim() 49 const token = stdout.trim()
50 50
51 const body = await server.usersCommand.getMyInfo({ token }) 51 const body = await server.users.getMyInfo({ token })
52 expect(body.username).to.equal('user_1') 52 expect(body.username).to.equal('user_1')
53 }) 53 })
54 54
@@ -103,10 +103,10 @@ describe('Test CLI wrapper', function () {
103 }) 103 })
104 104
105 it('Should have the video uploaded', async function () { 105 it('Should have the video uploaded', async function () {
106 const { total, data } = await server.videosCommand.list() 106 const { total, data } = await server.videos.list()
107 expect(total).to.equal(1) 107 expect(total).to.equal(1)
108 108
109 const video = await server.videosCommand.get({ id: data[0].uuid }) 109 const video = await server.videos.get({ id: data[0].uuid })
110 expect(video.name).to.equal('test upload') 110 expect(video.name).to.equal('test upload')
111 expect(video.support).to.equal('support_text') 111 expect(video.support).to.equal('support_text')
112 expect(video.channel.name).to.equal('user_channel') 112 expect(video.channel.name).to.equal('user_channel')
@@ -128,19 +128,19 @@ describe('Test CLI wrapper', function () {
128 128
129 await waitJobs([ server ]) 129 await waitJobs([ server ])
130 130
131 const { total, data } = await server.videosCommand.list() 131 const { total, data } = await server.videos.list()
132 expect(total).to.equal(2) 132 expect(total).to.equal(2)
133 133
134 const video = data.find(v => v.name === 'small video - youtube') 134 const video = data.find(v => v.name === 'small video - youtube')
135 expect(video).to.not.be.undefined 135 expect(video).to.not.be.undefined
136 136
137 const videoDetails = await server.videosCommand.get({ id: video.id }) 137 const videoDetails = await server.videos.get({ id: video.id })
138 expect(videoDetails.channel.name).to.equal('user_channel') 138 expect(videoDetails.channel.name).to.equal('user_channel')
139 expect(videoDetails.support).to.equal('super support text') 139 expect(videoDetails.support).to.equal('super support text')
140 expect(videoDetails.nsfw).to.be.false 140 expect(videoDetails.nsfw).to.be.false
141 141
142 // So we can reimport it 142 // So we can reimport it
143 await server.videosCommand.remove({ token: userAccessToken, id: video.id }) 143 await server.videos.remove({ token: userAccessToken, id: video.id })
144 }) 144 })
145 145
146 it('Should import and override some imported attributes', async function () { 146 it('Should import and override some imported attributes', async function () {
@@ -155,13 +155,13 @@ describe('Test CLI wrapper', function () {
155 await waitJobs([ server ]) 155 await waitJobs([ server ])
156 156
157 { 157 {
158 const { total, data } = await server.videosCommand.list() 158 const { total, data } = await server.videos.list()
159 expect(total).to.equal(2) 159 expect(total).to.equal(2)
160 160
161 const video = data.find(v => v.name === 'toto') 161 const video = data.find(v => v.name === 'toto')
162 expect(video).to.not.be.undefined 162 expect(video).to.not.be.undefined
163 163
164 const videoDetails = await server.videosCommand.get({ id: video.id }) 164 const videoDetails = await server.videos.get({ id: video.id })
165 expect(videoDetails.channel.name).to.equal('user_channel') 165 expect(videoDetails.channel.name).to.equal('user_channel')
166 expect(videoDetails.support).to.equal('support') 166 expect(videoDetails.support).to.equal('support')
167 expect(videoDetails.nsfw).to.be.true 167 expect(videoDetails.nsfw).to.be.true
@@ -225,10 +225,10 @@ describe('Test CLI wrapper', function () {
225 servers = [ server, anotherServer ] 225 servers = [ server, anotherServer ]
226 await waitJobs(servers) 226 await waitJobs(servers)
227 227
228 const { uuid } = await anotherServer.videosCommand.quickUpload({ name: 'super video' }) 228 const { uuid } = await anotherServer.videos.quickUpload({ name: 'super video' })
229 await waitJobs(servers) 229 await waitJobs(servers)
230 230
231 video1Server2 = await server.videosCommand.getId({ uuid }) 231 video1Server2 = await server.videos.getId({ uuid })
232 }) 232 })
233 233
234 it('Should add a redundancy', async function () { 234 it('Should add a redundancy', async function () {
diff --git a/server/tests/cli/plugins.ts b/server/tests/cli/plugins.ts
index 5344bfc96..178a7a2d9 100644
--- a/server/tests/cli/plugins.ts
+++ b/server/tests/cli/plugins.ts
@@ -27,13 +27,13 @@ describe('Test plugin scripts', function () {
27 27
28 const packagePath = PluginsCommand.getPluginTestPath() 28 const packagePath = PluginsCommand.getPluginTestPath()
29 29
30 await server.cliCommand.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`) 30 await server.cli.execWithEnv(`npm run plugin:install -- --plugin-path ${packagePath}`)
31 }) 31 })
32 32
33 it('Should install a theme from stateless CLI', async function () { 33 it('Should install a theme from stateless CLI', async function () {
34 this.timeout(60000) 34 this.timeout(60000)
35 35
36 await server.cliCommand.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`) 36 await server.cli.execWithEnv(`npm run plugin:install -- --npm-name peertube-theme-background-red`)
37 }) 37 })
38 38
39 it('Should have the theme and the plugin registered when we restart peertube', async function () { 39 it('Should have the theme and the plugin registered when we restart peertube', async function () {
@@ -42,7 +42,7 @@ describe('Test plugin scripts', function () {
42 await killallServers([ server ]) 42 await killallServers([ server ])
43 await reRunServer(server) 43 await reRunServer(server)
44 44
45 const config = await server.configCommand.getConfig() 45 const config = await server.config.getConfig()
46 46
47 const plugin = config.plugin.registered 47 const plugin = config.plugin.registered
48 .find(p => p.name === 'test') 48 .find(p => p.name === 'test')
@@ -56,7 +56,7 @@ describe('Test plugin scripts', function () {
56 it('Should uninstall a plugin from stateless CLI', async function () { 56 it('Should uninstall a plugin from stateless CLI', async function () {
57 this.timeout(60000) 57 this.timeout(60000)
58 58
59 await server.cliCommand.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`) 59 await server.cli.execWithEnv(`npm run plugin:uninstall -- --npm-name peertube-plugin-test`)
60 }) 60 })
61 61
62 it('Should have removed the plugin on another peertube restart', async function () { 62 it('Should have removed the plugin on another peertube restart', async function () {
@@ -65,7 +65,7 @@ describe('Test plugin scripts', function () {
65 await killallServers([ server ]) 65 await killallServers([ server ])
66 await reRunServer(server) 66 await reRunServer(server)
67 67
68 const config = await server.configCommand.getConfig() 68 const config = await server.config.getConfig()
69 69
70 const plugin = config.plugin.registered 70 const plugin = config.plugin.registered
71 .find(p => p.name === 'test') 71 .find(p => p.name === 'test')
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
index a4556312b..9912a36e0 100644
--- a/server/tests/cli/prune-storage.ts
+++ b/server/tests/cli/prune-storage.ts
@@ -24,13 +24,13 @@ import { VideoPlaylistPrivacy } from '@shared/models'
24const expect = chai.expect 24const expect = chai.expect
25 25
26async function countFiles (server: ServerInfo, directory: string) { 26async function countFiles (server: ServerInfo, directory: string) {
27 const files = await readdir(server.serversCommand.buildDirectory(directory)) 27 const files = await readdir(server.servers.buildDirectory(directory))
28 28
29 return files.length 29 return files.length
30} 30}
31 31
32async function assertNotExists (server: ServerInfo, directory: string, substring: string) { 32async function assertNotExists (server: ServerInfo, directory: string, substring: string) {
33 const files = await readdir(server.serversCommand.buildDirectory(directory)) 33 const files = await readdir(server.servers.buildDirectory(directory))
34 34
35 for (const f of files) { 35 for (const f of files) {
36 expect(f).to.not.contain(substring) 36 expect(f).to.not.contain(substring)
@@ -68,16 +68,16 @@ describe('Test prune storage scripts', function () {
68 await setDefaultVideoChannel(servers) 68 await setDefaultVideoChannel(servers)
69 69
70 for (const server of servers) { 70 for (const server of servers) {
71 await server.videosCommand.upload({ attributes: { name: 'video 1' } }) 71 await server.videos.upload({ attributes: { name: 'video 1' } })
72 await server.videosCommand.upload({ attributes: { name: 'video 2' } }) 72 await server.videos.upload({ attributes: { name: 'video 2' } })
73 73
74 await server.usersCommand.updateMyAvatar({ fixture: 'avatar.png' }) 74 await server.users.updateMyAvatar({ fixture: 'avatar.png' })
75 75
76 await server.playlistsCommand.create({ 76 await server.playlists.create({
77 attributes: { 77 attributes: {
78 displayName: 'playlist', 78 displayName: 'playlist',
79 privacy: VideoPlaylistPrivacy.PUBLIC, 79 privacy: VideoPlaylistPrivacy.PUBLIC,
80 videoChannelId: server.videoChannel.id, 80 videoChannelId: server.store.channel.id,
81 thumbnailfile: 'thumbnail.jpg' 81 thumbnailfile: 'thumbnail.jpg'
82 } 82 }
83 }) 83 })
@@ -87,7 +87,7 @@ describe('Test prune storage scripts', function () {
87 87
88 // Lazy load the remote avatar 88 // Lazy load the remote avatar
89 { 89 {
90 const account = await servers[0].accountsCommand.get({ accountName: 'root@localhost:' + servers[1].port }) 90 const account = await servers[0].accounts.get({ accountName: 'root@localhost:' + servers[1].port })
91 await makeGetRequest({ 91 await makeGetRequest({
92 url: servers[0].url, 92 url: servers[0].url,
93 path: account.avatar.path, 93 path: account.avatar.path,
@@ -96,7 +96,7 @@ describe('Test prune storage scripts', function () {
96 } 96 }
97 97
98 { 98 {
99 const account = await servers[1].accountsCommand.get({ accountName: 'root@localhost:' + servers[0].port }) 99 const account = await servers[1].accounts.get({ accountName: 'root@localhost:' + servers[0].port })
100 await makeGetRequest({ 100 await makeGetRequest({
101 url: servers[1].url, 101 url: servers[1].url,
102 path: account.avatar.path, 102 path: account.avatar.path,
@@ -119,7 +119,7 @@ describe('Test prune storage scripts', function () {
119 it('Should create some dirty files', async function () { 119 it('Should create some dirty files', async function () {
120 for (let i = 0; i < 2; i++) { 120 for (let i = 0; i < 2; i++) {
121 { 121 {
122 const base = servers[0].serversCommand.buildDirectory('videos') 122 const base = servers[0].servers.buildDirectory('videos')
123 123
124 const n1 = buildUUID() + '.mp4' 124 const n1 = buildUUID() + '.mp4'
125 const n2 = buildUUID() + '.webm' 125 const n2 = buildUUID() + '.webm'
@@ -131,7 +131,7 @@ describe('Test prune storage scripts', function () {
131 } 131 }
132 132
133 { 133 {
134 const base = servers[0].serversCommand.buildDirectory('torrents') 134 const base = servers[0].servers.buildDirectory('torrents')
135 135
136 const n1 = buildUUID() + '-240.torrent' 136 const n1 = buildUUID() + '-240.torrent'
137 const n2 = buildUUID() + '-480.torrent' 137 const n2 = buildUUID() + '-480.torrent'
@@ -143,7 +143,7 @@ describe('Test prune storage scripts', function () {
143 } 143 }
144 144
145 { 145 {
146 const base = servers[0].serversCommand.buildDirectory('thumbnails') 146 const base = servers[0].servers.buildDirectory('thumbnails')
147 147
148 const n1 = buildUUID() + '.jpg' 148 const n1 = buildUUID() + '.jpg'
149 const n2 = buildUUID() + '.jpg' 149 const n2 = buildUUID() + '.jpg'
@@ -155,7 +155,7 @@ describe('Test prune storage scripts', function () {
155 } 155 }
156 156
157 { 157 {
158 const base = servers[0].serversCommand.buildDirectory('previews') 158 const base = servers[0].servers.buildDirectory('previews')
159 159
160 const n1 = buildUUID() + '.jpg' 160 const n1 = buildUUID() + '.jpg'
161 const n2 = buildUUID() + '.jpg' 161 const n2 = buildUUID() + '.jpg'
@@ -167,7 +167,7 @@ describe('Test prune storage scripts', function () {
167 } 167 }
168 168
169 { 169 {
170 const base = servers[0].serversCommand.buildDirectory('avatars') 170 const base = servers[0].servers.buildDirectory('avatars')
171 171
172 const n1 = buildUUID() + '.png' 172 const n1 = buildUUID() + '.png'
173 const n2 = buildUUID() + '.jpg' 173 const n2 = buildUUID() + '.jpg'
@@ -183,7 +183,7 @@ describe('Test prune storage scripts', function () {
183 it('Should run prune storage', async function () { 183 it('Should run prune storage', async function () {
184 this.timeout(30000) 184 this.timeout(30000)
185 185
186 const env = servers[0].cliCommand.getEnv() 186 const env = servers[0].cli.getEnv()
187 await CLICommand.exec(`echo y | ${env} npm run prune-storage`) 187 await CLICommand.exec(`echo y | ${env} npm run prune-storage`)
188 }) 188 })
189 189
diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts
index d59520783..2df1a1157 100644
--- a/server/tests/cli/regenerate-thumbnails.ts
+++ b/server/tests/cli/regenerate-thumbnails.ts
@@ -15,7 +15,7 @@ import {
15} from '../../../shared/extra-utils' 15} from '../../../shared/extra-utils'
16 16
17async function testThumbnail (server: ServerInfo, videoId: number | string) { 17async function testThumbnail (server: ServerInfo, videoId: number | string) {
18 const video = await server.videosCommand.get({ id: videoId }) 18 const video = await server.videos.get({ id: videoId })
19 19
20 const requests = [ 20 const requests = [
21 makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200), 21 makeRawRequest(join(server.url, video.thumbnailPath), HttpStatusCode.OK_200),
@@ -47,22 +47,22 @@ describe('Test regenerate thumbnails script', function () {
47 await doubleFollow(servers[0], servers[1]) 47 await doubleFollow(servers[0], servers[1])
48 48
49 { 49 {
50 const videoUUID1 = (await servers[0].videosCommand.quickUpload({ name: 'video 1' })).uuid 50 const videoUUID1 = (await servers[0].videos.quickUpload({ name: 'video 1' })).uuid
51 video1 = await servers[0].videosCommand.get({ id: videoUUID1 }) 51 video1 = await servers[0].videos.get({ id: videoUUID1 })
52 52
53 thumbnail1Path = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(video1.thumbnailPath)) 53 thumbnail1Path = join(servers[0].servers.buildDirectory('thumbnails'), basename(video1.thumbnailPath))
54 54
55 const videoUUID2 = (await servers[0].videosCommand.quickUpload({ name: 'video 2' })).uuid 55 const videoUUID2 = (await servers[0].videos.quickUpload({ name: 'video 2' })).uuid
56 video2 = await servers[0].videosCommand.get({ id: videoUUID2 }) 56 video2 = await servers[0].videos.get({ id: videoUUID2 })
57 } 57 }
58 58
59 { 59 {
60 const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'video 3' })).uuid 60 const videoUUID = (await servers[1].videos.quickUpload({ name: 'video 3' })).uuid
61 await waitJobs(servers) 61 await waitJobs(servers)
62 62
63 remoteVideo = await servers[0].videosCommand.get({ id: videoUUID }) 63 remoteVideo = await servers[0].videos.get({ id: videoUUID })
64 64
65 thumbnailRemotePath = join(servers[0].serversCommand.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath)) 65 thumbnailRemotePath = join(servers[0].servers.buildDirectory('thumbnails'), basename(remoteVideo.thumbnailPath))
66 } 66 }
67 67
68 await writeFile(thumbnail1Path, '') 68 await writeFile(thumbnail1Path, '')
@@ -89,7 +89,7 @@ describe('Test regenerate thumbnails script', function () {
89 it('Should regenerate local thumbnails from the CLI', async function () { 89 it('Should regenerate local thumbnails from the CLI', async function () {
90 this.timeout(15000) 90 this.timeout(15000)
91 91
92 await servers[0].cliCommand.execWithEnv(`npm run regenerate-thumbnails`) 92 await servers[0].cli.execWithEnv(`npm run regenerate-thumbnails`)
93 }) 93 })
94 94
95 it('Should have generated new thumbnail files', async function () { 95 it('Should have generated new thumbnail files', async function () {
diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts
index 5e1e1c2af..e0d6f220a 100644
--- a/server/tests/cli/reset-password.ts
+++ b/server/tests/cli/reset-password.ts
@@ -9,16 +9,16 @@ describe('Test reset password scripts', function () {
9 server = await flushAndRunServer(1) 9 server = await flushAndRunServer(1)
10 await setAccessTokensToServers([ server ]) 10 await setAccessTokensToServers([ server ])
11 11
12 await server.usersCommand.create({ username: 'user_1', password: 'super password' }) 12 await server.users.create({ username: 'user_1', password: 'super password' })
13 }) 13 })
14 14
15 it('Should change the user password from CLI', async function () { 15 it('Should change the user password from CLI', async function () {
16 this.timeout(60000) 16 this.timeout(60000)
17 17
18 const env = server.cliCommand.getEnv() 18 const env = server.cli.getEnv()
19 await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`) 19 await CLICommand.exec(`echo coucou | ${env} npm run reset-password -- -u user_1`)
20 20
21 await server.loginCommand.login({ user: { username: 'user_1', password: 'coucou' } }) 21 await server.login.login({ user: { username: 'user_1', password: 'coucou' } })
22 }) 22 })
23 23
24 after(async function () { 24 after(async function () {
diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts
index d90b4a64d..d2d196456 100644
--- a/server/tests/cli/update-host.ts
+++ b/server/tests/cli/update-host.ts
@@ -30,11 +30,11 @@ describe('Test update host scripts', function () {
30 await setAccessTokensToServers([ server ]) 30 await setAccessTokensToServers([ server ])
31 31
32 // Upload two videos for our needs 32 // Upload two videos for our needs
33 const { uuid: video1UUID } = await server.videosCommand.upload() 33 const { uuid: video1UUID } = await server.videos.upload()
34 await server.videosCommand.upload() 34 await server.videos.upload()
35 35
36 // Create a user 36 // Create a user
37 await server.usersCommand.create({ username: 'toto', password: 'coucou' }) 37 await server.users.create({ username: 'toto', password: 'coucou' })
38 38
39 // Create channel 39 // Create channel
40 const videoChannel = { 40 const videoChannel = {
@@ -42,11 +42,11 @@ describe('Test update host scripts', function () {
42 displayName: 'second video channel', 42 displayName: 'second video channel',
43 description: 'super video channel description' 43 description: 'super video channel description'
44 } 44 }
45 await server.channelsCommand.create({ attributes: videoChannel }) 45 await server.channels.create({ attributes: videoChannel })
46 46
47 // Create comments 47 // Create comments
48 const text = 'my super first comment' 48 const text = 'my super first comment'
49 await server.commentsCommand.createThread({ videoId: video1UUID, text }) 49 await server.comments.createThread({ videoId: video1UUID, text })
50 50
51 await waitJobs(server) 51 await waitJobs(server)
52 }) 52 })
@@ -58,11 +58,11 @@ describe('Test update host scripts', function () {
58 // Run server with standard configuration 58 // Run server with standard configuration
59 await reRunServer(server) 59 await reRunServer(server)
60 60
61 await server.cliCommand.execWithEnv(`npm run update-host`) 61 await server.cli.execWithEnv(`npm run update-host`)
62 }) 62 })
63 63
64 it('Should have updated videos url', async function () { 64 it('Should have updated videos url', async function () {
65 const { total, data } = await server.videosCommand.list() 65 const { total, data } = await server.videos.list()
66 expect(total).to.equal(2) 66 expect(total).to.equal(2)
67 67
68 for (const video of data) { 68 for (const video of data) {
@@ -70,7 +70,7 @@ describe('Test update host scripts', function () {
70 70
71 expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid) 71 expect(body.id).to.equal('http://localhost:9002/videos/watch/' + video.uuid)
72 72
73 const videoDetails = await server.videosCommand.get({ id: video.uuid }) 73 const videoDetails = await server.videos.get({ id: video.uuid })
74 74
75 expect(videoDetails.trackerUrls[0]).to.include(server.host) 75 expect(videoDetails.trackerUrls[0]).to.include(server.host)
76 expect(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host) 76 expect(videoDetails.streamingPlaylists[0].playlistUrl).to.include(server.host)
@@ -79,7 +79,7 @@ describe('Test update host scripts', function () {
79 }) 79 })
80 80
81 it('Should have updated video channels url', async function () { 81 it('Should have updated video channels url', async function () {
82 const { data, total } = await server.channelsCommand.list({ sort: '-name' }) 82 const { data, total } = await server.channels.list({ sort: '-name' })
83 expect(total).to.equal(3) 83 expect(total).to.equal(3)
84 84
85 for (const channel of data) { 85 for (const channel of data) {
@@ -90,7 +90,7 @@ describe('Test update host scripts', function () {
90 }) 90 })
91 91
92 it('Should have updated accounts url', async function () { 92 it('Should have updated accounts url', async function () {
93 const body = await server.accountsCommand.list() 93 const body = await server.accounts.list()
94 expect(body.total).to.equal(3) 94 expect(body.total).to.equal(3)
95 95
96 for (const account of body.data) { 96 for (const account of body.data) {
@@ -104,11 +104,11 @@ describe('Test update host scripts', function () {
104 it('Should have updated torrent hosts', async function () { 104 it('Should have updated torrent hosts', async function () {
105 this.timeout(30000) 105 this.timeout(30000)
106 106
107 const { data } = await server.videosCommand.list() 107 const { data } = await server.videos.list()
108 expect(data).to.have.lengthOf(2) 108 expect(data).to.have.lengthOf(2)
109 109
110 for (const video of data) { 110 for (const video of data) {
111 const videoDetails = await server.videosCommand.get({ id: video.id }) 111 const videoDetails = await server.videos.get({ id: video.id })
112 112
113 expect(videoDetails.files).to.have.lengthOf(4) 113 expect(videoDetails.files).to.have.lengthOf(4)
114 114
diff --git a/server/tests/client.ts b/server/tests/client.ts
index e91d4c671..caf6fb00c 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -59,8 +59,8 @@ describe('Test a client controllers', function () {
59 59
60 await setDefaultVideoChannel(servers) 60 await setDefaultVideoChannel(servers)
61 61
62 await servers[0].channelsCommand.update({ 62 await servers[0].channels.update({
63 channelName: servers[0].videoChannel.name, 63 channelName: servers[0].store.channel.name,
64 attributes: { description: channelDescription } 64 attributes: { description: channelDescription }
65 }) 65 })
66 66
@@ -68,13 +68,13 @@ describe('Test a client controllers', function () {
68 68
69 { 69 {
70 const attributes = { name: videoName, description: videoDescription } 70 const attributes = { name: videoName, description: videoDescription }
71 await servers[0].videosCommand.upload({ attributes }) 71 await servers[0].videos.upload({ attributes })
72 72
73 const { data } = await servers[0].videosCommand.list() 73 const { data } = await servers[0].videos.list()
74 expect(data.length).to.equal(1) 74 expect(data.length).to.equal(1)
75 75
76 const video = data[0] 76 const video = data[0]
77 servers[0].video = video 77 servers[0].store.video = video
78 videoIds = [ video.id, video.uuid, video.shortUUID ] 78 videoIds = [ video.id, video.uuid, video.shortUUID ]
79 } 79 }
80 80
@@ -85,21 +85,21 @@ describe('Test a client controllers', function () {
85 displayName: playlistName, 85 displayName: playlistName,
86 description: playlistDescription, 86 description: playlistDescription,
87 privacy: VideoPlaylistPrivacy.PUBLIC, 87 privacy: VideoPlaylistPrivacy.PUBLIC,
88 videoChannelId: servers[0].videoChannel.id 88 videoChannelId: servers[0].store.channel.id
89 } 89 }
90 90
91 playlist = await servers[0].playlistsCommand.create({ attributes }) 91 playlist = await servers[0].playlists.create({ attributes })
92 playlistIds = [ playlist.id, playlist.shortUUID, playlist.uuid ] 92 playlistIds = [ playlist.id, playlist.shortUUID, playlist.uuid ]
93 93
94 await servers[0].playlistsCommand.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: servers[0].video.id } }) 94 await servers[0].playlists.addElement({ playlistId: playlist.shortUUID, attributes: { videoId: servers[0].store.video.id } })
95 } 95 }
96 96
97 // Account 97 // Account
98 98
99 { 99 {
100 await servers[0].usersCommand.updateMe({ description: 'my account description' }) 100 await servers[0].users.updateMe({ description: 'my account description' })
101 101
102 account = await servers[0].accountsCommand.get({ accountName: `${servers[0].user.username}@${servers[0].host}` }) 102 account = await servers[0].accounts.get({ accountName: `${servers[0].store.user.username}@${servers[0].host}` })
103 } 103 }
104 104
105 await waitJobs(servers) 105 await waitJobs(servers)
@@ -120,8 +120,8 @@ describe('Test a client controllers', function () {
120 const port = servers[0].port 120 const port = servers[0].port
121 121
122 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' + 122 const expectedLink = '<link rel="alternate" type="application/json+oembed" href="http://localhost:' + port + '/services/oembed?' +
123 `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2F${servers[0].video.uuid}" ` + 123 `url=http%3A%2F%2Flocalhost%3A${port}%2Fw%2F${servers[0].store.video.uuid}" ` +
124 `title="${servers[0].video.name}" />` 124 `title="${servers[0].store.video.name}" />`
125 125
126 expect(res.text).to.contain(expectedLink) 126 expect(res.text).to.contain(expectedLink)
127 } 127 }
@@ -159,17 +159,17 @@ describe('Test a client controllers', function () {
159 expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`) 159 expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`)
160 expect(text).to.contain(`<meta property="og:description" content="${account.description}" />`) 160 expect(text).to.contain(`<meta property="og:description" content="${account.description}" />`)
161 expect(text).to.contain('<meta property="og:type" content="website" />') 161 expect(text).to.contain('<meta property="og:type" content="website" />')
162 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].user.username}" />`) 162 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/accounts/${servers[0].store.user.username}" />`)
163 } 163 }
164 164
165 async function channelPageTest (path: string) { 165 async function channelPageTest (path: string) {
166 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 166 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
167 const text = res.text 167 const text = res.text
168 168
169 expect(text).to.contain(`<meta property="og:title" content="${servers[0].videoChannel.displayName}" />`) 169 expect(text).to.contain(`<meta property="og:title" content="${servers[0].store.channel.displayName}" />`)
170 expect(text).to.contain(`<meta property="og:description" content="${channelDescription}" />`) 170 expect(text).to.contain(`<meta property="og:description" content="${channelDescription}" />`)
171 expect(text).to.contain('<meta property="og:type" content="website" />') 171 expect(text).to.contain('<meta property="og:type" content="website" />')
172 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].videoChannel.name}" />`) 172 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/video-channels/${servers[0].store.channel.name}" />`)
173 } 173 }
174 174
175 async function watchVideoPageTest (path: string) { 175 async function watchVideoPageTest (path: string) {
@@ -179,7 +179,7 @@ describe('Test a client controllers', function () {
179 expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`) 179 expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`)
180 expect(text).to.contain(`<meta property="og:description" content="${videoDescriptionPlainText}" />`) 180 expect(text).to.contain(`<meta property="og:description" content="${videoDescriptionPlainText}" />`)
181 expect(text).to.contain('<meta property="og:type" content="video" />') 181 expect(text).to.contain('<meta property="og:type" content="video" />')
182 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/${servers[0].video.uuid}" />`) 182 expect(text).to.contain(`<meta property="og:url" content="${servers[0].url}/w/${servers[0].store.video.uuid}" />`)
183 } 183 }
184 184
185 async function watchPlaylistPageTest (path: string) { 185 async function watchPlaylistPageTest (path: string) {
@@ -193,15 +193,15 @@ describe('Test a client controllers', function () {
193 } 193 }
194 194
195 it('Should have valid Open Graph tags on the account page', async function () { 195 it('Should have valid Open Graph tags on the account page', async function () {
196 await accountPageTest('/accounts/' + servers[0].user.username) 196 await accountPageTest('/accounts/' + servers[0].store.user.username)
197 await accountPageTest('/a/' + servers[0].user.username) 197 await accountPageTest('/a/' + servers[0].store.user.username)
198 await accountPageTest('/@' + servers[0].user.username) 198 await accountPageTest('/@' + servers[0].store.user.username)
199 }) 199 })
200 200
201 it('Should have valid Open Graph tags on the channel page', async function () { 201 it('Should have valid Open Graph tags on the channel page', async function () {
202 await channelPageTest('/video-channels/' + servers[0].videoChannel.name) 202 await channelPageTest('/video-channels/' + servers[0].store.channel.name)
203 await channelPageTest('/c/' + servers[0].videoChannel.name) 203 await channelPageTest('/c/' + servers[0].store.channel.name)
204 await channelPageTest('/@' + servers[0].videoChannel.name) 204 await channelPageTest('/@' + servers[0].store.channel.name)
205 }) 205 })
206 206
207 it('Should have valid Open Graph tags on the watch page', async function () { 207 it('Should have valid Open Graph tags on the watch page', async function () {
@@ -241,7 +241,7 @@ describe('Test a client controllers', function () {
241 241
242 expect(text).to.contain('<meta property="twitter:card" content="summary" />') 242 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
243 expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />') 243 expect(text).to.contain('<meta property="twitter:site" content="@Chocobozzz" />')
244 expect(text).to.contain(`<meta property="twitter:title" content="${servers[0].videoChannel.displayName}" />`) 244 expect(text).to.contain(`<meta property="twitter:title" content="${servers[0].store.channel.displayName}" />`)
245 expect(text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`) 245 expect(text).to.contain(`<meta property="twitter:description" content="${channelDescription}" />`)
246 } 246 }
247 247
@@ -288,22 +288,22 @@ describe('Test a client controllers', function () {
288 }) 288 })
289 289
290 it('Should have valid twitter card on the channel page', async function () { 290 it('Should have valid twitter card on the channel page', async function () {
291 await channelPageTest('/video-channels/' + servers[0].videoChannel.name) 291 await channelPageTest('/video-channels/' + servers[0].store.channel.name)
292 await channelPageTest('/c/' + servers[0].videoChannel.name) 292 await channelPageTest('/c/' + servers[0].store.channel.name)
293 await channelPageTest('/@' + servers[0].videoChannel.name) 293 await channelPageTest('/@' + servers[0].store.channel.name)
294 }) 294 })
295 }) 295 })
296 296
297 describe('Whitelisted', function () { 297 describe('Whitelisted', function () {
298 298
299 before(async function () { 299 before(async function () {
300 const config = await servers[0].configCommand.getCustomConfig() 300 const config = await servers[0].config.getCustomConfig()
301 config.services.twitter = { 301 config.services.twitter = {
302 username: '@Kuja', 302 username: '@Kuja',
303 whitelisted: true 303 whitelisted: true
304 } 304 }
305 305
306 await servers[0].configCommand.updateCustomConfig({ newCustomConfig: config }) 306 await servers[0].config.updateCustomConfig({ newCustomConfig: config })
307 }) 307 })
308 308
309 async function accountPageTest (path: string) { 309 async function accountPageTest (path: string) {
@@ -361,9 +361,9 @@ describe('Test a client controllers', function () {
361 }) 361 })
362 362
363 it('Should have valid twitter card on the channel page', async function () { 363 it('Should have valid twitter card on the channel page', async function () {
364 await channelPageTest('/video-channels/' + servers[0].videoChannel.name) 364 await channelPageTest('/video-channels/' + servers[0].store.channel.name)
365 await channelPageTest('/c/' + servers[0].videoChannel.name) 365 await channelPageTest('/c/' + servers[0].store.channel.name)
366 await channelPageTest('/@' + servers[0].videoChannel.name) 366 await channelPageTest('/@' + servers[0].store.channel.name)
367 }) 367 })
368 }) 368 })
369 }) 369 })
@@ -371,7 +371,7 @@ describe('Test a client controllers', function () {
371 describe('Index HTML', function () { 371 describe('Index HTML', function () {
372 372
373 it('Should have valid index html tags (title, description...)', async function () { 373 it('Should have valid index html tags (title, description...)', async function () {
374 const config = await servers[0].configCommand.getConfig() 374 const config = await servers[0].config.getConfig()
375 const res = await makeHTMLRequest(servers[0].url, '/videos/trending') 375 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
376 376
377 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' 377 const description = 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.'
@@ -379,7 +379,7 @@ describe('Test a client controllers', function () {
379 }) 379 })
380 380
381 it('Should update the customized configuration and have the correct index html tags', async function () { 381 it('Should update the customized configuration and have the correct index html tags', async function () {
382 await servers[0].configCommand.updateCustomSubConfig({ 382 await servers[0].config.updateCustomSubConfig({
383 newConfig: { 383 newConfig: {
384 instance: { 384 instance: {
385 name: 'PeerTube updated', 385 name: 'PeerTube updated',
@@ -396,14 +396,14 @@ describe('Test a client controllers', function () {
396 } 396 }
397 }) 397 })
398 398
399 const config = await servers[0].configCommand.getConfig() 399 const config = await servers[0].config.getConfig()
400 const res = await makeHTMLRequest(servers[0].url, '/videos/trending') 400 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
401 401
402 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config) 402 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
403 }) 403 })
404 404
405 it('Should have valid index html updated tags (title, description...)', async function () { 405 it('Should have valid index html updated tags (title, description...)', async function () {
406 const config = await servers[0].configCommand.getConfig() 406 const config = await servers[0].config.getConfig()
407 const res = await makeHTMLRequest(servers[0].url, '/videos/trending') 407 const res = await makeHTMLRequest(servers[0].url, '/videos/trending')
408 408
409 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config) 409 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
@@ -413,7 +413,7 @@ describe('Test a client controllers', function () {
413 for (const basePath of watchVideoBasePaths) { 413 for (const basePath of watchVideoBasePaths) {
414 for (const id of videoIds) { 414 for (const id of videoIds) {
415 const res = await makeHTMLRequest(servers[1].url, basePath + id) 415 const res = await makeHTMLRequest(servers[1].url, basePath + id)
416 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].video.uuid}" />`) 416 expect(res.text).to.contain(`<link rel="canonical" href="${servers[0].url}/videos/watch/${servers[0].store.video.uuid}" />`)
417 } 417 }
418 } 418 }
419 }) 419 })
@@ -451,8 +451,8 @@ describe('Test a client controllers', function () {
451 describe('Embed HTML', function () { 451 describe('Embed HTML', function () {
452 452
453 it('Should have the correct embed html tags', async function () { 453 it('Should have the correct embed html tags', async function () {
454 const config = await servers[0].configCommand.getConfig() 454 const config = await servers[0].config.getConfig()
455 const res = await makeHTMLRequest(servers[0].url, servers[0].video.embedPath) 455 const res = await makeHTMLRequest(servers[0].url, servers[0].store.video.embedPath)
456 456
457 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config) 457 checkIndexTags(res.text, 'PeerTube updated', 'my short description', 'body { background-color: red; }', config)
458 }) 458 })
diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts
index b626ab2bb..ef624152e 100644
--- a/server/tests/external-plugins/auth-ldap.ts
+++ b/server/tests/external-plugins/auth-ldap.ts
@@ -16,15 +16,15 @@ describe('Official plugin auth-ldap', function () {
16 server = await flushAndRunServer(1) 16 server = await flushAndRunServer(1)
17 await setAccessTokensToServers([ server ]) 17 await setAccessTokensToServers([ server ])
18 18
19 await server.pluginsCommand.install({ npmName: 'peertube-plugin-auth-ldap' }) 19 await server.plugins.install({ npmName: 'peertube-plugin-auth-ldap' })
20 }) 20 })
21 21
22 it('Should not login with without LDAP settings', async function () { 22 it('Should not login with without LDAP settings', async function () {
23 await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 23 await server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
24 }) 24 })
25 25
26 it('Should not login with bad LDAP settings', async function () { 26 it('Should not login with bad LDAP settings', async function () {
27 await server.pluginsCommand.updateSettings({ 27 await server.plugins.updateSettings({
28 npmName: 'peertube-plugin-auth-ldap', 28 npmName: 'peertube-plugin-auth-ldap',
29 settings: { 29 settings: {
30 'bind-credentials': 'GoodNewsEveryone', 30 'bind-credentials': 'GoodNewsEveryone',
@@ -38,11 +38,11 @@ describe('Official plugin auth-ldap', function () {
38 } 38 }
39 }) 39 })
40 40
41 await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 41 await server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
42 }) 42 })
43 43
44 it('Should not login with good LDAP settings but wrong username/password', async function () { 44 it('Should not login with good LDAP settings but wrong username/password', async function () {
45 await server.pluginsCommand.updateSettings({ 45 await server.plugins.updateSettings({
46 npmName: 'peertube-plugin-auth-ldap', 46 npmName: 'peertube-plugin-auth-ldap',
47 settings: { 47 settings: {
48 'bind-credentials': 'GoodNewsEveryone', 48 'bind-credentials': 'GoodNewsEveryone',
@@ -56,20 +56,20 @@ describe('Official plugin auth-ldap', function () {
56 } 56 }
57 }) 57 })
58 58
59 await server.loginCommand.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 59 await server.login.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
60 await server.loginCommand.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 60 await server.login.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
61 }) 61 })
62 62
63 it('Should login with the appropriate username/password', async function () { 63 it('Should login with the appropriate username/password', async function () {
64 accessToken = await server.loginCommand.getAccessToken({ username: 'fry', password: 'fry' }) 64 accessToken = await server.login.getAccessToken({ username: 'fry', password: 'fry' })
65 }) 65 })
66 66
67 it('Should login with the appropriate email/password', async function () { 67 it('Should login with the appropriate email/password', async function () {
68 accessToken = await server.loginCommand.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' }) 68 accessToken = await server.login.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' })
69 }) 69 })
70 70
71 it('Should login get my profile', async function () { 71 it('Should login get my profile', async function () {
72 const body = await server.usersCommand.getMyInfo({ token: accessToken }) 72 const body = await server.users.getMyInfo({ token: accessToken })
73 expect(body.username).to.equal('fry') 73 expect(body.username).to.equal('fry')
74 expect(body.email).to.equal('fry@planetexpress.com') 74 expect(body.email).to.equal('fry@planetexpress.com')
75 75
@@ -77,28 +77,28 @@ describe('Official plugin auth-ldap', function () {
77 }) 77 })
78 78
79 it('Should upload a video', async function () { 79 it('Should upload a video', async function () {
80 await server.videosCommand.upload({ token: accessToken, attributes: { name: 'my super video' } }) 80 await server.videos.upload({ token: accessToken, attributes: { name: 'my super video' } })
81 }) 81 })
82 82
83 it('Should not be able to login if the user is banned', async function () { 83 it('Should not be able to login if the user is banned', async function () {
84 await server.usersCommand.banUser({ userId }) 84 await server.users.banUser({ userId })
85 85
86 await server.loginCommand.login({ 86 await server.login.login({
87 user: { username: 'fry@planetexpress.com', password: 'fry' }, 87 user: { username: 'fry@planetexpress.com', password: 'fry' },
88 expectedStatus: HttpStatusCode.BAD_REQUEST_400 88 expectedStatus: HttpStatusCode.BAD_REQUEST_400
89 }) 89 })
90 }) 90 })
91 91
92 it('Should be able to login if the user is unbanned', async function () { 92 it('Should be able to login if the user is unbanned', async function () {
93 await server.usersCommand.unbanUser({ userId }) 93 await server.users.unbanUser({ userId })
94 94
95 await server.loginCommand.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } }) 95 await server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } })
96 }) 96 })
97 97
98 it('Should not login if the plugin is uninstalled', async function () { 98 it('Should not login if the plugin is uninstalled', async function () {
99 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-auth-ldap' }) 99 await server.plugins.uninstall({ npmName: 'peertube-plugin-auth-ldap' })
100 100
101 await server.loginCommand.login({ 101 await server.login.login({
102 user: { username: 'fry@planetexpress.com', password: 'fry' }, 102 user: { username: 'fry@planetexpress.com', password: 'fry' },
103 expectedStatus: HttpStatusCode.BAD_REQUEST_400 103 expectedStatus: HttpStatusCode.BAD_REQUEST_400
104 }) 104 })
diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts
index 1cce15a2f..3b4b48bf0 100644
--- a/server/tests/external-plugins/auto-block-videos.ts
+++ b/server/tests/external-plugins/auto-block-videos.ts
@@ -16,7 +16,7 @@ import {
16import { Video } from '@shared/models' 16import { Video } from '@shared/models'
17 17
18async function check (server: ServerInfo, videoUUID: string, exists = true) { 18async function check (server: ServerInfo, videoUUID: string, exists = true) {
19 const { data } = await server.videosCommand.list() 19 const { data } = await server.videos.list()
20 20
21 const video = data.find(v => v.uuid === videoUUID) 21 const video = data.find(v => v.uuid === videoUUID)
22 22
@@ -38,24 +38,24 @@ describe('Official plugin auto-block videos', function () {
38 await setAccessTokensToServers(servers) 38 await setAccessTokensToServers(servers)
39 39
40 for (const server of servers) { 40 for (const server of servers) {
41 await server.pluginsCommand.install({ npmName: 'peertube-plugin-auto-block-videos' }) 41 await server.plugins.install({ npmName: 'peertube-plugin-auto-block-videos' })
42 } 42 }
43 43
44 blocklistServer = new MockBlocklist() 44 blocklistServer = new MockBlocklist()
45 port = await blocklistServer.initialize() 45 port = await blocklistServer.initialize()
46 46
47 await await servers[0].videosCommand.quickUpload({ name: 'video server 1' }) 47 await await servers[0].videos.quickUpload({ name: 'video server 1' })
48 await await servers[1].videosCommand.quickUpload({ name: 'video server 2' }) 48 await await servers[1].videos.quickUpload({ name: 'video server 2' })
49 await await servers[1].videosCommand.quickUpload({ name: 'video 2 server 2' }) 49 await await servers[1].videos.quickUpload({ name: 'video 2 server 2' })
50 await await servers[1].videosCommand.quickUpload({ name: 'video 3 server 2' }) 50 await await servers[1].videos.quickUpload({ name: 'video 3 server 2' })
51 51
52 { 52 {
53 const { data } = await servers[0].videosCommand.list() 53 const { data } = await servers[0].videos.list()
54 server1Videos = data.map(v => Object.assign(v, { url: servers[0].url + '/videos/watch/' + v.uuid })) 54 server1Videos = data.map(v => Object.assign(v, { url: servers[0].url + '/videos/watch/' + v.uuid }))
55 } 55 }
56 56
57 { 57 {
58 const { data } = await servers[1].videosCommand.list() 58 const { data } = await servers[1].videos.list()
59 server2Videos = data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid })) 59 server2Videos = data.map(v => Object.assign(v, { url: servers[1].url + '/videos/watch/' + v.uuid }))
60 } 60 }
61 61
@@ -63,7 +63,7 @@ describe('Official plugin auto-block videos', function () {
63 }) 63 })
64 64
65 it('Should update plugin settings', async function () { 65 it('Should update plugin settings', async function () {
66 await servers[0].pluginsCommand.updateSettings({ 66 await servers[0].plugins.updateSettings({
67 npmName: 'peertube-plugin-auto-block-videos', 67 npmName: 'peertube-plugin-auto-block-videos',
68 settings: { 68 settings: {
69 'blocklist-urls': `http://localhost:${port}/blocklist`, 69 'blocklist-urls': `http://localhost:${port}/blocklist`,
@@ -91,7 +91,7 @@ describe('Official plugin auto-block videos', function () {
91 }) 91 })
92 92
93 it('Should have video in blacklists', async function () { 93 it('Should have video in blacklists', async function () {
94 const body = await servers[0].blacklistCommand.list() 94 const body = await servers[0].blacklist.list()
95 95
96 const videoBlacklists = body.data 96 const videoBlacklists = body.data
97 expect(videoBlacklists).to.have.lengthOf(1) 97 expect(videoBlacklists).to.have.lengthOf(1)
@@ -156,7 +156,7 @@ describe('Official plugin auto-block videos', function () {
156 156
157 await check(servers[0], video.uuid, false) 157 await check(servers[0], video.uuid, false)
158 158
159 await servers[0].blacklistCommand.remove({ videoId: video.uuid }) 159 await servers[0].blacklist.remove({ videoId: video.uuid })
160 160
161 await check(servers[0], video.uuid, true) 161 await check(servers[0], video.uuid, true)
162 162
diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts
index 81a96744e..25b56a546 100644
--- a/server/tests/external-plugins/auto-mute.ts
+++ b/server/tests/external-plugins/auto-mute.ts
@@ -29,20 +29,20 @@ describe('Official plugin auto-mute', function () {
29 await setAccessTokensToServers(servers) 29 await setAccessTokensToServers(servers)
30 30
31 for (const server of servers) { 31 for (const server of servers) {
32 await server.pluginsCommand.install({ npmName: 'peertube-plugin-auto-mute' }) 32 await server.plugins.install({ npmName: 'peertube-plugin-auto-mute' })
33 } 33 }
34 34
35 blocklistServer = new MockBlocklist() 35 blocklistServer = new MockBlocklist()
36 port = await blocklistServer.initialize() 36 port = await blocklistServer.initialize()
37 37
38 await await servers[0].videosCommand.quickUpload({ name: 'video server 1' }) 38 await await servers[0].videos.quickUpload({ name: 'video server 1' })
39 await await servers[1].videosCommand.quickUpload({ name: 'video server 2' }) 39 await await servers[1].videos.quickUpload({ name: 'video server 2' })
40 40
41 await doubleFollow(servers[0], servers[1]) 41 await doubleFollow(servers[0], servers[1])
42 }) 42 })
43 43
44 it('Should update plugin settings', async function () { 44 it('Should update plugin settings', async function () {
45 await servers[0].pluginsCommand.updateSettings({ 45 await servers[0].plugins.updateSettings({
46 npmName: 'peertube-plugin-auto-mute', 46 npmName: 'peertube-plugin-auto-mute',
47 settings: { 47 settings: {
48 'blocklist-urls': `http://localhost:${port}/blocklist`, 48 'blocklist-urls': `http://localhost:${port}/blocklist`,
@@ -64,7 +64,7 @@ describe('Official plugin auto-mute', function () {
64 64
65 await wait(2000) 65 await wait(2000)
66 66
67 const { total } = await servers[0].videosCommand.list() 67 const { total } = await servers[0].videos.list()
68 expect(total).to.equal(1) 68 expect(total).to.equal(1)
69 }) 69 })
70 70
@@ -82,7 +82,7 @@ describe('Official plugin auto-mute', function () {
82 82
83 await wait(2000) 83 await wait(2000)
84 84
85 const { total } = await servers[0].videosCommand.list() 85 const { total } = await servers[0].videos.list()
86 expect(total).to.equal(2) 86 expect(total).to.equal(2)
87 }) 87 })
88 88
@@ -99,7 +99,7 @@ describe('Official plugin auto-mute', function () {
99 99
100 await wait(2000) 100 await wait(2000)
101 101
102 const { total } = await servers[0].videosCommand.list() 102 const { total } = await servers[0].videos.list()
103 expect(total).to.equal(1) 103 expect(total).to.equal(1)
104 }) 104 })
105 105
@@ -117,7 +117,7 @@ describe('Official plugin auto-mute', function () {
117 117
118 await wait(2000) 118 await wait(2000)
119 119
120 const { total } = await servers[0].videosCommand.list() 120 const { total } = await servers[0].videos.list()
121 expect(total).to.equal(2) 121 expect(total).to.equal(2)
122 }) 122 })
123 123
@@ -138,14 +138,14 @@ describe('Official plugin auto-mute', function () {
138 await wait(2000) 138 await wait(2000)
139 139
140 { 140 {
141 const { total } = await servers[0].videosCommand.list() 141 const { total } = await servers[0].videos.list()
142 expect(total).to.equal(1) 142 expect(total).to.equal(1)
143 } 143 }
144 144
145 await servers[0].blocklistCommand.removeFromServerBlocklist({ account }) 145 await servers[0].blocklist.removeFromServerBlocklist({ account })
146 146
147 { 147 {
148 const { total } = await servers[0].videosCommand.list() 148 const { total } = await servers[0].videos.list()
149 expect(total).to.equal(2) 149 expect(total).to.equal(2)
150 } 150 }
151 151
@@ -154,7 +154,7 @@ describe('Official plugin auto-mute', function () {
154 await wait(2000) 154 await wait(2000)
155 155
156 { 156 {
157 const { total } = await servers[0].videosCommand.list() 157 const { total } = await servers[0].videos.list()
158 expect(total).to.equal(2) 158 expect(total).to.equal(2)
159 } 159 }
160 }) 160 })
@@ -168,7 +168,7 @@ describe('Official plugin auto-mute', function () {
168 }) 168 })
169 169
170 it('Should enable auto mute list', async function () { 170 it('Should enable auto mute list', async function () {
171 await servers[0].pluginsCommand.updateSettings({ 171 await servers[0].plugins.updateSettings({
172 npmName: 'peertube-plugin-auto-mute', 172 npmName: 'peertube-plugin-auto-mute',
173 settings: { 173 settings: {
174 'blocklist-urls': '', 174 'blocklist-urls': '',
@@ -187,7 +187,7 @@ describe('Official plugin auto-mute', function () {
187 it('Should mute an account on server 1, and server 2 auto mutes it', async function () { 187 it('Should mute an account on server 1, and server 2 auto mutes it', async function () {
188 this.timeout(20000) 188 this.timeout(20000)
189 189
190 await servers[1].pluginsCommand.updateSettings({ 190 await servers[1].plugins.updateSettings({
191 npmName: 'peertube-plugin-auto-mute', 191 npmName: 'peertube-plugin-auto-mute',
192 settings: { 192 settings: {
193 'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath, 193 'blocklist-urls': 'http://localhost:' + servers[0].port + autoMuteListPath,
@@ -196,8 +196,8 @@ describe('Official plugin auto-mute', function () {
196 } 196 }
197 }) 197 })
198 198
199 await servers[0].blocklistCommand.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port }) 199 await servers[0].blocklist.addToServerBlocklist({ account: 'root@localhost:' + servers[1].port })
200 await servers[0].blocklistCommand.addToMyBlocklist({ server: 'localhost:' + servers[1].port }) 200 await servers[0].blocklist.addToMyBlocklist({ server: 'localhost:' + servers[1].port })
201 201
202 const res = await makeGetRequest({ 202 const res = await makeGetRequest({
203 url: servers[0].url, 203 url: servers[0].url,
@@ -213,7 +213,7 @@ describe('Official plugin auto-mute', function () {
213 await wait(2000) 213 await wait(2000)
214 214
215 for (const server of servers) { 215 for (const server of servers) {
216 const { total } = await server.videosCommand.list() 216 const { total } = await server.videos.list()
217 expect(total).to.equal(1) 217 expect(total).to.equal(1)
218 } 218 }
219 }) 219 })
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index c66cdde1b..8bdafc644 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -47,26 +47,26 @@ describe('Test syndication feeds', () => {
47 await doubleFollow(servers[0], servers[1]) 47 await doubleFollow(servers[0], servers[1])
48 48
49 { 49 {
50 const user = await servers[0].usersCommand.getMyInfo() 50 const user = await servers[0].users.getMyInfo()
51 rootAccountId = user.account.id 51 rootAccountId = user.account.id
52 rootChannelId = user.videoChannels[0].id 52 rootChannelId = user.videoChannels[0].id
53 } 53 }
54 54
55 { 55 {
56 const attr = { username: 'john', password: 'password' } 56 const attr = { username: 'john', password: 'password' }
57 await servers[0].usersCommand.create({ username: attr.username, password: attr.password }) 57 await servers[0].users.create({ username: attr.username, password: attr.password })
58 userAccessToken = await servers[0].loginCommand.getAccessToken(attr) 58 userAccessToken = await servers[0].login.getAccessToken(attr)
59 59
60 const user = await servers[0].usersCommand.getMyInfo({ token: userAccessToken }) 60 const user = await servers[0].users.getMyInfo({ token: userAccessToken })
61 userAccountId = user.account.id 61 userAccountId = user.account.id
62 userChannelId = user.videoChannels[0].id 62 userChannelId = user.videoChannels[0].id
63 63
64 const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken }) 64 const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken })
65 userFeedToken = token.feedToken 65 userFeedToken = token.feedToken
66 } 66 }
67 67
68 { 68 {
69 await servers[0].videosCommand.upload({ token: userAccessToken, attributes: { name: 'user video' } }) 69 await servers[0].videos.upload({ token: userAccessToken, attributes: { name: 'user video' } })
70 } 70 }
71 71
72 { 72 {
@@ -75,17 +75,17 @@ describe('Test syndication feeds', () => {
75 description: 'my super description for server 1', 75 description: 'my super description for server 1',
76 fixture: 'video_short.webm' 76 fixture: 'video_short.webm'
77 } 77 }
78 const { id } = await servers[0].videosCommand.upload({ attributes }) 78 const { id } = await servers[0].videos.upload({ attributes })
79 79
80 await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 1' }) 80 await servers[0].comments.createThread({ videoId: id, text: 'super comment 1' })
81 await servers[0].commentsCommand.createThread({ videoId: id, text: 'super comment 2' }) 81 await servers[0].comments.createThread({ videoId: id, text: 'super comment 2' })
82 } 82 }
83 83
84 { 84 {
85 const attributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED } 85 const attributes = { name: 'unlisted video', privacy: VideoPrivacy.UNLISTED }
86 const { id } = await servers[0].videosCommand.upload({ attributes }) 86 const { id } = await servers[0].videos.upload({ attributes })
87 87
88 await servers[0].commentsCommand.createThread({ videoId: id, text: 'comment on unlisted video' }) 88 await servers[0].comments.createThread({ videoId: id, text: 'comment on unlisted video' })
89 } 89 }
90 90
91 await waitJobs(servers) 91 await waitJobs(servers)
@@ -95,17 +95,17 @@ describe('Test syndication feeds', () => {
95 95
96 it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () { 96 it('Should be well formed XML (covers RSS 2.0 and ATOM 1.0 endpoints)', async function () {
97 for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { 97 for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) {
98 const rss = await servers[0].feedCommand.getXML({ feed }) 98 const rss = await servers[0].feed.getXML({ feed })
99 expect(rss).xml.to.be.valid() 99 expect(rss).xml.to.be.valid()
100 100
101 const atom = await servers[0].feedCommand.getXML({ feed, format: 'atom' }) 101 const atom = await servers[0].feed.getXML({ feed, format: 'atom' })
102 expect(atom).xml.to.be.valid() 102 expect(atom).xml.to.be.valid()
103 } 103 }
104 }) 104 })
105 105
106 it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () { 106 it('Should be well formed JSON (covers JSON feed 1.0 endpoint)', async function () {
107 for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) { 107 for (const feed of [ 'video-comments' as 'video-comments', 'videos' as 'videos' ]) {
108 const jsonText = await servers[0].feedCommand.getJSON({ feed }) 108 const jsonText = await servers[0].feed.getJSON({ feed })
109 expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' }) 109 expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' })
110 } 110 }
111 }) 111 })
@@ -115,7 +115,7 @@ describe('Test syndication feeds', () => {
115 115
116 it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () { 116 it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () {
117 for (const server of servers) { 117 for (const server of servers) {
118 const rss = await server.feedCommand.getXML({ feed: 'videos' }) 118 const rss = await server.feed.getXML({ feed: 'videos' })
119 expect(xmlParser.validate(rss)).to.be.true 119 expect(xmlParser.validate(rss)).to.be.true
120 120
121 const xmlDoc = xmlParser.parse(rss, { parseAttributeValue: true, ignoreAttributes: false }) 121 const xmlDoc = xmlParser.parse(rss, { parseAttributeValue: true, ignoreAttributes: false })
@@ -130,7 +130,7 @@ describe('Test syndication feeds', () => {
130 130
131 it('Should contain a valid \'attachments\' object (covers JSON feed 1.0 endpoint)', async function () { 131 it('Should contain a valid \'attachments\' object (covers JSON feed 1.0 endpoint)', async function () {
132 for (const server of servers) { 132 for (const server of servers) {
133 const json = await server.feedCommand.getJSON({ feed: 'videos' }) 133 const json = await server.feed.getJSON({ feed: 'videos' })
134 const jsonObj = JSON.parse(json) 134 const jsonObj = JSON.parse(json)
135 expect(jsonObj.items.length).to.be.equal(2) 135 expect(jsonObj.items.length).to.be.equal(2)
136 expect(jsonObj.items[0].attachments).to.exist 136 expect(jsonObj.items[0].attachments).to.exist
@@ -143,7 +143,7 @@ describe('Test syndication feeds', () => {
143 143
144 it('Should filter by account', async function () { 144 it('Should filter by account', async function () {
145 { 145 {
146 const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: rootAccountId } }) 146 const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: rootAccountId } })
147 const jsonObj = JSON.parse(json) 147 const jsonObj = JSON.parse(json)
148 expect(jsonObj.items.length).to.be.equal(1) 148 expect(jsonObj.items.length).to.be.equal(1)
149 expect(jsonObj.items[0].title).to.equal('my super name for server 1') 149 expect(jsonObj.items[0].title).to.equal('my super name for server 1')
@@ -151,7 +151,7 @@ describe('Test syndication feeds', () => {
151 } 151 }
152 152
153 { 153 {
154 const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { accountId: userAccountId } }) 154 const json = await servers[0].feed.getJSON({ feed: 'videos', query: { accountId: userAccountId } })
155 const jsonObj = JSON.parse(json) 155 const jsonObj = JSON.parse(json)
156 expect(jsonObj.items.length).to.be.equal(1) 156 expect(jsonObj.items.length).to.be.equal(1)
157 expect(jsonObj.items[0].title).to.equal('user video') 157 expect(jsonObj.items[0].title).to.equal('user video')
@@ -160,14 +160,14 @@ describe('Test syndication feeds', () => {
160 160
161 for (const server of servers) { 161 for (const server of servers) {
162 { 162 {
163 const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } }) 163 const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'root@localhost:' + servers[0].port } })
164 const jsonObj = JSON.parse(json) 164 const jsonObj = JSON.parse(json)
165 expect(jsonObj.items.length).to.be.equal(1) 165 expect(jsonObj.items.length).to.be.equal(1)
166 expect(jsonObj.items[0].title).to.equal('my super name for server 1') 166 expect(jsonObj.items[0].title).to.equal('my super name for server 1')
167 } 167 }
168 168
169 { 169 {
170 const json = await server.feedCommand.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } }) 170 const json = await server.feed.getJSON({ feed: 'videos', query: { accountName: 'john@localhost:' + servers[0].port } })
171 const jsonObj = JSON.parse(json) 171 const jsonObj = JSON.parse(json)
172 expect(jsonObj.items.length).to.be.equal(1) 172 expect(jsonObj.items.length).to.be.equal(1)
173 expect(jsonObj.items[0].title).to.equal('user video') 173 expect(jsonObj.items[0].title).to.equal('user video')
@@ -177,7 +177,7 @@ describe('Test syndication feeds', () => {
177 177
178 it('Should filter by video channel', async function () { 178 it('Should filter by video channel', async function () {
179 { 179 {
180 const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } }) 180 const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: rootChannelId } })
181 const jsonObj = JSON.parse(json) 181 const jsonObj = JSON.parse(json)
182 expect(jsonObj.items.length).to.be.equal(1) 182 expect(jsonObj.items.length).to.be.equal(1)
183 expect(jsonObj.items[0].title).to.equal('my super name for server 1') 183 expect(jsonObj.items[0].title).to.equal('my super name for server 1')
@@ -185,7 +185,7 @@ describe('Test syndication feeds', () => {
185 } 185 }
186 186
187 { 187 {
188 const json = await servers[0].feedCommand.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } }) 188 const json = await servers[0].feed.getJSON({ feed: 'videos', query: { videoChannelId: userChannelId } })
189 const jsonObj = JSON.parse(json) 189 const jsonObj = JSON.parse(json)
190 expect(jsonObj.items.length).to.be.equal(1) 190 expect(jsonObj.items.length).to.be.equal(1)
191 expect(jsonObj.items[0].title).to.equal('user video') 191 expect(jsonObj.items[0].title).to.equal('user video')
@@ -195,7 +195,7 @@ describe('Test syndication feeds', () => {
195 for (const server of servers) { 195 for (const server of servers) {
196 { 196 {
197 const query = { videoChannelName: 'root_channel@localhost:' + servers[0].port } 197 const query = { videoChannelName: 'root_channel@localhost:' + servers[0].port }
198 const json = await server.feedCommand.getJSON({ feed: 'videos', query }) 198 const json = await server.feed.getJSON({ feed: 'videos', query })
199 const jsonObj = JSON.parse(json) 199 const jsonObj = JSON.parse(json)
200 expect(jsonObj.items.length).to.be.equal(1) 200 expect(jsonObj.items.length).to.be.equal(1)
201 expect(jsonObj.items[0].title).to.equal('my super name for server 1') 201 expect(jsonObj.items[0].title).to.equal('my super name for server 1')
@@ -203,7 +203,7 @@ describe('Test syndication feeds', () => {
203 203
204 { 204 {
205 const query = { videoChannelName: 'john_channel@localhost:' + servers[0].port } 205 const query = { videoChannelName: 'john_channel@localhost:' + servers[0].port }
206 const json = await server.feedCommand.getJSON({ feed: 'videos', query }) 206 const json = await server.feed.getJSON({ feed: 'videos', query })
207 const jsonObj = JSON.parse(json) 207 const jsonObj = JSON.parse(json)
208 expect(jsonObj.items.length).to.be.equal(1) 208 expect(jsonObj.items.length).to.be.equal(1)
209 expect(jsonObj.items[0].title).to.equal('user video') 209 expect(jsonObj.items[0].title).to.equal('user video')
@@ -214,11 +214,11 @@ describe('Test syndication feeds', () => {
214 it('Should correctly have videos feed with HLS only', async function () { 214 it('Should correctly have videos feed with HLS only', async function () {
215 this.timeout(120000) 215 this.timeout(120000)
216 216
217 await serverHLSOnly.videosCommand.upload({ attributes: { name: 'hls only video' } }) 217 await serverHLSOnly.videos.upload({ attributes: { name: 'hls only video' } })
218 218
219 await waitJobs([ serverHLSOnly ]) 219 await waitJobs([ serverHLSOnly ])
220 220
221 const json = await serverHLSOnly.feedCommand.getJSON({ feed: 'videos' }) 221 const json = await serverHLSOnly.feed.getJSON({ feed: 'videos' })
222 const jsonObj = JSON.parse(json) 222 const jsonObj = JSON.parse(json)
223 expect(jsonObj.items.length).to.be.equal(1) 223 expect(jsonObj.items.length).to.be.equal(1)
224 expect(jsonObj.items[0].attachments).to.exist 224 expect(jsonObj.items[0].attachments).to.exist
@@ -236,7 +236,7 @@ describe('Test syndication feeds', () => {
236 236
237 it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', async function () { 237 it('Should contain valid comments (covers JSON feed 1.0 endpoint) and not from unlisted videos', async function () {
238 for (const server of servers) { 238 for (const server of servers) {
239 const json = await server.feedCommand.getJSON({ feed: 'video-comments' }) 239 const json = await server.feed.getJSON({ feed: 'video-comments' })
240 240
241 const jsonObj = JSON.parse(json) 241 const jsonObj = JSON.parse(json)
242 expect(jsonObj.items.length).to.be.equal(2) 242 expect(jsonObj.items.length).to.be.equal(2)
@@ -250,31 +250,31 @@ describe('Test syndication feeds', () => {
250 250
251 const remoteHandle = 'root@localhost:' + servers[0].port 251 const remoteHandle = 'root@localhost:' + servers[0].port
252 252
253 await servers[1].blocklistCommand.addToServerBlocklist({ account: remoteHandle }) 253 await servers[1].blocklist.addToServerBlocklist({ account: remoteHandle })
254 254
255 { 255 {
256 const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 2 } }) 256 const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 2 } })
257 const jsonObj = JSON.parse(json) 257 const jsonObj = JSON.parse(json)
258 expect(jsonObj.items.length).to.be.equal(0) 258 expect(jsonObj.items.length).to.be.equal(0)
259 } 259 }
260 260
261 await servers[1].blocklistCommand.removeFromServerBlocklist({ account: remoteHandle }) 261 await servers[1].blocklist.removeFromServerBlocklist({ account: remoteHandle })
262 262
263 { 263 {
264 const videoUUID = (await servers[1].videosCommand.quickUpload({ name: 'server 2' })).uuid 264 const videoUUID = (await servers[1].videos.quickUpload({ name: 'server 2' })).uuid
265 await waitJobs(servers) 265 await waitJobs(servers)
266 await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'super comment' }) 266 await servers[0].comments.createThread({ videoId: videoUUID, text: 'super comment' })
267 await waitJobs(servers) 267 await waitJobs(servers)
268 268
269 const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 3 } }) 269 const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 3 } })
270 const jsonObj = JSON.parse(json) 270 const jsonObj = JSON.parse(json)
271 expect(jsonObj.items.length).to.be.equal(3) 271 expect(jsonObj.items.length).to.be.equal(3)
272 } 272 }
273 273
274 await servers[1].blocklistCommand.addToMyBlocklist({ account: remoteHandle }) 274 await servers[1].blocklist.addToMyBlocklist({ account: remoteHandle })
275 275
276 { 276 {
277 const json = await servers[1].feedCommand.getJSON({ feed: 'video-comments', query: { version: 4 } }) 277 const json = await servers[1].feed.getJSON({ feed: 'video-comments', query: { version: 4 } })
278 const jsonObj = JSON.parse(json) 278 const jsonObj = JSON.parse(json)
279 expect(jsonObj.items.length).to.be.equal(2) 279 expect(jsonObj.items.length).to.be.equal(2)
280 } 280 }
@@ -287,25 +287,25 @@ describe('Test syndication feeds', () => {
287 287
288 it('Should list no videos for a user with no videos and no subscriptions', async function () { 288 it('Should list no videos for a user with no videos and no subscriptions', async function () {
289 const attr = { username: 'feeduser', password: 'password' } 289 const attr = { username: 'feeduser', password: 'password' }
290 await servers[0].usersCommand.create({ username: attr.username, password: attr.password }) 290 await servers[0].users.create({ username: attr.username, password: attr.password })
291 const feeduserAccessToken = await servers[0].loginCommand.getAccessToken(attr) 291 const feeduserAccessToken = await servers[0].login.getAccessToken(attr)
292 292
293 { 293 {
294 const user = await servers[0].usersCommand.getMyInfo({ token: feeduserAccessToken }) 294 const user = await servers[0].users.getMyInfo({ token: feeduserAccessToken })
295 feeduserAccountId = user.account.id 295 feeduserAccountId = user.account.id
296 } 296 }
297 297
298 { 298 {
299 const token = await servers[0].usersCommand.getMyScopedTokens({ token: feeduserAccessToken }) 299 const token = await servers[0].users.getMyScopedTokens({ token: feeduserAccessToken })
300 feeduserFeedToken = token.feedToken 300 feeduserFeedToken = token.feedToken
301 } 301 }
302 302
303 { 303 {
304 const body = await servers[0].subscriptionsCommand.listVideos({ token: feeduserAccessToken }) 304 const body = await servers[0].subscriptions.listVideos({ token: feeduserAccessToken })
305 expect(body.total).to.equal(0) 305 expect(body.total).to.equal(0)
306 306
307 const query = { accountId: feeduserAccountId, token: feeduserFeedToken } 307 const query = { accountId: feeduserAccountId, token: feeduserFeedToken }
308 const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) 308 const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
309 const jsonObj = JSON.parse(json) 309 const jsonObj = JSON.parse(json)
310 expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos 310 expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos
311 } 311 }
@@ -313,20 +313,20 @@ describe('Test syndication feeds', () => {
313 313
314 it('Should fail with an invalid token', async function () { 314 it('Should fail with an invalid token', async function () {
315 const query = { accountId: feeduserAccountId, token: 'toto' } 315 const query = { accountId: feeduserAccountId, token: 'toto' }
316 await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 316 await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
317 }) 317 })
318 318
319 it('Should fail with a token of another user', async function () { 319 it('Should fail with a token of another user', async function () {
320 const query = { accountId: feeduserAccountId, token: userFeedToken } 320 const query = { accountId: feeduserAccountId, token: userFeedToken }
321 await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 321 await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
322 }) 322 })
323 323
324 it('Should list no videos for a user with videos but no subscriptions', async function () { 324 it('Should list no videos for a user with videos but no subscriptions', async function () {
325 const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) 325 const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
326 expect(body.total).to.equal(0) 326 expect(body.total).to.equal(0)
327 327
328 const query = { accountId: userAccountId, token: userFeedToken } 328 const query = { accountId: userAccountId, token: userFeedToken }
329 const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) 329 const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
330 const jsonObj = JSON.parse(json) 330 const jsonObj = JSON.parse(json)
331 expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos 331 expect(jsonObj.items.length).to.be.equal(0) // no subscription, it should not list the instance's videos but list 0 videos
332 }) 332 })
@@ -334,16 +334,16 @@ describe('Test syndication feeds', () => {
334 it('Should list self videos for a user with a subscription to themselves', async function () { 334 it('Should list self videos for a user with a subscription to themselves', async function () {
335 this.timeout(30000) 335 this.timeout(30000)
336 336
337 await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port }) 337 await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'john_channel@localhost:' + servers[0].port })
338 await waitJobs(servers) 338 await waitJobs(servers)
339 339
340 { 340 {
341 const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) 341 const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
342 expect(body.total).to.equal(1) 342 expect(body.total).to.equal(1)
343 expect(body.data[0].name).to.equal('user video') 343 expect(body.data[0].name).to.equal('user video')
344 344
345 const query = { accountId: userAccountId, token: userFeedToken, version: 1 } 345 const query = { accountId: userAccountId, token: userFeedToken, version: 1 }
346 const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) 346 const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
347 const jsonObj = JSON.parse(json) 347 const jsonObj = JSON.parse(json)
348 expect(jsonObj.items.length).to.be.equal(1) // subscribed to self, it should not list the instance's videos but list john's 348 expect(jsonObj.items.length).to.be.equal(1) // subscribed to self, it should not list the instance's videos but list john's
349 } 349 }
@@ -352,33 +352,33 @@ describe('Test syndication feeds', () => {
352 it('Should list videos of a user\'s subscription', async function () { 352 it('Should list videos of a user\'s subscription', async function () {
353 this.timeout(30000) 353 this.timeout(30000)
354 354
355 await servers[0].subscriptionsCommand.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port }) 355 await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@localhost:' + servers[0].port })
356 await waitJobs(servers) 356 await waitJobs(servers)
357 357
358 { 358 {
359 const body = await servers[0].subscriptionsCommand.listVideos({ token: userAccessToken }) 359 const body = await servers[0].subscriptions.listVideos({ token: userAccessToken })
360 expect(body.total).to.equal(2, "there should be 2 videos part of the subscription") 360 expect(body.total).to.equal(2, "there should be 2 videos part of the subscription")
361 361
362 const query = { accountId: userAccountId, token: userFeedToken, version: 2 } 362 const query = { accountId: userAccountId, token: userFeedToken, version: 2 }
363 const json = await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) 363 const json = await servers[0].feed.getJSON({ feed: 'subscriptions', query })
364 const jsonObj = JSON.parse(json) 364 const jsonObj = JSON.parse(json)
365 expect(jsonObj.items.length).to.be.equal(2) // subscribed to root, it should not list the instance's videos but list root/john's 365 expect(jsonObj.items.length).to.be.equal(2) // subscribed to root, it should not list the instance's videos but list root/john's
366 } 366 }
367 }) 367 })
368 368
369 it('Should renew the token, and so have an invalid old token', async function () { 369 it('Should renew the token, and so have an invalid old token', async function () {
370 await servers[0].usersCommand.renewMyScopedTokens({ token: userAccessToken }) 370 await servers[0].users.renewMyScopedTokens({ token: userAccessToken })
371 371
372 const query = { accountId: userAccountId, token: userFeedToken, version: 3 } 372 const query = { accountId: userAccountId, token: userFeedToken, version: 3 }
373 await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 373 await servers[0].feed.getJSON({ feed: 'subscriptions', query, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
374 }) 374 })
375 375
376 it('Should succeed with the new token', async function () { 376 it('Should succeed with the new token', async function () {
377 const token = await servers[0].usersCommand.getMyScopedTokens({ token: userAccessToken }) 377 const token = await servers[0].users.getMyScopedTokens({ token: userAccessToken })
378 userFeedToken = token.feedToken 378 userFeedToken = token.feedToken
379 379
380 const query = { accountId: userAccountId, token: userFeedToken, version: 4 } 380 const query = { accountId: userAccountId, token: userFeedToken, version: 4 }
381 await servers[0].feedCommand.getJSON({ feed: 'subscriptions', query }) 381 await servers[0].feed.getJSON({ feed: 'subscriptions', query })
382 }) 382 })
383 383
384 }) 384 })
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts
index b5b10bd5e..f7c9e6c26 100644
--- a/server/tests/misc-endpoints.ts
+++ b/server/tests/misc-endpoints.ts
@@ -158,15 +158,15 @@ describe('Test misc endpoints', function () {
158 it('Should add videos, channel and accounts and get sitemap', async function () { 158 it('Should add videos, channel and accounts and get sitemap', async function () {
159 this.timeout(35000) 159 this.timeout(35000)
160 160
161 await server.videosCommand.upload({ attributes: { name: 'video 1', nsfw: false } }) 161 await server.videos.upload({ attributes: { name: 'video 1', nsfw: false } })
162 await server.videosCommand.upload({ attributes: { name: 'video 2', nsfw: false } }) 162 await server.videos.upload({ attributes: { name: 'video 2', nsfw: false } })
163 await server.videosCommand.upload({ attributes: { name: 'video 3', privacy: VideoPrivacy.PRIVATE } }) 163 await server.videos.upload({ attributes: { name: 'video 3', privacy: VideoPrivacy.PRIVATE } })
164 164
165 await server.channelsCommand.create({ attributes: { name: 'channel1', displayName: 'channel 1' } }) 165 await server.channels.create({ attributes: { name: 'channel1', displayName: 'channel 1' } })
166 await server.channelsCommand.create({ attributes: { name: 'channel2', displayName: 'channel 2' } }) 166 await server.channels.create({ attributes: { name: 'channel2', displayName: 'channel 2' } })
167 167
168 await server.usersCommand.create({ username: 'user1', password: 'password' }) 168 await server.users.create({ username: 'user1', password: 'password' })
169 await server.usersCommand.create({ username: 'user2', password: 'password' }) 169 await server.users.create({ username: 'user2', password: 'password' })
170 170
171 const res = await makeGetRequest({ 171 const res = await makeGetRequest({
172 url: server.url, 172 url: server.url,
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index 9e12c8aa7..12d5c23c5 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -19,7 +19,7 @@ describe('Test plugin action hooks', function () {
19 let threadId: number 19 let threadId: number
20 20
21 function checkHook (hook: ServerHookName) { 21 function checkHook (hook: ServerHookName) {
22 return servers[0].serversCommand.waitUntilLog('Run hook ' + hook) 22 return servers[0].servers.waitUntilLog('Run hook ' + hook)
23 } 23 }
24 24
25 before(async function () { 25 before(async function () {
@@ -29,7 +29,7 @@ describe('Test plugin action hooks', function () {
29 await setAccessTokensToServers(servers) 29 await setAccessTokensToServers(servers)
30 await setDefaultVideoChannel(servers) 30 await setDefaultVideoChannel(servers)
31 31
32 await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() }) 32 await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() })
33 33
34 await killallServers([ servers[0] ]) 34 await killallServers([ servers[0] ])
35 35
@@ -49,20 +49,20 @@ describe('Test plugin action hooks', function () {
49 describe('Videos hooks', function () { 49 describe('Videos hooks', function () {
50 50
51 it('Should run action:api.video.uploaded', async function () { 51 it('Should run action:api.video.uploaded', async function () {
52 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' } }) 52 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' } })
53 videoUUID = uuid 53 videoUUID = uuid
54 54
55 await checkHook('action:api.video.uploaded') 55 await checkHook('action:api.video.uploaded')
56 }) 56 })
57 57
58 it('Should run action:api.video.updated', async function () { 58 it('Should run action:api.video.updated', async function () {
59 await servers[0].videosCommand.update({ id: videoUUID, attributes: { name: 'video updated' } }) 59 await servers[0].videos.update({ id: videoUUID, attributes: { name: 'video updated' } })
60 60
61 await checkHook('action:api.video.updated') 61 await checkHook('action:api.video.updated')
62 }) 62 })
63 63
64 it('Should run action:api.video.viewed', async function () { 64 it('Should run action:api.video.viewed', async function () {
65 await servers[0].videosCommand.view({ id: videoUUID }) 65 await servers[0].videos.view({ id: videoUUID })
66 66
67 await checkHook('action:api.video.viewed') 67 await checkHook('action:api.video.viewed')
68 }) 68 })
@@ -74,10 +74,10 @@ describe('Test plugin action hooks', function () {
74 const attributes = { 74 const attributes = {
75 name: 'live', 75 name: 'live',
76 privacy: VideoPrivacy.PUBLIC, 76 privacy: VideoPrivacy.PUBLIC,
77 channelId: servers[0].videoChannel.id 77 channelId: servers[0].store.channel.id
78 } 78 }
79 79
80 await servers[0].liveCommand.create({ fields: attributes }) 80 await servers[0].live.create({ fields: attributes })
81 81
82 await checkHook('action:api.live-video.created') 82 await checkHook('action:api.live-video.created')
83 }) 83 })
@@ -85,20 +85,20 @@ describe('Test plugin action hooks', function () {
85 85
86 describe('Comments hooks', function () { 86 describe('Comments hooks', function () {
87 it('Should run action:api.video-thread.created', async function () { 87 it('Should run action:api.video-thread.created', async function () {
88 const created = await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'thread' }) 88 const created = await servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' })
89 threadId = created.id 89 threadId = created.id
90 90
91 await checkHook('action:api.video-thread.created') 91 await checkHook('action:api.video-thread.created')
92 }) 92 })
93 93
94 it('Should run action:api.video-comment-reply.created', async function () { 94 it('Should run action:api.video-comment-reply.created', async function () {
95 await servers[0].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text: 'reply' }) 95 await servers[0].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: 'reply' })
96 96
97 await checkHook('action:api.video-comment-reply.created') 97 await checkHook('action:api.video-comment-reply.created')
98 }) 98 })
99 99
100 it('Should run action:api.video-comment.deleted', async function () { 100 it('Should run action:api.video-comment.deleted', async function () {
101 await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId: threadId }) 101 await servers[0].comments.delete({ videoId: videoUUID, commentId: threadId })
102 102
103 await checkHook('action:api.video-comment.deleted') 103 await checkHook('action:api.video-comment.deleted')
104 }) 104 })
@@ -108,44 +108,44 @@ describe('Test plugin action hooks', function () {
108 let userId: number 108 let userId: number
109 109
110 it('Should run action:api.user.registered', async function () { 110 it('Should run action:api.user.registered', async function () {
111 await servers[0].usersCommand.register({ username: 'registered_user' }) 111 await servers[0].users.register({ username: 'registered_user' })
112 112
113 await checkHook('action:api.user.registered') 113 await checkHook('action:api.user.registered')
114 }) 114 })
115 115
116 it('Should run action:api.user.created', async function () { 116 it('Should run action:api.user.created', async function () {
117 const user = await servers[0].usersCommand.create({ username: 'created_user' }) 117 const user = await servers[0].users.create({ username: 'created_user' })
118 userId = user.id 118 userId = user.id
119 119
120 await checkHook('action:api.user.created') 120 await checkHook('action:api.user.created')
121 }) 121 })
122 122
123 it('Should run action:api.user.oauth2-got-token', async function () { 123 it('Should run action:api.user.oauth2-got-token', async function () {
124 await servers[0].loginCommand.getAccessToken('created_user', 'super_password') 124 await servers[0].login.getAccessToken('created_user', 'super_password')
125 125
126 await checkHook('action:api.user.oauth2-got-token') 126 await checkHook('action:api.user.oauth2-got-token')
127 }) 127 })
128 128
129 it('Should run action:api.user.blocked', async function () { 129 it('Should run action:api.user.blocked', async function () {
130 await servers[0].usersCommand.banUser({ userId }) 130 await servers[0].users.banUser({ userId })
131 131
132 await checkHook('action:api.user.blocked') 132 await checkHook('action:api.user.blocked')
133 }) 133 })
134 134
135 it('Should run action:api.user.unblocked', async function () { 135 it('Should run action:api.user.unblocked', async function () {
136 await servers[0].usersCommand.unbanUser({ userId }) 136 await servers[0].users.unbanUser({ userId })
137 137
138 await checkHook('action:api.user.unblocked') 138 await checkHook('action:api.user.unblocked')
139 }) 139 })
140 140
141 it('Should run action:api.user.updated', async function () { 141 it('Should run action:api.user.updated', async function () {
142 await servers[0].usersCommand.update({ userId, videoQuota: 50 }) 142 await servers[0].users.update({ userId, videoQuota: 50 })
143 143
144 await checkHook('action:api.user.updated') 144 await checkHook('action:api.user.updated')
145 }) 145 })
146 146
147 it('Should run action:api.user.deleted', async function () { 147 it('Should run action:api.user.deleted', async function () {
148 await servers[0].usersCommand.remove({ userId }) 148 await servers[0].users.remove({ userId })
149 149
150 await checkHook('action:api.user.deleted') 150 await checkHook('action:api.user.deleted')
151 }) 151 })
@@ -157,7 +157,7 @@ describe('Test plugin action hooks', function () {
157 157
158 before(async function () { 158 before(async function () {
159 { 159 {
160 const { id } = await servers[0].playlistsCommand.create({ 160 const { id } = await servers[0].playlists.create({
161 attributes: { 161 attributes: {
162 displayName: 'My playlist', 162 displayName: 'My playlist',
163 privacy: VideoPlaylistPrivacy.PRIVATE 163 privacy: VideoPlaylistPrivacy.PRIVATE
@@ -167,13 +167,13 @@ describe('Test plugin action hooks', function () {
167 } 167 }
168 168
169 { 169 {
170 const { id } = await servers[0].videosCommand.upload({ attributes: { name: 'my super name' } }) 170 const { id } = await servers[0].videos.upload({ attributes: { name: 'my super name' } })
171 videoId = id 171 videoId = id
172 } 172 }
173 }) 173 })
174 174
175 it('Should run action:api.video-playlist-element.created', async function () { 175 it('Should run action:api.video-playlist-element.created', async function () {
176 await servers[0].playlistsCommand.addElement({ playlistId, attributes: { videoId } }) 176 await servers[0].playlists.addElement({ playlistId, attributes: { videoId } })
177 177
178 await checkHook('action:api.video-playlist-element.created') 178 await checkHook('action:api.video-playlist-element.created')
179 }) 179 })
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts
index 3e8305611..48f942f7f 100644
--- a/server/tests/plugins/external-auth.ts
+++ b/server/tests/plugins/external-auth.ts
@@ -23,7 +23,7 @@ async function loginExternal (options: {
23 statusCodeExpected?: HttpStatusCode 23 statusCodeExpected?: HttpStatusCode
24 statusCodeExpectedStep2?: HttpStatusCode 24 statusCodeExpectedStep2?: HttpStatusCode
25}) { 25}) {
26 const res = await options.server.pluginsCommand.getExternalAuth({ 26 const res = await options.server.plugins.getExternalAuth({
27 npmName: options.npmName, 27 npmName: options.npmName,
28 npmVersion: '0.0.1', 28 npmVersion: '0.0.1',
29 authName: options.authName, 29 authName: options.authName,
@@ -36,7 +36,7 @@ async function loginExternal (options: {
36 const location = res.header.location 36 const location = res.header.location
37 const { externalAuthToken } = decodeQueryString(location) 37 const { externalAuthToken } = decodeQueryString(location)
38 38
39 const resLogin = await options.server.loginCommand.loginUsingExternalToken({ 39 const resLogin = await options.server.login.loginUsingExternalToken({
40 username: options.username, 40 username: options.username,
41 externalAuthToken: externalAuthToken as string, 41 externalAuthToken: externalAuthToken as string,
42 expectedStatus: options.statusCodeExpectedStep2 42 expectedStatus: options.statusCodeExpectedStep2
@@ -63,12 +63,12 @@ describe('Test external auth plugins', function () {
63 await setAccessTokensToServers([ server ]) 63 await setAccessTokensToServers([ server ])
64 64
65 for (const suffix of [ 'one', 'two', 'three' ]) { 65 for (const suffix of [ 'one', 'two', 'three' ]) {
66 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-external-auth-' + suffix) }) 66 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-external-auth-' + suffix) })
67 } 67 }
68 }) 68 })
69 69
70 it('Should display the correct configuration', async function () { 70 it('Should display the correct configuration', async function () {
71 const config = await server.configCommand.getConfig() 71 const config = await server.config.getConfig()
72 72
73 const auths = config.plugin.registeredExternalAuths 73 const auths = config.plugin.registeredExternalAuths
74 expect(auths).to.have.lengthOf(8) 74 expect(auths).to.have.lengthOf(8)
@@ -80,7 +80,7 @@ describe('Test external auth plugins', function () {
80 }) 80 })
81 81
82 it('Should redirect for a Cyan login', async function () { 82 it('Should redirect for a Cyan login', async function () {
83 const res = await server.pluginsCommand.getExternalAuth({ 83 const res = await server.plugins.getExternalAuth({
84 npmName: 'test-external-auth-one', 84 npmName: 'test-external-auth-one',
85 npmVersion: '0.0.1', 85 npmVersion: '0.0.1',
86 authName: 'external-auth-1', 86 authName: 'external-auth-1',
@@ -102,14 +102,14 @@ describe('Test external auth plugins', function () {
102 }) 102 })
103 103
104 it('Should reject auto external login with a missing or invalid token', async function () { 104 it('Should reject auto external login with a missing or invalid token', async function () {
105 const command = server.loginCommand 105 const command = server.login
106 106
107 await command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: '', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 107 await command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: '', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
108 await command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: 'blabla', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 108 await command.loginUsingExternalToken({ username: 'cyan', externalAuthToken: 'blabla', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
109 }) 109 })
110 110
111 it('Should reject auto external login with a missing or invalid username', async function () { 111 it('Should reject auto external login with a missing or invalid username', async function () {
112 const command = server.loginCommand 112 const command = server.login
113 113
114 await command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 114 await command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
115 await command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 115 await command.loginUsingExternalToken({ username: '', externalAuthToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
@@ -120,13 +120,13 @@ describe('Test external auth plugins', function () {
120 120
121 await wait(5000) 121 await wait(5000)
122 122
123 await server.loginCommand.loginUsingExternalToken({ 123 await server.login.loginUsingExternalToken({
124 username: 'cyan', 124 username: 'cyan',
125 externalAuthToken, 125 externalAuthToken,
126 expectedStatus: HttpStatusCode.BAD_REQUEST_400 126 expectedStatus: HttpStatusCode.BAD_REQUEST_400
127 }) 127 })
128 128
129 await server.serversCommand.waitUntilLog('expired external auth token', 2) 129 await server.servers.waitUntilLog('expired external auth token', 2)
130 }) 130 })
131 131
132 it('Should auto login Cyan, create the user and use the token', async function () { 132 it('Should auto login Cyan, create the user and use the token', async function () {
@@ -146,7 +146,7 @@ describe('Test external auth plugins', function () {
146 } 146 }
147 147
148 { 148 {
149 const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken }) 149 const body = await server.users.getMyInfo({ token: cyanAccessToken })
150 expect(body.username).to.equal('cyan') 150 expect(body.username).to.equal('cyan')
151 expect(body.account.displayName).to.equal('cyan') 151 expect(body.account.displayName).to.equal('cyan')
152 expect(body.email).to.equal('cyan@example.com') 152 expect(body.email).to.equal('cyan@example.com')
@@ -168,7 +168,7 @@ describe('Test external auth plugins', function () {
168 } 168 }
169 169
170 { 170 {
171 const body = await server.usersCommand.getMyInfo({ token: kefkaAccessToken }) 171 const body = await server.users.getMyInfo({ token: kefkaAccessToken })
172 expect(body.username).to.equal('kefka') 172 expect(body.username).to.equal('kefka')
173 expect(body.account.displayName).to.equal('Kefka Palazzo') 173 expect(body.account.displayName).to.equal('Kefka Palazzo')
174 expect(body.email).to.equal('kefka@example.com') 174 expect(body.email).to.equal('kefka@example.com')
@@ -178,39 +178,39 @@ describe('Test external auth plugins', function () {
178 178
179 it('Should refresh Cyan token, but not Kefka token', async function () { 179 it('Should refresh Cyan token, but not Kefka token', async function () {
180 { 180 {
181 const resRefresh = await server.loginCommand.refreshToken({ refreshToken: cyanRefreshToken }) 181 const resRefresh = await server.login.refreshToken({ refreshToken: cyanRefreshToken })
182 cyanAccessToken = resRefresh.body.access_token 182 cyanAccessToken = resRefresh.body.access_token
183 cyanRefreshToken = resRefresh.body.refresh_token 183 cyanRefreshToken = resRefresh.body.refresh_token
184 184
185 const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken }) 185 const body = await server.users.getMyInfo({ token: cyanAccessToken })
186 expect(body.username).to.equal('cyan') 186 expect(body.username).to.equal('cyan')
187 } 187 }
188 188
189 { 189 {
190 await server.loginCommand.refreshToken({ refreshToken: kefkaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 190 await server.login.refreshToken({ refreshToken: kefkaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
191 } 191 }
192 }) 192 })
193 193
194 it('Should update Cyan profile', async function () { 194 it('Should update Cyan profile', async function () {
195 await server.usersCommand.updateMe({ 195 await server.users.updateMe({
196 token: cyanAccessToken, 196 token: cyanAccessToken,
197 displayName: 'Cyan Garamonde', 197 displayName: 'Cyan Garamonde',
198 description: 'Retainer to the king of Doma' 198 description: 'Retainer to the king of Doma'
199 }) 199 })
200 200
201 const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken }) 201 const body = await server.users.getMyInfo({ token: cyanAccessToken })
202 expect(body.account.displayName).to.equal('Cyan Garamonde') 202 expect(body.account.displayName).to.equal('Cyan Garamonde')
203 expect(body.account.description).to.equal('Retainer to the king of Doma') 203 expect(body.account.description).to.equal('Retainer to the king of Doma')
204 }) 204 })
205 205
206 it('Should logout Cyan', async function () { 206 it('Should logout Cyan', async function () {
207 await server.loginCommand.logout({ token: cyanAccessToken }) 207 await server.login.logout({ token: cyanAccessToken })
208 }) 208 })
209 209
210 it('Should have logged out Cyan', async function () { 210 it('Should have logged out Cyan', async function () {
211 await server.serversCommand.waitUntilLog('On logout cyan') 211 await server.servers.waitUntilLog('On logout cyan')
212 212
213 await server.usersCommand.getMyInfo({ token: cyanAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 213 await server.users.getMyInfo({ token: cyanAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
214 }) 214 })
215 215
216 it('Should login Cyan and keep the old existing profile', async function () { 216 it('Should login Cyan and keep the old existing profile', async function () {
@@ -228,7 +228,7 @@ describe('Test external auth plugins', function () {
228 cyanAccessToken = res.access_token 228 cyanAccessToken = res.access_token
229 } 229 }
230 230
231 const body = await server.usersCommand.getMyInfo({ token: cyanAccessToken }) 231 const body = await server.users.getMyInfo({ token: cyanAccessToken })
232 expect(body.username).to.equal('cyan') 232 expect(body.username).to.equal('cyan')
233 expect(body.account.displayName).to.equal('Cyan Garamonde') 233 expect(body.account.displayName).to.equal('Cyan Garamonde')
234 expect(body.account.description).to.equal('Retainer to the king of Doma') 234 expect(body.account.description).to.equal('Retainer to the king of Doma')
@@ -236,7 +236,7 @@ describe('Test external auth plugins', function () {
236 }) 236 })
237 237
238 it('Should not update an external auth email', async function () { 238 it('Should not update an external auth email', async function () {
239 await server.usersCommand.updateMe({ 239 await server.users.updateMe({
240 token: cyanAccessToken, 240 token: cyanAccessToken,
241 email: 'toto@example.com', 241 email: 'toto@example.com',
242 currentPassword: 'toto', 242 currentPassword: 'toto',
@@ -249,16 +249,16 @@ describe('Test external auth plugins', function () {
249 249
250 await wait(5000) 250 await wait(5000)
251 251
252 await server.usersCommand.getMyInfo({ token: kefkaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 252 await server.users.getMyInfo({ token: kefkaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
253 }) 253 })
254 254
255 it('Should unregister external-auth-2 and do not login existing Kefka', async function () { 255 it('Should unregister external-auth-2 and do not login existing Kefka', async function () {
256 await server.pluginsCommand.updateSettings({ 256 await server.plugins.updateSettings({
257 npmName: 'peertube-plugin-test-external-auth-one', 257 npmName: 'peertube-plugin-test-external-auth-one',
258 settings: { disableKefka: true } 258 settings: { disableKefka: true }
259 }) 259 })
260 260
261 await server.loginCommand.login({ user: { username: 'kefka', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 261 await server.login.login({ user: { username: 'kefka', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
262 262
263 await loginExternal({ 263 await loginExternal({
264 server, 264 server,
@@ -273,7 +273,7 @@ describe('Test external auth plugins', function () {
273 }) 273 })
274 274
275 it('Should have disabled this auth', async function () { 275 it('Should have disabled this auth', async function () {
276 const config = await server.configCommand.getConfig() 276 const config = await server.config.getConfig()
277 277
278 const auths = config.plugin.registeredExternalAuths 278 const auths = config.plugin.registeredExternalAuths
279 expect(auths).to.have.lengthOf(7) 279 expect(auths).to.have.lengthOf(7)
@@ -283,7 +283,7 @@ describe('Test external auth plugins', function () {
283 }) 283 })
284 284
285 it('Should uninstall the plugin one and do not login Cyan', async function () { 285 it('Should uninstall the plugin one and do not login Cyan', async function () {
286 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-external-auth-one' }) 286 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-external-auth-one' })
287 287
288 await loginExternal({ 288 await loginExternal({
289 server, 289 server,
@@ -296,9 +296,9 @@ describe('Test external auth plugins', function () {
296 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 296 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
297 }) 297 })
298 298
299 await server.loginCommand.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 299 await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
300 await server.loginCommand.login({ user: { username: 'cyan', password: '' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 300 await server.login.login({ user: { username: 'cyan', password: '' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
301 await server.loginCommand.login({ user: { username: 'cyan', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 301 await server.login.login({ user: { username: 'cyan', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
302 }) 302 })
303 303
304 it('Should not login kefka with another plugin', async function () { 304 it('Should not login kefka with another plugin', async function () {
@@ -320,7 +320,7 @@ describe('Test external auth plugins', function () {
320 }) 320 })
321 321
322 it('Should not login an existing user', async function () { 322 it('Should not login an existing user', async function () {
323 await server.usersCommand.create({ username: 'existing_user', password: 'super_password' }) 323 await server.users.create({ username: 'existing_user', password: 'super_password' })
324 324
325 await loginExternal({ 325 await loginExternal({
326 server, 326 server,
@@ -332,7 +332,7 @@ describe('Test external auth plugins', function () {
332 }) 332 })
333 333
334 it('Should display the correct configuration', async function () { 334 it('Should display the correct configuration', async function () {
335 const config = await server.configCommand.getConfig() 335 const config = await server.config.getConfig()
336 336
337 const auths = config.plugin.registeredExternalAuths 337 const auths = config.plugin.registeredExternalAuths
338 expect(auths).to.have.lengthOf(6) 338 expect(auths).to.have.lengthOf(6)
@@ -353,7 +353,7 @@ describe('Test external auth plugins', function () {
353 username: 'cid' 353 username: 'cid'
354 }) 354 })
355 355
356 const { redirectUrl } = await server.loginCommand.logout({ token: resLogin.access_token }) 356 const { redirectUrl } = await server.login.logout({ token: resLogin.access_token })
357 expect(redirectUrl).to.equal('https://example.com/redirectUrl') 357 expect(redirectUrl).to.equal('https://example.com/redirectUrl')
358 }) 358 })
359 359
@@ -365,7 +365,7 @@ describe('Test external auth plugins', function () {
365 username: 'cid' 365 username: 'cid'
366 }) 366 })
367 367
368 const { redirectUrl } = await server.loginCommand.logout({ token: resLogin.access_token }) 368 const { redirectUrl } = await server.login.logout({ token: resLogin.access_token })
369 expect(redirectUrl).to.equal('https://example.com/redirectUrl?access_token=' + resLogin.access_token) 369 expect(redirectUrl).to.equal('https://example.com/redirectUrl?access_token=' + resLogin.access_token)
370 }) 370 })
371}) 371})
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index e82aa3bfb..18479dcf5 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -32,17 +32,17 @@ describe('Test plugin filter hooks', function () {
32 await setDefaultVideoChannel(servers) 32 await setDefaultVideoChannel(servers)
33 await doubleFollow(servers[0], servers[1]) 33 await doubleFollow(servers[0], servers[1])
34 34
35 await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath() }) 35 await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath() })
36 await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') }) 36 await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
37 37
38 for (let i = 0; i < 10; i++) { 38 for (let i = 0; i < 10; i++) {
39 await servers[0].videosCommand.upload({ attributes: { name: 'default video ' + i } }) 39 await servers[0].videos.upload({ attributes: { name: 'default video ' + i } })
40 } 40 }
41 41
42 const { data } = await servers[0].videosCommand.list() 42 const { data } = await servers[0].videos.list()
43 videoUUID = data[0].uuid 43 videoUUID = data[0].uuid
44 44
45 await servers[0].configCommand.updateCustomSubConfig({ 45 await servers[0].config.updateCustomSubConfig({
46 newConfig: { 46 newConfig: {
47 live: { enabled: true }, 47 live: { enabled: true },
48 signup: { enabled: true }, 48 signup: { enabled: true },
@@ -57,98 +57,98 @@ describe('Test plugin filter hooks', function () {
57 }) 57 })
58 58
59 it('Should run filter:api.videos.list.params', async function () { 59 it('Should run filter:api.videos.list.params', async function () {
60 const { data } = await servers[0].videosCommand.list({ start: 0, count: 2 }) 60 const { data } = await servers[0].videos.list({ start: 0, count: 2 })
61 61
62 // 2 plugins do +1 to the count parameter 62 // 2 plugins do +1 to the count parameter
63 expect(data).to.have.lengthOf(4) 63 expect(data).to.have.lengthOf(4)
64 }) 64 })
65 65
66 it('Should run filter:api.videos.list.result', async function () { 66 it('Should run filter:api.videos.list.result', async function () {
67 const { total } = await servers[0].videosCommand.list({ start: 0, count: 0 }) 67 const { total } = await servers[0].videos.list({ start: 0, count: 0 })
68 68
69 // Plugin do +1 to the total result 69 // Plugin do +1 to the total result
70 expect(total).to.equal(11) 70 expect(total).to.equal(11)
71 }) 71 })
72 72
73 it('Should run filter:api.accounts.videos.list.params', async function () { 73 it('Should run filter:api.accounts.videos.list.params', async function () {
74 const { data } = await servers[0].videosCommand.listByAccount({ accountName: 'root', start: 0, count: 2 }) 74 const { data } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 })
75 75
76 // 1 plugin do +1 to the count parameter 76 // 1 plugin do +1 to the count parameter
77 expect(data).to.have.lengthOf(3) 77 expect(data).to.have.lengthOf(3)
78 }) 78 })
79 79
80 it('Should run filter:api.accounts.videos.list.result', async function () { 80 it('Should run filter:api.accounts.videos.list.result', async function () {
81 const { total } = await servers[0].videosCommand.listByAccount({ accountName: 'root', start: 0, count: 2 }) 81 const { total } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 })
82 82
83 // Plugin do +2 to the total result 83 // Plugin do +2 to the total result
84 expect(total).to.equal(12) 84 expect(total).to.equal(12)
85 }) 85 })
86 86
87 it('Should run filter:api.video-channels.videos.list.params', async function () { 87 it('Should run filter:api.video-channels.videos.list.params', async function () {
88 const { data } = await servers[0].videosCommand.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 }) 88 const { data } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
89 89
90 // 1 plugin do +3 to the count parameter 90 // 1 plugin do +3 to the count parameter
91 expect(data).to.have.lengthOf(5) 91 expect(data).to.have.lengthOf(5)
92 }) 92 })
93 93
94 it('Should run filter:api.video-channels.videos.list.result', async function () { 94 it('Should run filter:api.video-channels.videos.list.result', async function () {
95 const { total } = await servers[0].videosCommand.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 }) 95 const { total } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
96 96
97 // Plugin do +3 to the total result 97 // Plugin do +3 to the total result
98 expect(total).to.equal(13) 98 expect(total).to.equal(13)
99 }) 99 })
100 100
101 it('Should run filter:api.user.me.videos.list.params', async function () { 101 it('Should run filter:api.user.me.videos.list.params', async function () {
102 const { data } = await servers[0].videosCommand.listMyVideos({ start: 0, count: 2 }) 102 const { data } = await servers[0].videos.listMyVideos({ start: 0, count: 2 })
103 103
104 // 1 plugin do +4 to the count parameter 104 // 1 plugin do +4 to the count parameter
105 expect(data).to.have.lengthOf(6) 105 expect(data).to.have.lengthOf(6)
106 }) 106 })
107 107
108 it('Should run filter:api.user.me.videos.list.result', async function () { 108 it('Should run filter:api.user.me.videos.list.result', async function () {
109 const { total } = await servers[0].videosCommand.listMyVideos({ start: 0, count: 2 }) 109 const { total } = await servers[0].videos.listMyVideos({ start: 0, count: 2 })
110 110
111 // Plugin do +4 to the total result 111 // Plugin do +4 to the total result
112 expect(total).to.equal(14) 112 expect(total).to.equal(14)
113 }) 113 })
114 114
115 it('Should run filter:api.video.get.result', async function () { 115 it('Should run filter:api.video.get.result', async function () {
116 const video = await servers[0].videosCommand.get({ id: videoUUID }) 116 const video = await servers[0].videos.get({ id: videoUUID })
117 expect(video.name).to.contain('<3') 117 expect(video.name).to.contain('<3')
118 }) 118 })
119 119
120 it('Should run filter:api.video.upload.accept.result', async function () { 120 it('Should run filter:api.video.upload.accept.result', async function () {
121 await servers[0].videosCommand.upload({ attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 121 await servers[0].videos.upload({ attributes: { name: 'video with bad word' }, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
122 }) 122 })
123 123
124 it('Should run filter:api.live-video.create.accept.result', async function () { 124 it('Should run filter:api.live-video.create.accept.result', async function () {
125 const attributes = { 125 const attributes = {
126 name: 'video with bad word', 126 name: 'video with bad word',
127 privacy: VideoPrivacy.PUBLIC, 127 privacy: VideoPrivacy.PUBLIC,
128 channelId: servers[0].videoChannel.id 128 channelId: servers[0].store.channel.id
129 } 129 }
130 130
131 await servers[0].liveCommand.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 131 await servers[0].live.create({ fields: attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
132 }) 132 })
133 133
134 it('Should run filter:api.video.pre-import-url.accept.result', async function () { 134 it('Should run filter:api.video.pre-import-url.accept.result', async function () {
135 const attributes = { 135 const attributes = {
136 name: 'normal title', 136 name: 'normal title',
137 privacy: VideoPrivacy.PUBLIC, 137 privacy: VideoPrivacy.PUBLIC,
138 channelId: servers[0].videoChannel.id, 138 channelId: servers[0].store.channel.id,
139 targetUrl: ImportsCommand.getGoodVideoUrl() + 'bad' 139 targetUrl: ImportsCommand.getGoodVideoUrl() + 'bad'
140 } 140 }
141 await servers[0].importsCommand.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 141 await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
142 }) 142 })
143 143
144 it('Should run filter:api.video.pre-import-torrent.accept.result', async function () { 144 it('Should run filter:api.video.pre-import-torrent.accept.result', async function () {
145 const attributes = { 145 const attributes = {
146 name: 'bad torrent', 146 name: 'bad torrent',
147 privacy: VideoPrivacy.PUBLIC, 147 privacy: VideoPrivacy.PUBLIC,
148 channelId: servers[0].videoChannel.id, 148 channelId: servers[0].store.channel.id,
149 torrentfile: 'video-720p.torrent' as any 149 torrentfile: 'video-720p.torrent' as any
150 } 150 }
151 await servers[0].importsCommand.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) 151 await servers[0].imports.importVideo({ attributes, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
152 }) 152 })
153 153
154 it('Should run filter:api.video.post-import-url.accept.result', async function () { 154 it('Should run filter:api.video.post-import-url.accept.result', async function () {
@@ -160,17 +160,17 @@ describe('Test plugin filter hooks', function () {
160 const attributes = { 160 const attributes = {
161 name: 'title with bad word', 161 name: 'title with bad word',
162 privacy: VideoPrivacy.PUBLIC, 162 privacy: VideoPrivacy.PUBLIC,
163 channelId: servers[0].videoChannel.id, 163 channelId: servers[0].store.channel.id,
164 targetUrl: ImportsCommand.getGoodVideoUrl() 164 targetUrl: ImportsCommand.getGoodVideoUrl()
165 } 165 }
166 const body = await servers[0].importsCommand.importVideo({ attributes }) 166 const body = await servers[0].imports.importVideo({ attributes })
167 videoImportId = body.id 167 videoImportId = body.id
168 } 168 }
169 169
170 await waitJobs(servers) 170 await waitJobs(servers)
171 171
172 { 172 {
173 const body = await servers[0].importsCommand.getMyVideoImports() 173 const body = await servers[0].imports.getMyVideoImports()
174 const videoImports = body.data 174 const videoImports = body.data
175 175
176 const videoImport = videoImports.find(i => i.id === videoImportId) 176 const videoImport = videoImports.find(i => i.id === videoImportId)
@@ -189,17 +189,17 @@ describe('Test plugin filter hooks', function () {
189 const attributes = { 189 const attributes = {
190 name: 'title with bad word', 190 name: 'title with bad word',
191 privacy: VideoPrivacy.PUBLIC, 191 privacy: VideoPrivacy.PUBLIC,
192 channelId: servers[0].videoChannel.id, 192 channelId: servers[0].store.channel.id,
193 torrentfile: 'video-720p.torrent' as any 193 torrentfile: 'video-720p.torrent' as any
194 } 194 }
195 const body = await servers[0].importsCommand.importVideo({ attributes }) 195 const body = await servers[0].imports.importVideo({ attributes })
196 videoImportId = body.id 196 videoImportId = body.id
197 } 197 }
198 198
199 await waitJobs(servers) 199 await waitJobs(servers)
200 200
201 { 201 {
202 const { data: videoImports } = await servers[0].importsCommand.getMyVideoImports() 202 const { data: videoImports } = await servers[0].imports.getMyVideoImports()
203 203
204 const videoImport = videoImports.find(i => i.id === videoImportId) 204 const videoImport = videoImports.find(i => i.id === videoImportId)
205 205
@@ -209,7 +209,7 @@ describe('Test plugin filter hooks', function () {
209 }) 209 })
210 210
211 it('Should run filter:api.video-thread.create.accept.result', async function () { 211 it('Should run filter:api.video-thread.create.accept.result', async function () {
212 await servers[0].commentsCommand.createThread({ 212 await servers[0].comments.createThread({
213 videoId: videoUUID, 213 videoId: videoUUID,
214 text: 'comment with bad word', 214 text: 'comment with bad word',
215 expectedStatus: HttpStatusCode.FORBIDDEN_403 215 expectedStatus: HttpStatusCode.FORBIDDEN_403
@@ -217,16 +217,16 @@ describe('Test plugin filter hooks', function () {
217 }) 217 })
218 218
219 it('Should run filter:api.video-comment-reply.create.accept.result', async function () { 219 it('Should run filter:api.video-comment-reply.create.accept.result', async function () {
220 const created = await servers[0].commentsCommand.createThread({ videoId: videoUUID, text: 'thread' }) 220 const created = await servers[0].comments.createThread({ videoId: videoUUID, text: 'thread' })
221 threadId = created.id 221 threadId = created.id
222 222
223 await servers[0].commentsCommand.addReply({ 223 await servers[0].comments.addReply({
224 videoId: videoUUID, 224 videoId: videoUUID,
225 toCommentId: threadId, 225 toCommentId: threadId,
226 text: 'comment with bad word', 226 text: 'comment with bad word',
227 expectedStatus: HttpStatusCode.FORBIDDEN_403 227 expectedStatus: HttpStatusCode.FORBIDDEN_403
228 }) 228 })
229 await servers[0].commentsCommand.addReply({ 229 await servers[0].comments.addReply({
230 videoId: videoUUID, 230 videoId: videoUUID,
231 toCommentId: threadId, 231 toCommentId: threadId,
232 text: 'comment with good word', 232 text: 'comment with good word',
@@ -235,14 +235,14 @@ describe('Test plugin filter hooks', function () {
235 }) 235 })
236 236
237 it('Should run filter:api.video-threads.list.params', async function () { 237 it('Should run filter:api.video-threads.list.params', async function () {
238 const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 0 }) 238 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 })
239 239
240 // our plugin do +1 to the count parameter 240 // our plugin do +1 to the count parameter
241 expect(data).to.have.lengthOf(1) 241 expect(data).to.have.lengthOf(1)
242 }) 242 })
243 243
244 it('Should run filter:api.video-threads.list.result', async function () { 244 it('Should run filter:api.video-threads.list.result', async function () {
245 const { total } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID, start: 0, count: 0 }) 245 const { total } = await servers[0].comments.listThreads({ videoId: videoUUID, start: 0, count: 0 })
246 246
247 // Plugin do +1 to the total result 247 // Plugin do +1 to the total result
248 expect(total).to.equal(2) 248 expect(total).to.equal(2)
@@ -251,7 +251,7 @@ describe('Test plugin filter hooks', function () {
251 it('Should run filter:api.video-thread-comments.list.params') 251 it('Should run filter:api.video-thread-comments.list.params')
252 252
253 it('Should run filter:api.video-thread-comments.list.result', async function () { 253 it('Should run filter:api.video-thread-comments.list.result', async function () {
254 const thread = await servers[0].commentsCommand.getThread({ videoId: videoUUID, threadId }) 254 const thread = await servers[0].comments.getThread({ videoId: videoUUID, threadId })
255 255
256 expect(thread.comment.text.endsWith(' <3')).to.be.true 256 expect(thread.comment.text.endsWith(' <3')).to.be.true
257 }) 257 })
@@ -259,12 +259,12 @@ describe('Test plugin filter hooks', function () {
259 describe('Should run filter:video.auto-blacklist.result', function () { 259 describe('Should run filter:video.auto-blacklist.result', function () {
260 260
261 async function checkIsBlacklisted (id: number | string, value: boolean) { 261 async function checkIsBlacklisted (id: number | string, value: boolean) {
262 const video = await servers[0].videosCommand.getWithToken({ id }) 262 const video = await servers[0].videos.getWithToken({ id })
263 expect(video.blacklisted).to.equal(value) 263 expect(video.blacklisted).to.equal(value)
264 } 264 }
265 265
266 it('Should blacklist on upload', async function () { 266 it('Should blacklist on upload', async function () {
267 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video please blacklist me' } }) 267 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video please blacklist me' } })
268 await checkIsBlacklisted(uuid, true) 268 await checkIsBlacklisted(uuid, true)
269 }) 269 })
270 270
@@ -274,24 +274,24 @@ describe('Test plugin filter hooks', function () {
274 const attributes = { 274 const attributes = {
275 name: 'video please blacklist me', 275 name: 'video please blacklist me',
276 targetUrl: ImportsCommand.getGoodVideoUrl(), 276 targetUrl: ImportsCommand.getGoodVideoUrl(),
277 channelId: servers[0].videoChannel.id 277 channelId: servers[0].store.channel.id
278 } 278 }
279 const body = await servers[0].importsCommand.importVideo({ attributes }) 279 const body = await servers[0].imports.importVideo({ attributes })
280 await checkIsBlacklisted(body.video.uuid, true) 280 await checkIsBlacklisted(body.video.uuid, true)
281 }) 281 })
282 282
283 it('Should blacklist on update', async function () { 283 it('Should blacklist on update', async function () {
284 const { uuid } = await servers[0].videosCommand.upload({ attributes: { name: 'video' } }) 284 const { uuid } = await servers[0].videos.upload({ attributes: { name: 'video' } })
285 await checkIsBlacklisted(uuid, false) 285 await checkIsBlacklisted(uuid, false)
286 286
287 await servers[0].videosCommand.update({ id: uuid, attributes: { name: 'please blacklist me' } }) 287 await servers[0].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } })
288 await checkIsBlacklisted(uuid, true) 288 await checkIsBlacklisted(uuid, true)
289 }) 289 })
290 290
291 it('Should blacklist on remote upload', async function () { 291 it('Should blacklist on remote upload', async function () {
292 this.timeout(120000) 292 this.timeout(120000)
293 293
294 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'remote please blacklist me' } }) 294 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'remote please blacklist me' } })
295 await waitJobs(servers) 295 await waitJobs(servers)
296 296
297 await checkIsBlacklisted(uuid, true) 297 await checkIsBlacklisted(uuid, true)
@@ -300,12 +300,12 @@ describe('Test plugin filter hooks', function () {
300 it('Should blacklist on remote update', async function () { 300 it('Should blacklist on remote update', async function () {
301 this.timeout(120000) 301 this.timeout(120000)
302 302
303 const { uuid } = await servers[1].videosCommand.upload({ attributes: { name: 'video' } }) 303 const { uuid } = await servers[1].videos.upload({ attributes: { name: 'video' } })
304 await waitJobs(servers) 304 await waitJobs(servers)
305 305
306 await checkIsBlacklisted(uuid, false) 306 await checkIsBlacklisted(uuid, false)
307 307
308 await servers[1].videosCommand.update({ id: uuid, attributes: { name: 'please blacklist me' } }) 308 await servers[1].videos.update({ id: uuid, attributes: { name: 'please blacklist me' } })
309 await waitJobs(servers) 309 await waitJobs(servers)
310 310
311 await checkIsBlacklisted(uuid, true) 311 await checkIsBlacklisted(uuid, true)
@@ -315,16 +315,16 @@ describe('Test plugin filter hooks', function () {
315 describe('Should run filter:api.user.signup.allowed.result', function () { 315 describe('Should run filter:api.user.signup.allowed.result', function () {
316 316
317 it('Should run on config endpoint', async function () { 317 it('Should run on config endpoint', async function () {
318 const body = await servers[0].configCommand.getConfig() 318 const body = await servers[0].config.getConfig()
319 expect(body.signup.allowed).to.be.true 319 expect(body.signup.allowed).to.be.true
320 }) 320 })
321 321
322 it('Should allow a signup', async function () { 322 it('Should allow a signup', async function () {
323 await servers[0].usersCommand.register({ username: 'john', password: 'password' }) 323 await servers[0].users.register({ username: 'john', password: 'password' })
324 }) 324 })
325 325
326 it('Should not allow a signup', async function () { 326 it('Should not allow a signup', async function () {
327 const res = await servers[0].usersCommand.register({ 327 const res = await servers[0].users.register({
328 username: 'jma', 328 username: 'jma',
329 password: 'password', 329 password: 'password',
330 expectedStatus: HttpStatusCode.FORBIDDEN_403 330 expectedStatus: HttpStatusCode.FORBIDDEN_403
@@ -340,7 +340,7 @@ describe('Test plugin filter hooks', function () {
340 before(async function () { 340 before(async function () {
341 this.timeout(120000) 341 this.timeout(120000)
342 342
343 await servers[0].configCommand.updateCustomSubConfig({ 343 await servers[0].config.updateCustomSubConfig({
344 newConfig: { 344 newConfig: {
345 transcoding: { 345 transcoding: {
346 webtorrent: { 346 webtorrent: {
@@ -356,14 +356,14 @@ describe('Test plugin filter hooks', function () {
356 const uuids: string[] = [] 356 const uuids: string[] = []
357 357
358 for (const name of [ 'bad torrent', 'bad file', 'bad playlist file' ]) { 358 for (const name of [ 'bad torrent', 'bad file', 'bad playlist file' ]) {
359 const uuid = (await servers[0].videosCommand.quickUpload({ name: name })).uuid 359 const uuid = (await servers[0].videos.quickUpload({ name: name })).uuid
360 uuids.push(uuid) 360 uuids.push(uuid)
361 } 361 }
362 362
363 await waitJobs(servers) 363 await waitJobs(servers)
364 364
365 for (const uuid of uuids) { 365 for (const uuid of uuids) {
366 downloadVideos.push(await servers[0].videosCommand.get({ id: uuid })) 366 downloadVideos.push(await servers[0].videos.get({ id: uuid }))
367 } 367 }
368 }) 368 })
369 369
@@ -403,7 +403,7 @@ describe('Test plugin filter hooks', function () {
403 before(async function () { 403 before(async function () {
404 this.timeout(60000) 404 this.timeout(60000)
405 405
406 await servers[0].configCommand.updateCustomSubConfig({ 406 await servers[0].config.updateCustomSubConfig({
407 newConfig: { 407 newConfig: {
408 transcoding: { 408 transcoding: {
409 enabled: false 409 enabled: false
@@ -413,15 +413,15 @@ describe('Test plugin filter hooks', function () {
413 413
414 for (const name of [ 'bad embed', 'good embed' ]) { 414 for (const name of [ 'bad embed', 'good embed' ]) {
415 { 415 {
416 const uuid = (await servers[0].videosCommand.quickUpload({ name: name })).uuid 416 const uuid = (await servers[0].videos.quickUpload({ name: name })).uuid
417 embedVideos.push(await servers[0].videosCommand.get({ id: uuid })) 417 embedVideos.push(await servers[0].videos.get({ id: uuid }))
418 } 418 }
419 419
420 { 420 {
421 const attributes = { displayName: name, videoChannelId: servers[0].videoChannel.id, privacy: VideoPlaylistPrivacy.PUBLIC } 421 const attributes = { displayName: name, videoChannelId: servers[0].store.channel.id, privacy: VideoPlaylistPrivacy.PUBLIC }
422 const { id } = await servers[0].playlistsCommand.create({ attributes }) 422 const { id } = await servers[0].playlists.create({ attributes })
423 423
424 const playlist = await servers[0].playlistsCommand.get({ playlistId: id }) 424 const playlist = await servers[0].playlists.get({ playlistId: id })
425 embedPlaylists.push(playlist) 425 embedPlaylists.push(playlist)
426 } 426 }
427 } 427 }
@@ -441,7 +441,7 @@ describe('Test plugin filter hooks', function () {
441 describe('Search filters', function () { 441 describe('Search filters', function () {
442 442
443 before(async function () { 443 before(async function () {
444 await servers[0].configCommand.updateCustomSubConfig({ 444 await servers[0].config.updateCustomSubConfig({
445 newConfig: { 445 newConfig: {
446 search: { 446 search: {
447 searchIndex: { 447 searchIndex: {
@@ -455,78 +455,78 @@ describe('Test plugin filter hooks', function () {
455 }) 455 })
456 456
457 it('Should run filter:api.search.videos.local.list.{params,result}', async function () { 457 it('Should run filter:api.search.videos.local.list.{params,result}', async function () {
458 await servers[0].searchCommand.advancedVideoSearch({ 458 await servers[0].search.advancedVideoSearch({
459 search: { 459 search: {
460 search: 'Sun Quan' 460 search: 'Sun Quan'
461 } 461 }
462 }) 462 })
463 463
464 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1) 464 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
465 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1) 465 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
466 }) 466 })
467 467
468 it('Should run filter:api.search.videos.index.list.{params,result}', async function () { 468 it('Should run filter:api.search.videos.index.list.{params,result}', async function () {
469 await servers[0].searchCommand.advancedVideoSearch({ 469 await servers[0].search.advancedVideoSearch({
470 search: { 470 search: {
471 search: 'Sun Quan', 471 search: 'Sun Quan',
472 searchTarget: 'search-index' 472 searchTarget: 'search-index'
473 } 473 }
474 }) 474 })
475 475
476 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1) 476 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.params', 1)
477 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1) 477 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.local.list.result', 1)
478 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1) 478 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.params', 1)
479 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1) 479 await servers[0].servers.waitUntilLog('Run hook filter:api.search.videos.index.list.result', 1)
480 }) 480 })
481 481
482 it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () { 482 it('Should run filter:api.search.video-channels.local.list.{params,result}', async function () {
483 await servers[0].searchCommand.advancedChannelSearch({ 483 await servers[0].search.advancedChannelSearch({
484 search: { 484 search: {
485 search: 'Sun Ce' 485 search: 'Sun Ce'
486 } 486 }
487 }) 487 })
488 488
489 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1) 489 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
490 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1) 490 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
491 }) 491 })
492 492
493 it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () { 493 it('Should run filter:api.search.video-channels.index.list.{params,result}', async function () {
494 await servers[0].searchCommand.advancedChannelSearch({ 494 await servers[0].search.advancedChannelSearch({
495 search: { 495 search: {
496 search: 'Sun Ce', 496 search: 'Sun Ce',
497 searchTarget: 'search-index' 497 searchTarget: 'search-index'
498 } 498 }
499 }) 499 })
500 500
501 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1) 501 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.params', 1)
502 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1) 502 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.local.list.result', 1)
503 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1) 503 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.params', 1)
504 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1) 504 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-channels.index.list.result', 1)
505 }) 505 })
506 506
507 it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () { 507 it('Should run filter:api.search.video-playlists.local.list.{params,result}', async function () {
508 await servers[0].searchCommand.advancedPlaylistSearch({ 508 await servers[0].search.advancedPlaylistSearch({
509 search: { 509 search: {
510 search: 'Sun Jian' 510 search: 'Sun Jian'
511 } 511 }
512 }) 512 })
513 513
514 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1) 514 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
515 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1) 515 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
516 }) 516 })
517 517
518 it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () { 518 it('Should run filter:api.search.video-playlists.index.list.{params,result}', async function () {
519 await servers[0].searchCommand.advancedPlaylistSearch({ 519 await servers[0].search.advancedPlaylistSearch({
520 search: { 520 search: {
521 search: 'Sun Jian', 521 search: 'Sun Jian',
522 searchTarget: 'search-index' 522 searchTarget: 'search-index'
523 } 523 }
524 }) 524 })
525 525
526 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1) 526 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.params', 1)
527 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1) 527 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.local.list.result', 1)
528 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1) 528 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.params', 1)
529 await servers[0].serversCommand.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1) 529 await servers[0].servers.waitUntilLog('Run hook filter:api.search.video-playlists.index.list.result', 1)
530 }) 530 })
531 }) 531 })
532 532
diff --git a/server/tests/plugins/html-injection.ts b/server/tests/plugins/html-injection.ts
index 80d67ae0e..0cb89f511 100644
--- a/server/tests/plugins/html-injection.ts
+++ b/server/tests/plugins/html-injection.ts
@@ -23,7 +23,7 @@ describe('Test plugins HTML injection', function () {
23 server = await flushAndRunServer(1) 23 server = await flushAndRunServer(1)
24 await setAccessTokensToServers([ server ]) 24 await setAccessTokensToServers([ server ])
25 25
26 command = server.pluginsCommand 26 command = server.plugins
27 }) 27 })
28 28
29 it('Should not inject global css file in HTML', async function () { 29 it('Should not inject global css file in HTML', async function () {
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts
index 787080e7c..203996af8 100644
--- a/server/tests/plugins/id-and-pass-auth.ts
+++ b/server/tests/plugins/id-and-pass-auth.ts
@@ -22,12 +22,12 @@ describe('Test id and pass auth plugins', function () {
22 await setAccessTokensToServers([ server ]) 22 await setAccessTokensToServers([ server ])
23 23
24 for (const suffix of [ 'one', 'two', 'three' ]) { 24 for (const suffix of [ 'one', 'two', 'three' ]) {
25 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) }) 25 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-id-pass-auth-' + suffix) })
26 } 26 }
27 }) 27 })
28 28
29 it('Should display the correct configuration', async function () { 29 it('Should display the correct configuration', async function () {
30 const config = await server.configCommand.getConfig() 30 const config = await server.config.getConfig()
31 31
32 const auths = config.plugin.registeredIdAndPassAuths 32 const auths = config.plugin.registeredIdAndPassAuths
33 expect(auths).to.have.lengthOf(8) 33 expect(auths).to.have.lengthOf(8)
@@ -39,13 +39,13 @@ describe('Test id and pass auth plugins', function () {
39 }) 39 })
40 40
41 it('Should not login', async function () { 41 it('Should not login', async function () {
42 await server.loginCommand.login({ user: { username: 'toto', password: 'password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 42 await server.login.login({ user: { username: 'toto', password: 'password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
43 }) 43 })
44 44
45 it('Should login Spyro, create the user and use the token', async function () { 45 it('Should login Spyro, create the user and use the token', async function () {
46 const accessToken = await server.loginCommand.getAccessToken({ username: 'spyro', password: 'spyro password' }) 46 const accessToken = await server.login.getAccessToken({ username: 'spyro', password: 'spyro password' })
47 47
48 const body = await server.usersCommand.getMyInfo({ token: accessToken }) 48 const body = await server.users.getMyInfo({ token: accessToken })
49 49
50 expect(body.username).to.equal('spyro') 50 expect(body.username).to.equal('spyro')
51 expect(body.account.displayName).to.equal('Spyro the Dragon') 51 expect(body.account.displayName).to.equal('Spyro the Dragon')
@@ -54,13 +54,13 @@ describe('Test id and pass auth plugins', function () {
54 54
55 it('Should login Crash, create the user and use the token', async function () { 55 it('Should login Crash, create the user and use the token', async function () {
56 { 56 {
57 const body = await server.loginCommand.login({ user: { username: 'crash', password: 'crash password' } }) 57 const body = await server.login.login({ user: { username: 'crash', password: 'crash password' } })
58 crashAccessToken = body.access_token 58 crashAccessToken = body.access_token
59 crashRefreshToken = body.refresh_token 59 crashRefreshToken = body.refresh_token
60 } 60 }
61 61
62 { 62 {
63 const body = await server.usersCommand.getMyInfo({ token: crashAccessToken }) 63 const body = await server.users.getMyInfo({ token: crashAccessToken })
64 64
65 expect(body.username).to.equal('crash') 65 expect(body.username).to.equal('crash')
66 expect(body.account.displayName).to.equal('Crash Bandicoot') 66 expect(body.account.displayName).to.equal('Crash Bandicoot')
@@ -70,13 +70,13 @@ describe('Test id and pass auth plugins', function () {
70 70
71 it('Should login the first Laguna, create the user and use the token', async function () { 71 it('Should login the first Laguna, create the user and use the token', async function () {
72 { 72 {
73 const body = await server.loginCommand.login({ user: { username: 'laguna', password: 'laguna password' } }) 73 const body = await server.login.login({ user: { username: 'laguna', password: 'laguna password' } })
74 lagunaAccessToken = body.access_token 74 lagunaAccessToken = body.access_token
75 lagunaRefreshToken = body.refresh_token 75 lagunaRefreshToken = body.refresh_token
76 } 76 }
77 77
78 { 78 {
79 const body = await server.usersCommand.getMyInfo({ token: lagunaAccessToken }) 79 const body = await server.users.getMyInfo({ token: lagunaAccessToken })
80 80
81 expect(body.username).to.equal('laguna') 81 expect(body.username).to.equal('laguna')
82 expect(body.account.displayName).to.equal('laguna') 82 expect(body.account.displayName).to.equal('laguna')
@@ -86,46 +86,46 @@ describe('Test id and pass auth plugins', function () {
86 86
87 it('Should refresh crash token, but not laguna token', async function () { 87 it('Should refresh crash token, but not laguna token', async function () {
88 { 88 {
89 const resRefresh = await server.loginCommand.refreshToken({ refreshToken: crashRefreshToken }) 89 const resRefresh = await server.login.refreshToken({ refreshToken: crashRefreshToken })
90 crashAccessToken = resRefresh.body.access_token 90 crashAccessToken = resRefresh.body.access_token
91 crashRefreshToken = resRefresh.body.refresh_token 91 crashRefreshToken = resRefresh.body.refresh_token
92 92
93 const body = await server.usersCommand.getMyInfo({ token: crashAccessToken }) 93 const body = await server.users.getMyInfo({ token: crashAccessToken })
94 expect(body.username).to.equal('crash') 94 expect(body.username).to.equal('crash')
95 } 95 }
96 96
97 { 97 {
98 await server.loginCommand.refreshToken({ refreshToken: lagunaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 98 await server.login.refreshToken({ refreshToken: lagunaRefreshToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
99 } 99 }
100 }) 100 })
101 101
102 it('Should update Crash profile', async function () { 102 it('Should update Crash profile', async function () {
103 await server.usersCommand.updateMe({ 103 await server.users.updateMe({
104 token: crashAccessToken, 104 token: crashAccessToken,
105 displayName: 'Beautiful Crash', 105 displayName: 'Beautiful Crash',
106 description: 'Mutant eastern barred bandicoot' 106 description: 'Mutant eastern barred bandicoot'
107 }) 107 })
108 108
109 const body = await server.usersCommand.getMyInfo({ token: crashAccessToken }) 109 const body = await server.users.getMyInfo({ token: crashAccessToken })
110 110
111 expect(body.account.displayName).to.equal('Beautiful Crash') 111 expect(body.account.displayName).to.equal('Beautiful Crash')
112 expect(body.account.description).to.equal('Mutant eastern barred bandicoot') 112 expect(body.account.description).to.equal('Mutant eastern barred bandicoot')
113 }) 113 })
114 114
115 it('Should logout Crash', async function () { 115 it('Should logout Crash', async function () {
116 await server.loginCommand.logout({ token: crashAccessToken }) 116 await server.login.logout({ token: crashAccessToken })
117 }) 117 })
118 118
119 it('Should have logged out Crash', async function () { 119 it('Should have logged out Crash', async function () {
120 await server.serversCommand.waitUntilLog('On logout for auth 1 - 2') 120 await server.servers.waitUntilLog('On logout for auth 1 - 2')
121 121
122 await server.usersCommand.getMyInfo({ token: crashAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 122 await server.users.getMyInfo({ token: crashAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
123 }) 123 })
124 124
125 it('Should login Crash and keep the old existing profile', async function () { 125 it('Should login Crash and keep the old existing profile', async function () {
126 crashAccessToken = await server.loginCommand.getAccessToken({ username: 'crash', password: 'crash password' }) 126 crashAccessToken = await server.login.getAccessToken({ username: 'crash', password: 'crash password' })
127 127
128 const body = await server.usersCommand.getMyInfo({ token: crashAccessToken }) 128 const body = await server.users.getMyInfo({ token: crashAccessToken })
129 129
130 expect(body.username).to.equal('crash') 130 expect(body.username).to.equal('crash')
131 expect(body.account.displayName).to.equal('Beautiful Crash') 131 expect(body.account.displayName).to.equal('Beautiful Crash')
@@ -138,38 +138,38 @@ describe('Test id and pass auth plugins', function () {
138 138
139 await wait(5000) 139 await wait(5000)
140 140
141 await server.usersCommand.getMyInfo({ token: lagunaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) 141 await server.users.getMyInfo({ token: lagunaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
142 }) 142 })
143 143
144 it('Should reject an invalid username, email, role or display name', async function () { 144 it('Should reject an invalid username, email, role or display name', async function () {
145 const command = server.loginCommand 145 const command = server.login
146 146
147 await command.login({ user: { username: 'ward', password: 'ward password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 147 await command.login({ user: { username: 'ward', password: 'ward password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
148 await server.serversCommand.waitUntilLog('valid username') 148 await server.servers.waitUntilLog('valid username')
149 149
150 await command.login({ user: { username: 'kiros', password: 'kiros password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 150 await command.login({ user: { username: 'kiros', password: 'kiros password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
151 await server.serversCommand.waitUntilLog('valid display name') 151 await server.servers.waitUntilLog('valid display name')
152 152
153 await command.login({ user: { username: 'raine', password: 'raine password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 153 await command.login({ user: { username: 'raine', password: 'raine password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
154 await server.serversCommand.waitUntilLog('valid role') 154 await server.servers.waitUntilLog('valid role')
155 155
156 await command.login({ user: { username: 'ellone', password: 'elonne password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 156 await command.login({ user: { username: 'ellone', password: 'elonne password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
157 await server.serversCommand.waitUntilLog('valid email') 157 await server.servers.waitUntilLog('valid email')
158 }) 158 })
159 159
160 it('Should unregister spyro-auth and do not login existing Spyro', async function () { 160 it('Should unregister spyro-auth and do not login existing Spyro', async function () {
161 await server.pluginsCommand.updateSettings({ 161 await server.plugins.updateSettings({
162 npmName: 'peertube-plugin-test-id-pass-auth-one', 162 npmName: 'peertube-plugin-test-id-pass-auth-one',
163 settings: { disableSpyro: true } 163 settings: { disableSpyro: true }
164 }) 164 })
165 165
166 const command = server.loginCommand 166 const command = server.login
167 await command.login({ user: { username: 'spyro', password: 'spyro password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 167 await command.login({ user: { username: 'spyro', password: 'spyro password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
168 await command.login({ user: { username: 'spyro', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 168 await command.login({ user: { username: 'spyro', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
169 }) 169 })
170 170
171 it('Should have disabled this auth', async function () { 171 it('Should have disabled this auth', async function () {
172 const config = await server.configCommand.getConfig() 172 const config = await server.config.getConfig()
173 173
174 const auths = config.plugin.registeredIdAndPassAuths 174 const auths = config.plugin.registeredIdAndPassAuths
175 expect(auths).to.have.lengthOf(7) 175 expect(auths).to.have.lengthOf(7)
@@ -179,16 +179,16 @@ describe('Test id and pass auth plugins', function () {
179 }) 179 })
180 180
181 it('Should uninstall the plugin one and do not login existing Crash', async function () { 181 it('Should uninstall the plugin one and do not login existing Crash', async function () {
182 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' }) 182 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-id-pass-auth-one' })
183 183
184 await server.loginCommand.login({ 184 await server.login.login({
185 user: { username: 'crash', password: 'crash password' }, 185 user: { username: 'crash', password: 'crash password' },
186 expectedStatus: HttpStatusCode.BAD_REQUEST_400 186 expectedStatus: HttpStatusCode.BAD_REQUEST_400
187 }) 187 })
188 }) 188 })
189 189
190 it('Should display the correct configuration', async function () { 190 it('Should display the correct configuration', async function () {
191 const config = await server.configCommand.getConfig() 191 const config = await server.config.getConfig()
192 192
193 const auths = config.plugin.registeredIdAndPassAuths 193 const auths = config.plugin.registeredIdAndPassAuths
194 expect(auths).to.have.lengthOf(6) 194 expect(auths).to.have.lengthOf(6)
@@ -198,7 +198,7 @@ describe('Test id and pass auth plugins', function () {
198 }) 198 })
199 199
200 it('Should display plugin auth information in users list', async function () { 200 it('Should display plugin auth information in users list', async function () {
201 const { data } = await server.usersCommand.list() 201 const { data } = await server.users.list()
202 202
203 const root = data.find(u => u.username === 'root') 203 const root = data.find(u => u.username === 'root')
204 const crash = data.find(u => u.username === 'crash') 204 const crash = data.find(u => u.username === 'crash')
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index 509aba13d..cf16aaa9d 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -39,28 +39,28 @@ describe('Test plugin helpers', function () {
39 39
40 await doubleFollow(servers[0], servers[1]) 40 await doubleFollow(servers[0], servers[1])
41 41
42 await servers[0].pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-four') }) 42 await servers[0].plugins.install({ path: PluginsCommand.getPluginTestPath('-four') })
43 }) 43 })
44 44
45 describe('Logger', function () { 45 describe('Logger', function () {
46 46
47 it('Should have logged things', async function () { 47 it('Should have logged things', async function () {
48 await servers[0].serversCommand.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false) 48 await servers[0].servers.waitUntilLog('localhost:' + servers[0].port + ' peertube-plugin-test-four', 1, false)
49 await servers[0].serversCommand.waitUntilLog('Hello world from plugin four', 1) 49 await servers[0].servers.waitUntilLog('Hello world from plugin four', 1)
50 }) 50 })
51 }) 51 })
52 52
53 describe('Database', function () { 53 describe('Database', function () {
54 54
55 it('Should have made a query', async function () { 55 it('Should have made a query', async function () {
56 await servers[0].serversCommand.waitUntilLog(`root email is admin${servers[0].internalServerNumber}@example.com`) 56 await servers[0].servers.waitUntilLog(`root email is admin${servers[0].internalServerNumber}@example.com`)
57 }) 57 })
58 }) 58 })
59 59
60 describe('Config', function () { 60 describe('Config', function () {
61 61
62 it('Should have the correct webserver url', async function () { 62 it('Should have the correct webserver url', async function () {
63 await servers[0].serversCommand.waitUntilLog(`server url is http://localhost:${servers[0].port}`) 63 await servers[0].servers.waitUntilLog(`server url is http://localhost:${servers[0].port}`)
64 }) 64 })
65 65
66 it('Should have the correct config', async function () { 66 it('Should have the correct config', async function () {
@@ -78,7 +78,7 @@ describe('Test plugin helpers', function () {
78 describe('Server', function () { 78 describe('Server', function () {
79 79
80 it('Should get the server actor', async function () { 80 it('Should get the server actor', async function () {
81 await servers[0].serversCommand.waitUntilLog('server actor name is peertube') 81 await servers[0].servers.waitUntilLog('server actor name is peertube')
82 }) 82 })
83 }) 83 })
84 84
@@ -140,17 +140,17 @@ describe('Test plugin helpers', function () {
140 this.timeout(60000) 140 this.timeout(60000)
141 141
142 { 142 {
143 const res = await await servers[0].videosCommand.quickUpload({ name: 'video server 1' }) 143 const res = await await servers[0].videos.quickUpload({ name: 'video server 1' })
144 videoUUIDServer1 = res.uuid 144 videoUUIDServer1 = res.uuid
145 } 145 }
146 146
147 { 147 {
148 await await servers[1].videosCommand.quickUpload({ name: 'video server 2' }) 148 await await servers[1].videos.quickUpload({ name: 'video server 2' })
149 } 149 }
150 150
151 await waitJobs(servers) 151 await waitJobs(servers)
152 152
153 const { data } = await servers[0].videosCommand.list() 153 const { data } = await servers[0].videos.list()
154 154
155 expect(data).to.have.lengthOf(2) 155 expect(data).to.have.lengthOf(2)
156 }) 156 })
@@ -159,7 +159,7 @@ describe('Test plugin helpers', function () {
159 this.timeout(10000) 159 this.timeout(10000)
160 await postCommand(servers[0], 'blockServer', { hostToBlock: `localhost:${servers[1].port}` }) 160 await postCommand(servers[0], 'blockServer', { hostToBlock: `localhost:${servers[1].port}` })
161 161
162 const { data } = await servers[0].videosCommand.list() 162 const { data } = await servers[0].videos.list()
163 163
164 expect(data).to.have.lengthOf(1) 164 expect(data).to.have.lengthOf(1)
165 expect(data[0].name).to.equal('video server 1') 165 expect(data[0].name).to.equal('video server 1')
@@ -168,7 +168,7 @@ describe('Test plugin helpers', function () {
168 it('Should unmute server 2', async function () { 168 it('Should unmute server 2', async function () {
169 await postCommand(servers[0], 'unblockServer', { hostToUnblock: `localhost:${servers[1].port}` }) 169 await postCommand(servers[0], 'unblockServer', { hostToUnblock: `localhost:${servers[1].port}` })
170 170
171 const { data } = await servers[0].videosCommand.list() 171 const { data } = await servers[0].videos.list()
172 172
173 expect(data).to.have.lengthOf(2) 173 expect(data).to.have.lengthOf(2)
174 }) 174 })
@@ -176,7 +176,7 @@ describe('Test plugin helpers', function () {
176 it('Should mute account of server 2', async function () { 176 it('Should mute account of server 2', async function () {
177 await postCommand(servers[0], 'blockAccount', { handleToBlock: `root@localhost:${servers[1].port}` }) 177 await postCommand(servers[0], 'blockAccount', { handleToBlock: `root@localhost:${servers[1].port}` })
178 178
179 const { data } = await servers[0].videosCommand.list() 179 const { data } = await servers[0].videos.list()
180 180
181 expect(data).to.have.lengthOf(1) 181 expect(data).to.have.lengthOf(1)
182 expect(data[0].name).to.equal('video server 1') 182 expect(data[0].name).to.equal('video server 1')
@@ -185,7 +185,7 @@ describe('Test plugin helpers', function () {
185 it('Should unmute account of server 2', async function () { 185 it('Should unmute account of server 2', async function () {
186 await postCommand(servers[0], 'unblockAccount', { handleToUnblock: `root@localhost:${servers[1].port}` }) 186 await postCommand(servers[0], 'unblockAccount', { handleToUnblock: `root@localhost:${servers[1].port}` })
187 187
188 const { data } = await servers[0].videosCommand.list() 188 const { data } = await servers[0].videos.list()
189 189
190 expect(data).to.have.lengthOf(2) 190 expect(data).to.have.lengthOf(2)
191 }) 191 })
@@ -198,7 +198,7 @@ describe('Test plugin helpers', function () {
198 await waitJobs(servers) 198 await waitJobs(servers)
199 199
200 for (const server of servers) { 200 for (const server of servers) {
201 const { data } = await server.videosCommand.list() 201 const { data } = await server.videos.list()
202 202
203 expect(data).to.have.lengthOf(1) 203 expect(data).to.have.lengthOf(1)
204 expect(data[0].name).to.equal('video server 2') 204 expect(data[0].name).to.equal('video server 2')
@@ -213,7 +213,7 @@ describe('Test plugin helpers', function () {
213 await waitJobs(servers) 213 await waitJobs(servers)
214 214
215 for (const server of servers) { 215 for (const server of servers) {
216 const { data } = await server.videosCommand.list() 216 const { data } = await server.videos.list()
217 217
218 expect(data).to.have.lengthOf(2) 218 expect(data).to.have.lengthOf(2)
219 } 219 }
@@ -224,7 +224,7 @@ describe('Test plugin helpers', function () {
224 let videoUUID: string 224 let videoUUID: string
225 225
226 before(async () => { 226 before(async () => {
227 const res = await await servers[0].videosCommand.quickUpload({ name: 'video1' }) 227 const res = await await servers[0].videos.quickUpload({ name: 'video1' })
228 videoUUID = res.uuid 228 videoUUID = res.uuid
229 }) 229 })
230 230
@@ -232,15 +232,15 @@ describe('Test plugin helpers', function () {
232 this.timeout(40000) 232 this.timeout(40000)
233 233
234 // Should not throw -> video exists 234 // Should not throw -> video exists
235 await servers[0].videosCommand.get({ id: videoUUID }) 235 await servers[0].videos.get({ id: videoUUID })
236 // Should delete the video 236 // Should delete the video
237 await servers[0].videosCommand.view({ id: videoUUID }) 237 await servers[0].videos.view({ id: videoUUID })
238 238
239 await servers[0].serversCommand.waitUntilLog('Video deleted by plugin four.') 239 await servers[0].servers.waitUntilLog('Video deleted by plugin four.')
240 240
241 try { 241 try {
242 // Should throw because the video should have been deleted 242 // Should throw because the video should have been deleted
243 await servers[0].videosCommand.get({ id: videoUUID }) 243 await servers[0].videos.get({ id: videoUUID })
244 throw new Error('Video exists') 244 throw new Error('Video exists')
245 } catch (err) { 245 } catch (err) {
246 if (err.message.includes('exists')) throw err 246 if (err.message.includes('exists')) throw err
@@ -250,7 +250,7 @@ describe('Test plugin helpers', function () {
250 }) 250 })
251 251
252 it('Should have fetched the video by URL', async function () { 252 it('Should have fetched the video by URL', async function () {
253 await servers[0].serversCommand.waitUntilLog(`video from DB uuid is ${videoUUID}`) 253 await servers[0].servers.waitUntilLog(`video from DB uuid is ${videoUUID}`)
254 }) 254 })
255 }) 255 })
256 256
diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts
index 81e18dabd..1c53dd80c 100644
--- a/server/tests/plugins/plugin-router.ts
+++ b/server/tests/plugins/plugin-router.ts
@@ -26,7 +26,7 @@ describe('Test plugin helpers', function () {
26 server = await flushAndRunServer(1) 26 server = await flushAndRunServer(1)
27 await setAccessTokensToServers([ server ]) 27 await setAccessTokensToServers([ server ])
28 28
29 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-five') }) 29 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') })
30 }) 30 })
31 31
32 it('Should answer "pong"', async function () { 32 it('Should answer "pong"', async function () {
@@ -82,7 +82,7 @@ describe('Test plugin helpers', function () {
82 }) 82 })
83 83
84 it('Should remove the plugin and remove the routes', async function () { 84 it('Should remove the plugin and remove the routes', async function () {
85 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-five' }) 85 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-five' })
86 86
87 for (const path of basePaths) { 87 for (const path of basePaths) {
88 await makeGetRequest({ 88 await makeGetRequest({
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts
index 9babfc83e..30e231439 100644
--- a/server/tests/plugins/plugin-storage.ts
+++ b/server/tests/plugins/plugin-storage.ts
@@ -16,13 +16,13 @@ describe('Test plugin storage', function () {
16 server = await flushAndRunServer(1) 16 server = await flushAndRunServer(1)
17 await setAccessTokensToServers([ server ]) 17 await setAccessTokensToServers([ server ])
18 18
19 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-six') }) 19 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') })
20 }) 20 })
21 21
22 describe('DB storage', function () { 22 describe('DB storage', function () {
23 23
24 it('Should correctly store a subkey', async function () { 24 it('Should correctly store a subkey', async function () {
25 await server.serversCommand.waitUntilLog('superkey stored value is toto') 25 await server.servers.waitUntilLog('superkey stored value is toto')
26 }) 26 })
27 }) 27 })
28 28
@@ -38,12 +38,12 @@ describe('Test plugin storage', function () {
38 } 38 }
39 39
40 before(function () { 40 before(function () {
41 dataPath = server.serversCommand.buildDirectory('plugins/data') 41 dataPath = server.servers.buildDirectory('plugins/data')
42 pluginDataPath = join(dataPath, 'peertube-plugin-test-six') 42 pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
43 }) 43 })
44 44
45 it('Should have created the directory on install', async function () { 45 it('Should have created the directory on install', async function () {
46 const dataPath = server.serversCommand.buildDirectory('plugins/data') 46 const dataPath = server.servers.buildDirectory('plugins/data')
47 const pluginDataPath = join(dataPath, 'peertube-plugin-test-six') 47 const pluginDataPath = join(dataPath, 'peertube-plugin-test-six')
48 48
49 expect(await pathExists(dataPath)).to.be.true 49 expect(await pathExists(dataPath)).to.be.true
@@ -64,14 +64,14 @@ describe('Test plugin storage', function () {
64 }) 64 })
65 65
66 it('Should still have the file after an uninstallation', async function () { 66 it('Should still have the file after an uninstallation', async function () {
67 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-six' }) 67 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-six' })
68 68
69 const content = await getFileContent() 69 const content = await getFileContent()
70 expect(content).to.equal('Prince Ali') 70 expect(content).to.equal('Prince Ali')
71 }) 71 })
72 72
73 it('Should still have the file after the reinstallation', async function () { 73 it('Should still have the file after the reinstallation', async function () {
74 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-six') }) 74 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-six') })
75 75
76 const content = await getFileContent() 76 const content = await getFileContent()
77 expect(content).to.equal('Prince Ali') 77 expect(content).to.equal('Prince Ali')
diff --git a/server/tests/plugins/plugin-transcoding.ts b/server/tests/plugins/plugin-transcoding.ts
index a3613293a..3a03065b0 100644
--- a/server/tests/plugins/plugin-transcoding.ts
+++ b/server/tests/plugins/plugin-transcoding.ts
@@ -19,17 +19,17 @@ import { VideoPrivacy } from '@shared/models'
19async function createLiveWrapper (server: ServerInfo) { 19async function createLiveWrapper (server: ServerInfo) {
20 const liveAttributes = { 20 const liveAttributes = {
21 name: 'live video', 21 name: 'live video',
22 channelId: server.videoChannel.id, 22 channelId: server.store.channel.id,
23 privacy: VideoPrivacy.PUBLIC 23 privacy: VideoPrivacy.PUBLIC
24 } 24 }
25 25
26 const { uuid } = await server.liveCommand.create({ fields: liveAttributes }) 26 const { uuid } = await server.live.create({ fields: liveAttributes })
27 27
28 return uuid 28 return uuid
29} 29}
30 30
31function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) { 31function updateConf (server: ServerInfo, vodProfile: string, liveProfile: string) {
32 return server.configCommand.updateCustomSubConfig({ 32 return server.config.updateCustomSubConfig({
33 newConfig: { 33 newConfig: {
34 transcoding: { 34 transcoding: {
35 enabled: true, 35 enabled: true,
@@ -79,7 +79,7 @@ describe('Test transcoding plugins', function () {
79 describe('When using a plugin adding profiles to existing encoders', function () { 79 describe('When using a plugin adding profiles to existing encoders', function () {
80 80
81 async function checkVideoFPS (uuid: string, type: 'above' | 'below', fps: number) { 81 async function checkVideoFPS (uuid: string, type: 'above' | 'below', fps: number) {
82 const video = await server.videosCommand.get({ id: uuid }) 82 const video = await server.videos.get({ id: uuid })
83 const files = video.files.concat(...video.streamingPlaylists.map(p => p.files)) 83 const files = video.files.concat(...video.streamingPlaylists.map(p => p.files))
84 84
85 for (const file of files) { 85 for (const file of files) {
@@ -103,11 +103,11 @@ describe('Test transcoding plugins', function () {
103 } 103 }
104 104
105 before(async function () { 105 before(async function () {
106 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-one') }) 106 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-transcoding-one') })
107 }) 107 })
108 108
109 it('Should have the appropriate available profiles', async function () { 109 it('Should have the appropriate available profiles', async function () {
110 const config = await server.configCommand.getConfig() 110 const config = await server.config.getConfig()
111 111
112 expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ]) 112 expect(config.transcoding.availableProfiles).to.have.members([ 'default', 'low-vod', 'input-options-vod', 'bad-scale-vod' ])
113 expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'low-live', 'input-options-live', 'bad-scale-live' ]) 113 expect(config.live.transcoding.availableProfiles).to.have.members([ 'default', 'low-live', 'input-options-live', 'bad-scale-live' ])
@@ -116,7 +116,7 @@ describe('Test transcoding plugins', function () {
116 it('Should not use the plugin profile if not chosen by the admin', async function () { 116 it('Should not use the plugin profile if not chosen by the admin', async function () {
117 this.timeout(240000) 117 this.timeout(240000)
118 118
119 const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid 119 const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
120 await waitJobs([ server ]) 120 await waitJobs([ server ])
121 121
122 await checkVideoFPS(videoUUID, 'above', 20) 122 await checkVideoFPS(videoUUID, 'above', 20)
@@ -127,7 +127,7 @@ describe('Test transcoding plugins', function () {
127 127
128 await updateConf(server, 'low-vod', 'default') 128 await updateConf(server, 'low-vod', 'default')
129 129
130 const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid 130 const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
131 await waitJobs([ server ]) 131 await waitJobs([ server ])
132 132
133 await checkVideoFPS(videoUUID, 'below', 12) 133 await checkVideoFPS(videoUUID, 'below', 12)
@@ -138,7 +138,7 @@ describe('Test transcoding plugins', function () {
138 138
139 await updateConf(server, 'input-options-vod', 'default') 139 await updateConf(server, 'input-options-vod', 'default')
140 140
141 const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid 141 const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
142 await waitJobs([ server ]) 142 await waitJobs([ server ])
143 143
144 await checkVideoFPS(videoUUID, 'below', 6) 144 await checkVideoFPS(videoUUID, 'below', 6)
@@ -149,11 +149,11 @@ describe('Test transcoding plugins', function () {
149 149
150 await updateConf(server, 'bad-scale-vod', 'default') 150 await updateConf(server, 'bad-scale-vod', 'default')
151 151
152 const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid 152 const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
153 await waitJobs([ server ]) 153 await waitJobs([ server ])
154 154
155 // Transcoding failed 155 // Transcoding failed
156 const video = await server.videosCommand.get({ id: videoUUID }) 156 const video = await server.videos.get({ id: videoUUID })
157 expect(video.files).to.have.lengthOf(1) 157 expect(video.files).to.have.lengthOf(1)
158 expect(video.streamingPlaylists).to.have.lengthOf(0) 158 expect(video.streamingPlaylists).to.have.lengthOf(0)
159 }) 159 })
@@ -163,8 +163,8 @@ describe('Test transcoding plugins', function () {
163 163
164 const liveVideoId = await createLiveWrapper(server) 164 const liveVideoId = await createLiveWrapper(server)
165 165
166 await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) 166 await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
167 await server.liveCommand.waitUntilPublished({ videoId: liveVideoId }) 167 await server.live.waitUntilPublished({ videoId: liveVideoId })
168 await waitJobs([ server ]) 168 await waitJobs([ server ])
169 169
170 await checkLiveFPS(liveVideoId, 'above', 20) 170 await checkLiveFPS(liveVideoId, 'above', 20)
@@ -177,8 +177,8 @@ describe('Test transcoding plugins', function () {
177 177
178 const liveVideoId = await createLiveWrapper(server) 178 const liveVideoId = await createLiveWrapper(server)
179 179
180 await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) 180 await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
181 await server.liveCommand.waitUntilPublished({ videoId: liveVideoId }) 181 await server.live.waitUntilPublished({ videoId: liveVideoId })
182 await waitJobs([ server ]) 182 await waitJobs([ server ])
183 183
184 await checkLiveFPS(liveVideoId, 'below', 12) 184 await checkLiveFPS(liveVideoId, 'below', 12)
@@ -191,8 +191,8 @@ describe('Test transcoding plugins', function () {
191 191
192 const liveVideoId = await createLiveWrapper(server) 192 const liveVideoId = await createLiveWrapper(server)
193 193
194 await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) 194 await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
195 await server.liveCommand.waitUntilPublished({ videoId: liveVideoId }) 195 await server.live.waitUntilPublished({ videoId: liveVideoId })
196 await waitJobs([ server ]) 196 await waitJobs([ server ])
197 197
198 await checkLiveFPS(liveVideoId, 'below', 6) 198 await checkLiveFPS(liveVideoId, 'below', 6)
@@ -205,21 +205,21 @@ describe('Test transcoding plugins', function () {
205 205
206 const liveVideoId = await createLiveWrapper(server) 206 const liveVideoId = await createLiveWrapper(server)
207 207
208 const command = await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) 208 const command = await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
209 await testFfmpegStreamError(command, true) 209 await testFfmpegStreamError(command, true)
210 }) 210 })
211 211
212 it('Should default to the default profile if the specified profile does not exist', async function () { 212 it('Should default to the default profile if the specified profile does not exist', async function () {
213 this.timeout(240000) 213 this.timeout(240000)
214 214
215 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' }) 215 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-transcoding-one' })
216 216
217 const config = await server.configCommand.getConfig() 217 const config = await server.config.getConfig()
218 218
219 expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ]) 219 expect(config.transcoding.availableProfiles).to.deep.equal([ 'default' ])
220 expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ]) 220 expect(config.live.transcoding.availableProfiles).to.deep.equal([ 'default' ])
221 221
222 const videoUUID = (await server.videosCommand.quickUpload({ name: 'video' })).uuid 222 const videoUUID = (await server.videos.quickUpload({ name: 'video' })).uuid
223 await waitJobs([ server ]) 223 await waitJobs([ server ])
224 224
225 await checkVideoFPS(videoUUID, 'above', 20) 225 await checkVideoFPS(videoUUID, 'above', 20)
@@ -230,7 +230,7 @@ describe('Test transcoding plugins', function () {
230 describe('When using a plugin adding new encoders', function () { 230 describe('When using a plugin adding new encoders', function () {
231 231
232 before(async function () { 232 before(async function () {
233 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-transcoding-two') }) 233 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-transcoding-two') })
234 234
235 await updateConf(server, 'test-vod-profile', 'test-live-profile') 235 await updateConf(server, 'test-vod-profile', 'test-live-profile')
236 }) 236 })
@@ -238,10 +238,10 @@ describe('Test transcoding plugins', function () {
238 it('Should use the new vod encoders', async function () { 238 it('Should use the new vod encoders', async function () {
239 this.timeout(240000) 239 this.timeout(240000)
240 240
241 const videoUUID = (await server.videosCommand.quickUpload({ name: 'video', fixture: 'video_short_240p.mp4' })).uuid 241 const videoUUID = (await server.videos.quickUpload({ name: 'video', fixture: 'video_short_240p.mp4' })).uuid
242 await waitJobs([ server ]) 242 await waitJobs([ server ])
243 243
244 const path = server.serversCommand.buildDirectory(join('videos', videoUUID + '-240.mp4')) 244 const path = server.servers.buildDirectory(join('videos', videoUUID + '-240.mp4'))
245 const audioProbe = await getAudioStream(path) 245 const audioProbe = await getAudioStream(path)
246 expect(audioProbe.audioStream.codec_name).to.equal('opus') 246 expect(audioProbe.audioStream.codec_name).to.equal('opus')
247 247
@@ -254,8 +254,8 @@ describe('Test transcoding plugins', function () {
254 254
255 const liveVideoId = await createLiveWrapper(server) 255 const liveVideoId = await createLiveWrapper(server)
256 256
257 await server.liveCommand.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' }) 257 await server.live.sendRTMPStreamInVideo({ videoId: liveVideoId, fixtureName: 'video_short2.webm' })
258 await server.liveCommand.waitUntilPublished({ videoId: liveVideoId }) 258 await server.live.waitUntilPublished({ videoId: liveVideoId })
259 await waitJobs([ server ]) 259 await waitJobs([ server ])
260 260
261 const playlistUrl = `${server.url}/static/streaming-playlists/hls/${liveVideoId}/0.m3u8` 261 const playlistUrl = `${server.url}/static/streaming-playlists/hls/${liveVideoId}/0.m3u8`
diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts
index f430f82b8..26a27abca 100644
--- a/server/tests/plugins/plugin-unloading.ts
+++ b/server/tests/plugins/plugin-unloading.ts
@@ -16,7 +16,7 @@ describe('Test plugins module unloading', function () {
16 server = await flushAndRunServer(1) 16 server = await flushAndRunServer(1)
17 await setAccessTokensToServers([ server ]) 17 await setAccessTokensToServers([ server ])
18 18
19 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) 19 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
20 }) 20 })
21 21
22 it('Should return a numeric value', async function () { 22 it('Should return a numeric value', async function () {
@@ -41,7 +41,7 @@ describe('Test plugins module unloading', function () {
41 }) 41 })
42 42
43 it('Should uninstall the plugin and free the route', async function () { 43 it('Should uninstall the plugin and free the route', async function () {
44 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-unloading' }) 44 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-unloading' })
45 45
46 await makeGetRequest({ 46 await makeGetRequest({
47 url: server.url, 47 url: server.url,
@@ -51,7 +51,7 @@ describe('Test plugins module unloading', function () {
51 }) 51 })
52 52
53 it('Should return a different numeric value', async function () { 53 it('Should return a different numeric value', async function () {
54 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-unloading') }) 54 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-unloading') })
55 55
56 const res = await makeGetRequest({ 56 const res = await makeGetRequest({
57 url: server.url, 57 url: server.url,
diff --git a/server/tests/plugins/translations.ts b/server/tests/plugins/translations.ts
index 0e11a0b53..d8d878026 100644
--- a/server/tests/plugins/translations.ts
+++ b/server/tests/plugins/translations.ts
@@ -17,7 +17,7 @@ describe('Test plugin translations', function () {
17 server = await flushAndRunServer(1) 17 server = await flushAndRunServer(1)
18 await setAccessTokensToServers([ server ]) 18 await setAccessTokensToServers([ server ])
19 19
20 command = server.pluginsCommand 20 command = server.plugins
21 21
22 await command.install({ path: PluginsCommand.getPluginTestPath() }) 22 await command.install({ path: PluginsCommand.getPluginTestPath() })
23 await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') }) 23 await command.install({ path: PluginsCommand.getPluginTestPath('-filter-translations') })
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts
index 641e37fbb..facc6bbc1 100644
--- a/server/tests/plugins/video-constants.ts
+++ b/server/tests/plugins/video-constants.ts
@@ -17,11 +17,11 @@ describe('Test plugin altering video constants', function () {
17 server = await flushAndRunServer(1) 17 server = await flushAndRunServer(1)
18 await setAccessTokensToServers([ server ]) 18 await setAccessTokensToServers([ server ])
19 19
20 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-video-constants') }) 20 await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-video-constants') })
21 }) 21 })
22 22
23 it('Should have updated languages', async function () { 23 it('Should have updated languages', async function () {
24 const languages = await server.videosCommand.getLanguages() 24 const languages = await server.videos.getLanguages()
25 25
26 expect(languages['en']).to.not.exist 26 expect(languages['en']).to.not.exist
27 expect(languages['fr']).to.not.exist 27 expect(languages['fr']).to.not.exist
@@ -32,7 +32,7 @@ describe('Test plugin altering video constants', function () {
32 }) 32 })
33 33
34 it('Should have updated categories', async function () { 34 it('Should have updated categories', async function () {
35 const categories = await server.videosCommand.getCategories() 35 const categories = await server.videos.getCategories()
36 36
37 expect(categories[1]).to.not.exist 37 expect(categories[1]).to.not.exist
38 expect(categories[2]).to.not.exist 38 expect(categories[2]).to.not.exist
@@ -42,7 +42,7 @@ describe('Test plugin altering video constants', function () {
42 }) 42 })
43 43
44 it('Should have updated licences', async function () { 44 it('Should have updated licences', async function () {
45 const licences = await server.videosCommand.getLicences() 45 const licences = await server.videos.getLicences()
46 46
47 expect(licences[1]).to.not.exist 47 expect(licences[1]).to.not.exist
48 expect(licences[7]).to.not.exist 48 expect(licences[7]).to.not.exist
@@ -52,7 +52,7 @@ describe('Test plugin altering video constants', function () {
52 }) 52 })
53 53
54 it('Should have updated video privacies', async function () { 54 it('Should have updated video privacies', async function () {
55 const privacies = await server.videosCommand.getPrivacies() 55 const privacies = await server.videos.getPrivacies()
56 56
57 expect(privacies[1]).to.exist 57 expect(privacies[1]).to.exist
58 expect(privacies[2]).to.not.exist 58 expect(privacies[2]).to.not.exist
@@ -61,7 +61,7 @@ describe('Test plugin altering video constants', function () {
61 }) 61 })
62 62
63 it('Should have updated playlist privacies', async function () { 63 it('Should have updated playlist privacies', async function () {
64 const playlistPrivacies = await server.playlistsCommand.getPrivacies() 64 const playlistPrivacies = await server.playlists.getPrivacies()
65 65
66 expect(playlistPrivacies[1]).to.exist 66 expect(playlistPrivacies[1]).to.exist
67 expect(playlistPrivacies[2]).to.exist 67 expect(playlistPrivacies[2]).to.exist
@@ -70,29 +70,29 @@ describe('Test plugin altering video constants', function () {
70 70
71 it('Should not be able to create a video with this privacy', async function () { 71 it('Should not be able to create a video with this privacy', async function () {
72 const attributes = { name: 'video', privacy: 2 } 72 const attributes = { name: 'video', privacy: 2 }
73 await server.videosCommand.upload({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 73 await server.videos.upload({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
74 }) 74 })
75 75
76 it('Should not be able to create a video with this privacy', async function () { 76 it('Should not be able to create a video with this privacy', async function () {
77 const attributes = { displayName: 'video playlist', privacy: VideoPlaylistPrivacy.PRIVATE } 77 const attributes = { displayName: 'video playlist', privacy: VideoPlaylistPrivacy.PRIVATE }
78 await server.playlistsCommand.create({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 78 await server.playlists.create({ attributes, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
79 }) 79 })
80 80
81 it('Should be able to upload a video with these values', async function () { 81 it('Should be able to upload a video with these values', async function () {
82 const attributes = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' } 82 const attributes = { name: 'video', category: 42, licence: 42, language: 'al_bhed2' }
83 const { uuid } = await server.videosCommand.upload({ attributes }) 83 const { uuid } = await server.videos.upload({ attributes })
84 84
85 const video = await server.videosCommand.get({ id: uuid }) 85 const video = await server.videos.get({ id: uuid })
86 expect(video.language.label).to.equal('Al Bhed 2') 86 expect(video.language.label).to.equal('Al Bhed 2')
87 expect(video.licence.label).to.equal('Best licence') 87 expect(video.licence.label).to.equal('Best licence')
88 expect(video.category.label).to.equal('Best category') 88 expect(video.category.label).to.equal('Best category')
89 }) 89 })
90 90
91 it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () { 91 it('Should uninstall the plugin and reset languages, categories, licences and privacies', async function () {
92 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-video-constants' }) 92 await server.plugins.uninstall({ npmName: 'peertube-plugin-test-video-constants' })
93 93
94 { 94 {
95 const languages = await server.videosCommand.getLanguages() 95 const languages = await server.videos.getLanguages()
96 96
97 expect(languages['en']).to.equal('English') 97 expect(languages['en']).to.equal('English')
98 expect(languages['fr']).to.equal('French') 98 expect(languages['fr']).to.equal('French')
@@ -103,7 +103,7 @@ describe('Test plugin altering video constants', function () {
103 } 103 }
104 104
105 { 105 {
106 const categories = await server.videosCommand.getCategories() 106 const categories = await server.videos.getCategories()
107 107
108 expect(categories[1]).to.equal('Music') 108 expect(categories[1]).to.equal('Music')
109 expect(categories[2]).to.equal('Films') 109 expect(categories[2]).to.equal('Films')
@@ -113,7 +113,7 @@ describe('Test plugin altering video constants', function () {
113 } 113 }
114 114
115 { 115 {
116 const licences = await server.videosCommand.getLicences() 116 const licences = await server.videos.getLicences()
117 117
118 expect(licences[1]).to.equal('Attribution') 118 expect(licences[1]).to.equal('Attribution')
119 expect(licences[7]).to.equal('Public Domain Dedication') 119 expect(licences[7]).to.equal('Public Domain Dedication')
@@ -123,7 +123,7 @@ describe('Test plugin altering video constants', function () {
123 } 123 }
124 124
125 { 125 {
126 const privacies = await server.videosCommand.getPrivacies() 126 const privacies = await server.videos.getPrivacies()
127 127
128 expect(privacies[1]).to.exist 128 expect(privacies[1]).to.exist
129 expect(privacies[2]).to.exist 129 expect(privacies[2]).to.exist
@@ -132,7 +132,7 @@ describe('Test plugin altering video constants', function () {
132 } 132 }
133 133
134 { 134 {
135 const playlistPrivacies = await server.playlistsCommand.getPrivacies() 135 const playlistPrivacies = await server.playlists.getPrivacies()
136 136
137 expect(playlistPrivacies[1]).to.exist 137 expect(playlistPrivacies[1]).to.exist
138 expect(playlistPrivacies[2]).to.exist 138 expect(playlistPrivacies[2]).to.exist