diff options
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/remotes.ts | 2 | ||||
-rw-r--r-- | server/tests/api/check-params/video-channels.ts | 310 | ||||
-rw-r--r-- | server/tests/api/check-params/videos.ts | 123 |
3 files changed, 416 insertions, 19 deletions
diff --git a/server/tests/api/check-params/remotes.ts b/server/tests/api/check-params/remotes.ts index 9456ae665..6d1747442 100644 --- a/server/tests/api/check-params/remotes.ts +++ b/server/tests/api/check-params/remotes.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | 1 | /* tslint:disable:no-unused-expression */ |
2 | 2 | ||
3 | import 'mocha' | ||
4 | |||
3 | import { | 5 | import { |
4 | ServerInfo, | 6 | ServerInfo, |
5 | flushTests, | 7 | flushTests, |
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts new file mode 100644 index 000000000..b99b5eda8 --- /dev/null +++ b/server/tests/api/check-params/video-channels.ts | |||
@@ -0,0 +1,310 @@ | |||
1 | /* tslint:disable:no-unused-expression */ | ||
2 | |||
3 | import * as request from 'supertest' | ||
4 | import { join } from 'path' | ||
5 | import 'mocha' | ||
6 | import * as chai from 'chai' | ||
7 | const expect = chai.expect | ||
8 | |||
9 | import { | ||
10 | ServerInfo, | ||
11 | flushTests, | ||
12 | runServer, | ||
13 | makePutBodyRequest, | ||
14 | setAccessTokensToServers, | ||
15 | killallServers, | ||
16 | getMyUserInformation, | ||
17 | makePostBodyRequest, | ||
18 | getVideoChannelsList, | ||
19 | createUser, | ||
20 | getUserAccessToken | ||
21 | } from '../../utils' | ||
22 | |||
23 | describe('Test videos API validator', function () { | ||
24 | const path = '/api/v1/videos/channels' | ||
25 | let server: ServerInfo | ||
26 | let channelId: number | ||
27 | let accessTokenUser: string | ||
28 | |||
29 | // --------------------------------------------------------------- | ||
30 | |||
31 | before(async function () { | ||
32 | this.timeout(20000) | ||
33 | |||
34 | await flushTests() | ||
35 | |||
36 | server = await runServer(1) | ||
37 | |||
38 | await setAccessTokensToServers([ server ]) | ||
39 | |||
40 | const res = await getMyUserInformation(server.url, server.accessToken) | ||
41 | channelId = res.body.videoChannels[0].id | ||
42 | |||
43 | const user = { | ||
44 | username: 'fake', | ||
45 | password: 'fake_password' | ||
46 | } | ||
47 | await createUser(server.url, server.accessToken, user.username, user.password) | ||
48 | |||
49 | accessTokenUser = await getUserAccessToken(server, user) | ||
50 | }) | ||
51 | |||
52 | describe('When listing a video channels', function () { | ||
53 | it('Should fail with a bad start pagination', async function () { | ||
54 | await request(server.url) | ||
55 | .get(path) | ||
56 | .query({ start: 'hello' }) | ||
57 | .set('Accept', 'application/json') | ||
58 | .expect(400) | ||
59 | }) | ||
60 | |||
61 | it('Should fail with a bad count pagination', async function () { | ||
62 | await request(server.url) | ||
63 | .get(path) | ||
64 | .query({ count: 'hello' }) | ||
65 | .set('Accept', 'application/json') | ||
66 | .expect(400) | ||
67 | }) | ||
68 | |||
69 | it('Should fail with an incorrect sort', async function () { | ||
70 | await request(server.url) | ||
71 | .get(path) | ||
72 | .query({ sort: 'hello' }) | ||
73 | .set('Accept', 'application/json') | ||
74 | .expect(400) | ||
75 | }) | ||
76 | }) | ||
77 | |||
78 | describe('When listing author video channels', function () { | ||
79 | it('Should fail with bad author', async function () { | ||
80 | const path = '/api/v1/videos/authors/hello/channels' | ||
81 | |||
82 | await request(server.url) | ||
83 | .get(path) | ||
84 | .set('Accept', 'application/json') | ||
85 | .expect(400) | ||
86 | }) | ||
87 | |||
88 | it('Should fail with a unknown author', async function () { | ||
89 | const path = '/api/v1/videos/authors/156/channels' | ||
90 | |||
91 | await request(server.url) | ||
92 | .get(path) | ||
93 | .set('Accept', 'application/json') | ||
94 | .expect(404) | ||
95 | }) | ||
96 | }) | ||
97 | |||
98 | describe('When adding a video channel', function () { | ||
99 | |||
100 | it('Should fail with a non authenticated user', async function () { | ||
101 | const fields = { | ||
102 | name: 'hello', | ||
103 | description: 'super description' | ||
104 | } | ||
105 | await makePostBodyRequest({ url: server.url, path, token: 'none', fields, statusCodeExpected: 401 }) | ||
106 | }) | ||
107 | |||
108 | it('Should fail with nothing', async function () { | ||
109 | const fields = {} | ||
110 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
111 | }) | ||
112 | |||
113 | it('Should fail without name', async function () { | ||
114 | const fields = { | ||
115 | description: 'super description' | ||
116 | } | ||
117 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
118 | }) | ||
119 | |||
120 | it('Should fail with a long name', async function () { | ||
121 | const fields = { | ||
122 | name: 'hello tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' + | ||
123 | 'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo long', | ||
124 | description: 'super description' | ||
125 | } | ||
126 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
127 | }) | ||
128 | |||
129 | it('Should fail with a long description', async function () { | ||
130 | const fields = { | ||
131 | name: 'hello', | ||
132 | description: 'super toooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' + | ||
133 | 'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo0' + | ||
134 | 'ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' + | ||
135 | 'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo long description' | ||
136 | } | ||
137 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
138 | }) | ||
139 | |||
140 | it('Should succeed with the correct parameters', async function () { | ||
141 | const fields = { | ||
142 | name: 'hello', | ||
143 | description: 'super description' | ||
144 | } | ||
145 | await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 204 }) | ||
146 | }) | ||
147 | }) | ||
148 | |||
149 | describe('When updating a video channel', function () { | ||
150 | let videoChannelId | ||
151 | |||
152 | before(async function () { | ||
153 | const res = await getVideoChannelsList(server.url, 0, 1) | ||
154 | videoChannelId = res.body.data[0].id | ||
155 | }) | ||
156 | |||
157 | it('Should fail with a non authenticated user', async function () { | ||
158 | const fields = { | ||
159 | name: 'hello', | ||
160 | description: 'super description' | ||
161 | } | ||
162 | await makePutBodyRequest({ url: server.url, path: path + '/' + videoChannelId, token: 'hi', fields, statusCodeExpected: 401 }) | ||
163 | }) | ||
164 | |||
165 | it('Should fail with another authenticated user', async function () { | ||
166 | const fields = { | ||
167 | name: 'hello', | ||
168 | description: 'super description' | ||
169 | } | ||
170 | await makePutBodyRequest({ | ||
171 | url: server.url, | ||
172 | path: path + '/' + videoChannelId, | ||
173 | token: accessTokenUser, | ||
174 | fields, | ||
175 | statusCodeExpected: 403 | ||
176 | }) | ||
177 | }) | ||
178 | |||
179 | it('Should fail with a long name', async function () { | ||
180 | const fields = { | ||
181 | name: 'hello tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' + | ||
182 | 'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo long', | ||
183 | description: 'super description' | ||
184 | } | ||
185 | await makePutBodyRequest({ url: server.url, path: path + '/' + videoChannelId, token: server.accessToken, fields }) | ||
186 | }) | ||
187 | |||
188 | it('Should fail with a long description', async function () { | ||
189 | const fields = { | ||
190 | name: 'hello', | ||
191 | description: 'super toooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' + | ||
192 | 'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo0' + | ||
193 | 'ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo' + | ||
194 | 'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo long description' | ||
195 | } | ||
196 | await makePutBodyRequest({ url: server.url, path: path + '/' + videoChannelId, token: server.accessToken, fields }) | ||
197 | }) | ||
198 | |||
199 | it('Should succeed with the correct parameters', async function () { | ||
200 | const fields = { | ||
201 | name: 'hello 2', | ||
202 | description: 'super description 2' | ||
203 | } | ||
204 | await makePutBodyRequest({ | ||
205 | url: server.url, | ||
206 | path: path + '/' + videoChannelId, | ||
207 | token: server.accessToken, | ||
208 | fields, | ||
209 | statusCodeExpected: 204 | ||
210 | }) | ||
211 | }) | ||
212 | }) | ||
213 | |||
214 | describe('When getting a video channel', function () { | ||
215 | let videoChannelId: number | ||
216 | |||
217 | before(async function () { | ||
218 | const res = await getVideoChannelsList(server.url, 0, 1) | ||
219 | videoChannelId = res.body.data[0].id | ||
220 | }) | ||
221 | |||
222 | it('Should return the list of the video channels with nothing', async function () { | ||
223 | const res = await request(server.url) | ||
224 | .get(path) | ||
225 | .set('Accept', 'application/json') | ||
226 | .expect(200) | ||
227 | .expect('Content-Type', /json/) | ||
228 | |||
229 | expect(res.body.data).to.be.an('array') | ||
230 | }) | ||
231 | |||
232 | it('Should fail without a correct uuid', async function () { | ||
233 | await request(server.url) | ||
234 | .get(path + '/coucou') | ||
235 | .set('Accept', 'application/json') | ||
236 | .expect(400) | ||
237 | }) | ||
238 | |||
239 | it('Should return 404 with an incorrect video channel', async function () { | ||
240 | await request(server.url) | ||
241 | .get(path + '/4da6fde3-88f7-4d16-b119-108df5630b06') | ||
242 | .set('Accept', 'application/json') | ||
243 | .expect(404) | ||
244 | }) | ||
245 | |||
246 | it('Should succeed with the correct parameters', async function () { | ||
247 | await request(server.url) | ||
248 | .get(path + '/' + videoChannelId) | ||
249 | .set('Accept', 'application/json') | ||
250 | .expect(200) | ||
251 | }) | ||
252 | }) | ||
253 | |||
254 | describe('When deleting a video channel', function () { | ||
255 | let videoChannelId: number | ||
256 | |||
257 | before(async function () { | ||
258 | const res = await getVideoChannelsList(server.url, 0, 1) | ||
259 | videoChannelId = res.body.data[0].id | ||
260 | }) | ||
261 | |||
262 | it('Should fail with a non authenticated user', async function () { | ||
263 | await request(server.url) | ||
264 | .delete(path + '/' + videoChannelId) | ||
265 | .set('Authorization', 'Bearer coucou') | ||
266 | .expect(401) | ||
267 | }) | ||
268 | |||
269 | it('Should fail with another authenticated user', async function () { | ||
270 | await request(server.url) | ||
271 | .delete(path + '/' + videoChannelId) | ||
272 | .set('Authorization', 'Bearer ' + accessTokenUser) | ||
273 | .expect(403) | ||
274 | }) | ||
275 | |||
276 | it('Should fail with an unknown id', async function () { | ||
277 | await request(server.url) | ||
278 | .delete(path + '/454554') | ||
279 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
280 | .expect(404) | ||
281 | }) | ||
282 | |||
283 | it('Should succeed with the correct parameters', async function () { | ||
284 | await request(server.url) | ||
285 | .delete(path + '/' + videoChannelId) | ||
286 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
287 | .expect(204) | ||
288 | }) | ||
289 | |||
290 | it('Should fail to delete the last user video channel', async function () { | ||
291 | const res = await getVideoChannelsList(server.url, 0, 1) | ||
292 | videoChannelId = res.body.data[0].id | ||
293 | |||
294 | await request(server.url) | ||
295 | .delete(path + '/' + videoChannelId) | ||
296 | .set('Authorization', 'Bearer ' + server.accessToken) | ||
297 | .expect(409 | ||
298 | ) | ||
299 | }) | ||
300 | }) | ||
301 | |||
302 | after(async function () { | ||
303 | killallServers([ server ]) | ||
304 | |||
305 | // Keep the logs if the test failed | ||
306 | if (this['ok']) { | ||
307 | await flushTests() | ||
308 | } | ||
309 | }) | ||
310 | }) | ||
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index af75d33c1..167b45b61 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -14,12 +14,16 @@ import { | |||
14 | makePutBodyRequest, | 14 | makePutBodyRequest, |
15 | setAccessTokensToServers, | 15 | setAccessTokensToServers, |
16 | killallServers, | 16 | killallServers, |
17 | makePostUploadRequest | 17 | makePostUploadRequest, |
18 | getMyUserInformation, | ||
19 | createUser, | ||
20 | getUserAccessToken | ||
18 | } from '../../utils' | 21 | } from '../../utils' |
19 | 22 | ||
20 | describe('Test videos API validator', function () { | 23 | describe('Test videos API validator', function () { |
21 | const path = '/api/v1/videos/' | 24 | const path = '/api/v1/videos/' |
22 | let server: ServerInfo | 25 | let server: ServerInfo |
26 | let channelId: number | ||
23 | 27 | ||
24 | // --------------------------------------------------------------- | 28 | // --------------------------------------------------------------- |
25 | 29 | ||
@@ -31,6 +35,9 @@ describe('Test videos API validator', function () { | |||
31 | server = await runServer(1) | 35 | server = await runServer(1) |
32 | 36 | ||
33 | await setAccessTokensToServers([ server ]) | 37 | await setAccessTokensToServers([ server ]) |
38 | |||
39 | const res = await getMyUserInformation(server.url, server.accessToken) | ||
40 | channelId = res.body.videoChannels[0].id | ||
34 | }) | 41 | }) |
35 | 42 | ||
36 | describe('When listing a video', function () { | 43 | describe('When listing a video', function () { |
@@ -106,7 +113,8 @@ describe('Test videos API validator', function () { | |||
106 | language: 6, | 113 | language: 6, |
107 | nsfw: false, | 114 | nsfw: false, |
108 | description: 'my super description', | 115 | description: 'my super description', |
109 | tags: [ 'tag1', 'tag2' ] | 116 | tags: [ 'tag1', 'tag2' ], |
117 | channelId | ||
110 | } | 118 | } |
111 | const attaches = { | 119 | const attaches = { |
112 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 120 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -122,7 +130,8 @@ describe('Test videos API validator', function () { | |||
122 | language: 6, | 130 | language: 6, |
123 | nsfw: false, | 131 | nsfw: false, |
124 | description: 'my super description', | 132 | description: 'my super description', |
125 | tags: [ 'tag1', 'tag2' ] | 133 | tags: [ 'tag1', 'tag2' ], |
134 | channelId | ||
126 | } | 135 | } |
127 | const attaches = { | 136 | const attaches = { |
128 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 137 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -137,7 +146,8 @@ describe('Test videos API validator', function () { | |||
137 | language: 6, | 146 | language: 6, |
138 | nsfw: false, | 147 | nsfw: false, |
139 | description: 'my super description', | 148 | description: 'my super description', |
140 | tags: [ 'tag1', 'tag2' ] | 149 | tags: [ 'tag1', 'tag2' ], |
150 | channelId | ||
141 | } | 151 | } |
142 | const attaches = { | 152 | const attaches = { |
143 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 153 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -153,7 +163,8 @@ describe('Test videos API validator', function () { | |||
153 | language: 6, | 163 | language: 6, |
154 | nsfw: false, | 164 | nsfw: false, |
155 | description: 'my super description', | 165 | description: 'my super description', |
156 | tags: [ 'tag1', 'tag2' ] | 166 | tags: [ 'tag1', 'tag2' ], |
167 | channelId | ||
157 | } | 168 | } |
158 | const attaches = { | 169 | const attaches = { |
159 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 170 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -168,7 +179,8 @@ describe('Test videos API validator', function () { | |||
168 | language: 6, | 179 | language: 6, |
169 | nsfw: false, | 180 | nsfw: false, |
170 | description: 'my super description', | 181 | description: 'my super description', |
171 | tags: [ 'tag1', 'tag2' ] | 182 | tags: [ 'tag1', 'tag2' ], |
183 | channelId | ||
172 | } | 184 | } |
173 | const attaches = { | 185 | const attaches = { |
174 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 186 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -184,7 +196,8 @@ describe('Test videos API validator', function () { | |||
184 | language: 6, | 196 | language: 6, |
185 | nsfw: false, | 197 | nsfw: false, |
186 | description: 'my super description', | 198 | description: 'my super description', |
187 | tags: [ 'tag1', 'tag2' ] | 199 | tags: [ 'tag1', 'tag2' ], |
200 | channelId | ||
188 | } | 201 | } |
189 | const attaches = { | 202 | const attaches = { |
190 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 203 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -200,7 +213,8 @@ describe('Test videos API validator', function () { | |||
200 | language: 563, | 213 | language: 563, |
201 | nsfw: false, | 214 | nsfw: false, |
202 | description: 'my super description', | 215 | description: 'my super description', |
203 | tags: [ 'tag1', 'tag2' ] | 216 | tags: [ 'tag1', 'tag2' ], |
217 | channelId | ||
204 | } | 218 | } |
205 | const attaches = { | 219 | const attaches = { |
206 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 220 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -215,7 +229,8 @@ describe('Test videos API validator', function () { | |||
215 | licence: 4, | 229 | licence: 4, |
216 | language: 6, | 230 | language: 6, |
217 | description: 'my super description', | 231 | description: 'my super description', |
218 | tags: [ 'tag1', 'tag2' ] | 232 | tags: [ 'tag1', 'tag2' ], |
233 | channelId | ||
219 | } | 234 | } |
220 | const attaches = { | 235 | const attaches = { |
221 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 236 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -223,7 +238,7 @@ describe('Test videos API validator', function () { | |||
223 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 238 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
224 | }) | 239 | }) |
225 | 240 | ||
226 | it('Should fail with a bad nsfw attribue', async function () { | 241 | it('Should fail with a bad nsfw attribute', async function () { |
227 | const fields = { | 242 | const fields = { |
228 | name: 'my super name', | 243 | name: 'my super name', |
229 | category: 5, | 244 | category: 5, |
@@ -231,7 +246,8 @@ describe('Test videos API validator', function () { | |||
231 | language: 6, | 246 | language: 6, |
232 | nsfw: 2, | 247 | nsfw: 2, |
233 | description: 'my super description', | 248 | description: 'my super description', |
234 | tags: [ 'tag1', 'tag2' ] | 249 | tags: [ 'tag1', 'tag2' ], |
250 | channelId | ||
235 | } | 251 | } |
236 | const attaches = { | 252 | const attaches = { |
237 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 253 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -246,7 +262,8 @@ describe('Test videos API validator', function () { | |||
246 | licence: 1, | 262 | licence: 1, |
247 | language: 6, | 263 | language: 6, |
248 | nsfw: false, | 264 | nsfw: false, |
249 | tags: [ 'tag1', 'tag2' ] | 265 | tags: [ 'tag1', 'tag2' ], |
266 | channelId | ||
250 | } | 267 | } |
251 | const attaches = { | 268 | const attaches = { |
252 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 269 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -264,6 +281,23 @@ describe('Test videos API validator', function () { | |||
264 | description: 'my super description which is very very very very very very very very very very very very very very' + | 281 | description: 'my super description which is very very very very very very very very very very very very very very' + |
265 | 'very very very very very very very very very very very very very very very very very very very very very' + | 282 | 'very very very very very very very very very very very very very very very very very very very very very' + |
266 | 'very very very very very very very very very very very very very very very long', | 283 | 'very very very very very very very very very very very very very very very long', |
284 | tags: [ 'tag1', 'tag2' ], | ||
285 | channelId | ||
286 | } | ||
287 | const attaches = { | ||
288 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
289 | } | ||
290 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | ||
291 | }) | ||
292 | |||
293 | it('Should fail without a channel', async function () { | ||
294 | const fields = { | ||
295 | name: 'my super name', | ||
296 | category: 5, | ||
297 | licence: 1, | ||
298 | language: 6, | ||
299 | nsfw: false, | ||
300 | description: 'my super description', | ||
267 | tags: [ 'tag1', 'tag2' ] | 301 | tags: [ 'tag1', 'tag2' ] |
268 | } | 302 | } |
269 | const attaches = { | 303 | const attaches = { |
@@ -272,6 +306,50 @@ describe('Test videos API validator', function () { | |||
272 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 306 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
273 | }) | 307 | }) |
274 | 308 | ||
309 | it('Should fail with a bad channel', async function () { | ||
310 | const fields = { | ||
311 | name: 'my super name', | ||
312 | category: 5, | ||
313 | licence: 1, | ||
314 | language: 6, | ||
315 | nsfw: false, | ||
316 | description: 'my super description', | ||
317 | tags: [ 'tag1', 'tag2' ], | ||
318 | channelId: 545454 | ||
319 | } | ||
320 | const attaches = { | ||
321 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
322 | } | ||
323 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | ||
324 | }) | ||
325 | |||
326 | it('Should fail with another user channel', async function () { | ||
327 | const user = { | ||
328 | username: 'fake', | ||
329 | password: 'fake_password' | ||
330 | } | ||
331 | await createUser(server.url, server.accessToken, user.username, user.password) | ||
332 | |||
333 | const accessTokenUser = await getUserAccessToken(server, user) | ||
334 | const res = await getMyUserInformation(server.url, accessTokenUser) | ||
335 | const channelId = res.body.videoChannels[0].id | ||
336 | |||
337 | const fields = { | ||
338 | name: 'my super name', | ||
339 | category: 5, | ||
340 | licence: 1, | ||
341 | language: 6, | ||
342 | nsfw: false, | ||
343 | description: 'my super description', | ||
344 | tags: [ 'tag1', 'tag2' ], | ||
345 | channelId | ||
346 | } | ||
347 | const attaches = { | ||
348 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | ||
349 | } | ||
350 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | ||
351 | }) | ||
352 | |||
275 | it('Should fail with too many tags', async function () { | 353 | it('Should fail with too many tags', async function () { |
276 | const fields = { | 354 | const fields = { |
277 | name: 'my super name', | 355 | name: 'my super name', |
@@ -280,7 +358,8 @@ describe('Test videos API validator', function () { | |||
280 | language: 6, | 358 | language: 6, |
281 | nsfw: false, | 359 | nsfw: false, |
282 | description: 'my super description', | 360 | description: 'my super description', |
283 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ] | 361 | tags: [ 'tag1', 'tag2', 'tag3', 'tag4' ], |
362 | channelId | ||
284 | } | 363 | } |
285 | const attaches = { | 364 | const attaches = { |
286 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 365 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -296,7 +375,8 @@ describe('Test videos API validator', function () { | |||
296 | language: 6, | 375 | language: 6, |
297 | nsfw: false, | 376 | nsfw: false, |
298 | description: 'my super description', | 377 | description: 'my super description', |
299 | tags: [ 'tag1', 't' ] | 378 | tags: [ 'tag1', 't' ], |
379 | channelId | ||
300 | } | 380 | } |
301 | const attaches = { | 381 | const attaches = { |
302 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 382 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -312,7 +392,8 @@ describe('Test videos API validator', function () { | |||
312 | language: 6, | 392 | language: 6, |
313 | nsfw: false, | 393 | nsfw: false, |
314 | description: 'my super description', | 394 | description: 'my super description', |
315 | tags: [ 'my_super_tag_too_long', 'tag1' ] | 395 | tags: [ 'my_super_tag_too_long', 'tag1' ], |
396 | channelId | ||
316 | } | 397 | } |
317 | const attaches = { | 398 | const attaches = { |
318 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 399 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |
@@ -328,7 +409,8 @@ describe('Test videos API validator', function () { | |||
328 | language: 6, | 409 | language: 6, |
329 | nsfw: false, | 410 | nsfw: false, |
330 | description: 'my super description', | 411 | description: 'my super description', |
331 | tags: [ 'tag1', 'tag2' ] | 412 | tags: [ 'tag1', 'tag2' ], |
413 | channelId | ||
332 | } | 414 | } |
333 | const attaches = {} | 415 | const attaches = {} |
334 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) | 416 | await makePostUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) |
@@ -342,7 +424,8 @@ describe('Test videos API validator', function () { | |||
342 | language: 6, | 424 | language: 6, |
343 | nsfw: false, | 425 | nsfw: false, |
344 | description: 'my super description', | 426 | description: 'my super description', |
345 | tags: [ 'tag1', 'tag2' ] | 427 | tags: [ 'tag1', 'tag2' ], |
428 | channelId | ||
346 | } | 429 | } |
347 | const attaches = { | 430 | const attaches = { |
348 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') | 431 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short_fake.webm') |
@@ -358,7 +441,8 @@ describe('Test videos API validator', function () { | |||
358 | language: 6, | 441 | language: 6, |
359 | nsfw: false, | 442 | nsfw: false, |
360 | description: 'my super description', | 443 | description: 'my super description', |
361 | tags: [ 'tag1', 'tag2' ] | 444 | tags: [ 'tag1', 'tag2' ], |
445 | channelId | ||
362 | } | 446 | } |
363 | const attaches = { | 447 | const attaches = { |
364 | 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm') | 448 | 'videofile': join(__dirname, '..', 'fixtures', 'video_too_long.webm') |
@@ -376,7 +460,8 @@ describe('Test videos API validator', function () { | |||
376 | language: 6, | 460 | language: 6, |
377 | nsfw: false, | 461 | nsfw: false, |
378 | description: 'my super description', | 462 | description: 'my super description', |
379 | tags: [ 'tag1', 'tag2' ] | 463 | tags: [ 'tag1', 'tag2' ], |
464 | channelId | ||
380 | } | 465 | } |
381 | const attaches = { | 466 | const attaches = { |
382 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') | 467 | 'videofile': join(__dirname, '..', 'fixtures', 'video_short.webm') |