diff options
Diffstat (limited to 'server/tests/api/check-params/services.ts')
-rw-r--r-- | server/tests/api/check-params/services.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts index e57edd9e4..514e3da70 100644 --- a/server/tests/api/check-params/services.ts +++ b/server/tests/api/check-params/services.ts | |||
@@ -13,6 +13,7 @@ import { | |||
13 | setDefaultVideoChannel | 13 | setDefaultVideoChannel |
14 | } from '../../../../shared/extra-utils' | 14 | } from '../../../../shared/extra-utils' |
15 | import { VideoPlaylistPrivacy } from '@shared/models' | 15 | import { VideoPlaylistPrivacy } from '@shared/models' |
16 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
16 | 17 | ||
17 | describe('Test services API validators', function () { | 18 | describe('Test services API validators', function () { |
18 | let server: ServerInfo | 19 | let server: ServerInfo |
@@ -66,7 +67,7 @@ describe('Test services API validators', function () { | |||
66 | 67 | ||
67 | it('Should fail with an unknown element', async function () { | 68 | it('Should fail with an unknown element', async function () { |
68 | const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c` | 69 | const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c` |
69 | await checkParamEmbed(server, embedUrl, 404) | 70 | await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_FOUND_404) |
70 | }) | 71 | }) |
71 | 72 | ||
72 | it('Should fail with an invalid path', async function () { | 73 | it('Should fail with an invalid path', async function () { |
@@ -78,25 +79,25 @@ describe('Test services API validators', function () { | |||
78 | it('Should fail with an invalid max height', async function () { | 79 | it('Should fail with an invalid max height', async function () { |
79 | const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` | 80 | const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` |
80 | 81 | ||
81 | await checkParamEmbed(server, embedUrl, 400, { maxheight: 'hello' }) | 82 | await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxheight: 'hello' }) |
82 | }) | 83 | }) |
83 | 84 | ||
84 | it('Should fail with an invalid max width', async function () { | 85 | it('Should fail with an invalid max width', async function () { |
85 | const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` | 86 | const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` |
86 | 87 | ||
87 | await checkParamEmbed(server, embedUrl, 400, { maxwidth: 'hello' }) | 88 | await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxwidth: 'hello' }) |
88 | }) | 89 | }) |
89 | 90 | ||
90 | it('Should fail with an invalid format', async function () { | 91 | it('Should fail with an invalid format', async function () { |
91 | const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` | 92 | const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` |
92 | 93 | ||
93 | await checkParamEmbed(server, embedUrl, 400, { format: 'blabla' }) | 94 | await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { format: 'blabla' }) |
94 | }) | 95 | }) |
95 | 96 | ||
96 | it('Should fail with a non supported format', async function () { | 97 | it('Should fail with a non supported format', async function () { |
97 | const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` | 98 | const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` |
98 | 99 | ||
99 | await checkParamEmbed(server, embedUrl, 501, { format: 'xml' }) | 100 | await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' }) |
100 | }) | 101 | }) |
101 | 102 | ||
102 | it('Should succeed with the correct params with a video', async function () { | 103 | it('Should succeed with the correct params with a video', async function () { |
@@ -107,7 +108,7 @@ describe('Test services API validators', function () { | |||
107 | maxwidth: 400 | 108 | maxwidth: 400 |
108 | } | 109 | } |
109 | 110 | ||
110 | await checkParamEmbed(server, embedUrl, 200, query) | 111 | await checkParamEmbed(server, embedUrl, HttpStatusCode.OK_200, query) |
111 | }) | 112 | }) |
112 | 113 | ||
113 | it('Should succeed with the correct params with a playlist', async function () { | 114 | it('Should succeed with the correct params with a playlist', async function () { |
@@ -118,7 +119,7 @@ describe('Test services API validators', function () { | |||
118 | maxwidth: 400 | 119 | maxwidth: 400 |
119 | } | 120 | } |
120 | 121 | ||
121 | await checkParamEmbed(server, embedUrl, 200, query) | 122 | await checkParamEmbed(server, embedUrl, HttpStatusCode.OK_200, query) |
122 | }) | 123 | }) |
123 | }) | 124 | }) |
124 | 125 | ||
@@ -127,7 +128,7 @@ describe('Test services API validators', function () { | |||
127 | }) | 128 | }) |
128 | }) | 129 | }) |
129 | 130 | ||
130 | function checkParamEmbed (server: ServerInfo, embedUrl: string, statusCodeExpected = 400, query = {}) { | 131 | function checkParamEmbed (server: ServerInfo, embedUrl: string, statusCodeExpected = HttpStatusCode.BAD_REQUEST_400, query = {}) { |
131 | const path = '/services/oembed' | 132 | const path = '/services/oembed' |
132 | 133 | ||
133 | return makeGetRequest({ | 134 | return makeGetRequest({ |