aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api')
-rw-r--r--server/tests/api/activitypub/client.ts3
-rw-r--r--server/tests/api/activitypub/refresher.ts15
-rw-r--r--server/tests/api/check-params/accounts.ts3
-rw-r--r--server/tests/api/check-params/contact-form.ts59
-rw-r--r--server/tests/api/check-params/users.ts12
-rw-r--r--server/tests/api/check-params/videos.ts18
-rw-r--r--server/tests/api/live/live-save-replay.ts33
-rw-r--r--server/tests/api/live/live.ts19
-rw-r--r--server/tests/api/server/config.ts9
-rw-r--r--server/tests/api/server/contact-form.ts3
-rw-r--r--server/tests/api/server/email.ts13
-rw-r--r--server/tests/api/server/follow-constraints.ts17
-rw-r--r--server/tests/api/server/handle-down.ts3
-rw-r--r--server/tests/api/server/no-client.ts3
-rw-r--r--server/tests/api/server/reverse-proxy.ts25
-rw-r--r--server/tests/api/videos/multiple-servers.ts5
-rw-r--r--server/tests/api/videos/video-change-ownership.ts14
-rw-r--r--server/tests/api/videos/video-hls.ts9
-rw-r--r--server/tests/api/videos/video-playlists.ts13
-rw-r--r--server/tests/api/videos/video-privacy.ts13
-rw-r--r--server/tests/api/videos/videos-history.ts3
21 files changed, 184 insertions, 108 deletions
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts
index d16f05108..b6c538e19 100644
--- a/server/tests/api/activitypub/client.ts
+++ b/server/tests/api/activitypub/client.ts
@@ -11,6 +11,7 @@ import {
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 uploadVideo 12 uploadVideo
13} from '../../../../shared/extra-utils' 13} from '../../../../shared/extra-utils'
14import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
14 15
15const expect = chai.expect 16const expect = chai.expect
16 17
@@ -53,7 +54,7 @@ describe('Test activitypub', function () {
53 }) 54 })
54 55
55 it('Should redirect to the origin video object', async function () { 56 it('Should redirect to the origin video object', async function () {
56 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, 302) 57 const res = await makeActivityPubGetRequest(servers[1].url, '/videos/watch/' + videoUUID, HttpStatusCode.FOUND_302)
57 58
58 expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID) 59 expect(res.header.location).to.equal('http://localhost:' + servers[0].port + '/videos/watch/' + videoUUID)
59 }) 60 })
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts
index 232c5d823..c717f1a30 100644
--- a/server/tests/api/activitypub/refresher.ts
+++ b/server/tests/api/activitypub/refresher.ts
@@ -24,6 +24,7 @@ import {
24} from '../../../../shared/extra-utils' 24} from '../../../../shared/extra-utils'
25import { getAccount } from '../../../../shared/extra-utils/users/accounts' 25import { getAccount } from '../../../../shared/extra-utils/users/accounts'
26import { VideoPlaylistPrivacy } from '../../../../shared/models/videos' 26import { VideoPlaylistPrivacy } from '../../../../shared/models/videos'
27import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
27 28
28describe('Test AP refresher', function () { 29describe('Test AP refresher', function () {
29 let servers: ServerInfo[] = [] 30 let servers: ServerInfo[] = []
@@ -86,8 +87,8 @@ describe('Test AP refresher', function () {
86 87
87 await waitJobs(servers) 88 await waitJobs(servers)
88 89
89 await getVideo(servers[0].url, videoUUID1, 404) 90 await getVideo(servers[0].url, videoUUID1, HttpStatusCode.NOT_FOUND_404)
90 await getVideo(servers[0].url, videoUUID2, 200) 91 await getVideo(servers[0].url, videoUUID2, HttpStatusCode.OK_200)
91 }) 92 })
92 93
93 it('Should not update a remote video if the remote instance is down', async function () { 94 it('Should not update a remote video if the remote instance is down', async function () {
@@ -106,7 +107,7 @@ describe('Test AP refresher', function () {
106 107
107 await reRunServer(servers[1]) 108 await reRunServer(servers[1])
108 109
109 await getVideo(servers[0].url, videoUUID3, 200) 110 await getVideo(servers[0].url, videoUUID3, HttpStatusCode.OK_200)
110 }) 111 })
111 }) 112 })
112 113
@@ -126,8 +127,8 @@ describe('Test AP refresher', function () {
126 127
127 await waitJobs(servers) 128 await waitJobs(servers)
128 129
129 await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port, 200) 130 await getAccount(servers[0].url, 'user1@localhost:' + servers[1].port, HttpStatusCode.OK_200)
130 await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port, 404) 131 await getAccount(servers[0].url, 'user2@localhost:' + servers[1].port, HttpStatusCode.NOT_FOUND_404)
131 }) 132 })
132 }) 133 })
133 134
@@ -146,8 +147,8 @@ describe('Test AP refresher', function () {
146 147
147 await waitJobs(servers) 148 await waitJobs(servers)
148 149
149 await getVideoPlaylist(servers[0].url, playlistUUID1, 200) 150 await getVideoPlaylist(servers[0].url, playlistUUID1, HttpStatusCode.OK_200)
150 await getVideoPlaylist(servers[0].url, playlistUUID2, 404) 151 await getVideoPlaylist(servers[0].url, playlistUUID2, HttpStatusCode.NOT_FOUND_404)
151 }) 152 })
152 }) 153 })
153 154
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts
index c29af7cd7..d1712cff6 100644
--- a/server/tests/api/check-params/accounts.ts
+++ b/server/tests/api/check-params/accounts.ts
@@ -9,6 +9,7 @@ import {
9 checkBadStartPagination 9 checkBadStartPagination
10} from '../../../../shared/extra-utils/requests/check-api-params' 10} from '../../../../shared/extra-utils/requests/check-api-params'
11import { getAccount } from '../../../../shared/extra-utils/users/accounts' 11import { getAccount } from '../../../../shared/extra-utils/users/accounts'
12import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
12 13
13describe('Test accounts API validators', function () { 14describe('Test accounts API validators', function () {
14 const path = '/api/v1/accounts/' 15 const path = '/api/v1/accounts/'
@@ -38,7 +39,7 @@ describe('Test accounts API validators', function () {
38 39
39 describe('When getting an account', function () { 40 describe('When getting an account', function () {
40 it('Should return 404 with a non existing name', async function () { 41 it('Should return 404 with a non existing name', async function () {
41 await getAccount(server.url, 'arfaze', 404) 42 await getAccount(server.url, 'arfaze', HttpStatusCode.NOT_FOUND_404)
42 }) 43 })
43 }) 44 })
44 45
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts
index b2126b9b0..c7f9c1b47 100644
--- a/server/tests/api/check-params/contact-form.ts
+++ b/server/tests/api/check-params/contact-form.ts
@@ -5,6 +5,7 @@ import 'mocha'
5import { cleanupTests, flushAndRunServer, immutableAssign, killallServers, reRunServer, ServerInfo } from '../../../../shared/extra-utils' 5import { cleanupTests, flushAndRunServer, immutableAssign, killallServers, reRunServer, ServerInfo } from '../../../../shared/extra-utils'
6import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form' 6import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form'
7import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' 7import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
8import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
8 9
9describe('Test contact form API validators', function () { 10describe('Test contact form API validators', function () {
10 let server: ServerInfo 11 let server: ServerInfo
@@ -29,7 +30,7 @@ describe('Test contact form API validators', function () {
29 }) 30 })
30 31
31 it('Should not accept a contact form if emails are disabled', async function () { 32 it('Should not accept a contact form if emails are disabled', async function () {
32 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 409 })) 33 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: HttpStatusCode.CONFLICT_409 }))
33 }) 34 })
34 35
35 it('Should not accept a contact form if it is disabled in the configuration', async function () { 36 it('Should not accept a contact form if it is disabled in the configuration', async function () {
@@ -39,7 +40,7 @@ describe('Test contact form API validators', function () {
39 40
40 // Contact form is disabled 41 // Contact form is disabled
41 await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort }, contact_form: { enabled: false } }) 42 await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort }, contact_form: { enabled: false } })
42 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 409 })) 43 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: HttpStatusCode.CONFLICT_409 }))
43 }) 44 })
44 45
45 it('Should not accept a contact form if from email is invalid', async function () { 46 it('Should not accept a contact form if from email is invalid', async function () {
@@ -50,21 +51,57 @@ describe('Test contact form API validators', function () {
50 // Email & contact form enabled 51 // Email & contact form enabled
51 await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort } }) 52 await reRunServer(server, { smtp: { hostname: 'localhost', port: emailPort } })
52 53
53 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: 'badEmail' })) 54 await sendContactForm(immutableAssign(defaultBody, {
54 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: 'badEmail@' })) 55 url: server.url,
55 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromEmail: undefined })) 56 expectedStatus: HttpStatusCode.BAD_REQUEST_400,
57 fromEmail: 'badEmail'
58 }))
59 await sendContactForm(immutableAssign(defaultBody, {
60 url: server.url,
61 expectedStatus: HttpStatusCode.BAD_REQUEST_400,
62 fromEmail: 'badEmail@'
63 }))
64 await sendContactForm(immutableAssign(defaultBody, {
65 url: server.url,
66 expectedStatus: HttpStatusCode.BAD_REQUEST_400,
67 fromEmail: undefined
68 }))
56 }) 69 })
57 70
58 it('Should not accept a contact form if from name is invalid', async function () { 71 it('Should not accept a contact form if from name is invalid', async function () {
59 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromName: 'name'.repeat(100) })) 72 await sendContactForm(immutableAssign(defaultBody, {
60 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromName: '' })) 73 url: server.url,
61 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, fromName: undefined })) 74 expectedStatus: HttpStatusCode.BAD_REQUEST_400,
75 fromName: 'name'.repeat(100)
76 }))
77 await sendContactForm(immutableAssign(defaultBody, {
78 url: server.url,
79 expectedStatus: HttpStatusCode.BAD_REQUEST_400,
80 fromName: ''
81 }))
82 await sendContactForm(immutableAssign(defaultBody, {
83 url: server.url,
84 expectedStatus: HttpStatusCode.BAD_REQUEST_400,
85 fromName: undefined
86 }))
62 }) 87 })
63 88
64 it('Should not accept a contact form if body is invalid', async function () { 89 it('Should not accept a contact form if body is invalid', async function () {
65 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, body: 'body'.repeat(5000) })) 90 await sendContactForm(immutableAssign(defaultBody, {
66 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, body: 'a' })) 91 url: server.url,
67 await sendContactForm(immutableAssign(defaultBody, { url: server.url, expectedStatus: 400, body: undefined })) 92 expectedStatus: HttpStatusCode.BAD_REQUEST_400,
93 body: 'body'.repeat(5000)
94 }))
95 await sendContactForm(immutableAssign(defaultBody, {
96 url: server.url,
97 expectedStatus: HttpStatusCode.BAD_REQUEST_400,
98 body: 'a'
99 }))
100 await sendContactForm(immutableAssign(defaultBody, {
101 url: server.url,
102 expectedStatus: HttpStatusCode.BAD_REQUEST_400,
103 body: undefined
104 }))
68 }) 105 })
69 106
70 it('Should accept a contact form with the correct parameters', async function () { 107 it('Should accept a contact form with the correct parameters', async function () {
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index 21ace36aa..0a13f5b67 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -1102,7 +1102,7 @@ describe('Test users API validators', function () {
1102 videoQuota: 42 1102 videoQuota: 42
1103 }) 1103 })
1104 1104
1105 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.FORBIDDEN_403) 1105 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413)
1106 }) 1106 })
1107 1107
1108 it('Should fail with a registered user having too many videos', async function () { 1108 it('Should fail with a registered user having too many videos', async function () {
@@ -1120,7 +1120,7 @@ describe('Test users API validators', function () {
1120 await uploadVideo(server.url, userAccessToken, videoAttributes) 1120 await uploadVideo(server.url, userAccessToken, videoAttributes)
1121 await uploadVideo(server.url, userAccessToken, videoAttributes) 1121 await uploadVideo(server.url, userAccessToken, videoAttributes)
1122 await uploadVideo(server.url, userAccessToken, videoAttributes) 1122 await uploadVideo(server.url, userAccessToken, videoAttributes)
1123 await uploadVideo(server.url, userAccessToken, videoAttributes, HttpStatusCode.FORBIDDEN_403) 1123 await uploadVideo(server.url, userAccessToken, videoAttributes, HttpStatusCode.PAYLOAD_TOO_LARGE_413)
1124 }) 1124 })
1125 1125
1126 it('Should fail to import with HTTP/Torrent/magnet', async function () { 1126 it('Should fail to import with HTTP/Torrent/magnet', async function () {
@@ -1151,7 +1151,7 @@ describe('Test users API validators', function () {
1151 }) 1151 })
1152 1152
1153 describe('When having a daily video quota', function () { 1153 describe('When having a daily video quota', function () {
1154 it('Should fail with a user having too many videos', async function () { 1154 it('Should fail with a user having too many videos daily', async function () {
1155 await updateUser({ 1155 await updateUser({
1156 url: server.url, 1156 url: server.url,
1157 userId: rootId, 1157 userId: rootId,
@@ -1159,7 +1159,7 @@ describe('Test users API validators', function () {
1159 videoQuotaDaily: 42 1159 videoQuotaDaily: 42
1160 }) 1160 })
1161 1161
1162 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.FORBIDDEN_403) 1162 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413)
1163 }) 1163 })
1164 }) 1164 })
1165 1165
@@ -1173,7 +1173,7 @@ describe('Test users API validators', function () {
1173 videoQuotaDaily: 1024 * 1024 * 1024 1173 videoQuotaDaily: 1024 * 1024 * 1024
1174 }) 1174 })
1175 1175
1176 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.FORBIDDEN_403) 1176 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413)
1177 }) 1177 })
1178 1178
1179 it('Should fail if exceeding daily quota', async function () { 1179 it('Should fail if exceeding daily quota', async function () {
@@ -1185,7 +1185,7 @@ describe('Test users API validators', function () {
1185 videoQuotaDaily: 42 1185 videoQuotaDaily: 42
1186 }) 1186 })
1187 1187
1188 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.FORBIDDEN_403) 1188 await uploadVideo(server.url, server.accessToken, {}, HttpStatusCode.PAYLOAD_TOO_LARGE_413)
1189 }) 1189 })
1190 }) 1190 })
1191 1191
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index d60546917..5faba82c4 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -348,12 +348,26 @@ describe('Test videos API validator', function () {
348 let attaches = { 348 let attaches = {
349 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm') 349 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short_fake.webm')
350 } 350 }
351 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 351 await makeUploadRequest({
352 url: server.url,
353 path: path + '/upload',
354 token: server.accessToken,
355 fields,
356 attaches,
357 statusCodeExpected: HttpStatusCode.UNPROCESSABLE_ENTITY_422
358 })
352 359
353 attaches = { 360 attaches = {
354 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv') 361 videofile: join(root(), 'server', 'tests', 'fixtures', 'video_short.mkv')
355 } 362 }
356 await makeUploadRequest({ url: server.url, path: path + '/upload', token: server.accessToken, fields, attaches }) 363 await makeUploadRequest({
364 url: server.url,
365 path: path + '/upload',
366 token: server.accessToken,
367 fields,
368 attaches,
369 statusCodeExpected: HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415
370 })
357 }) 371 })
358 372
359 it('Should fail with an incorrect thumbnail file', async function () { 373 it('Should fail with an incorrect thumbnail file', async function () {
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index 3ffa0c093..e300ec345 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -25,6 +25,7 @@ import {
25 waitJobs, 25 waitJobs,
26 waitUntilLiveStarts 26 waitUntilLiveStarts
27} from '../../../../shared/extra-utils' 27} from '../../../../shared/extra-utils'
28import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
28 29
29const expect = chai.expect 30const expect = chai.expect
30 31
@@ -118,7 +119,7 @@ describe('Save replay setting', function () {
118 119
119 await waitJobs(servers) 120 await waitJobs(servers)
120 121
121 await checkVideosExist(liveVideoUUID, false, 200) 122 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
122 await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE) 123 await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE)
123 }) 124 })
124 125
@@ -130,7 +131,7 @@ describe('Save replay setting', function () {
130 131
131 await waitJobs(servers) 132 await waitJobs(servers)
132 133
133 await checkVideosExist(liveVideoUUID, true, 200) 134 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
134 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) 135 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
135 }) 136 })
136 137
@@ -142,7 +143,7 @@ describe('Save replay setting', function () {
142 await waitJobs(servers) 143 await waitJobs(servers)
143 144
144 // Live still exist, but cannot be played anymore 145 // Live still exist, but cannot be played anymore
145 await checkVideosExist(liveVideoUUID, false, 200) 146 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
146 await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED) 147 await checkVideoState(liveVideoUUID, VideoState.LIVE_ENDED)
147 148
148 // No resolutions saved since we did not save replay 149 // No resolutions saved since we did not save replay
@@ -158,7 +159,7 @@ describe('Save replay setting', function () {
158 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 159 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
159 160
160 await waitJobs(servers) 161 await waitJobs(servers)
161 await checkVideosExist(liveVideoUUID, true, 200) 162 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
162 163
163 await Promise.all([ 164 await Promise.all([
164 addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideoUUID, 'bad live', true), 165 addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideoUUID, 'bad live', true),
@@ -169,8 +170,8 @@ describe('Save replay setting', function () {
169 170
170 await checkVideosExist(liveVideoUUID, false) 171 await checkVideosExist(liveVideoUUID, false)
171 172
172 await getVideo(servers[0].url, liveVideoUUID, 401) 173 await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401)
173 await getVideo(servers[1].url, liveVideoUUID, 404) 174 await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404)
174 175
175 await checkLiveCleanup(servers[0], liveVideoUUID, []) 176 await checkLiveCleanup(servers[0], liveVideoUUID, [])
176 }) 177 })
@@ -184,7 +185,7 @@ describe('Save replay setting', function () {
184 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 185 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
185 186
186 await waitJobs(servers) 187 await waitJobs(servers)
187 await checkVideosExist(liveVideoUUID, true, 200) 188 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
188 189
189 await Promise.all([ 190 await Promise.all([
190 testFfmpegStreamError(ffmpegCommand, true), 191 testFfmpegStreamError(ffmpegCommand, true),
@@ -193,7 +194,7 @@ describe('Save replay setting', function () {
193 194
194 await waitJobs(servers) 195 await waitJobs(servers)
195 196
196 await checkVideosExist(liveVideoUUID, false, 404) 197 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
197 await checkLiveCleanup(servers[0], liveVideoUUID, []) 198 await checkLiveCleanup(servers[0], liveVideoUUID, [])
198 }) 199 })
199 }) 200 })
@@ -207,7 +208,7 @@ describe('Save replay setting', function () {
207 208
208 await waitJobs(servers) 209 await waitJobs(servers)
209 210
210 await checkVideosExist(liveVideoUUID, false, 200) 211 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.OK_200)
211 await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE) 212 await checkVideoState(liveVideoUUID, VideoState.WAITING_FOR_LIVE)
212 }) 213 })
213 214
@@ -219,7 +220,7 @@ describe('Save replay setting', function () {
219 220
220 await waitJobs(servers) 221 await waitJobs(servers)
221 222
222 await checkVideosExist(liveVideoUUID, true, 200) 223 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
223 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) 224 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
224 }) 225 })
225 226
@@ -231,7 +232,7 @@ describe('Save replay setting', function () {
231 await waitJobs(servers) 232 await waitJobs(servers)
232 233
233 // Live has been transcoded 234 // Live has been transcoded
234 await checkVideosExist(liveVideoUUID, true, 200) 235 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
235 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED) 236 await checkVideoState(liveVideoUUID, VideoState.PUBLISHED)
236 }) 237 })
237 238
@@ -261,7 +262,7 @@ describe('Save replay setting', function () {
261 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 262 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
262 263
263 await waitJobs(servers) 264 await waitJobs(servers)
264 await checkVideosExist(liveVideoUUID, true, 200) 265 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
265 266
266 await Promise.all([ 267 await Promise.all([
267 addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideoUUID, 'bad live', true), 268 addVideoToBlacklist(servers[0].url, servers[0].accessToken, liveVideoUUID, 'bad live', true),
@@ -272,8 +273,8 @@ describe('Save replay setting', function () {
272 273
273 await checkVideosExist(liveVideoUUID, false) 274 await checkVideosExist(liveVideoUUID, false)
274 275
275 await getVideo(servers[0].url, liveVideoUUID, 401) 276 await getVideo(servers[0].url, liveVideoUUID, HttpStatusCode.UNAUTHORIZED_401)
276 await getVideo(servers[1].url, liveVideoUUID, 404) 277 await getVideo(servers[1].url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404)
277 278
278 await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ]) 279 await checkLiveCleanup(servers[0], liveVideoUUID, [ 720 ])
279 }) 280 })
@@ -287,7 +288,7 @@ describe('Save replay setting', function () {
287 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID) 288 await waitUntilLiveStarts(servers[0].url, servers[0].accessToken, liveVideoUUID)
288 289
289 await waitJobs(servers) 290 await waitJobs(servers)
290 await checkVideosExist(liveVideoUUID, true, 200) 291 await checkVideosExist(liveVideoUUID, true, HttpStatusCode.OK_200)
291 292
292 await Promise.all([ 293 await Promise.all([
293 removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID), 294 removeVideo(servers[0].url, servers[0].accessToken, liveVideoUUID),
@@ -296,7 +297,7 @@ describe('Save replay setting', function () {
296 297
297 await waitJobs(servers) 298 await waitJobs(servers)
298 299
299 await checkVideosExist(liveVideoUUID, false, 404) 300 await checkVideosExist(liveVideoUUID, false, HttpStatusCode.NOT_FOUND_404)
300 await checkLiveCleanup(servers[0], liveVideoUUID, []) 301 await checkLiveCleanup(servers[0], liveVideoUUID, [])
301 }) 302 })
302 }) 303 })
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index d784650b5..fdfc6105f 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -44,6 +44,7 @@ import {
44 waitUntilLiveStarts, 44 waitUntilLiveStarts,
45 waitUntilLog 45 waitUntilLog
46} from '../../../../shared/extra-utils' 46} from '../../../../shared/extra-utils'
47import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
47 48
48const expect = chai.expect 49const expect = chai.expect
49 50
@@ -164,8 +165,8 @@ describe('Test live', function () {
164 expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED) 165 expect(video.privacy.id).to.equal(VideoPrivacy.UNLISTED)
165 expect(video.nsfw).to.be.true 166 expect(video.nsfw).to.be.true
166 167
167 await makeRawRequest(server.url + video.thumbnailPath, 200) 168 await makeRawRequest(server.url + video.thumbnailPath, HttpStatusCode.OK_200)
168 await makeRawRequest(server.url + video.previewPath, 200) 169 await makeRawRequest(server.url + video.previewPath, HttpStatusCode.OK_200)
169 } 170 }
170 }) 171 })
171 172
@@ -179,7 +180,7 @@ describe('Test live', function () {
179 }) 180 })
180 181
181 it('Should not be able to update a live of another server', async function () { 182 it('Should not be able to update a live of another server', async function () {
182 await updateLive(servers[1].url, servers[1].accessToken, liveVideoUUID, { saveReplay: false }, 403) 183 await updateLive(servers[1].url, servers[1].accessToken, liveVideoUUID, { saveReplay: false }, HttpStatusCode.FORBIDDEN_403)
183 }) 184 })
184 185
185 it('Should update the live', async function () { 186 it('Should update the live', async function () {
@@ -215,8 +216,8 @@ describe('Test live', function () {
215 216
216 it('Should have the live deleted', async function () { 217 it('Should have the live deleted', async function () {
217 for (const server of servers) { 218 for (const server of servers) {
218 await getVideo(server.url, liveVideoUUID, 404) 219 await getVideo(server.url, liveVideoUUID, HttpStatusCode.NOT_FOUND_404)
219 await getLive(server.url, server.accessToken, liveVideoUUID, 404) 220 await getLive(server.url, server.accessToken, liveVideoUUID, HttpStatusCode.NOT_FOUND_404)
220 } 221 }
221 }) 222 })
222 }) 223 })
@@ -430,8 +431,8 @@ describe('Test live', function () {
430 expect(video.files).to.have.lengthOf(0) 431 expect(video.files).to.have.lengthOf(0)
431 432
432 const hlsPlaylist = video.streamingPlaylists.find(s => s.type === VideoStreamingPlaylistType.HLS) 433 const hlsPlaylist = video.streamingPlaylists.find(s => s.type === VideoStreamingPlaylistType.HLS)
433 await makeRawRequest(hlsPlaylist.playlistUrl, 200) 434 await makeRawRequest(hlsPlaylist.playlistUrl, HttpStatusCode.OK_200)
434 await makeRawRequest(hlsPlaylist.segmentsSha256Url, 200) 435 await makeRawRequest(hlsPlaylist.segmentsSha256Url, HttpStatusCode.OK_200)
435 436
436 expect(hlsPlaylist.files).to.have.lengthOf(resolutions.length) 437 expect(hlsPlaylist.files).to.have.lengthOf(resolutions.length)
437 438
@@ -455,8 +456,8 @@ describe('Test live', function () {
455 456
456 expect(probe.format.bit_rate).to.be.below(bitrateLimits[videoStream.height]) 457 expect(probe.format.bit_rate).to.be.below(bitrateLimits[videoStream.height])
457 458
458 await makeRawRequest(file.torrentUrl, 200) 459 await makeRawRequest(file.torrentUrl, HttpStatusCode.OK_200)
459 await makeRawRequest(file.fileUrl, 200) 460 await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
460 } 461 }
461 } 462 }
462 }) 463 })
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index eb51d8909..a505b8ede 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -21,6 +21,7 @@ import {
21 uploadVideo 21 uploadVideo
22} from '../../../../shared/extra-utils' 22} from '../../../../shared/extra-utils'
23import { ServerConfig } from '../../../../shared/models' 23import { ServerConfig } from '../../../../shared/models'
24import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
24 25
25const expect = chai.expect 26const expect = chai.expect
26 27
@@ -237,8 +238,8 @@ describe('Test config', function () {
237 expect(data.video.file.extensions).to.contain('.webm') 238 expect(data.video.file.extensions).to.contain('.webm')
238 expect(data.video.file.extensions).to.contain('.ogv') 239 expect(data.video.file.extensions).to.contain('.ogv')
239 240
240 await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.mkv' }, 400) 241 await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.mkv' }, HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415)
241 await uploadVideo(server.url, server.accessToken, { fixture: 'sample.ogg' }, 400) 242 await uploadVideo(server.url, server.accessToken, { fixture: 'sample.ogg' }, HttpStatusCode.UNSUPPORTED_MEDIA_TYPE_415)
242 243
243 expect(data.contactForm.enabled).to.be.true 244 expect(data.contactForm.enabled).to.be.true
244 }) 245 })
@@ -427,8 +428,8 @@ describe('Test config', function () {
427 expect(data.video.file.extensions).to.contain('.ogg') 428 expect(data.video.file.extensions).to.contain('.ogg')
428 expect(data.video.file.extensions).to.contain('.flac') 429 expect(data.video.file.extensions).to.contain('.flac')
429 430
430 await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.mkv' }, 200) 431 await uploadVideo(server.url, server.accessToken, { fixture: 'video_short.mkv' }, HttpStatusCode.OK_200)
431 await uploadVideo(server.url, server.accessToken, { fixture: 'sample.ogg' }, 200) 432 await uploadVideo(server.url, server.accessToken, { fixture: 'sample.ogg' }, HttpStatusCode.OK_200)
432 }) 433 })
433 434
434 it('Should have the configuration updated after a restart', async function () { 435 it('Should have the configuration updated after a restart', async function () {
diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts
index c0965d9d1..9b4af1915 100644
--- a/server/tests/api/server/contact-form.ts
+++ b/server/tests/api/server/contact-form.ts
@@ -6,6 +6,7 @@ import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers,
6import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' 6import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
7import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 7import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
8import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form' 8import { sendContactForm } from '../../../../shared/extra-utils/server/contact-form'
9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
9 10
10const expect = chai.expect 11const expect = chai.expect
11 12
@@ -67,7 +68,7 @@ describe('Test contact form', function () {
67 body: 'my super message', 68 body: 'my super message',
68 fromName: 'Super toto', 69 fromName: 'Super toto',
69 subject: 'my subject', 70 subject: 'my subject',
70 expectedStatus: 403 71 expectedStatus: HttpStatusCode.FORBIDDEN_403
71 }) 72 })
72 }) 73 })
73 74
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index 53f96a94f..17d9e902c 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -22,6 +22,7 @@ import {
22} from '../../../../shared/extra-utils' 22} from '../../../../shared/extra-utils'
23import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email' 23import { MockSmtpServer } from '../../../../shared/extra-utils/miscs/email'
24import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 24import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
25import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
25 26
26const expect = chai.expect 27const expect = chai.expect
27 28
@@ -116,7 +117,7 @@ describe('Test emails', function () {
116 }) 117 })
117 118
118 it('Should not reset the password with an invalid verification string', async function () { 119 it('Should not reset the password with an invalid verification string', async function () {
119 await resetPassword(server.url, userId, verificationString + 'b', 'super_password2', 403) 120 await resetPassword(server.url, userId, verificationString + 'b', 'super_password2', HttpStatusCode.FORBIDDEN_403)
120 }) 121 })
121 122
122 it('Should reset the password', async function () { 123 it('Should reset the password', async function () {
@@ -124,7 +125,7 @@ describe('Test emails', function () {
124 }) 125 })
125 126
126 it('Should not reset the password with the same verification string', async function () { 127 it('Should not reset the password with the same verification string', async function () {
127 await resetPassword(server.url, userId, verificationString, 'super_password3', 403) 128 await resetPassword(server.url, userId, verificationString, 'super_password3', HttpStatusCode.FORBIDDEN_403)
128 }) 129 })
129 130
130 it('Should login with this new password', async function () { 131 it('Should login with this new password', async function () {
@@ -169,7 +170,7 @@ describe('Test emails', function () {
169 }) 170 })
170 171
171 it('Should not reset the password with an invalid verification string', async function () { 172 it('Should not reset the password with an invalid verification string', async function () {
172 await resetPassword(server.url, userId2, verificationString2 + 'c', 'newly_created_password', 403) 173 await resetPassword(server.url, userId2, verificationString2 + 'c', 'newly_created_password', HttpStatusCode.FORBIDDEN_403)
173 }) 174 })
174 175
175 it('Should reset the password', async function () { 176 it('Should reset the password', async function () {
@@ -210,7 +211,7 @@ describe('Test emails', function () {
210 this.timeout(10000) 211 this.timeout(10000)
211 212
212 const reason = 'my super bad reason' 213 const reason = 'my super bad reason'
213 await blockUser(server.url, userId, server.accessToken, 204, reason) 214 await blockUser(server.url, userId, server.accessToken, HttpStatusCode.NO_CONTENT_204, reason)
214 215
215 await waitJobs(server) 216 await waitJobs(server)
216 expect(emails).to.have.lengthOf(4) 217 expect(emails).to.have.lengthOf(4)
@@ -228,7 +229,7 @@ describe('Test emails', function () {
228 it('Should send the notification email when unblocking a user', async function () { 229 it('Should send the notification email when unblocking a user', async function () {
229 this.timeout(10000) 230 this.timeout(10000)
230 231
231 await unblockUser(server.url, userId, server.accessToken, 204) 232 await unblockUser(server.url, userId, server.accessToken, HttpStatusCode.NO_CONTENT_204)
232 233
233 await waitJobs(server) 234 await waitJobs(server)
234 expect(emails).to.have.lengthOf(5) 235 expect(emails).to.have.lengthOf(5)
@@ -317,7 +318,7 @@ describe('Test emails', function () {
317 }) 318 })
318 319
319 it('Should not verify the email with an invalid verification string', async function () { 320 it('Should not verify the email with an invalid verification string', async function () {
320 await verifyEmail(server.url, userId, verificationString + 'b', false, 403) 321 await verifyEmail(server.url, userId, verificationString + 'b', false, HttpStatusCode.FORBIDDEN_403)
321 }) 322 })
322 323
323 it('Should verify the email', async function () { 324 it('Should verify the email', async function () {
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts
index a73440286..0846b04f4 100644
--- a/server/tests/api/server/follow-constraints.ts
+++ b/server/tests/api/server/follow-constraints.ts
@@ -17,6 +17,7 @@ import {
17import { unfollow } from '../../../../shared/extra-utils/server/follows' 17import { unfollow } from '../../../../shared/extra-utils/server/follows'
18import { userLogin } from '../../../../shared/extra-utils/users/login' 18import { userLogin } from '../../../../shared/extra-utils/users/login'
19import { createUser } from '../../../../shared/extra-utils/users/users' 19import { createUser } from '../../../../shared/extra-utils/users/users'
20import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
20 21
21const expect = chai.expect 22const expect = chai.expect
22 23
@@ -58,11 +59,11 @@ describe('Test follow constraints', function () {
58 describe('With an unlogged user', function () { 59 describe('With an unlogged user', function () {
59 60
60 it('Should get the local video', async function () { 61 it('Should get the local video', async function () {
61 await getVideo(servers[0].url, video1UUID, 200) 62 await getVideo(servers[0].url, video1UUID, HttpStatusCode.OK_200)
62 }) 63 })
63 64
64 it('Should get the remote video', async function () { 65 it('Should get the remote video', async function () {
65 await getVideo(servers[0].url, video2UUID, 200) 66 await getVideo(servers[0].url, video2UUID, HttpStatusCode.OK_200)
66 }) 67 })
67 68
68 it('Should list local account videos', async function () { 69 it('Should list local account videos', async function () {
@@ -98,11 +99,11 @@ describe('Test follow constraints', function () {
98 99
99 describe('With a logged user', function () { 100 describe('With a logged user', function () {
100 it('Should get the local video', async function () { 101 it('Should get the local video', async function () {
101 await getVideoWithToken(servers[0].url, userAccessToken, video1UUID, 200) 102 await getVideoWithToken(servers[0].url, userAccessToken, video1UUID, HttpStatusCode.OK_200)
102 }) 103 })
103 104
104 it('Should get the remote video', async function () { 105 it('Should get the remote video', async function () {
105 await getVideoWithToken(servers[0].url, userAccessToken, video2UUID, 200) 106 await getVideoWithToken(servers[0].url, userAccessToken, video2UUID, HttpStatusCode.OK_200)
106 }) 107 })
107 108
108 it('Should list local account videos', async function () { 109 it('Should list local account videos', async function () {
@@ -148,11 +149,11 @@ describe('Test follow constraints', function () {
148 describe('With an unlogged user', function () { 149 describe('With an unlogged user', function () {
149 150
150 it('Should get the local video', async function () { 151 it('Should get the local video', async function () {
151 await getVideo(servers[0].url, video1UUID, 200) 152 await getVideo(servers[0].url, video1UUID, HttpStatusCode.OK_200)
152 }) 153 })
153 154
154 it('Should not get the remote video', async function () { 155 it('Should not get the remote video', async function () {
155 await getVideo(servers[0].url, video2UUID, 403) 156 await getVideo(servers[0].url, video2UUID, HttpStatusCode.FORBIDDEN_403)
156 }) 157 })
157 158
158 it('Should list local account videos', async function () { 159 it('Should list local account videos', async function () {
@@ -188,11 +189,11 @@ describe('Test follow constraints', function () {
188 189
189 describe('With a logged user', function () { 190 describe('With a logged user', function () {
190 it('Should get the local video', async function () { 191 it('Should get the local video', async function () {
191 await getVideoWithToken(servers[0].url, userAccessToken, video1UUID, 200) 192 await getVideoWithToken(servers[0].url, userAccessToken, video1UUID, HttpStatusCode.OK_200)
192 }) 193 })
193 194
194 it('Should get the remote video', async function () { 195 it('Should get the remote video', async function () {
195 await getVideoWithToken(servers[0].url, userAccessToken, video2UUID, 200) 196 await getVideoWithToken(servers[0].url, userAccessToken, video2UUID, HttpStatusCode.OK_200)
196 }) 197 })
197 198
198 it('Should list local account videos', async function () { 199 it('Should list local account videos', async function () {
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index 2cf6e15ad..043754e70 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -33,6 +33,7 @@ import {
33 getVideoCommentThreads, 33 getVideoCommentThreads,
34 getVideoThreadComments 34 getVideoThreadComments
35} from '../../../../shared/extra-utils/videos/video-comments' 35} from '../../../../shared/extra-utils/videos/video-comments'
36import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
36 37
37const expect = chai.expect 38const expect = chai.expect
38 39
@@ -352,7 +353,7 @@ describe('Test handle downs', function () {
352 } 353 }
353 354
354 for (const id of videoIdsServer1) { 355 for (const id of videoIdsServer1) {
355 await getVideo(servers[1].url, id, 403) 356 await getVideo(servers[1].url, id, HttpStatusCode.FORBIDDEN_403)
356 } 357 }
357 }) 358 })
358 359
diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts
index d0450aba0..d589f51f3 100644
--- a/server/tests/api/server/no-client.ts
+++ b/server/tests/api/server/no-client.ts
@@ -2,6 +2,7 @@ import 'mocha'
2import * as request from 'supertest' 2import * as request from 'supertest'
3import { ServerInfo } from '../../../../shared/extra-utils' 3import { ServerInfo } from '../../../../shared/extra-utils'
4import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers' 4import { cleanupTests, flushAndRunServer } from '../../../../shared/extra-utils/server/servers'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
5 6
6describe('Start and stop server without web client routes', function () { 7describe('Start and stop server without web client routes', function () {
7 let server: ServerInfo 8 let server: ServerInfo
@@ -16,7 +17,7 @@ describe('Start and stop server without web client routes', function () {
16 const req = request(server.url) 17 const req = request(server.url)
17 .get('/') 18 .get('/')
18 19
19 return req.expect(404) 20 return req.expect(HttpStatusCode.NOT_FOUND_404)
20 }) 21 })
21 22
22 after(async function () { 23 after(async function () {
diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts
index d0d79c4f6..17d1ee4a5 100644
--- a/server/tests/api/server/reverse-proxy.ts
+++ b/server/tests/api/server/reverse-proxy.ts
@@ -4,6 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { cleanupTests, getVideo, registerUser, uploadVideo, userLogin, viewVideo, wait } from '../../../../shared/extra-utils' 5import { cleanupTests, getVideo, registerUser, uploadVideo, userLogin, viewVideo, wait } from '../../../../shared/extra-utils'
6import { flushAndRunServer, setAccessTokensToServers } from '../../../../shared/extra-utils/index' 6import { flushAndRunServer, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
7import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
7 8
8const expect = chai.expect 9const expect = chai.expect
9 10
@@ -56,8 +57,8 @@ describe('Test application behind a reverse proxy', function () {
56 it('Should view a video 2 times with the X-Forwarded-For header set', async function () { 57 it('Should view a video 2 times with the X-Forwarded-For header set', async function () {
57 this.timeout(20000) 58 this.timeout(20000)
58 59
59 await viewVideo(server.url, videoId, 204, '0.0.0.1,127.0.0.1') 60 await viewVideo(server.url, videoId, HttpStatusCode.NO_CONTENT_204, '0.0.0.1,127.0.0.1')
60 await viewVideo(server.url, videoId, 204, '0.0.0.2,127.0.0.1') 61 await viewVideo(server.url, videoId, HttpStatusCode.NO_CONTENT_204, '0.0.0.2,127.0.0.1')
61 62
62 // Wait the repeatable job 63 // Wait the repeatable job
63 await wait(8000) 64 await wait(8000)
@@ -69,8 +70,8 @@ describe('Test application behind a reverse proxy', function () {
69 it('Should view a video only once with the same client IP in the X-Forwarded-For header', async function () { 70 it('Should view a video only once with the same client IP in the X-Forwarded-For header', async function () {
70 this.timeout(20000) 71 this.timeout(20000)
71 72
72 await viewVideo(server.url, videoId, 204, '0.0.0.4,0.0.0.3,::ffff:127.0.0.1') 73 await viewVideo(server.url, videoId, HttpStatusCode.NO_CONTENT_204, '0.0.0.4,0.0.0.3,::ffff:127.0.0.1')
73 await viewVideo(server.url, videoId, 204, '0.0.0.5,0.0.0.3,127.0.0.1') 74 await viewVideo(server.url, videoId, HttpStatusCode.NO_CONTENT_204, '0.0.0.5,0.0.0.3,127.0.0.1')
74 75
75 // Wait the repeatable job 76 // Wait the repeatable job
76 await wait(8000) 77 await wait(8000)
@@ -82,8 +83,8 @@ describe('Test application behind a reverse proxy', function () {
82 it('Should view a video two times with a different client IP in the X-Forwarded-For header', async function () { 83 it('Should view a video two times with a different client IP in the X-Forwarded-For header', async function () {
83 this.timeout(20000) 84 this.timeout(20000)
84 85
85 await viewVideo(server.url, videoId, 204, '0.0.0.8,0.0.0.6,127.0.0.1') 86 await viewVideo(server.url, videoId, HttpStatusCode.NO_CONTENT_204, '0.0.0.8,0.0.0.6,127.0.0.1')
86 await viewVideo(server.url, videoId, 204, '0.0.0.8,0.0.0.7,127.0.0.1') 87 await viewVideo(server.url, videoId, HttpStatusCode.NO_CONTENT_204, '0.0.0.8,0.0.0.7,127.0.0.1')
87 88
88 // Wait the repeatable job 89 // Wait the repeatable job
89 await wait(8000) 90 await wait(8000)
@@ -96,10 +97,10 @@ describe('Test application behind a reverse proxy', function () {
96 const user = { username: 'root', password: 'fail' } 97 const user = { username: 'root', password: 'fail' }
97 98
98 for (let i = 0; i < 19; i++) { 99 for (let i = 0; i < 19; i++) {
99 await userLogin(server, user, 400) 100 await userLogin(server, user, HttpStatusCode.BAD_REQUEST_400)
100 } 101 }
101 102
102 await userLogin(server, user, 429) 103 await userLogin(server, user, HttpStatusCode.TOO_MANY_REQUESTS_429)
103 }) 104 })
104 105
105 it('Should rate limit signup', async function () { 106 it('Should rate limit signup', async function () {
@@ -111,7 +112,7 @@ describe('Test application behind a reverse proxy', function () {
111 } 112 }
112 } 113 }
113 114
114 await registerUser(server.url, 'test42', 'password', 429) 115 await registerUser(server.url, 'test42', 'password', HttpStatusCode.TOO_MANY_REQUESTS_429)
115 }) 116 })
116 117
117 it('Should not rate limit failed signup', async function () { 118 it('Should not rate limit failed signup', async function () {
@@ -120,10 +121,10 @@ describe('Test application behind a reverse proxy', function () {
120 await wait(7000) 121 await wait(7000)
121 122
122 for (let i = 0; i < 3; i++) { 123 for (let i = 0; i < 3; i++) {
123 await registerUser(server.url, 'test' + i, 'password', 409) 124 await registerUser(server.url, 'test' + i, 'password', HttpStatusCode.CONFLICT_409)
124 } 125 }
125 126
126 await registerUser(server.url, 'test43', 'password', 204) 127 await registerUser(server.url, 'test43', 'password', HttpStatusCode.NO_CONTENT_204)
127 128
128 }) 129 })
129 130
@@ -140,7 +141,7 @@ describe('Test application behind a reverse proxy', function () {
140 } 141 }
141 } 142 }
142 143
143 await getVideo(server.url, videoId, 429) 144 await getVideo(server.url, videoId, HttpStatusCode.TOO_MANY_REQUESTS_429)
144 }) 145 })
145 146
146 after(async function () { 147 after(async function () {
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index fdd5e33f3..f754df04e 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -41,6 +41,7 @@ import {
41 findCommentId 41 findCommentId
42} from '../../../../shared/extra-utils/videos/video-comments' 42} from '../../../../shared/extra-utils/videos/video-comments'
43import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 43import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
44import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
44 45
45const expect = chai.expect 46const expect = chai.expect
46 47
@@ -999,7 +1000,7 @@ describe('Test multiple servers', function () {
999 expect(res.body.downloadEnabled).to.be.false 1000 expect(res.body.downloadEnabled).to.be.false
1000 1001
1001 const text = 'my super forbidden comment' 1002 const text = 'my super forbidden comment'
1002 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, 409) 1003 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, HttpStatusCode.CONFLICT_409)
1003 } 1004 }
1004 }) 1005 })
1005 }) 1006 })
@@ -1021,7 +1022,7 @@ describe('Test multiple servers', function () {
1021 const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm') 1022 const filePath = join(__dirname, '..', '..', 'fixtures', 'video_short.webm')
1022 1023
1023 await req.attach('videofile', filePath) 1024 await req.attach('videofile', filePath)
1024 .expect(200) 1025 .expect(HttpStatusCode.OK_200)
1025 1026
1026 await waitJobs(servers) 1027 await waitJobs(servers)
1027 1028
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index dee6575b9..fad4c8b1f 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -23,6 +23,7 @@ import {
23import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 23import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
24import { User } from '../../../../shared/models/users' 24import { User } from '../../../../shared/models/users'
25import { VideoDetails } from '../../../../shared/models/videos' 25import { VideoDetails } from '../../../../shared/models/videos'
26import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
26 27
27const expect = chai.expect 28const expect = chai.expect
28 29
@@ -140,7 +141,7 @@ describe('Test video change ownership - nominal', function () {
140 it('Should not be possible to refuse the change of ownership from first user', async function () { 141 it('Should not be possible to refuse the change of ownership from first user', async function () {
141 this.timeout(10000) 142 this.timeout(10000)
142 143
143 await refuseChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, 403) 144 await refuseChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, HttpStatusCode.FORBIDDEN_403)
144 }) 145 })
145 146
146 it('Should be possible to refuse the change of ownership from second user', async function () { 147 it('Should be possible to refuse the change of ownership from second user', async function () {
@@ -177,7 +178,7 @@ describe('Test video change ownership - nominal', function () {
177 const secondUserInformationResponse = await getMyUserInformation(servers[0].url, secondUserAccessToken) 178 const secondUserInformationResponse = await getMyUserInformation(servers[0].url, secondUserAccessToken)
178 const secondUserInformation: User = secondUserInformationResponse.body 179 const secondUserInformation: User = secondUserInformationResponse.body
179 const channelId = secondUserInformation.videoChannels[0].id 180 const channelId = secondUserInformation.videoChannels[0].id
180 await acceptChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, channelId, 403) 181 await acceptChangeOwnership(servers[0].url, firstUserAccessToken, lastRequestChangeOwnershipId, channelId, HttpStatusCode.FORBIDDEN_403)
181 }) 182 })
182 183
183 it('Should be possible to accept the change of ownership from second user', async function () { 184 it('Should be possible to accept the change of ownership from second user', async function () {
@@ -294,7 +295,14 @@ describe('Test video change ownership - quota too small', function () {
294 const secondUserInformationResponse = await getMyUserInformation(server.url, secondUserAccessToken) 295 const secondUserInformationResponse = await getMyUserInformation(server.url, secondUserAccessToken)
295 const secondUserInformation: User = secondUserInformationResponse.body 296 const secondUserInformation: User = secondUserInformationResponse.body
296 const channelId = secondUserInformation.videoChannels[0].id 297 const channelId = secondUserInformation.videoChannels[0].id
297 await acceptChangeOwnership(server.url, secondUserAccessToken, lastRequestChangeOwnershipId, channelId, 403) 298
299 await acceptChangeOwnership(
300 server.url,
301 secondUserAccessToken,
302 lastRequestChangeOwnershipId,
303 channelId,
304 HttpStatusCode.PAYLOAD_TOO_LARGE_413
305 )
298 }) 306 })
299 307
300 after(async function () { 308 after(async function () {
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index 3a65cc1d2..f3dbbb114 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -26,6 +26,7 @@ import {
26import { VideoDetails } from '../../../../shared/models/videos' 26import { VideoDetails } from '../../../../shared/models/videos'
27import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type' 27import { VideoStreamingPlaylistType } from '../../../../shared/models/videos/video-streaming-playlist.type'
28import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants' 28import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
29import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
29 30
30const expect = chai.expect 31const expect = chai.expect
31 32
@@ -57,8 +58,8 @@ async function checkHlsPlaylist (servers: ServerInfo[], videoUUID: string, hlsOn
57 ) 58 )
58 expect(file.resolution.label).to.equal(resolution + 'p') 59 expect(file.resolution.label).to.equal(resolution + 'p')
59 60
60 await makeRawRequest(file.torrentUrl, 200) 61 await makeRawRequest(file.torrentUrl, HttpStatusCode.OK_200)
61 await makeRawRequest(file.fileUrl, 200) 62 await makeRawRequest(file.fileUrl, HttpStatusCode.OK_200)
62 63
63 const torrent = await webtorrentAdd(file.magnetUri, true) 64 const torrent = await webtorrentAdd(file.magnetUri, true)
64 expect(torrent.files).to.be.an('array') 65 expect(torrent.files).to.be.an('array')
@@ -144,8 +145,8 @@ describe('Test HLS videos', function () {
144 await waitJobs(servers) 145 await waitJobs(servers)
145 146
146 for (const server of servers) { 147 for (const server of servers) {
147 await getVideo(server.url, videoUUID, 404) 148 await getVideo(server.url, videoUUID, HttpStatusCode.NOT_FOUND_404)
148 await getVideo(server.url, videoAudioUUID, 404) 149 await getVideo(server.url, videoAudioUUID, HttpStatusCode.NOT_FOUND_404)
149 } 150 }
150 }) 151 })
151 152
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 7d1215990..0a96ea9a0 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -61,6 +61,7 @@ import {
61 removeServerFromAccountBlocklist, 61 removeServerFromAccountBlocklist,
62 removeServerFromServerBlocklist 62 removeServerFromServerBlocklist
63} from '../../../../shared/extra-utils/users/blocklist' 63} from '../../../../shared/extra-utils/users/blocklist'
64import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
64 65
65const expect = chai.expect 66const expect = chai.expect
66 67
@@ -1091,7 +1092,7 @@ describe('Test video playlists', function () {
1091 await waitJobs(servers) 1092 await waitJobs(servers)
1092 1093
1093 for (const server of servers) { 1094 for (const server of servers) {
1094 await getVideoPlaylist(server.url, videoPlaylistIds.uuid, 200) 1095 await getVideoPlaylist(server.url, videoPlaylistIds.uuid, HttpStatusCode.OK_200)
1095 } 1096 }
1096 1097
1097 const playlistAttrs = { privacy: VideoPlaylistPrivacy.PRIVATE } 1098 const playlistAttrs = { privacy: VideoPlaylistPrivacy.PRIVATE }
@@ -1100,11 +1101,11 @@ describe('Test video playlists', function () {
1100 await waitJobs(servers) 1101 await waitJobs(servers)
1101 1102
1102 for (const server of [ servers[1], servers[2] ]) { 1103 for (const server of [ servers[1], servers[2] ]) {
1103 await getVideoPlaylist(server.url, videoPlaylistIds.uuid, 404) 1104 await getVideoPlaylist(server.url, videoPlaylistIds.uuid, HttpStatusCode.NOT_FOUND_404)
1104 } 1105 }
1105 await getVideoPlaylist(servers[0].url, videoPlaylistIds.uuid, 401) 1106 await getVideoPlaylist(servers[0].url, videoPlaylistIds.uuid, HttpStatusCode.UNAUTHORIZED_401)
1106 1107
1107 await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistIds.uuid, 200) 1108 await getVideoPlaylistWithToken(servers[0].url, servers[0].accessToken, videoPlaylistIds.uuid, HttpStatusCode.OK_200)
1108 }) 1109 })
1109 }) 1110 })
1110 1111
@@ -1118,7 +1119,7 @@ describe('Test video playlists', function () {
1118 await waitJobs(servers) 1119 await waitJobs(servers)
1119 1120
1120 for (const server of servers) { 1121 for (const server of servers) {
1121 await getVideoPlaylist(server.url, playlistServer1UUID, 404) 1122 await getVideoPlaylist(server.url, playlistServer1UUID, HttpStatusCode.NOT_FOUND_404)
1122 } 1123 }
1123 }) 1124 })
1124 1125
@@ -1178,7 +1179,7 @@ describe('Test video playlists', function () {
1178 expect(res3.body.displayName).to.equal('channel playlist') 1179 expect(res3.body.displayName).to.equal('channel playlist')
1179 expect(res3.body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE) 1180 expect(res3.body.privacy.id).to.equal(VideoPlaylistPrivacy.PRIVATE)
1180 1181
1181 await getVideoPlaylist(servers[1].url, videoPlaylistUUID, 404) 1182 await getVideoPlaylist(servers[1].url, videoPlaylistUUID, HttpStatusCode.NOT_FOUND_404)
1182 }) 1183 })
1183 1184
1184 it('Should delete an account and delete its playlists', async function () { 1185 it('Should delete an account and delete its playlists', async function () {
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
index 38e93bbe6..f25d75af4 100644
--- a/server/tests/api/videos/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -18,6 +18,7 @@ import { createUser } from '../../../../shared/extra-utils/users/users'
18import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/extra-utils/videos/videos' 18import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/extra-utils/videos/videos'
19import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 19import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
20import { Video } from '@shared/models' 20import { Video } from '@shared/models'
21import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
21 22
22const expect = chai.expect 23const expect = chai.expect
23 24
@@ -110,8 +111,8 @@ describe('Test video privacy', function () {
110 }) 111 })
111 112
112 it('Should not be able to watch the private/internal video with non authenticated user', async function () { 113 it('Should not be able to watch the private/internal video with non authenticated user', async function () {
113 await getVideo(servers[0].url, privateVideoUUID, 401) 114 await getVideo(servers[0].url, privateVideoUUID, HttpStatusCode.UNAUTHORIZED_401)
114 await getVideo(servers[0].url, internalVideoUUID, 401) 115 await getVideo(servers[0].url, internalVideoUUID, HttpStatusCode.UNAUTHORIZED_401)
115 }) 116 })
116 117
117 it('Should not be able to watch the private video with another user', async function () { 118 it('Should not be able to watch the private video with another user', async function () {
@@ -124,15 +125,15 @@ describe('Test video privacy', function () {
124 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password }) 125 await createUser({ url: servers[0].url, accessToken: servers[0].accessToken, username: user.username, password: user.password })
125 126
126 anotherUserToken = await userLogin(servers[0], user) 127 anotherUserToken = await userLogin(servers[0], user)
127 await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, 403) 128 await getVideoWithToken(servers[0].url, anotherUserToken, privateVideoUUID, HttpStatusCode.FORBIDDEN_403)
128 }) 129 })
129 130
130 it('Should be able to watch the internal video with another user', async function () { 131 it('Should be able to watch the internal video with another user', async function () {
131 await getVideoWithToken(servers[0].url, anotherUserToken, internalVideoUUID, 200) 132 await getVideoWithToken(servers[0].url, anotherUserToken, internalVideoUUID, HttpStatusCode.OK_200)
132 }) 133 })
133 134
134 it('Should be able to watch the private video with the correct user', async function () { 135 it('Should be able to watch the private video with the correct user', async function () {
135 await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID, 200) 136 await getVideoWithToken(servers[0].url, servers[0].accessToken, privateVideoUUID, HttpStatusCode.OK_200)
136 }) 137 })
137 138
138 it('Should upload an unlisted video on server 2', async function () { 139 it('Should upload an unlisted video on server 2', async function () {
@@ -202,7 +203,7 @@ describe('Test video privacy', function () {
202 }) 203 })
203 204
204 it('Should not be able to get non-federated unlisted video from federated server', async function () { 205 it('Should not be able to get non-federated unlisted video from federated server', async function () {
205 await getVideo(servers[1].url, nonFederatedUnlistedVideoUUID, 404) 206 await getVideo(servers[1].url, nonFederatedUnlistedVideoUUID, HttpStatusCode.NOT_FOUND_404)
206 }) 207 })
207 208
208 it('Should update the private and internal videos to public on server 1', async function () { 209 it('Should update the private and internal videos to public on server 1', async function () {
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index 6f90e9a57..661d603cb 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -20,6 +20,7 @@ import {
20} from '../../../../shared/extra-utils' 20} from '../../../../shared/extra-utils'
21import { Video, VideoDetails } from '../../../../shared/models/videos' 21import { Video, VideoDetails } from '../../../../shared/models/videos'
22import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '../../../../shared/extra-utils/videos/video-history' 22import { listMyVideosHistory, removeMyVideosHistory, userWatchVideo } from '../../../../shared/extra-utils/videos/video-history'
23import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
23 24
24const expect = chai.expect 25const expect = chai.expect
25 26
@@ -171,7 +172,7 @@ describe('Test videos history', function () {
171 videosHistoryEnabled: false 172 videosHistoryEnabled: false
172 }) 173 })
173 174
174 await userWatchVideo(server.url, server.accessToken, video2UUID, 8, 409) 175 await userWatchVideo(server.url, server.accessToken, video2UUID, 8, HttpStatusCode.CONFLICT_409)
175 }) 176 })
176 177
177 it('Should re-enable videos history', async function () { 178 it('Should re-enable videos history', async function () {