aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/live
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-15 10:02:54 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitd23dd9fbfc4d26026352c10f81d2795ceaf2908a (patch)
treeda82286d423c5e834a1ee2dcd5970076b8263cf1 /server/tests/api/live
parent7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0 (diff)
downloadPeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.gz
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.tar.zst
PeerTube-d23dd9fbfc4d26026352c10f81d2795ceaf2908a.zip
Introduce videos command
Diffstat (limited to 'server/tests/api/live')
-rw-r--r--server/tests/api/live/live-constraints.ts7
-rw-r--r--server/tests/api/live/live-permanent.ts11
-rw-r--r--server/tests/api/live/live-save-replay.ts48
-rw-r--r--server/tests/api/live/live-socket-messages.ts16
-rw-r--r--server/tests/api/live/live-views.ts18
-rw-r--r--server/tests/api/live/live.ts88
6 files changed, 78 insertions, 110 deletions
diff --git a/server/tests/api/live/live-constraints.ts b/server/tests/api/live/live-constraints.ts
index 290d325d4..7900b1abe 100644
--- a/server/tests/api/live/live-constraints.ts
+++ b/server/tests/api/live/live-constraints.ts
@@ -2,14 +2,13 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { VideoDetails, VideoPrivacy } from '@shared/models' 5import { VideoPrivacy } from '@shared/models'
6import { 6import {
7 checkLiveCleanup, 7 checkLiveCleanup,
8 cleanupTests, 8 cleanupTests,
9 ConfigCommand, 9 ConfigCommand,
10 doubleFollow, 10 doubleFollow,
11 flushAndRunMultipleServers, 11 flushAndRunMultipleServers,
12 getVideo,
13 ServerInfo, 12 ServerInfo,
14 setAccessTokensToServers, 13 setAccessTokensToServers,
15 setDefaultVideoChannel, 14 setDefaultVideoChannel,
@@ -39,9 +38,7 @@ describe('Test live constraints', function () {
39 38
40 async function checkSaveReplay (videoId: string, resolutions = [ 720 ]) { 39 async function checkSaveReplay (videoId: string, resolutions = [ 720 ]) {
41 for (const server of servers) { 40 for (const server of servers) {
42 const res = await getVideo(server.url, videoId) 41 const video = await server.videosCommand.get({ id: videoId })
43
44 const video: VideoDetails = res.body
45 expect(video.isLive).to.be.false 42 expect(video.isLive).to.be.false
46 expect(video.duration).to.be.greaterThan(0) 43 expect(video.duration).to.be.greaterThan(0)
47 } 44 }
diff --git a/server/tests/api/live/live-permanent.ts b/server/tests/api/live/live-permanent.ts
index 6f4915a6b..707f2edf8 100644
--- a/server/tests/api/live/live-permanent.ts
+++ b/server/tests/api/live/live-permanent.ts
@@ -2,13 +2,12 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models' 5import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 ConfigCommand, 8 ConfigCommand,
9 doubleFollow, 9 doubleFollow,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 getVideo,
12 ServerInfo, 11 ServerInfo,
13 setAccessTokensToServers, 12 setAccessTokensToServers,
14 setDefaultVideoChannel, 13 setDefaultVideoChannel,
@@ -38,8 +37,8 @@ describe('Permanent live', function () {
38 37
39 async function checkVideoState (videoId: string, state: VideoState) { 38 async function checkVideoState (videoId: string, state: VideoState) {
40 for (const server of servers) { 39 for (const server of servers) {
41 const res = await getVideo(server.url, videoId) 40 const video = await server.videosCommand.get({ id: videoId })
42 expect((res.body as VideoDetails).state.id).to.equal(state) 41 expect(video.state.id).to.equal(state)
43 } 42 }
44 } 43 }
45 44
@@ -123,9 +122,7 @@ describe('Permanent live', function () {
123 await waitJobs(servers) 122 await waitJobs(servers)
124 123
125 for (const server of servers) { 124 for (const server of servers) {
126 const res = await getVideo(server.url, videoUUID) 125 const videoDetails = await server.videosCommand.get({ id: videoUUID })
127
128 const videoDetails = res.body as VideoDetails
129 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1) 126 expect(videoDetails.streamingPlaylists).to.have.lengthOf(1)
130 } 127 }
131 }) 128 })
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index 363fb561c..a87a2cd12 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -3,26 +3,22 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { FfmpegCommand } from 'fluent-ffmpeg' 5import { FfmpegCommand } from 'fluent-ffmpeg'
6import { LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState } from '@shared/models' 6import { HttpStatusCode } from '@shared/core-utils'
7import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
8import { 7import {
9 checkLiveCleanup, 8 checkLiveCleanup,
10 cleanupTests, 9 cleanupTests,
11 ConfigCommand, 10 ConfigCommand,
12 doubleFollow, 11 doubleFollow,
13 flushAndRunMultipleServers, 12 flushAndRunMultipleServers,
14 getVideo,
15 getVideosList,
16 removeVideo,
17 ServerInfo, 13 ServerInfo,
18 setAccessTokensToServers, 14 setAccessTokensToServers,
19 setDefaultVideoChannel, 15 setDefaultVideoChannel,
20 stopFfmpeg, 16 stopFfmpeg,
21 testFfmpegStreamError, 17 testFfmpegStreamError,
22 updateVideo,
23 wait, 18 wait,
24 waitJobs 19 waitJobs
25} from '../../../../shared/extra-utils' 20} from '@shared/extra-utils'
21import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models'
26 22
27const expect = chai.expect 23const expect = chai.expect
28 24
@@ -34,7 +30,7 @@ describe('Save replay setting', function () {
34 async function createLiveWrapper (saveReplay: boolean) { 30 async function createLiveWrapper (saveReplay: boolean) {
35 if (liveVideoUUID) { 31 if (liveVideoUUID) {
36 try { 32 try {
37 await removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 33 await servers[0].videosCommand.remove({ id: liveVideoUUID })
38 await waitJobs(servers) 34 await waitJobs(servers)
39 } catch {} 35 } catch {}
40 } 36 }
@@ -50,24 +46,24 @@ describe('Save replay setting', function () {
50 return uuid 46 return uuid
51 } 47 }
52 48
53 async function checkVideosExist (videoId: string, existsInList: boolean, getStatus?: number) { 49 async function checkVideosExist (videoId: string, existsInList: boolean, expectedStatus?: number) {
54 for (const server of servers) { 50 for (const server of servers) {
55 const length = existsInList ? 1 : 0 51 const length = existsInList ? 1 : 0
56 52
57 const resVideos = await getVideosList(server.url) 53 const { data, total } = await server.videosCommand.list()
58 expect(resVideos.body.data).to.have.lengthOf(length) 54 expect(data).to.have.lengthOf(length)
59 expect(resVideos.body.total).to.equal(length) 55 expect(total).to.equal(length)
60 56
61 if (getStatus) { 57 if (expectedStatus) {
62 await getVideo(server.url, videoId, getStatus) 58 await server.videosCommand.get({ id: videoId, expectedStatus })
63 } 59 }
64 } 60 }
65 } 61 }
66 62
67 async function checkVideoState (videoId: string, state: VideoState) { 63 async function checkVideoState (videoId: string, state: VideoState) {
68 for (const server of servers) { 64 for (const server of servers) {
69 const res = await getVideo(server.url, videoId) 65 const video = await server.videosCommand.get({ id: videoId })
70 expect((res.body as VideoDetails).state.id).to.equal(state) 66 expect(video.state.id).to.equal(state)
71 } 67 }
72 } 68 }
73 69
@@ -179,8 +175,8 @@ describe('Save replay setting', function () {
179 175
180 await checkVideosExist(liveVideoUUID, false) 176 await checkVideosExist(liveVideoUUID, false)
181 177
182 await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401) 178 await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
183 await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404) 179 await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
184 180
185 await wait(5000) 181 await wait(5000)
186 await waitJobs(servers) 182 await waitJobs(servers)
@@ -201,7 +197,7 @@ describe('Save replay setting', function () {
201 197
202 await Promise.all([ 198 await Promise.all([
203 testFfmpegStreamError(ffmpegCommand, true), 199 testFfmpegStreamError(ffmpegCommand, true),
204 removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 200 servers[0].videosCommand.remove({ id: liveVideoUUID })
205 ]) 201 ])
206 202
207 await wait(5000) 203 await wait(5000)
@@ -253,13 +249,13 @@ describe('Save replay setting', function () {
253 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 () {
254 this.timeout(30000) 250 this.timeout(30000)
255 251
256 await updateVideo(servers[0].url, servers[0].accessToken, liveVideoUUID, { name: 'video updated' }) 252 await servers[0].videosCommand.update({ id: liveVideoUUID, attributes: { name: 'video updated' } })
257 await waitJobs(servers) 253 await waitJobs(servers)
258 254
259 for (const server of servers) { 255 for (const server of servers) {
260 const res = await getVideo(server.url, liveVideoUUID) 256 const video = await server.videosCommand.get({ id: liveVideoUUID })
261 expect(res.body.name).to.equal('video updated') 257 expect(video.name).to.equal('video updated')
262 expect(res.body.isLive).to.be.false 258 expect(video.isLive).to.be.false
263 } 259 }
264 }) 260 })
265 261
@@ -287,8 +283,8 @@ describe('Save replay setting', function () {
287 283
288 await checkVideosExist(liveVideoUUID, false) 284 await checkVideosExist(liveVideoUUID, false)
289 285
290 await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401) 286 await servers[0].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
291 await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404) 287 await servers[1].videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
292 288
293 await wait(5000) 289 await wait(5000)
294 await waitJobs(servers) 290 await waitJobs(servers)
@@ -307,7 +303,7 @@ describe('Save replay setting', function () {
307 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200) 303 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
308 304
309 await Promise.all([ 305 await Promise.all([
310 removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID), 306 servers[0].videosCommand.remove({ id: liveVideoUUID }),
311 testFfmpegStreamError(ffmpegCommand, true) 307 testFfmpegStreamError(ffmpegCommand, true)
312 ]) 308 ])
313 309
diff --git a/server/tests/api/live/live-socket-messages.ts b/server/tests/api/live/live-socket-messages.ts
index 4a6677c0a..1f3d455a8 100644
--- a/server/tests/api/live/live-socket-messages.ts
+++ b/server/tests/api/live/live-socket-messages.ts
@@ -7,12 +7,10 @@ import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
9 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
10 getVideoIdFromUUID,
11 ServerInfo, 10 ServerInfo,
12 setAccessTokensToServers, 11 setAccessTokensToServers,
13 setDefaultVideoChannel, 12 setDefaultVideoChannel,
14 stopFfmpeg, 13 stopFfmpeg,
15 viewVideo,
16 wait, 14 wait,
17 waitJobs, 15 waitJobs,
18 waitUntilLivePublishedOnAllServers 16 waitUntilLivePublishedOnAllServers
@@ -71,7 +69,7 @@ describe('Test live', function () {
71 await waitJobs(servers) 69 await waitJobs(servers)
72 70
73 { 71 {
74 const videoId = await getVideoIdFromUUID(servers[0].url, liveVideoUUID) 72 const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID })
75 73
76 const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket() 74 const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket()
77 localSocket.on('state-change', data => localStateChanges.push(data.state)) 75 localSocket.on('state-change', data => localStateChanges.push(data.state))
@@ -79,7 +77,7 @@ describe('Test live', function () {
79 } 77 }
80 78
81 { 79 {
82 const videoId = await getVideoIdFromUUID(servers[1].url, liveVideoUUID) 80 const videoId = await servers[1].videosCommand.getId({ uuid: liveVideoUUID })
83 81
84 const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket() 82 const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket()
85 remoteSocket.on('state-change', data => remoteStateChanges.push(data.state)) 83 remoteSocket.on('state-change', data => remoteStateChanges.push(data.state))
@@ -119,7 +117,7 @@ describe('Test live', function () {
119 await waitJobs(servers) 117 await waitJobs(servers)
120 118
121 { 119 {
122 const videoId = await getVideoIdFromUUID(servers[0].url, liveVideoUUID) 120 const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID })
123 121
124 const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket() 122 const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket()
125 localSocket.on('views-change', data => { localLastVideoViews = data.views }) 123 localSocket.on('views-change', data => { localLastVideoViews = data.views })
@@ -127,7 +125,7 @@ describe('Test live', function () {
127 } 125 }
128 126
129 { 127 {
130 const videoId = await getVideoIdFromUUID(servers[1].url, liveVideoUUID) 128 const videoId = await servers[1].videosCommand.getId({ uuid: liveVideoUUID })
131 129
132 const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket() 130 const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket()
133 remoteSocket.on('views-change', data => { remoteLastVideoViews = data.views }) 131 remoteSocket.on('views-change', data => { remoteLastVideoViews = data.views })
@@ -142,8 +140,8 @@ describe('Test live', function () {
142 expect(localLastVideoViews).to.equal(0) 140 expect(localLastVideoViews).to.equal(0)
143 expect(remoteLastVideoViews).to.equal(0) 141 expect(remoteLastVideoViews).to.equal(0)
144 142
145 await viewVideo(servers[0].url, liveVideoUUID) 143 await servers[0].videosCommand.view({ id: liveVideoUUID })
146 await viewVideo(servers[1].url, liveVideoUUID) 144 await servers[1].videosCommand.view({ id: liveVideoUUID })
147 145
148 await waitJobs(servers) 146 await waitJobs(servers)
149 await wait(5000) 147 await wait(5000)
@@ -163,7 +161,7 @@ describe('Test live', function () {
163 const liveVideoUUID = await createLiveWrapper() 161 const liveVideoUUID = await createLiveWrapper()
164 await waitJobs(servers) 162 await waitJobs(servers)
165 163
166 const videoId = await getVideoIdFromUUID(servers[0].url, liveVideoUUID) 164 const videoId = await servers[0].videosCommand.getId({ uuid: liveVideoUUID })
167 165
168 const socket = servers[0].socketIOCommand.getLiveNotificationSocket() 166 const socket = servers[0].socketIOCommand.getLiveNotificationSocket()
169 socket.on('state-change', data => stateChanges.push(data.state)) 167 socket.on('state-change', data => stateChanges.push(data.state))
diff --git a/server/tests/api/live/live-views.ts b/server/tests/api/live/live-views.ts
index 75f95b167..1951b11a5 100644
--- a/server/tests/api/live/live-views.ts
+++ b/server/tests/api/live/live-views.ts
@@ -3,17 +3,15 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { FfmpegCommand } from 'fluent-ffmpeg' 5import { FfmpegCommand } from 'fluent-ffmpeg'
6import { VideoDetails, VideoPrivacy } from '@shared/models' 6import { VideoPrivacy } from '@shared/models'
7import { 7import {
8 cleanupTests, 8 cleanupTests,
9 doubleFollow, 9 doubleFollow,
10 flushAndRunMultipleServers, 10 flushAndRunMultipleServers,
11 getVideo,
12 ServerInfo, 11 ServerInfo,
13 setAccessTokensToServers, 12 setAccessTokensToServers,
14 setDefaultVideoChannel, 13 setDefaultVideoChannel,
15 stopFfmpeg, 14 stopFfmpeg,
16 viewVideo,
17 wait, 15 wait,
18 waitJobs, 16 waitJobs,
19 waitUntilLivePublishedOnAllServers 17 waitUntilLivePublishedOnAllServers
@@ -55,9 +53,7 @@ describe('Test live', function () {
55 53
56 async function countViews (expected: number) { 54 async function countViews (expected: number) {
57 for (const server of servers) { 55 for (const server of servers) {
58 const res = await getVideo(server.url, liveVideoId) 56 const video = await server.videosCommand.get({ id: liveVideoId })
59 const video: VideoDetails = res.body
60
61 expect(video.views).to.equal(expected) 57 expect(video.views).to.equal(expected)
62 } 58 }
63 } 59 }
@@ -86,8 +82,8 @@ describe('Test live', function () {
86 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 () {
87 this.timeout(30000) 83 this.timeout(30000)
88 84
89 await viewVideo(servers[0].url, liveVideoId) 85 await servers[0].videosCommand.view({ id: liveVideoId })
90 await viewVideo(servers[0].url, liveVideoId) 86 await servers[0].videosCommand.view({ id: liveVideoId })
91 87
92 await wait(7000) 88 await wait(7000)
93 89
@@ -108,9 +104,9 @@ describe('Test live', function () {
108 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 () {
109 this.timeout(30000) 105 this.timeout(30000)
110 106
111 await viewVideo(servers[0].url, liveVideoId) 107 await servers[0].videosCommand.view({ id: liveVideoId })
112 await viewVideo(servers[1].url, liveVideoId) 108 await servers[1].videosCommand.view({ id: liveVideoId })
113 await viewVideo(servers[1].url, liveVideoId) 109 await servers[1].videosCommand.view({ id: liveVideoId })
114 110
115 await wait(7000) 111 await wait(7000)
116 await waitJobs(servers) 112 await waitJobs(servers)
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 999a49051..c88143982 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -4,8 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' 6import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
7import { LiveVideo, LiveVideoCreate, Video, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models' 7import { HttpStatusCode } from '@shared/core-utils'
8import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
9import { 8import {
10 checkLiveCleanup, 9 checkLiveCleanup,
11 checkLiveSegmentHash, 10 checkLiveSegmentHash,
@@ -13,14 +12,9 @@ import {
13 cleanupTests, 12 cleanupTests,
14 doubleFollow, 13 doubleFollow,
15 flushAndRunMultipleServers, 14 flushAndRunMultipleServers,
16 getMyVideosWithFilter,
17 getVideo,
18 getVideosList,
19 getVideosWithFilters,
20 killallServers, 15 killallServers,
21 LiveCommand, 16 LiveCommand,
22 makeRawRequest, 17 makeRawRequest,
23 removeVideo,
24 reRunServer, 18 reRunServer,
25 sendRTMPStream, 19 sendRTMPStream,
26 ServerInfo, 20 ServerInfo,
@@ -29,11 +23,11 @@ import {
29 stopFfmpeg, 23 stopFfmpeg,
30 testFfmpegStreamError, 24 testFfmpegStreamError,
31 testImage, 25 testImage,
32 uploadVideoAndGetId,
33 wait, 26 wait,
34 waitJobs, 27 waitJobs,
35 waitUntilLivePublishedOnAllServers 28 waitUntilLivePublishedOnAllServers
36} from '../../../../shared/extra-utils' 29} from '@shared/extra-utils'
30import { LiveVideo, LiveVideoCreate, VideoDetails, VideoPrivacy, VideoState, VideoStreamingPlaylistType } from '@shared/models'
37 31
38const expect = chai.expect 32const expect = chai.expect
39 33
@@ -99,8 +93,7 @@ describe('Test live', function () {
99 await waitJobs(servers) 93 await waitJobs(servers)
100 94
101 for (const server of servers) { 95 for (const server of servers) {
102 const resVideo = await getVideo(server.url, liveVideoUUID) 96 const video = await server.videosCommand.get({ id: liveVideoUUID })
103 const video: VideoDetails = resVideo.body
104 97
105 expect(video.category.id).to.equal(1) 98 expect(video.category.id).to.equal(1)
106 expect(video.licence.id).to.equal(2) 99 expect(video.licence.id).to.equal(2)
@@ -154,9 +147,7 @@ describe('Test live', function () {
154 await waitJobs(servers) 147 await waitJobs(servers)
155 148
156 for (const server of servers) { 149 for (const server of servers) {
157 const resVideo = await getVideo(server.url, videoId) 150 const video = await server.videosCommand.get({ id: videoId })
158 const video: VideoDetails = resVideo.body
159
160 expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED) 151 expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED)
161 expect(video.nsfw).to.be.true 152 expect(video.nsfw).to.be.true
162 153
@@ -167,10 +158,10 @@ describe('Test live', function () {
167 158
168 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 () {
169 for (const server of servers) { 160 for (const server of servers) {
170 const res = await getVideosList(server.url) 161 const { total, data } = await server.videosCommand.list()
171 162
172 expect(res.body.total).to.equal(0) 163 expect(total).to.equal(0)
173 expect(res.body.data).to.have.lengthOf(0) 164 expect(data).to.have.lengthOf(0)
174 } 165 }
175 }) 166 })
176 167
@@ -204,13 +195,13 @@ describe('Test live', function () {
204 it('Delete the live', async function () { 195 it('Delete the live', async function () {
205 this.timeout(10000) 196 this.timeout(10000)
206 197
207 await removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID) 198 await servers[0].videosCommand.remove({ id: liveVideoUUID })
208 await waitJobs(servers) 199 await waitJobs(servers)
209 }) 200 })
210 201
211 it('Should have the live deleted', async function () { 202 it('Should have the live deleted', async function () {
212 for (const server of servers) { 203 for (const server of servers) {
213 await getVideo(server.url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404) 204 await server.videosCommand.get({ id: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
214 await server.liveCommand.get({ videoId: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) 205 await server.liveCommand.get({ videoId: liveVideoUUID, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
215 } 206 }
216 }) 207 })
@@ -224,7 +215,7 @@ describe('Test live', function () {
224 before(async function () { 215 before(async function () {
225 this.timeout(120000) 216 this.timeout(120000)
226 217
227 vodVideoId = (await uploadVideoAndGetId({ server: servers[0], videoName: 'vod video' })).uuid 218 vodVideoId = (await servers[0].videosCommand.quickUpload({ name: 'vod video' })).uuid
228 219
229 const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].videoChannel.id } 220 const liveOptions = { name: 'live', privacy: VideoPrivacy.PUBLIC, channelId: servers[0].videoChannel.id }
230 const live = await commands[0].create({ fields: liveOptions }) 221 const live = await commands[0].create({ fields: liveOptions })
@@ -236,19 +227,19 @@ describe('Test live', function () {
236 }) 227 })
237 228
238 it('Should only display lives', async function () { 229 it('Should only display lives', async function () {
239 const res = await getVideosWithFilters(servers[0].url, { isLive: true }) 230 const { data, total } = await servers[0].videosCommand.list({ isLive: true })
240 231
241 expect(res.body.total).to.equal(1) 232 expect(total).to.equal(1)
242 expect(res.body.data).to.have.lengthOf(1) 233 expect(data).to.have.lengthOf(1)
243 expect(res.body.data[0].name).to.equal('live') 234 expect(data[0].name).to.equal('live')
244 }) 235 })
245 236
246 it('Should not display lives', async function () { 237 it('Should not display lives', async function () {
247 const res = await getVideosWithFilters(servers[0].url, { isLive: false }) 238 const { data, total } = await servers[0].videosCommand.list({ isLive: false })
248 239
249 expect(res.body.total).to.equal(1) 240 expect(total).to.equal(1)
250 expect(res.body.data).to.have.lengthOf(1) 241 expect(data).to.have.lengthOf(1)
251 expect(res.body.data[0].name).to.equal('vod video') 242 expect(data[0].name).to.equal('vod video')
252 }) 243 })
253 244
254 it('Should display my lives', async function () { 245 it('Should display my lives', async function () {
@@ -257,24 +248,22 @@ describe('Test live', function () {
257 await stopFfmpeg(ffmpegCommand) 248 await stopFfmpeg(ffmpegCommand)
258 await waitJobs(servers) 249 await waitJobs(servers)
259 250
260 const res = await getMyVideosWithFilter(servers[0].url, servers[0].accessToken, { isLive: true }) 251 const { data } = await servers[0].videosCommand.listMyVideos({ isLive: true })
261 const videos = res.body.data as Video[]
262 252
263 const result = videos.every(v => v.isLive) 253 const result = data.every(v => v.isLive)
264 expect(result).to.be.true 254 expect(result).to.be.true
265 }) 255 })
266 256
267 it('Should not display my lives', async function () { 257 it('Should not display my lives', async function () {
268 const res = await getMyVideosWithFilter(servers[0].url, servers[0].accessToken, { isLive: false }) 258 const { data } = await servers[0].videosCommand.listMyVideos({ isLive: false })
269 const videos = res.body.data as Video[]
270 259
271 const result = videos.every(v => !v.isLive) 260 const result = data.every(v => !v.isLive)
272 expect(result).to.be.true 261 expect(result).to.be.true
273 }) 262 })
274 263
275 after(async function () { 264 after(async function () {
276 await removeVideo(servers[0].url, servers[0].accessToken, vodVideoId) 265 await servers[0].videosCommand.remove({ id: vodVideoId })
277 await removeVideo(servers[0].url, servers[0].accessToken, liveVideoId) 266 await servers[0].videosCommand.remove({ id: liveVideoId })
278 }) 267 })
279 }) 268 })
280 269
@@ -297,9 +286,9 @@ describe('Test live', function () {
297 const { uuid } = await commands[0].create({ fields: liveAttributes }) 286 const { uuid } = await commands[0].create({ fields: liveAttributes })
298 287
299 const live = await commands[0].get({ videoId: uuid }) 288 const live = await commands[0].get({ videoId: uuid })
300 const resVideo = await getVideo(servers[0].url, uuid) 289 const video = await servers[0].videosCommand.get({ id: uuid })
301 290
302 return Object.assign(resVideo.body as VideoDetails, live) 291 return Object.assign(video, live)
303 } 292 }
304 293
305 it('Should not allow a stream without the appropriate path', async function () { 294 it('Should not allow a stream without the appropriate path', async function () {
@@ -327,13 +316,12 @@ describe('Test live', function () {
327 316
328 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 () {
329 for (const server of servers) { 318 for (const server of servers) {
330 const res = await getVideosList(server.url) 319 const { total, data } = await server.videosCommand.list()
331
332 expect(res.body.total).to.equal(1)
333 expect(res.body.data).to.have.lengthOf(1)
334 320
335 const video: Video = res.body.data[0] 321 expect(total).to.equal(1)
322 expect(data).to.have.lengthOf(1)
336 323
324 const video = data[0]
337 expect(video.name).to.equal('user live') 325 expect(video.name).to.equal('user live')
338 expect(video.isLive).to.be.true 326 expect(video.isLive).to.be.true
339 } 327 }
@@ -355,7 +343,7 @@ describe('Test live', function () {
355 343
356 liveVideo = await createLiveWrapper() 344 liveVideo = await createLiveWrapper()
357 345
358 await removeVideo(servers[0].url, servers[0].accessToken, liveVideo.uuid) 346 await servers[0].videosCommand.remove({ id: liveVideo.uuid })
359 347
360 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey) 348 const command = sendRTMPStream(rtmpUrl + '/live', liveVideo.streamKey)
361 await testFfmpegStreamError(command, true) 349 await testFfmpegStreamError(command, true)
@@ -379,13 +367,10 @@ describe('Test live', function () {
379 367
380 async function testVideoResolutions (liveVideoId: string, resolutions: number[]) { 368 async function testVideoResolutions (liveVideoId: string, resolutions: number[]) {
381 for (const server of servers) { 369 for (const server of servers) {
382 const resList = await getVideosList(server.url) 370 const { data } = await server.videosCommand.list()
383 const videos: Video[] = resList.body.data 371 expect(data.find(v => v.uuid === liveVideoId)).to.exist
384
385 expect(videos.find(v => v.uuid === liveVideoId)).to.exist
386 372
387 const resVideo = await getVideo(server.url, liveVideoId) 373 const video = await server.videosCommand.get({ id: liveVideoId })
388 const video: VideoDetails = resVideo.body
389 374
390 expect(video.streamingPlaylists).to.have.lengthOf(1) 375 expect(video.streamingPlaylists).to.have.lengthOf(1)
391 376
@@ -505,8 +490,7 @@ describe('Test live', function () {
505 } 490 }
506 491
507 for (const server of servers) { 492 for (const server of servers) {
508 const resVideo = await getVideo(server.url, liveVideoId) 493 const video = await server.videosCommand.get({ id: liveVideoId })
509 const video: VideoDetails = resVideo.body
510 494
511 expect(video.state.id).to.equal(VideoState.PUBLISHED) 495 expect(video.state.id).to.equal(VideoState.PUBLISHED)
512 expect(video.duration).to.be.greaterThan(1) 496 expect(video.duration).to.be.greaterThan(1)