aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-17 15:45:42 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commit8a19bee1a1ee39f973bb37429e4f73c3f2873cdb (patch)
tree33c93ef19451d7e46d4be74ce0681359d2dcc70e /server/tests/api/check-params
parent965c4b22d0e4d2f853501e844e6ebbb861bd389d (diff)
downloadPeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.tar.gz
PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.tar.zst
PeerTube-8a19bee1a1ee39f973bb37429e4f73c3f2873cdb.zip
Add ability to set a name to a channel
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts19
-rw-r--r--server/tests/api/check-params/video-channels.ts47
2 files changed, 26 insertions, 40 deletions
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 9f7d15b27..628a74476 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -5,7 +5,6 @@ import 'mocha'
5import { 5import {
6 createUser, 6 createUser,
7 flushTests, 7 flushTests,
8 getMyUserInformation,
9 killallServers, 8 killallServers,
10 makeDeleteRequest, 9 makeDeleteRequest,
11 makeGetRequest, 10 makeGetRequest,
@@ -21,7 +20,6 @@ describe('Test user subscriptions API validators', function () {
21 const path = '/api/v1/users/me/subscriptions' 20 const path = '/api/v1/users/me/subscriptions'
22 let server: ServerInfo 21 let server: ServerInfo
23 let userAccessToken = '' 22 let userAccessToken = ''
24 let userChannelUUID: string
25 23
26 // --------------------------------------------------------------- 24 // ---------------------------------------------------------------
27 25
@@ -40,11 +38,6 @@ describe('Test user subscriptions API validators', function () {
40 } 38 }
41 await createUser(server.url, server.accessToken, user.username, user.password) 39 await createUser(server.url, server.accessToken, user.username, user.password)
42 userAccessToken = await userLogin(server, user) 40 userAccessToken = await userLogin(server, user)
43
44 {
45 const res = await getMyUserInformation(server.url, server.accessToken)
46 userChannelUUID = res.body.videoChannels[ 0 ].uuid
47 }
48 }) 41 })
49 42
50 describe('When listing my subscriptions', function () { 43 describe('When listing my subscriptions', function () {
@@ -69,7 +62,7 @@ describe('Test user subscriptions API validators', function () {
69 }) 62 })
70 63
71 it('Should success with the correct parameters', async function () { 64 it('Should success with the correct parameters', async function () {
72 await await makeGetRequest({ 65 await makeGetRequest({
73 url: server.url, 66 url: server.url,
74 path, 67 path,
75 token: userAccessToken, 68 token: userAccessToken,
@@ -102,7 +95,7 @@ describe('Test user subscriptions API validators', function () {
102 }) 95 })
103 96
104 it('Should success with the correct parameters', async function () { 97 it('Should success with the correct parameters', async function () {
105 await await makeGetRequest({ 98 await makeGetRequest({
106 url: server.url, 99 url: server.url,
107 path, 100 path,
108 token: userAccessToken, 101 token: userAccessToken,
@@ -116,7 +109,7 @@ describe('Test user subscriptions API validators', function () {
116 await makePostBodyRequest({ 109 await makePostBodyRequest({
117 url: server.url, 110 url: server.url,
118 path, 111 path,
119 fields: { uri: userChannelUUID + '@localhost:9001' }, 112 fields: { uri: 'user1_channel@localhost:9001' },
120 statusCodeExpected: 401 113 statusCodeExpected: 401
121 }) 114 })
122 }) 115 })
@@ -152,7 +145,7 @@ describe('Test user subscriptions API validators', function () {
152 url: server.url, 145 url: server.url,
153 path, 146 path,
154 token: server.accessToken, 147 token: server.accessToken,
155 fields: { uri: userChannelUUID + '@localhost:9001' }, 148 fields: { uri: 'user1_channel@localhost:9001' },
156 statusCodeExpected: 204 149 statusCodeExpected: 204
157 }) 150 })
158 }) 151 })
@@ -162,7 +155,7 @@ describe('Test user subscriptions API validators', function () {
162 it('Should fail with a non authenticated user', async function () { 155 it('Should fail with a non authenticated user', async function () {
163 await makeDeleteRequest({ 156 await makeDeleteRequest({
164 url: server.url, 157 url: server.url,
165 path: path + '/' + userChannelUUID + '@localhost:9001', 158 path: path + '/user1_channel@localhost:9001',
166 statusCodeExpected: 401 159 statusCodeExpected: 401
167 }) 160 })
168 }) 161 })
@@ -202,7 +195,7 @@ describe('Test user subscriptions API validators', function () {
202 it('Should success with the correct parameters', async function () { 195 it('Should success with the correct parameters', async function () {
203 await makeDeleteRequest({ 196 await makeDeleteRequest({
204 url: server.url, 197 url: server.url,
205 path: path + '/' + userChannelUUID + '@localhost:9001', 198 path: path + '/user1_channel@localhost:9001',
206 token: server.accessToken, 199 token: server.accessToken,
207 statusCodeExpected: 204 200 statusCodeExpected: 204
208 }) 201 })
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 0980de73b..bcf4b7473 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -31,7 +31,6 @@ describe('Test video channels API validator', function () {
31 const videoChannelPath = '/api/v1/video-channels' 31 const videoChannelPath = '/api/v1/video-channels'
32 let server: ServerInfo 32 let server: ServerInfo
33 let accessTokenUser: string 33 let accessTokenUser: string
34 let videoChannelUUID: string
35 34
36 // --------------------------------------------------------------- 35 // ---------------------------------------------------------------
37 36
@@ -53,12 +52,6 @@ describe('Test video channels API validator', function () {
53 await createUser(server.url, server.accessToken, user.username, user.password) 52 await createUser(server.url, server.accessToken, user.username, user.password)
54 accessTokenUser = await userLogin(server, user) 53 accessTokenUser = await userLogin(server, user)
55 } 54 }
56
57 {
58 const res = await getMyUserInformation(server.url, server.accessToken)
59 const user: User = res.body
60 videoChannelUUID = user.videoChannels[0].uuid
61 }
62 }) 55 })
63 56
64 describe('When listing a video channels', function () { 57 describe('When listing a video channels', function () {
@@ -83,6 +76,7 @@ describe('Test video channels API validator', function () {
83 76
84 describe('When adding a video channel', function () { 77 describe('When adding a video channel', function () {
85 const baseCorrectParams = { 78 const baseCorrectParams = {
79 name: 'super_channel',
86 displayName: 'hello', 80 displayName: 'hello',
87 description: 'super description', 81 description: 'super description',
88 support: 'super support text' 82 support: 'super support text'
@@ -104,6 +98,16 @@ describe('Test video channels API validator', function () {
104 }) 98 })
105 99
106 it('Should fail without a name', async function () { 100 it('Should fail without a name', async function () {
101 const fields = omit(baseCorrectParams, 'name')
102 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
103 })
104
105 it('Should fail with a bad name', async function () {
106 const fields = immutableAssign(baseCorrectParams, { name: 'super name' })
107 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
108 })
109
110 it('Should fail without a name', async function () {
107 const fields = omit(baseCorrectParams, 'displayName') 111 const fields = omit(baseCorrectParams, 'displayName')
108 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields }) 112 await makePostBodyRequest({ url: server.url, path: videoChannelPath, token: server.accessToken, fields })
109 }) 113 })
@@ -142,7 +146,7 @@ describe('Test video channels API validator', function () {
142 let path: string 146 let path: string
143 147
144 before(async function () { 148 before(async function () {
145 path = videoChannelPath + '/' + videoChannelUUID 149 path = videoChannelPath + '/super_channel'
146 }) 150 })
147 151
148 it('Should fail with a non authenticated user', async function () { 152 it('Should fail with a non authenticated user', async function () {
@@ -195,7 +199,7 @@ describe('Test video channels API validator', function () {
195 let path: string 199 let path: string
196 200
197 before(async function () { 201 before(async function () {
198 path = videoChannelPath + '/' + videoChannelUUID 202 path = videoChannelPath + '/super_channel'
199 }) 203 })
200 204
201 it('Should fail with an incorrect input file', async function () { 205 it('Should fail with an incorrect input file', async function () {
@@ -255,18 +259,10 @@ describe('Test video channels API validator', function () {
255 expect(res.body.data).to.be.an('array') 259 expect(res.body.data).to.be.an('array')
256 }) 260 })
257 261
258 it('Should fail without a correct uuid', async function () {
259 await makeGetRequest({
260 url: server.url,
261 path: videoChannelPath + '/coucou',
262 statusCodeExpected: 400
263 })
264 })
265
266 it('Should return 404 with an incorrect video channel', async function () { 262 it('Should return 404 with an incorrect video channel', async function () {
267 await makeGetRequest({ 263 await makeGetRequest({
268 url: server.url, 264 url: server.url,
269 path: videoChannelPath + '/4da6fde3-88f7-4d16-b119-108df5630b06', 265 path: videoChannelPath + '/super_channel2',
270 statusCodeExpected: 404 266 statusCodeExpected: 404
271 }) 267 })
272 }) 268 })
@@ -274,7 +270,7 @@ describe('Test video channels API validator', function () {
274 it('Should succeed with the correct parameters', async function () { 270 it('Should succeed with the correct parameters', async function () {
275 await makeGetRequest({ 271 await makeGetRequest({
276 url: server.url, 272 url: server.url,
277 path: videoChannelPath + '/' + videoChannelUUID, 273 path: videoChannelPath + '/super_channel',
278 statusCodeExpected: 200 274 statusCodeExpected: 200
279 }) 275 })
280 }) 276 })
@@ -282,26 +278,23 @@ describe('Test video channels API validator', function () {
282 278
283 describe('When deleting a video channel', function () { 279 describe('When deleting a video channel', function () {
284 it('Should fail with a non authenticated user', async function () { 280 it('Should fail with a non authenticated user', async function () {
285 await deleteVideoChannel(server.url, 'coucou', videoChannelUUID, 401) 281 await deleteVideoChannel(server.url, 'coucou', 'super_channel', 401)
286 }) 282 })
287 283
288 it('Should fail with another authenticated user', async function () { 284 it('Should fail with another authenticated user', async function () {
289 await deleteVideoChannel(server.url, accessTokenUser, videoChannelUUID, 403) 285 await deleteVideoChannel(server.url, accessTokenUser, 'super_channel', 403)
290 }) 286 })
291 287
292 it('Should fail with an unknown video channel id', async function () { 288 it('Should fail with an unknown video channel id', async function () {
293 await deleteVideoChannel(server.url, server.accessToken,454554, 404) 289 await deleteVideoChannel(server.url, server.accessToken,'super_channel2', 404)
294 }) 290 })
295 291
296 it('Should succeed with the correct parameters', async function () { 292 it('Should succeed with the correct parameters', async function () {
297 await deleteVideoChannel(server.url, server.accessToken, videoChannelUUID) 293 await deleteVideoChannel(server.url, server.accessToken, 'super_channel')
298 }) 294 })
299 295
300 it('Should fail to delete the last user video channel', async function () { 296 it('Should fail to delete the last user video channel', async function () {
301 const res = await getVideoChannelsList(server.url, 0, 1) 297 await deleteVideoChannel(server.url, server.accessToken, 'root_channel', 409)
302 const lastVideoChannelUUID = res.body.data[0].uuid
303
304 await deleteVideoChannel(server.url, server.accessToken, lastVideoChannelUUID, 409)
305 }) 298 })
306 }) 299 })
307 300