diff options
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r-- | server/tests/api/check-params/config.ts | 4 | ||||
-rw-r--r-- | server/tests/api/check-params/users.ts | 45 | ||||
-rw-r--r-- | server/tests/api/check-params/video-channels.ts | 36 | ||||
-rw-r--r-- | server/tests/api/check-params/video-playlists.ts | 12 |
4 files changed, 77 insertions, 20 deletions
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 2a2ec606a..a0d9392dc 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -59,13 +59,15 @@ describe('Test config API validators', function () { | |||
59 | transcoding: { | 59 | transcoding: { |
60 | enabled: true, | 60 | enabled: true, |
61 | allowAdditionalExtensions: true, | 61 | allowAdditionalExtensions: true, |
62 | allowAudioFiles: true, | ||
62 | threads: 1, | 63 | threads: 1, |
63 | resolutions: { | 64 | resolutions: { |
64 | '240p': false, | 65 | '240p': false, |
65 | '360p': true, | 66 | '360p': true, |
66 | '480p': true, | 67 | '480p': true, |
67 | '720p': false, | 68 | '720p': false, |
68 | '1080p': false | 69 | '1080p': false, |
70 | '2160p': false | ||
69 | }, | 71 | }, |
70 | hls: { | 72 | hls: { |
71 | enabled: false | 73 | enabled: false |
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index 5935104a5..2316033a1 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -6,6 +6,7 @@ import { join } from 'path' | |||
6 | import { UserRole, VideoImport, VideoImportState } from '../../../../shared' | 6 | import { UserRole, VideoImport, VideoImportState } from '../../../../shared' |
7 | 7 | ||
8 | import { | 8 | import { |
9 | addVideoChannel, | ||
9 | blockUser, | 10 | blockUser, |
10 | cleanupTests, | 11 | cleanupTests, |
11 | createUser, | 12 | createUser, |
@@ -378,8 +379,7 @@ describe('Test users API validators', function () { | |||
378 | it('Should succeed without password change with the correct params', async function () { | 379 | it('Should succeed without password change with the correct params', async function () { |
379 | const fields = { | 380 | const fields = { |
380 | nsfwPolicy: 'blur', | 381 | nsfwPolicy: 'blur', |
381 | autoPlayVideo: false, | 382 | autoPlayVideo: false |
382 | email: 'super_email@example.com' | ||
383 | } | 383 | } |
384 | 384 | ||
385 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 }) | 385 | await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 }) |
@@ -638,10 +638,11 @@ describe('Test users API validators', function () { | |||
638 | }) | 638 | }) |
639 | }) | 639 | }) |
640 | 640 | ||
641 | describe('When register a new user', function () { | 641 | describe('When registering a new user', function () { |
642 | const registrationPath = path + '/register' | 642 | const registrationPath = path + '/register' |
643 | const baseCorrectParams = { | 643 | const baseCorrectParams = { |
644 | username: 'user3', | 644 | username: 'user3', |
645 | displayName: 'super user', | ||
645 | email: 'test3@example.com', | 646 | email: 'test3@example.com', |
646 | password: 'my super password' | 647 | password: 'my super password' |
647 | } | 648 | } |
@@ -724,12 +725,48 @@ describe('Test users API validators', function () { | |||
724 | }) | 725 | }) |
725 | }) | 726 | }) |
726 | 727 | ||
728 | it('Should fail with a bad display name', async function () { | ||
729 | const fields = immutableAssign(baseCorrectParams, { displayName: 'a'.repeat(150) }) | ||
730 | |||
731 | await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) | ||
732 | }) | ||
733 | |||
734 | it('Should fail with a bad channel name', async function () { | ||
735 | const fields = immutableAssign(baseCorrectParams, { channel: { name: '[]azf', displayName: 'toto' } }) | ||
736 | |||
737 | await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) | ||
738 | }) | ||
739 | |||
740 | it('Should fail with a bad channel display name', async function () { | ||
741 | const fields = immutableAssign(baseCorrectParams, { channel: { name: 'toto', displayName: '' } }) | ||
742 | |||
743 | await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) | ||
744 | }) | ||
745 | |||
746 | it('Should fail with a channel name that is the same than user username', async function () { | ||
747 | const source = { username: 'super_user', channel: { name: 'super_user', displayName: 'display name' } } | ||
748 | const fields = immutableAssign(baseCorrectParams, source) | ||
749 | |||
750 | await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields }) | ||
751 | }) | ||
752 | |||
753 | it('Should fail with an existing channel', async function () { | ||
754 | const videoChannelAttributesArg = { name: 'existing_channel', displayName: 'hello', description: 'super description' } | ||
755 | await addVideoChannel(server.url, server.accessToken, videoChannelAttributesArg) | ||
756 | |||
757 | const fields = immutableAssign(baseCorrectParams, { channel: { name: 'existing_channel', displayName: 'toto' } }) | ||
758 | |||
759 | await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields, statusCodeExpected: 409 }) | ||
760 | }) | ||
761 | |||
727 | it('Should succeed with the correct params', async function () { | 762 | it('Should succeed with the correct params', async function () { |
763 | const fields = immutableAssign(baseCorrectParams, { channel: { name: 'super_channel', displayName: 'toto' } }) | ||
764 | |||
728 | await makePostBodyRequest({ | 765 | await makePostBodyRequest({ |
729 | url: server.url, | 766 | url: server.url, |
730 | path: registrationPath, | 767 | path: registrationPath, |
731 | token: server.accessToken, | 768 | token: server.accessToken, |
732 | fields: baseCorrectParams, | 769 | fields: fields, |
733 | statusCodeExpected: 204 | 770 | statusCodeExpected: 204 |
734 | }) | 771 | }) |
735 | }) | 772 | }) |
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index 65bc20613..de88298d1 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts | |||
@@ -24,6 +24,7 @@ import { | |||
24 | checkBadStartPagination | 24 | checkBadStartPagination |
25 | } from '../../../../shared/extra-utils/requests/check-api-params' | 25 | } from '../../../../shared/extra-utils/requests/check-api-params' |
26 | import { join } from 'path' | 26 | import { join } from 'path' |
27 | import { VideoChannelUpdate } from '../../../../shared/models/videos' | ||
27 | 28 | ||
28 | const expect = chai.expect | 29 | const expect = chai.expect |
29 | 30 | ||
@@ -67,8 +68,30 @@ describe('Test video channels API validator', function () { | |||
67 | }) | 68 | }) |
68 | 69 | ||
69 | describe('When listing account video channels', function () { | 70 | describe('When listing account video channels', function () { |
71 | const accountChannelPath = '/api/v1/accounts/fake/video-channels' | ||
72 | |||
73 | it('Should fail with a bad start pagination', async function () { | ||
74 | await checkBadStartPagination(server.url, accountChannelPath, server.accessToken) | ||
75 | }) | ||
76 | |||
77 | it('Should fail with a bad count pagination', async function () { | ||
78 | await checkBadCountPagination(server.url, accountChannelPath, server.accessToken) | ||
79 | }) | ||
80 | |||
81 | it('Should fail with an incorrect sort', async function () { | ||
82 | await checkBadSortPagination(server.url, accountChannelPath, server.accessToken) | ||
83 | }) | ||
84 | |||
70 | it('Should fail with a unknown account', async function () { | 85 | it('Should fail with a unknown account', async function () { |
71 | await getAccountVideoChannelsList(server.url, 'unknown', 404) | 86 | await getAccountVideoChannelsList({ url: server.url, accountName: 'unknown', specialStatus: 404 }) |
87 | }) | ||
88 | |||
89 | it('Should succeed with the correct parameters', async function () { | ||
90 | await makeGetRequest({ | ||
91 | url: server.url, | ||
92 | path: accountChannelPath, | ||
93 | statusCodeExpected: 200 | ||
94 | }) | ||
72 | }) | 95 | }) |
73 | }) | 96 | }) |
74 | 97 | ||
@@ -147,9 +170,11 @@ describe('Test video channels API validator', function () { | |||
147 | }) | 170 | }) |
148 | 171 | ||
149 | describe('When updating a video channel', function () { | 172 | describe('When updating a video channel', function () { |
150 | const baseCorrectParams = { | 173 | const baseCorrectParams: VideoChannelUpdate = { |
151 | displayName: 'hello', | 174 | displayName: 'hello', |
152 | description: 'super description' | 175 | description: 'super description', |
176 | support: 'toto', | ||
177 | bulkVideosSupportUpdate: false | ||
153 | } | 178 | } |
154 | let path: string | 179 | let path: string |
155 | 180 | ||
@@ -192,6 +217,11 @@ describe('Test video channels API validator', function () { | |||
192 | await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | 217 | await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) |
193 | }) | 218 | }) |
194 | 219 | ||
220 | it('Should fail with a bad bulkVideosSupportUpdate field', async function () { | ||
221 | const fields = immutableAssign(baseCorrectParams, { bulkVideosSupportUpdate: 'super' }) | ||
222 | await makePutBodyRequest({ url: server.url, path, token: server.accessToken, fields }) | ||
223 | }) | ||
224 | |||
195 | it('Should succeed with the correct parameters', async function () { | 225 | it('Should succeed with the correct parameters', async function () { |
196 | await makePutBodyRequest({ | 226 | await makePutBodyRequest({ |
197 | url: server.url, | 227 | url: server.url, |
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts index b7b94c035..8c5e44bdd 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts | |||
@@ -205,7 +205,6 @@ describe('Test video playlists API validator', function () { | |||
205 | const params = getBase({ displayName: undefined }) | 205 | const params = getBase({ displayName: undefined }) |
206 | 206 | ||
207 | await createVideoPlaylist(params) | 207 | await createVideoPlaylist(params) |
208 | await updateVideoPlaylist(getUpdate(params, playlistUUID)) | ||
209 | }) | 208 | }) |
210 | 209 | ||
211 | it('Should fail with an incorrect display name', async function () { | 210 | it('Should fail with an incorrect display name', async function () { |
@@ -269,17 +268,6 @@ describe('Test video playlists API validator', function () { | |||
269 | )) | 268 | )) |
270 | }) | 269 | }) |
271 | 270 | ||
272 | it('Should fail to update to private a public/unlisted playlist', async function () { | ||
273 | const params = getBase({ privacy: VideoPlaylistPrivacy.PUBLIC }, { expectedStatus: 200 }) | ||
274 | |||
275 | const res = await createVideoPlaylist(params) | ||
276 | const playlist = res.body.videoPlaylist | ||
277 | |||
278 | const paramsUpdate = getBase({ privacy: VideoPlaylistPrivacy.PRIVATE }, { expectedStatus: 400 }) | ||
279 | |||
280 | await updateVideoPlaylist(getUpdate(paramsUpdate, playlist.id)) | ||
281 | }) | ||
282 | |||
283 | it('Should fail to update the watch later playlist', async function () { | 271 | it('Should fail to update the watch later playlist', async function () { |
284 | await updateVideoPlaylist(getUpdate( | 272 | await updateVideoPlaylist(getUpdate( |
285 | getBase({}, { expectedStatus: 400 }), | 273 | getBase({}, { expectedStatus: 400 }), |