diff options
Diffstat (limited to 'server/tests/api/check-params/videos-filter.ts')
-rw-r--r-- | server/tests/api/check-params/videos-filter.ts | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts index bf8248b0e..2391584a7 100644 --- a/server/tests/api/check-params/videos-filter.ts +++ b/server/tests/api/check-params/videos-filter.ts | |||
@@ -12,8 +12,9 @@ import { | |||
12 | userLogin | 12 | userLogin |
13 | } from '../../../../shared/extra-utils' | 13 | } from '../../../../shared/extra-utils' |
14 | import { UserRole } from '../../../../shared/models/users' | 14 | import { UserRole } from '../../../../shared/models/users' |
15 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
15 | 16 | ||
16 | async function testEndpoints (server: ServerInfo, token: string, filter: string, statusCodeExpected: number) { | 17 | async function testEndpoints (server: ServerInfo, token: string, filter: string, statusCodeExpected: HttpStatusCode) { |
17 | const paths = [ | 18 | const paths = [ |
18 | '/api/v1/video-channels/root_channel/videos', | 19 | '/api/v1/video-channels/root_channel/videos', |
19 | '/api/v1/accounts/root/videos', | 20 | '/api/v1/accounts/root/videos', |
@@ -71,26 +72,26 @@ describe('Test videos filters', function () { | |||
71 | describe('When setting a video filter', function () { | 72 | describe('When setting a video filter', function () { |
72 | 73 | ||
73 | it('Should fail with a bad filter', async function () { | 74 | it('Should fail with a bad filter', async function () { |
74 | await testEndpoints(server, server.accessToken, 'bad-filter', 400) | 75 | await testEndpoints(server, server.accessToken, 'bad-filter', HttpStatusCode.BAD_REQUEST_400) |
75 | }) | 76 | }) |
76 | 77 | ||
77 | it('Should succeed with a good filter', async function () { | 78 | it('Should succeed with a good filter', async function () { |
78 | await testEndpoints(server, server.accessToken, 'local', 200) | 79 | await testEndpoints(server, server.accessToken, 'local', HttpStatusCode.OK_200) |
79 | }) | 80 | }) |
80 | 81 | ||
81 | it('Should fail to list all-local/all with a simple user', async function () { | 82 | it('Should fail to list all-local/all with a simple user', async function () { |
82 | await testEndpoints(server, userAccessToken, 'all-local', 401) | 83 | await testEndpoints(server, userAccessToken, 'all-local', HttpStatusCode.UNAUTHORIZED_401) |
83 | await testEndpoints(server, userAccessToken, 'all', 401) | 84 | await testEndpoints(server, userAccessToken, 'all', HttpStatusCode.UNAUTHORIZED_401) |
84 | }) | 85 | }) |
85 | 86 | ||
86 | it('Should succeed to list all-local/all with a moderator', async function () { | 87 | it('Should succeed to list all-local/all with a moderator', async function () { |
87 | await testEndpoints(server, moderatorAccessToken, 'all-local', 200) | 88 | await testEndpoints(server, moderatorAccessToken, 'all-local', HttpStatusCode.OK_200) |
88 | await testEndpoints(server, moderatorAccessToken, 'all', 200) | 89 | await testEndpoints(server, moderatorAccessToken, 'all', HttpStatusCode.OK_200) |
89 | }) | 90 | }) |
90 | 91 | ||
91 | it('Should succeed to list all-local/all with an admin', async function () { | 92 | it('Should succeed to list all-local/all with an admin', async function () { |
92 | await testEndpoints(server, server.accessToken, 'all-local', 200) | 93 | await testEndpoints(server, server.accessToken, 'all-local', HttpStatusCode.OK_200) |
93 | await testEndpoints(server, server.accessToken, 'all', 200) | 94 | await testEndpoints(server, server.accessToken, 'all', HttpStatusCode.OK_200) |
94 | }) | 95 | }) |
95 | 96 | ||
96 | // Because we cannot authenticate the user on the RSS endpoint | 97 | // Because we cannot authenticate the user on the RSS endpoint |
@@ -99,7 +100,7 @@ describe('Test videos filters', function () { | |||
99 | await makeGetRequest({ | 100 | await makeGetRequest({ |
100 | url: server.url, | 101 | url: server.url, |
101 | path: '/feeds/videos.json', | 102 | path: '/feeds/videos.json', |
102 | statusCodeExpected: 401, | 103 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401, |
103 | query: { | 104 | query: { |
104 | filter | 105 | filter |
105 | } | 106 | } |
@@ -111,7 +112,7 @@ describe('Test videos filters', function () { | |||
111 | await makeGetRequest({ | 112 | await makeGetRequest({ |
112 | url: server.url, | 113 | url: server.url, |
113 | path: '/feeds/videos.json', | 114 | path: '/feeds/videos.json', |
114 | statusCodeExpected: 200, | 115 | statusCodeExpected: HttpStatusCode.OK_200, |
115 | query: { | 116 | query: { |
116 | filter: 'local' | 117 | filter: 'local' |
117 | } | 118 | } |