diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-25 16:15:39 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-25 16:16:21 +0200 |
commit | cc918ac3f45e32f031cce7b6e0473e5c2c34b8ae (patch) | |
tree | 034c0ce9cda37d572fe1c0c34eff750681e18574 /server/tests/api/check-params | |
parent | d3e91a5f72ac9c986cdb67d7d6c85bb4819e680c (diff) | |
download | PeerTube-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/api/check-params')
-rw-r--r-- | server/tests/api/check-params/video-channels.ts | 58 |
1 files changed, 23 insertions, 35 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 | ||
28 | describe('Test videos API validator', function () { | 28 | describe('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 | ||