aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-04-25 16:15:39 +0200
committerChocobozzz <me@florianbigard.com>2018-04-25 16:16:21 +0200
commitcc918ac3f45e32f031cce7b6e0473e5c2c34b8ae (patch)
tree034c0ce9cda37d572fe1c0c34eff750681e18574 /server/tests
parentd3e91a5f72ac9c986cdb67d7d6c85bb4819e680c (diff)
downloadPeerTube-cc918ac3f45e32f031cce7b6e0473e5c2c34b8ae.tar.gz
PeerTube-cc918ac3f45e32f031cce7b6e0473e5c2c34b8ae.tar.zst
PeerTube-cc918ac3f45e32f031cce7b6e0473e5c2c34b8ae.zip
Update video-channel routes (again)
Use /video-channels now, it's more simple for clients
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/api/check-params/video-channels.ts58
-rw-r--r--server/tests/api/videos/video-channels.ts10
-rw-r--r--server/tests/api/videos/video-nsfw.ts4
-rw-r--r--server/tests/utils/videos/video-channels.ts14
-rw-r--r--server/tests/utils/videos/videos.ts3
5 files changed, 37 insertions, 52 deletions
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 25b2dc9b9..7cda879ed 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -27,10 +27,8 @@ const expect = chai.expect
27 27
28describe('Test videos API validator', function () { 28describe('Test videos API validator', function () {
29 const videoChannelPath = '/api/v1/video-channels' 29 const videoChannelPath = '/api/v1/video-channels'
30 const accountPath = '/api/v1/accounts/'
31 let server: ServerInfo 30 let server: ServerInfo
32 let accessTokenUser: string 31 let accessTokenUser: string
33 let accountUUID: string
34 let videoChannelUUID: string 32 let videoChannelUUID: string
35 33
36 // --------------------------------------------------------------- 34 // ---------------------------------------------------------------
@@ -57,7 +55,6 @@ describe('Test videos API validator', function () {
57 { 55 {
58 const res = await getMyUserInformation(server.url, server.accessToken) 56 const res = await getMyUserInformation(server.url, server.accessToken)
59 const user: User = res.body 57 const user: User = res.body
60 accountUUID = user.account.uuid
61 videoChannelUUID = user.videoChannels[0].uuid 58 videoChannelUUID = user.videoChannels[0].uuid
62 } 59 }
63 }) 60 })
@@ -92,45 +89,46 @@ describe('Test videos API validator', function () {
92 description: 'super description', 89 description: 'super description',
93 support: 'super support text' 90 support: 'super support text'
94 } 91 }
95 let path: string
96
97 before(async function () {
98 path = accountPath + accountUUID + '/video-channels'
99 })
100 92
101 it('Should fail with a non authenticated user', async function () { 93 it('Should fail with a non authenticated user', async function () {
102 await makePostBodyRequest({ url: server.url, path, token: 'none', fields: baseCorrectParams, statusCodeExpected: 401 }) 94 await makePostBodyRequest({
95 url: server.url,
96 path: videoChannelPath,
97 token: 'none',
98 fields: baseCorrectParams,
99 statusCodeExpected: 401
100 })
103 }) 101 })
104 102
105 it('Should fail with nothing', async function () { 103 it('Should fail with nothing', async function () {
106 const fields = {} 104 const fields = {}
107 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 105 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
108 }) 106 })
109 107
110 it('Should fail without name', async function () { 108 it('Should fail without name', async function () {
111 const fields = omit(baseCorrectParams, 'name') 109 const fields = omit(baseCorrectParams, 'name')
112 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 110 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
113 }) 111 })
114 112
115 it('Should fail with a long name', async function () { 113 it('Should fail with a long name', async function () {
116 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(25) }) 114 const fields = immutableAssign(baseCorrectParams, { name: 'super'.repeat(25) })
117 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 115 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
118 }) 116 })
119 117
120 it('Should fail with a long description', async function () { 118 it('Should fail with a long description', async function () {
121 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(60) }) 119 const fields = immutableAssign(baseCorrectParams, { description: 'super'.repeat(60) })
122 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 120 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
123 }) 121 })
124 122
125 it('Should fail with a long support text', async function () { 123 it('Should fail with a long support text', async function () {
126 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) }) 124 const fields = immutableAssign(baseCorrectParams, { support: 'super'.repeat(70) })
127 await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) 125 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
128 }) 126 })
129 127
130 it('Should succeed with the correct parameters', async function () { 128 it('Should succeed with the correct parameters', async function () {
131 await makePostBodyRequest({ 129 await makePostBodyRequest({
132 url: server.url, 130 url: server.url,
133 path, 131 path: videoChannelPath,
134 token: server.accessToken, 132 token: server.accessToken,
135 fields: baseCorrectParams, 133 fields: baseCorrectParams,
136 statusCodeExpected: 200 134 statusCodeExpected: 200
@@ -146,7 +144,7 @@ describe('Test videos API validator', function () {
146 let path: string 144 let path: string
147 145
148 before(async function () { 146 before(async function () {
149 path = accountPath + accountUUID + '/video-channels/' + videoChannelUUID 147 path = videoChannelPath + '/' + videoChannelUUID
150 }) 148 })
151 149
152 it('Should fail with a non authenticated user', async function () { 150 it('Should fail with a non authenticated user', async function () {
@@ -196,16 +194,10 @@ describe('Test videos API validator', function () {
196 }) 194 })
197 195
198 describe('When getting a video channel', function () { 196 describe('When getting a video channel', function () {
199 let basePath: string
200
201 before(async function () {
202 basePath = accountPath + accountUUID + '/video-channels'
203 })
204
205 it('Should return the list of the video channels with nothing', async function () { 197 it('Should return the list of the video channels with nothing', async function () {
206 const res = await makeGetRequest({ 198 const res = await makeGetRequest({
207 url: server.url, 199 url: server.url,
208 path: basePath, 200 path: videoChannelPath,
209 statusCodeExpected: 200 201 statusCodeExpected: 200
210 }) 202 })
211 203
@@ -215,7 +207,7 @@ describe('Test videos API validator', function () {
215 it('Should fail without a correct uuid', async function () { 207 it('Should fail without a correct uuid', async function () {
216 await makeGetRequest({ 208 await makeGetRequest({
217 url: server.url, 209 url: server.url,
218 path: basePath + '/coucou', 210 path: videoChannelPath + '/coucou',
219 statusCodeExpected: 400 211 statusCodeExpected: 400
220 }) 212 })
221 }) 213 })
@@ -223,7 +215,7 @@ describe('Test videos API validator', function () {
223 it('Should return 404 with an incorrect video channel', async function () { 215 it('Should return 404 with an incorrect video channel', async function () {
224 await makeGetRequest({ 216 await makeGetRequest({
225 url: server.url, 217 url: server.url,
226 path: basePath + '/4da6fde3-88f7-4d16-b119-108df5630b06', 218 path: videoChannelPath + '/4da6fde3-88f7-4d16-b119-108df5630b06',
227 statusCodeExpected: 404 219 statusCodeExpected: 404
228 }) 220 })
229 }) 221 })
@@ -231,7 +223,7 @@ describe('Test videos API validator', function () {
231 it('Should succeed with the correct parameters', async function () { 223 it('Should succeed with the correct parameters', async function () {
232 await makeGetRequest({ 224 await makeGetRequest({
233 url: server.url, 225 url: server.url,
234 path: basePath + '/' + videoChannelUUID, 226 path: videoChannelPath + '/' + videoChannelUUID,
235 statusCodeExpected: 200 227 statusCodeExpected: 200
236 }) 228 })
237 }) 229 })
@@ -239,30 +231,26 @@ describe('Test videos API validator', function () {
239 231
240 describe('When deleting a video channel', function () { 232 describe('When deleting a video channel', function () {
241 it('Should fail with a non authenticated user', async function () { 233 it('Should fail with a non authenticated user', async function () {
242 await deleteVideoChannel(server.url, 'coucou', accountUUID, videoChannelUUID, 401) 234 await deleteVideoChannel(server.url, 'coucou', videoChannelUUID, 401)
243 }) 235 })
244 236
245 it('Should fail with another authenticated user', async function () { 237 it('Should fail with another authenticated user', async function () {
246 await deleteVideoChannel(server.url, accessTokenUser, accountUUID, videoChannelUUID, 403) 238 await deleteVideoChannel(server.url, accessTokenUser, videoChannelUUID, 403)
247 })
248
249 it('Should fail with an unknown account id', async function () {
250 await deleteVideoChannel(server.url, server.accessToken, 454554,videoChannelUUID, 404)
251 }) 239 })
252 240
253 it('Should fail with an unknown video channel id', async function () { 241 it('Should fail with an unknown video channel id', async function () {
254 await deleteVideoChannel(server.url, server.accessToken, accountUUID,454554, 404) 242 await deleteVideoChannel(server.url, server.accessToken,454554, 404)
255 }) 243 })
256 244
257 it('Should succeed with the correct parameters', async function () { 245 it('Should succeed with the correct parameters', async function () {
258 await deleteVideoChannel(server.url, server.accessToken, accountUUID, videoChannelUUID) 246 await deleteVideoChannel(server.url, server.accessToken, videoChannelUUID)
259 }) 247 })
260 248
261 it('Should fail to delete the last user video channel', async function () { 249 it('Should fail to delete the last user video channel', async function () {
262 const res = await getVideoChannelsList(server.url, 0, 1) 250 const res = await getVideoChannelsList(server.url, 0, 1)
263 const lastVideoChannelUUID = res.body.data[0].uuid 251 const lastVideoChannelUUID = res.body.data[0].uuid
264 252
265 await deleteVideoChannel(server.url, server.accessToken, accountUUID, lastVideoChannelUUID, 409) 253 await deleteVideoChannel(server.url, server.accessToken, lastVideoChannelUUID, 409)
266 }) 254 })
267 }) 255 })
268 256
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 04e7b8c6a..d24b8ab0b 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -63,7 +63,7 @@ describe('Test video channels', function () {
63 description: 'super video channel description', 63 description: 'super video channel description',
64 support: 'super video channel support text' 64 support: 'super video channel support text'
65 } 65 }
66 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, accountUUID, videoChannel) 66 const res = await addVideoChannel(servers[0].url, servers[0].accessToken, videoChannel)
67 videoChannelId = res.body.videoChannel.id 67 videoChannelId = res.body.videoChannel.id
68 videoChannelUUID = res.body.videoChannel.uuid 68 videoChannelUUID = res.body.videoChannel.uuid
69 69
@@ -130,7 +130,7 @@ describe('Test video channels', function () {
130 support: 'video channel support text updated' 130 support: 'video channel support text updated'
131 } 131 }
132 132
133 await updateVideoChannel(servers[0].url, servers[0].accessToken, accountUUID, videoChannelId, videoChannelAttributes) 133 await updateVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId, videoChannelAttributes)
134 134
135 await wait(3000) 135 await wait(3000)
136 }) 136 })
@@ -149,7 +149,7 @@ describe('Test video channels', function () {
149 }) 149 })
150 150
151 it('Should get video channel', async function () { 151 it('Should get video channel', async function () {
152 const res = await getVideoChannel(servers[0].url, accountUUID, videoChannelId) 152 const res = await getVideoChannel(servers[0].url, videoChannelId)
153 153
154 const videoChannel = res.body 154 const videoChannel = res.body
155 expect(videoChannel.displayName).to.equal('video channel updated') 155 expect(videoChannel.displayName).to.equal('video channel updated')
@@ -161,7 +161,7 @@ describe('Test video channels', function () {
161 this.timeout(10000) 161 this.timeout(10000)
162 162
163 for (const server of servers) { 163 for (const server of servers) {
164 const res = await getVideoChannelVideos(server.url, server.accessToken, accountUUID, videoChannelUUID, 0, 5) 164 const res = await getVideoChannelVideos(server.url, server.accessToken, videoChannelUUID, 0, 5)
165 expect(res.body.total).to.equal(1) 165 expect(res.body.total).to.equal(1)
166 expect(res.body.data).to.be.an('array') 166 expect(res.body.data).to.be.an('array')
167 expect(res.body.data).to.have.lengthOf(1) 167 expect(res.body.data).to.have.lengthOf(1)
@@ -170,7 +170,7 @@ describe('Test video channels', function () {
170 }) 170 })
171 171
172 it('Should delete video channel', async function () { 172 it('Should delete video channel', async function () {
173 await deleteVideoChannel(servers[0].url, servers[0].accessToken, accountUUID, videoChannelId) 173 await deleteVideoChannel(servers[0].url, servers[0].accessToken, videoChannelId)
174 }) 174 })
175 175
176 it('Should have video channel deleted', async function () { 176 it('Should have video channel deleted', async function () {
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index 8901f38f9..b8c85f45b 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -39,7 +39,7 @@ describe('Test video NSFW policy', function () {
39 getVideosListWithToken(server.url, token), 39 getVideosListWithToken(server.url, token),
40 searchVideoWithToken(server.url, 'n', token), 40 searchVideoWithToken(server.url, 'n', token),
41 getAccountVideos(server.url, token, accountUUID, 0, 5), 41 getAccountVideos(server.url, token, accountUUID, 0, 5),
42 getVideoChannelVideos(server.url, token, accountUUID, videoChannelUUID, 0, 5) 42 getVideoChannelVideos(server.url, token, videoChannelUUID, 0, 5)
43 ]) 43 ])
44 } 44 }
45 45
@@ -47,7 +47,7 @@ describe('Test video NSFW policy', function () {
47 getVideosList(server.url), 47 getVideosList(server.url),
48 searchVideo(server.url, 'n'), 48 searchVideo(server.url, 'n'),
49 getAccountVideos(server.url, undefined, accountUUID, 0, 5), 49 getAccountVideos(server.url, undefined, accountUUID, 0, 5),
50 getVideoChannelVideos(server.url, undefined, accountUUID, videoChannelUUID, 0, 5) 50 getVideoChannelVideos(server.url, undefined, videoChannelUUID, 0, 5)
51 ]) 51 ])
52 }) 52 })
53 } 53 }
diff --git a/server/tests/utils/videos/video-channels.ts b/server/tests/utils/videos/video-channels.ts
index 0b4fa89b7..978e21b19 100644
--- a/server/tests/utils/videos/video-channels.ts
+++ b/server/tests/utils/videos/video-channels.ts
@@ -34,11 +34,10 @@ function getAccountVideoChannelsList (url: string, accountId: number | string, s
34function addVideoChannel ( 34function addVideoChannel (
35 url: string, 35 url: string,
36 token: string, 36 token: string,
37 accountId: number | string,
38 videoChannelAttributesArg: VideoChannelAttributes, 37 videoChannelAttributesArg: VideoChannelAttributes,
39 expectedStatus = 200 38 expectedStatus = 200
40) { 39) {
41 const path = '/api/v1/accounts/' + accountId + '/video-channels/' 40 const path = '/api/v1/video-channels/'
42 41
43 // Default attributes 42 // Default attributes
44 let attributes = { 43 let attributes = {
@@ -59,13 +58,12 @@ function addVideoChannel (
59function updateVideoChannel ( 58function updateVideoChannel (
60 url: string, 59 url: string,
61 token: string, 60 token: string,
62 accountId: number | string,
63 channelId: number | string, 61 channelId: number | string,
64 attributes: VideoChannelAttributes, 62 attributes: VideoChannelAttributes,
65 expectedStatus = 204 63 expectedStatus = 204
66) { 64) {
67 const body = {} 65 const body = {}
68 const path = '/api/v1/accounts/' + accountId + '/video-channels/' + channelId 66 const path = '/api/v1/video-channels/' + channelId
69 67
70 if (attributes.name) body['name'] = attributes.name 68 if (attributes.name) body['name'] = attributes.name
71 if (attributes.description) body['description'] = attributes.description 69 if (attributes.description) body['description'] = attributes.description
@@ -79,8 +77,8 @@ function updateVideoChannel (
79 .expect(expectedStatus) 77 .expect(expectedStatus)
80} 78}
81 79
82function deleteVideoChannel (url: string, token: string, accountId: number | string, channelId: number | string, expectedStatus = 204) { 80function deleteVideoChannel (url: string, token: string, channelId: number | string, expectedStatus = 204) {
83 const path = '/api/v1/accounts/' + accountId + '/video-channels/' + channelId 81 const path = '/api/v1/video-channels/' + channelId
84 82
85 return request(url) 83 return request(url)
86 .delete(path) 84 .delete(path)
@@ -89,8 +87,8 @@ function deleteVideoChannel (url: string, token: string, accountId: number | str
89 .expect(expectedStatus) 87 .expect(expectedStatus)
90} 88}
91 89
92function getVideoChannel (url: string, accountId: number | string, channelId: number | string) { 90function getVideoChannel (url: string, channelId: number | string) {
93 const path = '/api/v1/accounts/' + accountId + '/video-channels/' + channelId 91 const path = '/api/v1/video-channels/' + channelId
94 92
95 return request(url) 93 return request(url)
96 .get(path) 94 .get(path)
diff --git a/server/tests/utils/videos/videos.ts b/server/tests/utils/videos/videos.ts
index d1d8c07df..870dfd21f 100644
--- a/server/tests/utils/videos/videos.ts
+++ b/server/tests/utils/videos/videos.ts
@@ -186,13 +186,12 @@ function getAccountVideos (url: string, accessToken: string, accountId: number |
186function getVideoChannelVideos ( 186function getVideoChannelVideos (
187 url: string, 187 url: string,
188 accessToken: string, 188 accessToken: string,
189 accountId: number | string,
190 videoChannelId: number | string, 189 videoChannelId: number | string,
191 start: number, 190 start: number,
192 count: number, 191 count: number,
193 sort?: string 192 sort?: string
194) { 193) {
195 const path = '/api/v1/accounts/' + accountId + '/video-channels/' + videoChannelId + '/videos' 194 const path = '/api/v1/video-channels/' + videoChannelId + '/videos'
196 195
197 return makeGetRequest({ 196 return makeGetRequest({
198 url, 197 url,