aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 10:42:24 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitc0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea (patch)
treebaf29753ac5d4598643e3bee719f8df0cc36c59d /server
parent08642a765ea514a00f159db898edf14c376fbe6c (diff)
downloadPeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.tar.gz
PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.tar.zst
PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.zip
Refactor requests
Diffstat (limited to 'server')
-rw-r--r--server/controllers/activitypub/inbox.ts2
-rw-r--r--server/controllers/api/abuse.ts2
-rw-r--r--server/controllers/api/bulk.ts2
-rw-r--r--server/controllers/api/custom-page.ts2
-rw-r--r--server/controllers/api/index.ts2
-rw-r--r--server/controllers/api/oauth-clients.ts2
-rw-r--r--server/controllers/api/plugins.ts2
-rw-r--r--server/controllers/api/search/search-video-channels.ts2
-rw-r--r--server/controllers/api/search/search-video-playlists.ts2
-rw-r--r--server/controllers/api/search/search-videos.ts2
-rw-r--r--server/controllers/api/server/contact.ts4
-rw-r--r--server/controllers/api/server/debug.ts2
-rw-r--r--server/controllers/api/server/follows.ts2
-rw-r--r--server/controllers/api/server/redundancy.ts16
-rw-r--r--server/controllers/api/server/server-blocklist.ts4
-rw-r--r--server/controllers/api/users/index.ts2
-rw-r--r--server/controllers/api/users/me.ts2
-rw-r--r--server/controllers/api/users/my-blocklist.ts2
-rw-r--r--server/controllers/api/users/my-history.ts2
-rw-r--r--server/controllers/api/users/my-notifications.ts2
-rw-r--r--server/controllers/api/users/my-subscriptions.ts2
-rw-r--r--server/controllers/api/video-channel.ts2
-rw-r--r--server/controllers/api/video-playlist.ts2
-rw-r--r--server/controllers/api/videos/blacklist.ts2
-rw-r--r--server/controllers/api/videos/captions.ts2
-rw-r--r--server/controllers/api/videos/comment.ts2
-rw-r--r--server/controllers/api/videos/index.ts2
-rw-r--r--server/controllers/api/videos/live.ts2
-rw-r--r--server/controllers/api/videos/ownership.ts2
-rw-r--r--server/controllers/api/videos/rate.ts2
-rw-r--r--server/controllers/api/videos/update.ts4
-rw-r--r--server/controllers/api/videos/upload.ts2
-rw-r--r--server/controllers/api/videos/watching.ts2
-rw-r--r--server/controllers/client.ts2
-rw-r--r--server/controllers/download.ts2
-rw-r--r--server/controllers/lazy-static.ts2
-rw-r--r--server/controllers/live.ts2
-rw-r--r--server/controllers/plugins.ts2
-rw-r--r--server/controllers/static.ts2
-rw-r--r--server/helpers/custom-validators/video-ownership.ts2
-rw-r--r--server/helpers/express-utils.ts2
-rw-r--r--server/helpers/youtube-dl.ts2
-rw-r--r--server/lib/activitypub/actors/refresh.ts2
-rw-r--r--server/lib/activitypub/playlists/refresh.ts2
-rw-r--r--server/lib/activitypub/videos/refresh.ts2
-rw-r--r--server/lib/client-html.ts2
-rw-r--r--server/lib/job-queue/handlers/activitypub-cleaner.ts2
-rw-r--r--server/middlewares/activitypub.ts2
-rw-r--r--server/middlewares/auth.ts2
-rw-r--r--server/middlewares/cache.ts2
-rw-r--r--server/middlewares/error.ts2
-rw-r--r--server/middlewares/servers.ts2
-rw-r--r--server/middlewares/user-right.ts2
-rw-r--r--server/middlewares/validators/abuse.ts2
-rw-r--r--server/middlewares/validators/activitypub/activity.ts2
-rw-r--r--server/middlewares/validators/blocklist.ts2
-rw-r--r--server/middlewares/validators/bulk.ts2
-rw-r--r--server/middlewares/validators/feeds.ts2
-rw-r--r--server/middlewares/validators/follows.ts2
-rw-r--r--server/middlewares/validators/oembed.ts2
-rw-r--r--server/middlewares/validators/plugins.ts2
-rw-r--r--server/middlewares/validators/redundancy.ts2
-rw-r--r--server/middlewares/validators/server.ts2
-rw-r--r--server/middlewares/validators/shared/abuses.ts2
-rw-r--r--server/middlewares/validators/shared/accounts.ts2
-rw-r--r--server/middlewares/validators/shared/video-blacklists.ts2
-rw-r--r--server/middlewares/validators/shared/video-captions.ts2
-rw-r--r--server/middlewares/validators/shared/video-channels.ts2
-rw-r--r--server/middlewares/validators/shared/video-comments.ts2
-rw-r--r--server/middlewares/validators/shared/video-imports.ts2
-rw-r--r--server/middlewares/validators/shared/video-ownerships.ts2
-rw-r--r--server/middlewares/validators/shared/video-playlists.ts2
-rw-r--r--server/middlewares/validators/shared/videos.ts2
-rw-r--r--server/middlewares/validators/themes.ts2
-rw-r--r--server/middlewares/validators/user-subscriptions.ts2
-rw-r--r--server/middlewares/validators/users.ts2
-rw-r--r--server/middlewares/validators/videos/video-blacklist.ts2
-rw-r--r--server/middlewares/validators/videos/video-channels.ts2
-rw-r--r--server/middlewares/validators/videos/video-comments.ts2
-rw-r--r--server/middlewares/validators/videos/video-imports.ts2
-rw-r--r--server/middlewares/validators/videos/video-live.ts2
-rw-r--r--server/middlewares/validators/videos/video-ownership-changes.ts2
-rw-r--r--server/middlewares/validators/videos/video-playlists.ts2
-rw-r--r--server/middlewares/validators/videos/video-rates.ts2
-rw-r--r--server/middlewares/validators/videos/video-shares.ts2
-rw-r--r--server/middlewares/validators/videos/video-watch.ts2
-rw-r--r--server/middlewares/validators/videos/videos.ts2
-rw-r--r--server/middlewares/validators/webfinger.ts2
-rw-r--r--server/tests/api/activitypub/client.ts4
-rw-r--r--server/tests/api/activitypub/refresher.ts2
-rw-r--r--server/tests/api/activitypub/security.ts19
-rw-r--r--server/tests/api/check-params/abuses.ts26
-rw-r--r--server/tests/api/check-params/accounts.ts2
-rw-r--r--server/tests/api/check-params/blocklist.ts91
-rw-r--r--server/tests/api/check-params/bulk.ts20
-rw-r--r--server/tests/api/check-params/config.ts24
-rw-r--r--server/tests/api/check-params/contact-form.ts2
-rw-r--r--server/tests/api/check-params/custom-pages.ts15
-rw-r--r--server/tests/api/check-params/debug.ts17
-rw-r--r--server/tests/api/check-params/follows.ts64
-rw-r--r--server/tests/api/check-params/jobs.ts19
-rw-r--r--server/tests/api/check-params/live.ts14
-rw-r--r--server/tests/api/check-params/logs.ts25
-rw-r--r--server/tests/api/check-params/plugins.ts66
-rw-r--r--server/tests/api/check-params/redundancy.ts39
-rw-r--r--server/tests/api/check-params/search.ts62
-rw-r--r--server/tests/api/check-params/services.ts6
-rw-r--r--server/tests/api/check-params/upload-quota.ts4
-rw-r--r--server/tests/api/check-params/user-notifications.ts32
-rw-r--r--server/tests/api/check-params/user-subscriptions.ts68
-rw-r--r--server/tests/api/check-params/users.ts74
-rw-r--r--server/tests/api/check-params/video-blacklist.ts18
-rw-r--r--server/tests/api/check-params/video-captions.ts30
-rw-r--r--server/tests/api/check-params/video-channels.ts26
-rw-r--r--server/tests/api/check-params/video-comments.ts52
-rw-r--r--server/tests/api/check-params/video-imports.ts14
-rw-r--r--server/tests/api/check-params/video-playlists.ts18
-rw-r--r--server/tests/api/check-params/videos-filter.ts14
-rw-r--r--server/tests/api/check-params/videos-history.ts24
-rw-r--r--server/tests/api/check-params/videos.ts36
-rw-r--r--server/tests/api/live/live-save-replay.ts2
-rw-r--r--server/tests/api/live/live.ts2
-rw-r--r--server/tests/api/moderation/abuses.ts8
-rw-r--r--server/tests/api/redundancy/redundancy-constraints.ts2
-rw-r--r--server/tests/api/redundancy/redundancy.ts6
-rw-r--r--server/tests/api/search/search-activitypub-video-channels.ts8
-rw-r--r--server/tests/api/server/config.ts6
-rw-r--r--server/tests/api/server/contact-form.ts2
-rw-r--r--server/tests/api/server/email.ts2
-rw-r--r--server/tests/api/server/follow-constraints.ts50
-rw-r--r--server/tests/api/server/handle-down.ts2
-rw-r--r--server/tests/api/server/homepage.ts2
-rw-r--r--server/tests/api/server/no-client.ts5
-rw-r--r--server/tests/api/server/plugins.ts2
-rw-r--r--server/tests/api/server/reverse-proxy.ts2
-rw-r--r--server/tests/api/users/users-multiple-servers.ts4
-rw-r--r--server/tests/api/users/users-verification.ts2
-rw-r--r--server/tests/api/users/users.ts4
-rw-r--r--server/tests/api/videos/multiple-servers.ts2
-rw-r--r--server/tests/api/videos/resumable-upload.ts2
-rw-r--r--server/tests/api/videos/video-change-ownership.ts2
-rw-r--r--server/tests/api/videos/video-channels.ts6
-rw-r--r--server/tests/api/videos/video-hls.ts2
-rw-r--r--server/tests/api/videos/video-nsfw.ts12
-rw-r--r--server/tests/api/videos/video-playlists.ts2
-rw-r--r--server/tests/api/videos/video-privacy.ts2
-rw-r--r--server/tests/api/videos/video-transcoder.ts10
-rw-r--r--server/tests/api/videos/videos-filter.ts6
-rw-r--r--server/tests/api/videos/videos-history.ts2
-rw-r--r--server/tests/cli/prune-storage.ts6
-rw-r--r--server/tests/cli/regenerate-thumbnails.ts2
-rw-r--r--server/tests/client.ts30
-rw-r--r--server/tests/external-plugins/auth-ldap.ts2
-rw-r--r--server/tests/external-plugins/auto-block-videos.ts8
-rw-r--r--server/tests/external-plugins/auto-mute.ts12
-rw-r--r--server/tests/feeds/feeds.ts2
-rw-r--r--server/tests/misc-endpoints.ts26
-rw-r--r--server/tests/plugins/external-auth.ts20
-rw-r--r--server/tests/plugins/filter-hooks.ts10
-rw-r--r--server/tests/plugins/id-and-pass-auth.ts2
-rw-r--r--server/tests/plugins/plugin-helpers.ts20
-rw-r--r--server/tests/plugins/plugin-router.ts14
-rw-r--r--server/tests/plugins/plugin-storage.ts4
-rw-r--r--server/tests/plugins/plugin-unloading.ts10
-rw-r--r--server/tests/plugins/video-constants.ts2
-rw-r--r--server/tools/peertube-redundancy.ts2
-rw-r--r--server/typings/express/index.d.ts3
167 files changed, 709 insertions, 748 deletions
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts
index 14f301ab7..30662990a 100644
--- a/server/controllers/activitypub/inbox.ts
+++ b/server/controllers/activitypub/inbox.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { InboxManager } from '@server/lib/activitypub/inbox-manager' 2import { InboxManager } from '@server/lib/activitypub/inbox-manager'
3import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' 3import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared'
4import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
5import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' 5import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity'
6import { logger } from '../../helpers/logger' 6import { logger } from '../../helpers/logger'
7import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares' 7import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares'
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts
index ba5b94840..e851365e9 100644
--- a/server/controllers/api/abuse.ts
+++ b/server/controllers/api/abuse.ts
@@ -6,7 +6,7 @@ import { AbuseModel } from '@server/models/abuse/abuse'
6import { AbuseMessageModel } from '@server/models/abuse/abuse-message' 6import { AbuseMessageModel } from '@server/models/abuse/abuse-message'
7import { getServerActor } from '@server/models/application/application' 7import { getServerActor } from '@server/models/application/application'
8import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' 8import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
9import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '@shared/models'
10import { AbuseCreate, AbuseState, UserRight } from '../../../shared' 10import { AbuseCreate, AbuseState, UserRight } from '../../../shared'
11import { getFormattedObjects } from '../../helpers/utils' 11import { getFormattedObjects } from '../../helpers/utils'
12import { sequelizeTypescript } from '../../initializers/database' 12import { sequelizeTypescript } from '../../initializers/database'
diff --git a/server/controllers/api/bulk.ts b/server/controllers/api/bulk.ts
index 192daccde..10d83571d 100644
--- a/server/controllers/api/bulk.ts
+++ b/server/controllers/api/bulk.ts
@@ -4,7 +4,7 @@ import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bu
4import { VideoCommentModel } from '@server/models/video/video-comment' 4import { VideoCommentModel } from '@server/models/video/video-comment'
5import { removeComment } from '@server/lib/video-comment' 5import { removeComment } from '@server/lib/video-comment'
6import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' 6import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
7import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 7import { HttpStatusCode } from '@shared/models'
8 8
9const bulkRouter = express.Router() 9const bulkRouter = express.Router()
10 10
diff --git a/server/controllers/api/custom-page.ts b/server/controllers/api/custom-page.ts
index c19f03c56..cc1aa8427 100644
--- a/server/controllers/api/custom-page.ts
+++ b/server/controllers/api/custom-page.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { ServerConfigManager } from '@server/lib/server-config-manager' 2import { ServerConfigManager } from '@server/lib/server-config-manager'
3import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' 3import { ActorCustomPageModel } from '@server/models/account/actor-custom-page'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { UserRight } from '@shared/models' 5import { UserRight } from '@shared/models'
6import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' 6import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
7 7
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index 28378654a..93b14dadb 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -1,7 +1,7 @@
1import * as cors from 'cors' 1import * as cors from 'cors'
2import * as express from 'express' 2import * as express from 'express'
3import * as RateLimit from 'express-rate-limit' 3import * as RateLimit from 'express-rate-limit'
4import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '../../../shared/models'
5import { badRequest } from '../../helpers/express-utils' 5import { badRequest } from '../../helpers/express-utils'
6import { CONFIG } from '../../initializers/config' 6import { CONFIG } from '../../initializers/config'
7import { abuseRouter } from './abuse' 7import { abuseRouter } from './abuse'
diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts
index 15bbf5c4d..f95f06864 100644
--- a/server/controllers/api/oauth-clients.ts
+++ b/server/controllers/api/oauth-clients.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { OAuthClientLocal } from '../../../shared' 2import { OAuthClientLocal } from '../../../shared'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { CONFIG } from '../../initializers/config' 5import { CONFIG } from '../../initializers/config'
6import { asyncMiddleware, openapiOperationDoc } from '../../middlewares' 6import { asyncMiddleware, openapiOperationDoc } from '../../middlewares'
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts
index 1e6a02c49..4b213c246 100644
--- a/server/controllers/api/plugins.ts
+++ b/server/controllers/api/plugins.ts
@@ -23,7 +23,7 @@ import {
23 updatePluginSettingsValidator 23 updatePluginSettingsValidator
24} from '@server/middlewares/validators/plugins' 24} from '@server/middlewares/validators/plugins'
25import { PluginModel } from '@server/models/server/plugin' 25import { PluginModel } from '@server/models/server/plugin'
26import { HttpStatusCode } from '@shared/core-utils' 26import { HttpStatusCode } from '@shared/models'
27import { 27import {
28 InstallOrUpdatePlugin, 28 InstallOrUpdatePlugin,
29 ManagePlugin, 29 ManagePlugin,
diff --git a/server/controllers/api/search/search-video-channels.ts b/server/controllers/api/search/search-video-channels.ts
index 16beeed60..fe9178e69 100644
--- a/server/controllers/api/search/search-video-channels.ts
+++ b/server/controllers/api/search/search-video-channels.ts
@@ -6,7 +6,7 @@ import { WEBSERVER } from '@server/initializers/constants'
6import { Hooks } from '@server/lib/plugins/hooks' 6import { Hooks } from '@server/lib/plugins/hooks'
7import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' 7import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search'
8import { getServerActor } from '@server/models/application/application' 8import { getServerActor } from '@server/models/application/application'
9import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '@shared/models'
10import { ResultList, VideoChannel } from '@shared/models' 10import { ResultList, VideoChannel } from '@shared/models'
11import { VideoChannelsSearchQuery } from '../../../../shared/models/search' 11import { VideoChannelsSearchQuery } from '../../../../shared/models/search'
12import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' 12import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils'
diff --git a/server/controllers/api/search/search-video-playlists.ts b/server/controllers/api/search/search-video-playlists.ts
index b231ff1e2..a0e2c1747 100644
--- a/server/controllers/api/search/search-video-playlists.ts
+++ b/server/controllers/api/search/search-video-playlists.ts
@@ -11,7 +11,7 @@ import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@ser
11import { getServerActor } from '@server/models/application/application' 11import { getServerActor } from '@server/models/application/application'
12import { VideoPlaylistModel } from '@server/models/video/video-playlist' 12import { VideoPlaylistModel } from '@server/models/video/video-playlist'
13import { MVideoPlaylistFullSummary } from '@server/types/models' 13import { MVideoPlaylistFullSummary } from '@server/types/models'
14import { HttpStatusCode } from '@shared/core-utils' 14import { HttpStatusCode } from '@shared/models'
15import { ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models' 15import { ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models'
16import { 16import {
17 asyncMiddleware, 17 asyncMiddleware,
diff --git a/server/controllers/api/search/search-videos.ts b/server/controllers/api/search/search-videos.ts
index b626baa28..0e6fd9c72 100644
--- a/server/controllers/api/search/search-videos.ts
+++ b/server/controllers/api/search/search-videos.ts
@@ -6,7 +6,7 @@ import { WEBSERVER } from '@server/initializers/constants'
6import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' 6import { getOrCreateAPVideo } from '@server/lib/activitypub/videos'
7import { Hooks } from '@server/lib/plugins/hooks' 7import { Hooks } from '@server/lib/plugins/hooks'
8import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' 8import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search'
9import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '@shared/models'
10import { ResultList, Video } from '@shared/models' 10import { ResultList, Video } from '@shared/models'
11import { VideosSearchQuery } from '../../../../shared/models/search' 11import { VideosSearchQuery } from '../../../../shared/models/search'
12import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' 12import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils'
diff --git a/server/controllers/api/server/contact.ts b/server/controllers/api/server/contact.ts
index caddc0909..ae36dd599 100644
--- a/server/controllers/api/server/contact.ts
+++ b/server/controllers/api/server/contact.ts
@@ -3,7 +3,7 @@ import { asyncMiddleware, contactAdministratorValidator } from '../../../middlew
3import { Redis } from '../../../lib/redis' 3import { Redis } from '../../../lib/redis'
4import { Emailer } from '../../../lib/emailer' 4import { Emailer } from '../../../lib/emailer'
5import { ContactForm } from '../../../../shared/models/server' 5import { ContactForm } from '../../../../shared/models/server'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
7 7
8const contactRouter = express.Router() 8const contactRouter = express.Router()
9 9
@@ -15,7 +15,7 @@ contactRouter.post('/contact',
15async function contactAdministrator (req: express.Request, res: express.Response) { 15async function contactAdministrator (req: express.Request, res: express.Response) {
16 const data = req.body as ContactForm 16 const data = req.body as ContactForm
17 17
18 await Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body) 18 Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body)
19 19
20 await Redis.Instance.setContactFormIp(req.ip) 20 await Redis.Instance.setContactFormIp(req.ip)
21 21
diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts
index 31888e963..0601b89ce 100644
--- a/server/controllers/api/server/debug.ts
+++ b/server/controllers/api/server/debug.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { InboxManager } from '@server/lib/activitypub/inbox-manager' 2import { InboxManager } from '@server/lib/activitypub/inbox-manager'
3import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' 3import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
4import { Debug, SendDebugCommand } from '@shared/models' 4import { Debug, SendDebugCommand } from '@shared/models'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
6import { UserRight } from '../../../../shared/models/users' 6import { UserRight } from '../../../../shared/models/users'
7import { authenticate, ensureUserHasRight } from '../../../middlewares' 7import { authenticate, ensureUserHasRight } from '../../../middlewares'
8 8
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index 12357a2ca..e6f4f6b92 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { getServerActor } from '@server/models/application/application' 2import { getServerActor } from '@server/models/application/application'
3import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { UserRight } from '../../../../shared/models/users' 4import { UserRight } from '../../../../shared/models/users'
5import { logger } from '../../../helpers/logger' 5import { logger } from '../../../helpers/logger'
6import { getFormattedObjects } from '../../../helpers/utils' 6import { getFormattedObjects } from '../../../helpers/utils'
diff --git a/server/controllers/api/server/redundancy.ts b/server/controllers/api/server/redundancy.ts
index bc593ad43..99d1c762b 100644
--- a/server/controllers/api/server/redundancy.ts
+++ b/server/controllers/api/server/redundancy.ts
@@ -1,5 +1,10 @@
1import * as express from 'express' 1import * as express from 'express'
2import { JobQueue } from '@server/lib/job-queue'
3import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
4import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
2import { UserRight } from '../../../../shared/models/users' 5import { UserRight } from '../../../../shared/models/users'
6import { logger } from '../../../helpers/logger'
7import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy'
3import { 8import {
4 asyncMiddleware, 9 asyncMiddleware,
5 authenticate, 10 authenticate,
@@ -10,16 +15,11 @@ import {
10 videoRedundanciesSortValidator 15 videoRedundanciesSortValidator
11} from '../../../middlewares' 16} from '../../../middlewares'
12import { 17import {
13 listVideoRedundanciesValidator,
14 updateServerRedundancyValidator,
15 addVideoRedundancyValidator, 18 addVideoRedundancyValidator,
16 removeVideoRedundancyValidator 19 listVideoRedundanciesValidator,
20 removeVideoRedundancyValidator,
21 updateServerRedundancyValidator
17} from '../../../middlewares/validators/redundancy' 22} from '../../../middlewares/validators/redundancy'
18import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy'
19import { logger } from '../../../helpers/logger'
20import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
21import { JobQueue } from '@server/lib/job-queue'
22import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
23 23
24const serverRedundancyRouter = express.Router() 24const serverRedundancyRouter = express.Router()
25 25
diff --git a/server/controllers/api/server/server-blocklist.ts b/server/controllers/api/server/server-blocklist.ts
index a86bc7d19..b3ee50d85 100644
--- a/server/controllers/api/server/server-blocklist.ts
+++ b/server/controllers/api/server/server-blocklist.ts
@@ -1,8 +1,9 @@
1import 'multer' 1import 'multer'
2import * as express from 'express' 2import * as express from 'express'
3import { logger } from '@server/helpers/logger' 3import { logger } from '@server/helpers/logger'
4import { UserNotificationModel } from '@server/models/user/user-notification'
5import { getServerActor } from '@server/models/application/application' 4import { getServerActor } from '@server/models/application/application'
5import { UserNotificationModel } from '@server/models/user/user-notification'
6import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
6import { UserRight } from '../../../../shared/models/users' 7import { UserRight } from '../../../../shared/models/users'
7import { getFormattedObjects } from '../../../helpers/utils' 8import { getFormattedObjects } from '../../../helpers/utils'
8import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' 9import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist'
@@ -25,7 +26,6 @@ import {
25} from '../../../middlewares/validators' 26} from '../../../middlewares/validators'
26import { AccountBlocklistModel } from '../../../models/account/account-blocklist' 27import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
27import { ServerBlocklistModel } from '../../../models/server/server-blocklist' 28import { ServerBlocklistModel } from '../../../models/server/server-blocklist'
28import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
29 29
30const serverBlocklistRouter = express.Router() 30const serverBlocklistRouter = express.Router()
31 31
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index b86fc94ef..be800e8b5 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -5,7 +5,7 @@ import { Hooks } from '@server/lib/plugins/hooks'
5import { OAuthTokenModel } from '@server/models/oauth/oauth-token' 5import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
6import { MUser, MUserAccountDefault } from '@server/types/models' 6import { MUser, MUserAccountDefault } from '@server/types/models'
7import { UserCreate, UserCreateResult, UserRight, UserRole, UserUpdate } from '../../../../shared' 7import { UserCreate, UserCreateResult, UserRight, UserRole, UserUpdate } from '../../../../shared'
8import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 8import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
9import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' 9import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
10import { UserRegister } from '../../../../shared/models/users/user-register.model' 10import { UserRegister } from '../../../../shared/models/users/user-register.model'
11import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' 11import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index 1f2b2f9dd..c9610c59f 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -3,7 +3,7 @@ import * as express from 'express'
3import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' 3import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger'
4import { Hooks } from '@server/lib/plugins/hooks' 4import { Hooks } from '@server/lib/plugins/hooks'
5import { ActorImageType, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' 5import { ActorImageType, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
7import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' 7import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model'
8import { createReqFiles } from '../../../helpers/express-utils' 8import { createReqFiles } from '../../../helpers/express-utils'
9import { getFormattedObjects } from '../../../helpers/utils' 9import { getFormattedObjects } from '../../../helpers/utils'
diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts
index a1561b751..fe11b6e77 100644
--- a/server/controllers/api/users/my-blocklist.ts
+++ b/server/controllers/api/users/my-blocklist.ts
@@ -22,7 +22,7 @@ import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist
22import { ServerBlocklistModel } from '../../../models/server/server-blocklist' 22import { ServerBlocklistModel } from '../../../models/server/server-blocklist'
23import { UserNotificationModel } from '@server/models/user/user-notification' 23import { UserNotificationModel } from '@server/models/user/user-notification'
24import { logger } from '@server/helpers/logger' 24import { logger } from '@server/helpers/logger'
25import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 25import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
26 26
27const myBlocklistRouter = express.Router() 27const myBlocklistRouter = express.Router()
28 28
diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts
index cff1697ab..85e04925e 100644
--- a/server/controllers/api/users/my-history.ts
+++ b/server/controllers/api/users/my-history.ts
@@ -11,7 +11,7 @@ import {
11import { getFormattedObjects } from '../../../helpers/utils' 11import { getFormattedObjects } from '../../../helpers/utils'
12import { UserVideoHistoryModel } from '../../../models/user/user-video-history' 12import { UserVideoHistoryModel } from '../../../models/user/user-video-history'
13import { sequelizeTypescript } from '../../../initializers/database' 13import { sequelizeTypescript } from '../../../initializers/database'
14import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 14import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
15 15
16const myVideosHistoryRouter = express.Router() 16const myVideosHistoryRouter = express.Router()
17 17
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts
index 2909770da..3beee07c0 100644
--- a/server/controllers/api/users/my-notifications.ts
+++ b/server/controllers/api/users/my-notifications.ts
@@ -1,7 +1,7 @@
1import 'multer' 1import 'multer'
2import * as express from 'express' 2import * as express from 'express'
3import { UserNotificationModel } from '@server/models/user/user-notification' 3import { UserNotificationModel } from '@server/models/user/user-notification'
4import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
5import { UserNotificationSetting } from '../../../../shared/models/users' 5import { UserNotificationSetting } from '../../../../shared/models/users'
6import { getFormattedObjects } from '../../../helpers/utils' 6import { getFormattedObjects } from '../../../helpers/utils'
7import { 7import {
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts
index 46a73d49e..84f519926 100644
--- a/server/controllers/api/users/my-subscriptions.ts
+++ b/server/controllers/api/users/my-subscriptions.ts
@@ -3,7 +3,7 @@ import * as express from 'express'
3import { sendUndoFollow } from '@server/lib/activitypub/send' 3import { sendUndoFollow } from '@server/lib/activitypub/send'
4import { VideoChannelModel } from '@server/models/video/video-channel' 4import { VideoChannelModel } from '@server/models/video/video-channel'
5import { VideosCommonQuery } from '@shared/models' 5import { VideosCommonQuery } from '@shared/models'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
7import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' 7import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
8import { getFormattedObjects } from '../../../helpers/utils' 8import { getFormattedObjects } from '../../../helpers/utils'
9import { WEBSERVER } from '../../../initializers/constants' 9import { WEBSERVER } from '../../../initializers/constants'
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index bc8d203b0..784f97b1e 100644
--- a/server/controllers/api/video-channel.ts
+++ b/server/controllers/api/video-channel.ts
@@ -3,7 +3,7 @@ import { Hooks } from '@server/lib/plugins/hooks'
3import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
4import { MChannelBannerAccountDefault } from '@server/types/models' 4import { MChannelBannerAccountDefault } from '@server/types/models'
5import { ActorImageType, VideoChannelCreate, VideoChannelUpdate, VideosCommonQuery } from '../../../shared' 5import { ActorImageType, VideoChannelCreate, VideoChannelUpdate, VideosCommonQuery } from '../../../shared'
6import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
7import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' 7import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
8import { resetSequelizeInstance } from '../../helpers/database-utils' 8import { resetSequelizeInstance } from '../../helpers/database-utils'
9import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 9import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index 78cbd9cff..4971d0a77 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -6,7 +6,7 @@ import { Hooks } from '@server/lib/plugins/hooks'
6import { getServerActor } from '@server/models/application/application' 6import { getServerActor } from '@server/models/application/application'
7import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' 7import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'
8import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models' 8import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models'
9import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
10import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' 10import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model'
11import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' 11import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model'
12import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' 12import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model'
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts
index 530e17965..a7f5f53d8 100644
--- a/server/controllers/api/videos/blacklist.ts
+++ b/server/controllers/api/videos/blacklist.ts
@@ -19,7 +19,7 @@ import {
19 videosBlacklistUpdateValidator 19 videosBlacklistUpdateValidator
20} from '../../../middlewares' 20} from '../../../middlewares'
21import { VideoBlacklistModel } from '../../../models/video/video-blacklist' 21import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
22import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 22import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
23 23
24const blacklistRouter = express.Router() 24const blacklistRouter = express.Router()
25 25
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts
index ad7423a31..4008de60f 100644
--- a/server/controllers/api/videos/captions.ts
+++ b/server/controllers/api/videos/captions.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { MVideoCaption } from '@server/types/models' 2import { MVideoCaption } from '@server/types/models'
3import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' 4import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
5import { createReqFiles } from '../../../helpers/express-utils' 5import { createReqFiles } from '../../../helpers/express-utils'
6import { logger } from '../../../helpers/logger' 6import { logger } from '../../../helpers/logger'
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts
index 6a25511e5..90b633bb5 100644
--- a/server/controllers/api/videos/comment.ts
+++ b/server/controllers/api/videos/comment.ts
@@ -1,5 +1,5 @@
1import * as express from 'express' 1import * as express from 'express'
2import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 2import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
3import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' 3import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models'
4import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' 4import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model'
5import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' 5import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 74b100e59..5a2ff81dc 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -6,7 +6,7 @@ import { openapiOperationDoc } from '@server/middlewares/doc'
6import { getServerActor } from '@server/models/application/application' 6import { getServerActor } from '@server/models/application/application'
7import { MVideoAccountLight } from '@server/types/models' 7import { MVideoAccountLight } from '@server/types/models'
8import { VideosCommonQuery } from '../../../../shared' 8import { VideosCommonQuery } from '../../../../shared'
9import { HttpStatusCode } from '../../../../shared/core-utils/miscs' 9import { HttpStatusCode } from '../../../../shared/models'
10import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 10import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
11import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' 11import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
12import { logger } from '../../../helpers/logger' 12import { logger } from '../../../helpers/logger'
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts
index d8c51c2d4..ed4da8f47 100644
--- a/server/controllers/api/videos/live.ts
+++ b/server/controllers/api/videos/live.ts
@@ -11,7 +11,7 @@ import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator
11import { VideoLiveModel } from '@server/models/video/video-live' 11import { VideoLiveModel } from '@server/models/video/video-live'
12import { MVideoDetails, MVideoFullLight } from '@server/types/models' 12import { MVideoDetails, MVideoFullLight } from '@server/types/models'
13import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared' 13import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared'
14import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 14import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
15import { logger } from '../../../helpers/logger' 15import { logger } from '../../../helpers/logger'
16import { sequelizeTypescript } from '../../../initializers/database' 16import { sequelizeTypescript } from '../../../initializers/database'
17import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail' 17import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail'
diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts
index 1bb96e046..e6c94a45a 100644
--- a/server/controllers/api/videos/ownership.ts
+++ b/server/controllers/api/videos/ownership.ts
@@ -19,7 +19,7 @@ import { changeVideoChannelShare } from '../../../lib/activitypub/share'
19import { sendUpdateVideo } from '../../../lib/activitypub/send' 19import { sendUpdateVideo } from '../../../lib/activitypub/send'
20import { VideoModel } from '../../../models/video/video' 20import { VideoModel } from '../../../models/video/video'
21import { MVideoFullLight } from '@server/types/models' 21import { MVideoFullLight } from '@server/types/models'
22import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 22import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
23 23
24const ownershipVideoRouter = express.Router() 24const ownershipVideoRouter = express.Router()
25 25
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index 84f42633e..134c9e5ca 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -7,7 +7,7 @@ import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUp
7import { AccountModel } from '../../../models/account/account' 7import { AccountModel } from '../../../models/account/account'
8import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 8import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
9import { sequelizeTypescript } from '../../../initializers/database' 9import { sequelizeTypescript } from '../../../initializers/database'
10import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 10import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
11 11
12const rateVideoRouter = express.Router() 12const rateVideoRouter = express.Router()
13 13
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts
index 8affe71c6..49639060b 100644
--- a/server/controllers/api/videos/update.ts
+++ b/server/controllers/api/videos/update.ts
@@ -2,10 +2,11 @@ import * as express from 'express'
2import { Transaction } from 'sequelize/types' 2import { Transaction } from 'sequelize/types'
3import { changeVideoChannelShare } from '@server/lib/activitypub/share' 3import { changeVideoChannelShare } from '@server/lib/activitypub/share'
4import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' 4import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
5import { openapiOperationDoc } from '@server/middlewares/doc'
5import { FilteredModelAttributes } from '@server/types' 6import { FilteredModelAttributes } from '@server/types'
6import { MVideoFullLight } from '@server/types/models' 7import { MVideoFullLight } from '@server/types/models'
7import { VideoUpdate } from '../../../../shared' 8import { VideoUpdate } from '../../../../shared'
8import { HttpStatusCode } from '../../../../shared/core-utils/miscs' 9import { HttpStatusCode } from '../../../../shared/models'
9import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 10import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
10import { resetSequelizeInstance } from '../../../helpers/database-utils' 11import { resetSequelizeInstance } from '../../../helpers/database-utils'
11import { createReqFiles } from '../../../helpers/express-utils' 12import { createReqFiles } from '../../../helpers/express-utils'
@@ -20,7 +21,6 @@ import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
20import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares' 21import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares'
21import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' 22import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
22import { VideoModel } from '../../../models/video/video' 23import { VideoModel } from '../../../models/video/video'
23import { openapiOperationDoc } from '@server/middlewares/doc'
24 24
25const lTags = loggerTagsFactory('api', 'video') 25const lTags = loggerTagsFactory('api', 'video')
26const auditLogger = auditLoggerFactory('videos') 26const auditLogger = auditLoggerFactory('videos')
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index bcd21ac99..1603ef127 100644
--- a/server/controllers/api/videos/upload.ts
+++ b/server/controllers/api/videos/upload.ts
@@ -11,7 +11,7 @@ import { openapiOperationDoc } from '@server/middlewares/doc'
11import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' 11import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
12import { uploadx } from '@uploadx/core' 12import { uploadx } from '@uploadx/core'
13import { VideoCreate, VideoState } from '../../../../shared' 13import { VideoCreate, VideoState } from '../../../../shared'
14import { HttpStatusCode } from '../../../../shared/core-utils/miscs' 14import { HttpStatusCode } from '../../../../shared/models'
15import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 15import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
16import { retryTransactionWrapper } from '../../../helpers/database-utils' 16import { retryTransactionWrapper } from '../../../helpers/database-utils'
17import { createReqFiles } from '../../../helpers/express-utils' 17import { createReqFiles } from '../../../helpers/express-utils'
diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts
index 8b15525aa..2899dbd9c 100644
--- a/server/controllers/api/videos/watching.ts
+++ b/server/controllers/api/videos/watching.ts
@@ -8,7 +8,7 @@ import {
8 videoWatchingValidator 8 videoWatchingValidator
9} from '../../../middlewares' 9} from '../../../middlewares'
10import { UserVideoHistoryModel } from '../../../models/user/user-video-history' 10import { UserVideoHistoryModel } from '../../../models/user/user-video-history'
11import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 11import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
12 12
13const watchingRouter = express.Router() 13const watchingRouter = express.Router()
14 14
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index eb1ee6cbd..ba3c54440 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -5,7 +5,7 @@ import { join } from 'path'
5import { logger } from '@server/helpers/logger' 5import { logger } from '@server/helpers/logger'
6import { CONFIG } from '@server/initializers/config' 6import { CONFIG } from '@server/initializers/config'
7import { Hooks } from '@server/lib/plugins/hooks' 7import { Hooks } from '@server/lib/plugins/hooks'
8import { HttpStatusCode } from '@shared/core-utils' 8import { HttpStatusCode } from '@shared/models'
9import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n' 9import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n'
10import { root } from '../helpers/core-utils' 10import { root } from '../helpers/core-utils'
11import { STATIC_MAX_AGE } from '../initializers/constants' 11import { STATIC_MAX_AGE } from '../initializers/constants'
diff --git a/server/controllers/download.ts b/server/controllers/download.ts
index 4293a32e2..13bc66900 100644
--- a/server/controllers/download.ts
+++ b/server/controllers/download.ts
@@ -5,7 +5,7 @@ import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache
5import { Hooks } from '@server/lib/plugins/hooks' 5import { Hooks } from '@server/lib/plugins/hooks'
6import { getVideoFilePath } from '@server/lib/video-paths' 6import { getVideoFilePath } from '@server/lib/video-paths'
7import { MStreamingPlaylist, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' 7import { MStreamingPlaylist, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
8import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 8import { HttpStatusCode } from '@shared/models'
9import { VideoStreamingPlaylistType } from '@shared/models' 9import { VideoStreamingPlaylistType } from '@shared/models'
10import { STATIC_DOWNLOAD_PATHS } from '../initializers/constants' 10import { STATIC_DOWNLOAD_PATHS } from '../initializers/constants'
11import { asyncMiddleware, videosDownloadValidator } from '../middlewares' 11import { asyncMiddleware, videosDownloadValidator } from '../middlewares'
diff --git a/server/controllers/lazy-static.ts b/server/controllers/lazy-static.ts
index 9a7dacba0..632e4dcd8 100644
--- a/server/controllers/lazy-static.ts
+++ b/server/controllers/lazy-static.ts
@@ -1,7 +1,7 @@
1import * as cors from 'cors' 1import * as cors from 'cors'
2import * as express from 'express' 2import * as express from 'express'
3import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' 3import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
4import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
5import { logger } from '../helpers/logger' 5import { logger } from '../helpers/logger'
6import { LAZY_STATIC_PATHS, STATIC_MAX_AGE } from '../initializers/constants' 6import { LAZY_STATIC_PATHS, STATIC_MAX_AGE } from '../initializers/constants'
7import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache' 7import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache'
diff --git a/server/controllers/live.ts b/server/controllers/live.ts
index f2686fb23..95d5c0135 100644
--- a/server/controllers/live.ts
+++ b/server/controllers/live.ts
@@ -2,7 +2,7 @@ import * as cors from 'cors'
2import * as express from 'express' 2import * as express from 'express'
3import { mapToJSON } from '@server/helpers/core-utils' 3import { mapToJSON } from '@server/helpers/core-utils'
4import { LiveSegmentShaStore } from '@server/lib/live' 4import { LiveSegmentShaStore } from '@server/lib/live'
5import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '@shared/models'
6 6
7const liveRouter = express.Router() 7const liveRouter = express.Router()
8 8
diff --git a/server/controllers/plugins.ts b/server/controllers/plugins.ts
index 7213e3f15..11ab3f10a 100644
--- a/server/controllers/plugins.ts
+++ b/server/controllers/plugins.ts
@@ -3,7 +3,7 @@ import { join } from 'path'
3import { logger } from '@server/helpers/logger' 3import { logger } from '@server/helpers/logger'
4import { optionalAuthenticate } from '@server/middlewares/auth' 4import { optionalAuthenticate } from '@server/middlewares/auth'
5import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n' 5import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n'
6import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
7import { PluginType } from '../../shared/models/plugins/plugin.type' 7import { PluginType } from '../../shared/models/plugins/plugin.type'
8import { isTestInstance } from '../helpers/core-utils' 8import { isTestInstance } from '../helpers/core-utils'
9import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants' 9import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants'
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 35e024dda..5900eaff3 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -3,7 +3,7 @@ import * as express from 'express'
3import { join } from 'path' 3import { join } from 'path'
4import { serveIndexHTML } from '@server/lib/client-html' 4import { serveIndexHTML } from '@server/lib/client-html'
5import { ServerConfigManager } from '@server/lib/server-config-manager' 5import { ServerConfigManager } from '@server/lib/server-config-manager'
6import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '@shared/models'
7import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model' 7import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model'
8import { root } from '../helpers/core-utils' 8import { root } from '../helpers/core-utils'
9import { CONFIG, isEmailEnabled } from '../initializers/config' 9import { CONFIG, isEmailEnabled } from '../initializers/config'
diff --git a/server/helpers/custom-validators/video-ownership.ts b/server/helpers/custom-validators/video-ownership.ts
index 0e1c63bad..cf15b385a 100644
--- a/server/helpers/custom-validators/video-ownership.ts
+++ b/server/helpers/custom-validators/video-ownership.ts
@@ -1,7 +1,7 @@
1import { Response } from 'express' 1import { Response } from 'express'
2import { MUserId } from '@server/types/models' 2import { MUserId } from '@server/types/models'
3import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership' 3import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership'
4import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
5 5
6function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) { 6function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) {
7 if (videoChangeOwnership.NextOwner.userId === user.id) { 7 if (videoChangeOwnership.NextOwner.userId === user.id) {
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts
index 0ff113274..c299b70f1 100644
--- a/server/helpers/express-utils.ts
+++ b/server/helpers/express-utils.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import * as multer from 'multer' 2import * as multer from 'multer'
3import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
4import { CONFIG } from '../initializers/config' 4import { CONFIG } from '../initializers/config'
5import { REMOTE_SCHEME } from '../initializers/constants' 5import { REMOTE_SCHEME } from '../initializers/constants'
6import { getLowercaseExtension } from './core-utils' 6import { getLowercaseExtension } from './core-utils'
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index fdd361390..3c80e7d41 100644
--- a/server/helpers/youtube-dl.ts
+++ b/server/helpers/youtube-dl.ts
@@ -3,7 +3,7 @@ import { ensureDir, move, pathExists, remove, writeFile } from 'fs-extra'
3import got from 'got' 3import got from 'got'
4import { join } from 'path' 4import { join } from 'path'
5import { CONFIG } from '@server/initializers/config' 5import { CONFIG } from '@server/initializers/config'
6import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
7import { VideoResolution } from '../../shared/models/videos' 7import { VideoResolution } from '../../shared/models/videos'
8import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES } from '../initializers/constants' 8import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES } from '../initializers/constants'
9import { peertubeTruncate, pipelinePromise, root } from './core-utils' 9import { peertubeTruncate, pipelinePromise, root } from './core-utils'
diff --git a/server/lib/activitypub/actors/refresh.ts b/server/lib/activitypub/actors/refresh.ts
index b2fe3932f..0acaa9f62 100644
--- a/server/lib/activitypub/actors/refresh.ts
+++ b/server/lib/activitypub/actors/refresh.ts
@@ -4,7 +4,7 @@ import { PeerTubeRequestError } from '@server/helpers/requests'
4import { ActorLoadByUrlType } from '@server/lib/model-loaders' 4import { ActorLoadByUrlType } from '@server/lib/model-loaders'
5import { ActorModel } from '@server/models/actor/actor' 5import { ActorModel } from '@server/models/actor/actor'
6import { MActorAccountChannelId, MActorFull } from '@server/types/models' 6import { MActorAccountChannelId, MActorFull } from '@server/types/models'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/models'
8import { fetchRemoteActor } from './shared' 8import { fetchRemoteActor } from './shared'
9import { APActorUpdater } from './updater' 9import { APActorUpdater } from './updater'
10import { getUrlFromWebfinger } from './webfinger' 10import { getUrlFromWebfinger } from './webfinger'
diff --git a/server/lib/activitypub/playlists/refresh.ts b/server/lib/activitypub/playlists/refresh.ts
index ef3cb3fe4..493e8c7ec 100644
--- a/server/lib/activitypub/playlists/refresh.ts
+++ b/server/lib/activitypub/playlists/refresh.ts
@@ -2,7 +2,7 @@ import { logger, loggerTagsFactory } from '@server/helpers/logger'
2import { PeerTubeRequestError } from '@server/helpers/requests' 2import { PeerTubeRequestError } from '@server/helpers/requests'
3import { JobQueue } from '@server/lib/job-queue' 3import { JobQueue } from '@server/lib/job-queue'
4import { MVideoPlaylist, MVideoPlaylistOwner } from '@server/types/models' 4import { MVideoPlaylist, MVideoPlaylistOwner } from '@server/types/models'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { createOrUpdateVideoPlaylist } from './create-update' 6import { createOrUpdateVideoPlaylist } from './create-update'
7import { fetchRemoteVideoPlaylist } from './shared' 7import { fetchRemoteVideoPlaylist } from './shared'
8 8
diff --git a/server/lib/activitypub/videos/refresh.ts b/server/lib/activitypub/videos/refresh.ts
index a7b82f286..3af08acf4 100644
--- a/server/lib/activitypub/videos/refresh.ts
+++ b/server/lib/activitypub/videos/refresh.ts
@@ -4,7 +4,7 @@ import { ActorFollowScoreCache } from '@server/lib/files-cache'
4import { VideoLoadByUrlType } from '@server/lib/model-loaders' 4import { VideoLoadByUrlType } from '@server/lib/model-loaders'
5import { VideoModel } from '@server/models/video/video' 5import { VideoModel } from '@server/models/video/video'
6import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models' 6import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/models'
8import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared' 8import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared'
9import { APVideoUpdater } from './updater' 9import { APVideoUpdater } from './updater'
10 10
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index 72194416d..c5d39445b 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -5,7 +5,7 @@ import validator from 'validator'
5import { escapeHTML } from '@shared/core-utils/renderer' 5import { escapeHTML } from '@shared/core-utils/renderer'
6import { HTMLServerConfig } from '@shared/models' 6import { HTMLServerConfig } from '@shared/models'
7import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n' 7import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n'
8import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' 8import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
9import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' 9import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos'
10import { isTestInstance, sha256 } from '../helpers/core-utils' 10import { isTestInstance, sha256 } from '../helpers/core-utils'
11import { logger } from '../helpers/logger' 11import { logger } from '../helpers/logger'
diff --git a/server/lib/job-queue/handlers/activitypub-cleaner.ts b/server/lib/job-queue/handlers/activitypub-cleaner.ts
index 1caca1dcc..56e2b0ceb 100644
--- a/server/lib/job-queue/handlers/activitypub-cleaner.ts
+++ b/server/lib/job-queue/handlers/activitypub-cleaner.ts
@@ -12,7 +12,7 @@ import { AP_CLEANER_CONCURRENCY } from '@server/initializers/constants'
12import { VideoModel } from '@server/models/video/video' 12import { VideoModel } from '@server/models/video/video'
13import { VideoCommentModel } from '@server/models/video/video-comment' 13import { VideoCommentModel } from '@server/models/video/video-comment'
14import { VideoShareModel } from '@server/models/video/video-share' 14import { VideoShareModel } from '@server/models/video/video-share'
15import { HttpStatusCode } from '@shared/core-utils' 15import { HttpStatusCode } from '@shared/models'
16import { logger } from '../../../helpers/logger' 16import { logger } from '../../../helpers/logger'
17import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 17import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
18 18
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts
index 6b43b7764..6ef90b275 100644
--- a/server/middlewares/activitypub.ts
+++ b/server/middlewares/activitypub.ts
@@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from 'express'
2import { getAPId } from '@server/helpers/activitypub' 2import { getAPId } from '@server/helpers/activitypub'
3import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' 3import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor'
4import { ActivityDelete, ActivityPubSignature } from '../../shared' 4import { ActivityDelete, ActivityPubSignature } from '../../shared'
5import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
6import { logger } from '../helpers/logger' 6import { logger } from '../helpers/logger'
7import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' 7import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto'
8import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' 8import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants'
diff --git a/server/middlewares/auth.ts b/server/middlewares/auth.ts
index 176461cc2..9e6327b23 100644
--- a/server/middlewares/auth.ts
+++ b/server/middlewares/auth.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { Socket } from 'socket.io' 2import { Socket } from 'socket.io'
3import { getAccessToken } from '@server/lib/auth/oauth-model' 3import { getAccessToken } from '@server/lib/auth/oauth-model'
4import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
5import { logger } from '../helpers/logger' 5import { logger } from '../helpers/logger'
6import { handleOAuthAuthenticate } from '../lib/auth/oauth' 6import { handleOAuthAuthenticate } from '../lib/auth/oauth'
7 7
diff --git a/server/middlewares/cache.ts b/server/middlewares/cache.ts
index 0708ee8e8..1ced06042 100644
--- a/server/middlewares/cache.ts
+++ b/server/middlewares/cache.ts
@@ -1,6 +1,6 @@
1import { Redis } from '../lib/redis' 1import { Redis } from '../lib/redis'
2import * as apicache from 'apicache' 2import * as apicache from 'apicache'
3import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
4 4
5// Ensure Redis is initialized 5// Ensure Redis is initialized
6Redis.Instance.init() 6Redis.Instance.init()
diff --git a/server/middlewares/error.ts b/server/middlewares/error.ts
index e3eb1c8f5..af5a9c29a 100644
--- a/server/middlewares/error.ts
+++ b/server/middlewares/error.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details' 2import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details'
3import { HttpStatusCode } from '@shared/core-utils' 3import { HttpStatusCode } from '@shared/models'
4 4
5function apiFailMiddleware (req: express.Request, res: express.Response, next: express.NextFunction) { 5function apiFailMiddleware (req: express.Request, res: express.Response, next: express.NextFunction) {
6 res.fail = options => { 6 res.fail = options => {
diff --git a/server/middlewares/servers.ts b/server/middlewares/servers.ts
index 9aa56bc93..49a2241b3 100644
--- a/server/middlewares/servers.ts
+++ b/server/middlewares/servers.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { getHostWithPort } from '../helpers/express-utils' 2import { getHostWithPort } from '../helpers/express-utils'
3import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
4 4
5function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) { 5function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) {
6 if (!req.body.hosts) return next() 6 if (!req.body.hosts) return next()
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts
index d1888c2d3..87a1766cf 100644
--- a/server/middlewares/user-right.ts
+++ b/server/middlewares/user-right.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { UserRight } from '../../shared' 2import { UserRight } from '../../shared'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
5 5
6function ensureUserHasRight (userRight: UserRight) { 6function ensureUserHasRight (userRight: UserRight) {
7 return function (req: express.Request, res: express.Response, next: express.NextFunction) { 7 return function (req: express.Request, res: express.Response, next: express.NextFunction) {
diff --git a/server/middlewares/validators/abuse.ts b/server/middlewares/validators/abuse.ts
index c048bc6af..f4d9c3af2 100644
--- a/server/middlewares/validators/abuse.ts
+++ b/server/middlewares/validators/abuse.ts
@@ -16,7 +16,7 @@ import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID, toIntOrNull } from
16import { logger } from '@server/helpers/logger' 16import { logger } from '@server/helpers/logger'
17import { AbuseMessageModel } from '@server/models/abuse/abuse-message' 17import { AbuseMessageModel } from '@server/models/abuse/abuse-message'
18import { AbuseCreate, UserRight } from '@shared/models' 18import { AbuseCreate, UserRight } from '@shared/models'
19import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 19import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
20import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdExist, doesVideoExist } from './shared' 20import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdExist, doesVideoExist } from './shared'
21 21
22const abuseReportValidator = [ 22const abuseReportValidator = [
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts
index cc6acd4b1..d65a8e455 100644
--- a/server/middlewares/validators/activitypub/activity.ts
+++ b/server/middlewares/validators/activitypub/activity.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' 2import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { getServerActor } from '@server/models/application/application' 4import { getServerActor } from '@server/models/application/application'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
6 6
7async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) { 7async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) {
8 logger.debug('Checking activity pub parameters') 8 logger.debug('Checking activity pub parameters')
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts
index 826b16fc8..f15b293e9 100644
--- a/server/middlewares/validators/blocklist.ts
+++ b/server/middlewares/validators/blocklist.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param } from 'express-validator' 2import { body, param } from 'express-validator'
3import { getServerActor } from '@server/models/application/application' 3import { getServerActor } from '@server/models/application/application'
4import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
5import { isHostValid } from '../../helpers/custom-validators/servers' 5import { isHostValid } from '../../helpers/custom-validators/servers'
6import { logger } from '../../helpers/logger' 6import { logger } from '../../helpers/logger'
7import { WEBSERVER } from '../../initializers/constants' 7import { WEBSERVER } from '../../initializers/constants'
diff --git a/server/middlewares/validators/bulk.ts b/server/middlewares/validators/bulk.ts
index 9bb95f5b7..4057b1e01 100644
--- a/server/middlewares/validators/bulk.ts
+++ b/server/middlewares/validators/bulk.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk' 3import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk'
4import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '@shared/models'
5import { UserRight } from '@shared/models' 5import { UserRight } from '@shared/models'
6import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' 6import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
7import { logger } from '../../helpers/logger' 7import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts
index 51b8fdd19..1a5a8ffa0 100644
--- a/server/middlewares/validators/feeds.ts
+++ b/server/middlewares/validators/feeds.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param, query } from 'express-validator' 2import { param, query } from 'express-validator'
3 3
4import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
5import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' 5import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
6import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID } from '../../helpers/custom-validators/misc' 6import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID } from '../../helpers/custom-validators/misc'
7import { logger } from '../../helpers/logger' 7import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts
index 205baca48..05cc66c38 100644
--- a/server/middlewares/validators/follows.ts
+++ b/server/middlewares/validators/follows.ts
@@ -4,7 +4,7 @@ import { isFollowStateValid } from '@server/helpers/custom-validators/follows'
4import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors' 4import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors'
5import { getServerActor } from '@server/models/application/application' 5import { getServerActor } from '@server/models/application/application'
6import { MActorFollowActorsDefault } from '@server/types/models' 6import { MActorFollowActorsDefault } from '@server/types/models'
7import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 7import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
8import { isTestInstance } from '../../helpers/core-utils' 8import { isTestInstance } from '../../helpers/core-utils'
9import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' 9import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
10import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' 10import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts
index 0a82e6932..e5fc0c277 100644
--- a/server/middlewares/validators/oembed.ts
+++ b/server/middlewares/validators/oembed.ts
@@ -4,7 +4,7 @@ import { join } from 'path'
4import { loadVideo } from '@server/lib/model-loaders' 4import { loadVideo } from '@server/lib/model-loaders'
5import { VideoPlaylistModel } from '@server/models/video/video-playlist' 5import { VideoPlaylistModel } from '@server/models/video/video-playlist'
6import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' 6import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
7import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 7import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
8import { isTestInstance } from '../../helpers/core-utils' 8import { isTestInstance } from '../../helpers/core-utils'
9import { isIdOrUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc' 9import { isIdOrUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc'
10import { logger } from '../../helpers/logger' 10import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index 8c76d2e36..3fb2176b9 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query, ValidationChain } from 'express-validator' 2import { body, param, query, ValidationChain } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { PluginType } from '../../../shared/models/plugins/plugin.type' 4import { PluginType } from '../../../shared/models/plugins/plugin.type'
5import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model' 5import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model'
6import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' 6import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/redundancy.ts b/server/middlewares/validators/redundancy.ts
index 116c8c611..f1b2ff5cd 100644
--- a/server/middlewares/validators/redundancy.ts
+++ b/server/middlewares/validators/redundancy.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies' 3import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies'
4import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 4import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
5import { 5import {
6 exists, 6 exists,
7 isBooleanValid, 7 isBooleanValid,
diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts
index fc7239b25..29fdc13d2 100644
--- a/server/middlewares/validators/server.ts
+++ b/server/middlewares/validators/server.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers' 4import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers'
5import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' 5import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
6import { logger } from '../../helpers/logger' 6import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/shared/abuses.ts b/server/middlewares/validators/shared/abuses.ts
index 4a20a55fa..2b8d86ba5 100644
--- a/server/middlewares/validators/shared/abuses.ts
+++ b/server/middlewares/validators/shared/abuses.ts
@@ -1,6 +1,6 @@
1import { Response } from 'express' 1import { Response } from 'express'
2import { AbuseModel } from '@server/models/abuse/abuse' 2import { AbuseModel } from '@server/models/abuse/abuse'
3import { HttpStatusCode } from '@shared/core-utils' 3import { HttpStatusCode } from '@shared/models'
4 4
5async function doesAbuseExist (abuseId: number | string, res: Response) { 5async function doesAbuseExist (abuseId: number | string, res: Response) {
6 const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10)) 6 const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10))
diff --git a/server/middlewares/validators/shared/accounts.ts b/server/middlewares/validators/shared/accounts.ts
index 04da15441..fe4f83aa0 100644
--- a/server/middlewares/validators/shared/accounts.ts
+++ b/server/middlewares/validators/shared/accounts.ts
@@ -2,7 +2,7 @@ import { Response } from 'express'
2import { AccountModel } from '@server/models/account/account' 2import { AccountModel } from '@server/models/account/account'
3import { UserModel } from '@server/models/user/user' 3import { UserModel } from '@server/models/user/user'
4import { MAccountDefault } from '@server/types/models' 4import { MAccountDefault } from '@server/types/models'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6 6
7function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { 7function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) {
8 const promise = AccountModel.load(parseInt(id + '', 10)) 8 const promise = AccountModel.load(parseInt(id + '', 10))
diff --git a/server/middlewares/validators/shared/video-blacklists.ts b/server/middlewares/validators/shared/video-blacklists.ts
index 01491c10f..f85b39b23 100644
--- a/server/middlewares/validators/shared/video-blacklists.ts
+++ b/server/middlewares/validators/shared/video-blacklists.ts
@@ -1,6 +1,6 @@
1import { Response } from 'express' 1import { Response } from 'express'
2import { VideoBlacklistModel } from '@server/models/video/video-blacklist' 2import { VideoBlacklistModel } from '@server/models/video/video-blacklist'
3import { HttpStatusCode } from '@shared/core-utils' 3import { HttpStatusCode } from '@shared/models'
4 4
5async function doesVideoBlacklistExist (videoId: number, res: Response) { 5async function doesVideoBlacklistExist (videoId: number, res: Response) {
6 const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId) 6 const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId)
diff --git a/server/middlewares/validators/shared/video-captions.ts b/server/middlewares/validators/shared/video-captions.ts
index 80f6c5a52..831b366ea 100644
--- a/server/middlewares/validators/shared/video-captions.ts
+++ b/server/middlewares/validators/shared/video-captions.ts
@@ -1,7 +1,7 @@
1import { Response } from 'express' 1import { Response } from 'express'
2import { VideoCaptionModel } from '@server/models/video/video-caption' 2import { VideoCaptionModel } from '@server/models/video/video-caption'
3import { MVideoId } from '@server/types/models' 3import { MVideoId } from '@server/types/models'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5 5
6async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) { 6async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) {
7 const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language) 7 const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language)
diff --git a/server/middlewares/validators/shared/video-channels.ts b/server/middlewares/validators/shared/video-channels.ts
index fe2e663b7..3fc3d012a 100644
--- a/server/middlewares/validators/shared/video-channels.ts
+++ b/server/middlewares/validators/shared/video-channels.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { VideoChannelModel } from '@server/models/video/video-channel' 2import { VideoChannelModel } from '@server/models/video/video-channel'
3import { MChannelBannerAccountDefault } from '@server/types/models' 3import { MChannelBannerAccountDefault } from '@server/types/models'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5 5
6async function doesLocalVideoChannelNameExist (name: string, res: express.Response) { 6async function doesLocalVideoChannelNameExist (name: string, res: express.Response) {
7 const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) 7 const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name)
diff --git a/server/middlewares/validators/shared/video-comments.ts b/server/middlewares/validators/shared/video-comments.ts
index 83ea15c98..60132fb6e 100644
--- a/server/middlewares/validators/shared/video-comments.ts
+++ b/server/middlewares/validators/shared/video-comments.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { VideoCommentModel } from '@server/models/video/video-comment' 2import { VideoCommentModel } from '@server/models/video/video-comment'
3import { MVideoId } from '@server/types/models' 3import { MVideoId } from '@server/types/models'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5 5
6async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) { 6async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) {
7 const id = parseInt(idArg + '', 10) 7 const id = parseInt(idArg + '', 10)
diff --git a/server/middlewares/validators/shared/video-imports.ts b/server/middlewares/validators/shared/video-imports.ts
index 0f984bc17..50b49ffcb 100644
--- a/server/middlewares/validators/shared/video-imports.ts
+++ b/server/middlewares/validators/shared/video-imports.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { VideoImportModel } from '@server/models/video/video-import' 2import { VideoImportModel } from '@server/models/video/video-import'
3import { HttpStatusCode } from '@shared/core-utils' 3import { HttpStatusCode } from '@shared/models'
4 4
5async function doesVideoImportExist (id: number, res: express.Response) { 5async function doesVideoImportExist (id: number, res: express.Response) {
6 const videoImport = await VideoImportModel.loadAndPopulateVideo(id) 6 const videoImport = await VideoImportModel.loadAndPopulateVideo(id)
diff --git a/server/middlewares/validators/shared/video-ownerships.ts b/server/middlewares/validators/shared/video-ownerships.ts
index fc27006ce..93a23ef40 100644
--- a/server/middlewares/validators/shared/video-ownerships.ts
+++ b/server/middlewares/validators/shared/video-ownerships.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' 2import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'
3import { HttpStatusCode } from '@shared/core-utils' 3import { HttpStatusCode } from '@shared/models'
4 4
5async function doesChangeVideoOwnershipExist (idArg: number | string, res: express.Response) { 5async function doesChangeVideoOwnershipExist (idArg: number | string, res: express.Response) {
6 const id = parseInt(idArg + '', 10) 6 const id = parseInt(idArg + '', 10)
diff --git a/server/middlewares/validators/shared/video-playlists.ts b/server/middlewares/validators/shared/video-playlists.ts
index d762859a8..3f6768179 100644
--- a/server/middlewares/validators/shared/video-playlists.ts
+++ b/server/middlewares/validators/shared/video-playlists.ts
@@ -1,7 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { VideoPlaylistModel } from '@server/models/video/video-playlist' 2import { VideoPlaylistModel } from '@server/models/video/video-playlist'
3import { MVideoPlaylist } from '@server/types/models' 3import { MVideoPlaylist } from '@server/types/models'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5 5
6export type VideoPlaylistFetchType = 'summary' | 'all' 6export type VideoPlaylistFetchType = 'summary' | 'all'
7async function doesVideoPlaylistExist (id: number | string, res: express.Response, fetchType: VideoPlaylistFetchType = 'summary') { 7async function doesVideoPlaylistExist (id: number | string, res: express.Response, fetchType: VideoPlaylistFetchType = 'summary') {
diff --git a/server/middlewares/validators/shared/videos.ts b/server/middlewares/validators/shared/videos.ts
index 2c66c1a3a..7f42a4893 100644
--- a/server/middlewares/validators/shared/videos.ts
+++ b/server/middlewares/validators/shared/videos.ts
@@ -12,7 +12,7 @@ import {
12 MVideoImmutable, 12 MVideoImmutable,
13 MVideoThumbnail 13 MVideoThumbnail
14} from '@server/types/models' 14} from '@server/types/models'
15import { HttpStatusCode } from '@shared/core-utils' 15import { HttpStatusCode } from '@shared/models'
16import { UserRight } from '@shared/models' 16import { UserRight } from '@shared/models'
17 17
18async function doesVideoExist (id: number | string, res: Response, fetchType: VideoLoadType = 'all') { 18async function doesVideoExist (id: number | string, res: Response, fetchType: VideoLoadType = 'all') {
diff --git a/server/middlewares/validators/themes.ts b/server/middlewares/validators/themes.ts
index d4716257f..2953b9505 100644
--- a/server/middlewares/validators/themes.ts
+++ b/server/middlewares/validators/themes.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator' 2import { param } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { isSafePath } from '../../helpers/custom-validators/misc' 4import { isSafePath } from '../../helpers/custom-validators/misc'
5import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' 5import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
6import { logger } from '../../helpers/logger' 6import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts
index ab7962923..df5777771 100644
--- a/server/middlewares/validators/user-subscriptions.ts
+++ b/server/middlewares/validators/user-subscriptions.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' 4import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
5import { toArray } from '../../helpers/custom-validators/misc' 5import { toArray } from '../../helpers/custom-validators/misc'
6import { logger } from '../../helpers/logger' 6import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 698d7d814..748b89f8f 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -3,7 +3,7 @@ import { body, param, query } from 'express-validator'
3import { omit } from 'lodash' 3import { omit } from 'lodash'
4import { Hooks } from '@server/lib/plugins/hooks' 4import { Hooks } from '@server/lib/plugins/hooks'
5import { MUserDefault } from '@server/types/models' 5import { MUserDefault } from '@server/types/models'
6import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
7import { UserRole } from '../../../shared/models/users' 7import { UserRole } from '../../../shared/models/users'
8import { UserRegister } from '../../../shared/models/users/user-register.model' 8import { UserRegister } from '../../../shared/models/users/user-register.model'
9import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' 9import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor'
diff --git a/server/middlewares/validators/videos/video-blacklist.ts b/server/middlewares/validators/videos/video-blacklist.ts
index 21141d84d..3a4937b7b 100644
--- a/server/middlewares/validators/videos/video-blacklist.ts
+++ b/server/middlewares/validators/videos/video-blacklist.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, query } from 'express-validator' 2import { body, query } from 'express-validator'
3import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' 4import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
5import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' 5import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist'
6import { logger } from '../../../helpers/logger' 6import { logger } from '../../../helpers/logger'
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts
index e7df185e4..ea10fe425 100644
--- a/server/middlewares/validators/videos/video-channels.ts
+++ b/server/middlewares/validators/videos/video-channels.ts
@@ -3,7 +3,7 @@ import { body, param, query } from 'express-validator'
3import { VIDEO_CHANNELS } from '@server/initializers/constants' 3import { VIDEO_CHANNELS } from '@server/initializers/constants'
4import { MChannelAccountDefault, MUser } from '@server/types/models' 4import { MChannelAccountDefault, MUser } from '@server/types/models'
5import { UserRight } from '../../../../shared' 5import { UserRight } from '../../../../shared'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
7import { isActorPreferredUsernameValid } from '../../../helpers/custom-validators/activitypub/actor' 7import { isActorPreferredUsernameValid } from '../../../helpers/custom-validators/activitypub/actor'
8import { isBooleanValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' 8import { isBooleanValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
9import { 9import {
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index 885506ebe..61c2ed92f 100644
--- a/server/middlewares/validators/videos/video-comments.ts
+++ b/server/middlewares/validators/videos/video-comments.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { MUserAccountUrl } from '@server/types/models' 3import { MUserAccountUrl } from '@server/types/models'
4import { UserRight } from '../../../../shared' 4import { UserRight } from '../../../../shared'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
6import { exists, isBooleanValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' 6import { exists, isBooleanValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
7import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments' 7import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments'
8import { logger } from '../../../helpers/logger' 8import { logger } from '../../../helpers/logger'
diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts
index 85dc647ce..52b839e56 100644
--- a/server/middlewares/validators/videos/video-imports.ts
+++ b/server/middlewares/validators/videos/video-imports.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { isPreImportVideoAccepted } from '@server/lib/moderation' 3import { isPreImportVideoAccepted } from '@server/lib/moderation'
4import { Hooks } from '@server/lib/plugins/hooks' 4import { Hooks } from '@server/lib/plugins/hooks'
5import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 5import { HttpStatusCode } from '@shared/models'
6import { VideoImportCreate } from '@shared/models/videos/import/video-import-create.model' 6import { VideoImportCreate } from '@shared/models/videos/import/video-import-create.model'
7import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc' 7import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
8import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports' 8import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports'
diff --git a/server/middlewares/validators/videos/video-live.ts b/server/middlewares/validators/videos/video-live.ts
index 7cfb935e3..5c8a4269d 100644
--- a/server/middlewares/validators/videos/video-live.ts
+++ b/server/middlewares/validators/videos/video-live.ts
@@ -5,7 +5,7 @@ import { isLocalLiveVideoAccepted } from '@server/lib/moderation'
5import { Hooks } from '@server/lib/plugins/hooks' 5import { Hooks } from '@server/lib/plugins/hooks'
6import { VideoModel } from '@server/models/video/video' 6import { VideoModel } from '@server/models/video/video'
7import { VideoLiveModel } from '@server/models/video/video-live' 7import { VideoLiveModel } from '@server/models/video/video-live'
8import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 8import { HttpStatusCode } from '@shared/models'
9import { ServerErrorCode, UserRight, VideoState } from '@shared/models' 9import { ServerErrorCode, UserRight, VideoState } from '@shared/models'
10import { isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' 10import { isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
11import { isVideoNameValid } from '../../../helpers/custom-validators/videos' 11import { isVideoNameValid } from '../../../helpers/custom-validators/videos'
diff --git a/server/middlewares/validators/videos/video-ownership-changes.ts b/server/middlewares/validators/videos/video-ownership-changes.ts
index 54ac46c99..06f86a4c8 100644
--- a/server/middlewares/validators/videos/video-ownership-changes.ts
+++ b/server/middlewares/validators/videos/video-ownership-changes.ts
@@ -6,7 +6,7 @@ import { logger } from '@server/helpers/logger'
6import { isAbleToUploadVideo } from '@server/lib/user' 6import { isAbleToUploadVideo } from '@server/lib/user'
7import { AccountModel } from '@server/models/account/account' 7import { AccountModel } from '@server/models/account/account'
8import { MVideoWithAllFiles } from '@server/types/models' 8import { MVideoWithAllFiles } from '@server/types/models'
9import { HttpStatusCode } from '@shared/core-utils' 9import { HttpStatusCode } from '@shared/models'
10import { ServerErrorCode, UserRight, VideoChangeOwnershipAccept, VideoChangeOwnershipStatus, VideoState } from '@shared/models' 10import { ServerErrorCode, UserRight, VideoChangeOwnershipAccept, VideoChangeOwnershipStatus, VideoState } from '@shared/models'
11import { 11import {
12 areValidationErrors, 12 areValidationErrors,
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index 5ee7ee0ce..ab84b4814 100644
--- a/server/middlewares/validators/videos/video-playlists.ts
+++ b/server/middlewares/validators/videos/video-playlists.ts
@@ -3,7 +3,7 @@ import { body, param, query, ValidationChain } from 'express-validator'
3import { ExpressPromiseHandler } from '@server/types/express' 3import { ExpressPromiseHandler } from '@server/types/express'
4import { MUserAccountId } from '@server/types/models' 4import { MUserAccountId } from '@server/types/models'
5import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared' 5import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
7import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' 7import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
8import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' 8import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
9import { 9import {
diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/middlewares/validators/videos/video-rates.ts
index 5d5dfb222..5fe78b39e 100644
--- a/server/middlewares/validators/videos/video-rates.ts
+++ b/server/middlewares/validators/videos/video-rates.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body, param, query } from 'express-validator' 2import { body, param, query } from 'express-validator'
3import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { VideoRateType } from '../../../../shared/models/videos' 4import { VideoRateType } from '../../../../shared/models/videos'
5import { isAccountNameValid } from '../../../helpers/custom-validators/accounts' 5import { isAccountNameValid } from '../../../helpers/custom-validators/accounts'
6import { isIdValid } from '../../../helpers/custom-validators/misc' 6import { isIdValid } from '../../../helpers/custom-validators/misc'
diff --git a/server/middlewares/validators/videos/video-shares.ts b/server/middlewares/validators/videos/video-shares.ts
index 7e54b6fc0..3b8d61768 100644
--- a/server/middlewares/validators/videos/video-shares.ts
+++ b/server/middlewares/validators/videos/video-shares.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { param } from 'express-validator' 2import { param } from 'express-validator'
3import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { isIdValid } from '../../../helpers/custom-validators/misc' 4import { isIdValid } from '../../../helpers/custom-validators/misc'
5import { logger } from '../../../helpers/logger' 5import { logger } from '../../../helpers/logger'
6import { VideoShareModel } from '../../../models/video/video-share' 6import { VideoShareModel } from '../../../models/video/video-share'
diff --git a/server/middlewares/validators/videos/video-watch.ts b/server/middlewares/validators/videos/video-watch.ts
index 43306f7cd..431515eb1 100644
--- a/server/middlewares/validators/videos/video-watch.ts
+++ b/server/middlewares/validators/videos/video-watch.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { body } from 'express-validator' 2import { body } from 'express-validator'
3import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
4import { toIntOrNull } from '../../../helpers/custom-validators/misc' 4import { toIntOrNull } from '../../../helpers/custom-validators/misc'
5import { logger } from '../../../helpers/logger' 5import { logger } from '../../../helpers/logger'
6import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' 6import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared'
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 49e10e2b5..374a59c50 100644
--- a/server/middlewares/validators/videos/videos.ts
+++ b/server/middlewares/validators/videos/videos.ts
@@ -6,7 +6,7 @@ import { getServerActor } from '@server/models/application/application'
6import { ExpressPromiseHandler } from '@server/types/express' 6import { ExpressPromiseHandler } from '@server/types/express'
7import { MUserAccountId, MVideoFullLight } from '@server/types/models' 7import { MUserAccountId, MVideoFullLight } from '@server/types/models'
8import { ServerErrorCode, UserRight, VideoPrivacy } from '../../../../shared' 8import { ServerErrorCode, UserRight, VideoPrivacy } from '../../../../shared'
9import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
10import { 10import {
11 exists, 11 exists,
12 isBooleanValid, 12 isBooleanValid,
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts
index bcdd136c6..131360820 100644
--- a/server/middlewares/validators/webfinger.ts
+++ b/server/middlewares/validators/webfinger.ts
@@ -1,6 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { query } from 'express-validator' 2import { query } from 'express-validator'
3import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' 3import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
4import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger' 4import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger'
5import { getHostWithPort } from '../../helpers/express-utils' 5import { getHostWithPort } from '../../helpers/express-utils'
6import { logger } from '../../helpers/logger' 6import { logger } from '../../helpers/logger'
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts
index 720231f02..53cc40663 100644
--- a/server/tests/api/activitypub/client.ts
+++ b/server/tests/api/activitypub/client.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
@@ -68,7 +68,7 @@ describe('Test activitypub', function () {
68 await setDefaultVideoChannel(servers) 68 await setDefaultVideoChannel(servers)
69 69
70 { 70 {
71 video = await await servers[0].videos.quickUpload({ name: 'video' }) 71 video = await servers[0].videos.quickUpload({ name: 'video' })
72 } 72 }
73 73
74 { 74 {
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts
index bbec0d309..a0b72c7e6 100644
--- a/server/tests/api/activitypub/refresher.ts
+++ b/server/tests/api/activitypub/refresher.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 doubleFollow, 7 doubleFollow,
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index c173648b3..94d946563 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -2,20 +2,13 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { activityPubContextify, buildSignedActivity } from '@server/helpers/activitypub'
5import { buildDigest } from '@server/helpers/peertube-crypto' 6import { buildDigest } from '@server/helpers/peertube-crypto'
6import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 7import { HTTP_SIGNATURE } from '@server/initializers/constants'
7import { 8import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils'
8 buildAbsoluteFixturePath, 9import { buildAbsoluteFixturePath, cleanupTests, createMultipleServers, killallServers, PeerTubeServer, wait } from '@shared/extra-utils'
9 cleanupTests, 10import { makeFollowRequest, makePOSTAPRequest } from '@shared/extra-utils/requests/activitypub'
10 createMultipleServers, 11import { HttpStatusCode } from '@shared/models'
11 killallServers,
12 PeerTubeServer,
13 wait
14} from '../../../../shared/extra-utils'
15import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-utils/requests/activitypub'
16import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub'
17import { HTTP_SIGNATURE } from '../../../initializers/constants'
18import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
19 12
20const expect = chai.expect 13const expect = chai.expect
21 14
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts
index 62811f932..87d93195c 100644
--- a/server/tests/api/check-params/abuses.ts
+++ b/server/tests/api/check-params/abuses.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 AbusesCommand, 6 AbusesCommand,
7 checkBadCountPagination, 7 checkBadCountPagination,
@@ -66,7 +66,7 @@ describe('Test abuses API validators', function () {
66 await makeGetRequest({ 66 await makeGetRequest({
67 url: server.url, 67 url: server.url,
68 path, 68 path,
69 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 69 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
70 }) 70 })
71 }) 71 })
72 72
@@ -75,7 +75,7 @@ describe('Test abuses API validators', function () {
75 url: server.url, 75 url: server.url,
76 path, 76 path,
77 token: userToken, 77 token: userToken,
78 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 78 expectedStatus: HttpStatusCode.FORBIDDEN_403
79 }) 79 })
80 }) 80 })
81 81
@@ -110,7 +110,7 @@ describe('Test abuses API validators', function () {
110 videoIs: 'deleted' 110 videoIs: 'deleted'
111 } 111 }
112 112
113 await makeGetRequest({ url: server.url, path, token: server.accessToken, query, statusCodeExpected: HttpStatusCode.OK_200 }) 113 await makeGetRequest({ url: server.url, path, token: server.accessToken, query, expectedStatus: HttpStatusCode.OK_200 })
114 }) 114 })
115 }) 115 })
116 116
@@ -133,7 +133,7 @@ describe('Test abuses API validators', function () {
133 await makeGetRequest({ 133 await makeGetRequest({
134 url: server.url, 134 url: server.url,
135 path, 135 path,
136 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 136 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
137 }) 137 })
138 }) 138 })
139 139
@@ -152,7 +152,7 @@ describe('Test abuses API validators', function () {
152 state: 2 152 state: 2
153 } 153 }
154 154
155 await makeGetRequest({ url: server.url, path, token: userToken, query, statusCodeExpected: HttpStatusCode.OK_200 }) 155 await makeGetRequest({ url: server.url, path, token: userToken, query, expectedStatus: HttpStatusCode.OK_200 })
156 }) 156 })
157 }) 157 })
158 158
@@ -176,7 +176,7 @@ describe('Test abuses API validators', function () {
176 path, 176 path,
177 token: userToken, 177 token: userToken,
178 fields, 178 fields,
179 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 179 expectedStatus: HttpStatusCode.NOT_FOUND_404
180 }) 180 })
181 }) 181 })
182 182
@@ -192,7 +192,7 @@ describe('Test abuses API validators', function () {
192 path, 192 path,
193 token: userToken, 193 token: userToken,
194 fields, 194 fields,
195 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 195 expectedStatus: HttpStatusCode.NOT_FOUND_404
196 }) 196 })
197 }) 197 })
198 198
@@ -208,7 +208,7 @@ describe('Test abuses API validators', function () {
208 path, 208 path,
209 token: userToken, 209 token: userToken,
210 fields, 210 fields,
211 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 211 expectedStatus: HttpStatusCode.NOT_FOUND_404
212 }) 212 })
213 }) 213 })
214 214
@@ -219,14 +219,14 @@ describe('Test abuses API validators', function () {
219 path, 219 path,
220 token: userToken, 220 token: userToken,
221 fields, 221 fields,
222 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 222 expectedStatus: HttpStatusCode.BAD_REQUEST_400
223 }) 223 })
224 }) 224 })
225 225
226 it('Should fail with a non authenticated user', async function () { 226 it('Should fail with a non authenticated user', async function () {
227 const fields = { video: { id: server.store.video.id }, reason: 'my super reason' } 227 const fields = { video: { id: server.store.video.id }, reason: 'my super reason' }
228 228
229 await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 229 await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
230 }) 230 })
231 231
232 it('Should fail with a reason too short', async function () { 232 it('Should fail with a reason too short', async function () {
@@ -249,7 +249,7 @@ describe('Test abuses API validators', function () {
249 path, 249 path,
250 token: userToken, 250 token: userToken,
251 fields, 251 fields,
252 statusCodeExpected: HttpStatusCode.OK_200 252 expectedStatus: HttpStatusCode.OK_200
253 }) 253 })
254 abuseId = res.body.abuse.id 254 abuseId = res.body.abuse.id
255 }) 255 })
@@ -283,7 +283,7 @@ describe('Test abuses API validators', function () {
283 predefinedReasons: [ 'serverRules' ] 283 predefinedReasons: [ 'serverRules' ]
284 } 284 }
285 285
286 await makePostBodyRequest({ url: server.url, path, token: userToken, fields, statusCodeExpected: HttpStatusCode.OK_200 }) 286 await makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: HttpStatusCode.OK_200 })
287 }) 287 })
288 }) 288 })
289 289
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts
index e866593db..0cae485d9 100644
--- a/server/tests/api/check-params/accounts.ts
+++ b/server/tests/api/check-params/accounts.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadSortPagination, 7 checkBadSortPagination,
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts
index b2a1cc4e2..7d5fae5cf 100644
--- a/server/tests/api/check-params/blocklist.ts
+++ b/server/tests/api/check-params/blocklist.ts
@@ -1,23 +1,20 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4
5import { 4import {
5 checkBadCountPagination,
6 checkBadSortPagination,
7 checkBadStartPagination,
6 cleanupTests, 8 cleanupTests,
7 doubleFollow,
8 createMultipleServers, 9 createMultipleServers,
10 doubleFollow,
9 makeDeleteRequest, 11 makeDeleteRequest,
10 makeGetRequest, 12 makeGetRequest,
11 makePostBodyRequest, 13 makePostBodyRequest,
12 PeerTubeServer, 14 PeerTubeServer,
13 setAccessTokensToServers 15 setAccessTokensToServers
14} from '../../../../shared/extra-utils' 16} from '@shared/extra-utils'
15import { 17import { HttpStatusCode } from '@shared/models'
16 checkBadCountPagination,
17 checkBadSortPagination,
18 checkBadStartPagination
19} from '../../../../shared/extra-utils/requests/check-api-params'
20import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
21 18
22describe('Test blocklist API validators', function () { 19describe('Test blocklist API validators', function () {
23 let servers: PeerTubeServer[] 20 let servers: PeerTubeServer[]
@@ -52,7 +49,7 @@ describe('Test blocklist API validators', function () {
52 await makeGetRequest({ 49 await makeGetRequest({
53 url: server.url, 50 url: server.url,
54 path, 51 path,
55 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 52 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
56 }) 53 })
57 }) 54 })
58 55
@@ -75,7 +72,7 @@ describe('Test blocklist API validators', function () {
75 url: server.url, 72 url: server.url,
76 path, 73 path,
77 fields: { accountName: 'user1' }, 74 fields: { accountName: 'user1' },
78 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 75 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
79 }) 76 })
80 }) 77 })
81 78
@@ -85,7 +82,7 @@ describe('Test blocklist API validators', function () {
85 token: server.accessToken, 82 token: server.accessToken,
86 path, 83 path,
87 fields: { accountName: 'user2' }, 84 fields: { accountName: 'user2' },
88 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 85 expectedStatus: HttpStatusCode.NOT_FOUND_404
89 }) 86 })
90 }) 87 })
91 88
@@ -95,7 +92,7 @@ describe('Test blocklist API validators', function () {
95 token: server.accessToken, 92 token: server.accessToken,
96 path, 93 path,
97 fields: { accountName: 'root' }, 94 fields: { accountName: 'root' },
98 statusCodeExpected: HttpStatusCode.CONFLICT_409 95 expectedStatus: HttpStatusCode.CONFLICT_409
99 }) 96 })
100 }) 97 })
101 98
@@ -105,7 +102,7 @@ describe('Test blocklist API validators', function () {
105 token: server.accessToken, 102 token: server.accessToken,
106 path, 103 path,
107 fields: { accountName: 'user1' }, 104 fields: { accountName: 'user1' },
108 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 105 expectedStatus: HttpStatusCode.NO_CONTENT_204
109 }) 106 })
110 }) 107 })
111 }) 108 })
@@ -115,7 +112,7 @@ describe('Test blocklist API validators', function () {
115 await makeDeleteRequest({ 112 await makeDeleteRequest({
116 url: server.url, 113 url: server.url,
117 path: path + '/user1', 114 path: path + '/user1',
118 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 115 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
119 }) 116 })
120 }) 117 })
121 118
@@ -124,7 +121,7 @@ describe('Test blocklist API validators', function () {
124 url: server.url, 121 url: server.url,
125 path: path + '/user2', 122 path: path + '/user2',
126 token: server.accessToken, 123 token: server.accessToken,
127 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 124 expectedStatus: HttpStatusCode.NOT_FOUND_404
128 }) 125 })
129 }) 126 })
130 127
@@ -133,7 +130,7 @@ describe('Test blocklist API validators', function () {
133 url: server.url, 130 url: server.url,
134 path: path + '/user1', 131 path: path + '/user1',
135 token: server.accessToken, 132 token: server.accessToken,
136 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 133 expectedStatus: HttpStatusCode.NO_CONTENT_204
137 }) 134 })
138 }) 135 })
139 }) 136 })
@@ -147,7 +144,7 @@ describe('Test blocklist API validators', function () {
147 await makeGetRequest({ 144 await makeGetRequest({
148 url: server.url, 145 url: server.url,
149 path, 146 path,
150 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 147 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
151 }) 148 })
152 }) 149 })
153 150
@@ -170,7 +167,7 @@ describe('Test blocklist API validators', function () {
170 url: server.url, 167 url: server.url,
171 path, 168 path,
172 fields: { host: 'localhost:9002' }, 169 fields: { host: 'localhost:9002' },
173 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 170 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
174 }) 171 })
175 }) 172 })
176 173
@@ -180,7 +177,7 @@ describe('Test blocklist API validators', function () {
180 token: server.accessToken, 177 token: server.accessToken,
181 path, 178 path,
182 fields: { host: 'localhost:9003' }, 179 fields: { host: 'localhost:9003' },
183 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 180 expectedStatus: HttpStatusCode.NO_CONTENT_204
184 }) 181 })
185 }) 182 })
186 183
@@ -190,7 +187,7 @@ describe('Test blocklist API validators', function () {
190 token: server.accessToken, 187 token: server.accessToken,
191 path, 188 path,
192 fields: { host: 'localhost:' + server.port }, 189 fields: { host: 'localhost:' + server.port },
193 statusCodeExpected: HttpStatusCode.CONFLICT_409 190 expectedStatus: HttpStatusCode.CONFLICT_409
194 }) 191 })
195 }) 192 })
196 193
@@ -200,7 +197,7 @@ describe('Test blocklist API validators', function () {
200 token: server.accessToken, 197 token: server.accessToken,
201 path, 198 path,
202 fields: { host: 'localhost:' + servers[1].port }, 199 fields: { host: 'localhost:' + servers[1].port },
203 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 200 expectedStatus: HttpStatusCode.NO_CONTENT_204
204 }) 201 })
205 }) 202 })
206 }) 203 })
@@ -210,7 +207,7 @@ describe('Test blocklist API validators', function () {
210 await makeDeleteRequest({ 207 await makeDeleteRequest({
211 url: server.url, 208 url: server.url,
212 path: path + '/localhost:' + servers[1].port, 209 path: path + '/localhost:' + servers[1].port,
213 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 210 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
214 }) 211 })
215 }) 212 })
216 213
@@ -219,7 +216,7 @@ describe('Test blocklist API validators', function () {
219 url: server.url, 216 url: server.url,
220 path: path + '/localhost:9004', 217 path: path + '/localhost:9004',
221 token: server.accessToken, 218 token: server.accessToken,
222 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 219 expectedStatus: HttpStatusCode.NOT_FOUND_404
223 }) 220 })
224 }) 221 })
225 222
@@ -228,7 +225,7 @@ describe('Test blocklist API validators', function () {
228 url: server.url, 225 url: server.url,
229 path: path + '/localhost:' + servers[1].port, 226 path: path + '/localhost:' + servers[1].port,
230 token: server.accessToken, 227 token: server.accessToken,
231 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 228 expectedStatus: HttpStatusCode.NO_CONTENT_204
232 }) 229 })
233 }) 230 })
234 }) 231 })
@@ -245,7 +242,7 @@ describe('Test blocklist API validators', function () {
245 await makeGetRequest({ 242 await makeGetRequest({
246 url: server.url, 243 url: server.url,
247 path, 244 path,
248 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 245 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
249 }) 246 })
250 }) 247 })
251 248
@@ -254,7 +251,7 @@ describe('Test blocklist API validators', function () {
254 url: server.url, 251 url: server.url,
255 token: userAccessToken, 252 token: userAccessToken,
256 path, 253 path,
257 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 254 expectedStatus: HttpStatusCode.FORBIDDEN_403
258 }) 255 })
259 }) 256 })
260 257
@@ -277,7 +274,7 @@ describe('Test blocklist API validators', function () {
277 url: server.url, 274 url: server.url,
278 path, 275 path,
279 fields: { accountName: 'user1' }, 276 fields: { accountName: 'user1' },
280 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 277 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
281 }) 278 })
282 }) 279 })
283 280
@@ -287,7 +284,7 @@ describe('Test blocklist API validators', function () {
287 token: userAccessToken, 284 token: userAccessToken,
288 path, 285 path,
289 fields: { accountName: 'user1' }, 286 fields: { accountName: 'user1' },
290 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 287 expectedStatus: HttpStatusCode.FORBIDDEN_403
291 }) 288 })
292 }) 289 })
293 290
@@ -297,7 +294,7 @@ describe('Test blocklist API validators', function () {
297 token: server.accessToken, 294 token: server.accessToken,
298 path, 295 path,
299 fields: { accountName: 'user2' }, 296 fields: { accountName: 'user2' },
300 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 297 expectedStatus: HttpStatusCode.NOT_FOUND_404
301 }) 298 })
302 }) 299 })
303 300
@@ -307,7 +304,7 @@ describe('Test blocklist API validators', function () {
307 token: server.accessToken, 304 token: server.accessToken,
308 path, 305 path,
309 fields: { accountName: 'root' }, 306 fields: { accountName: 'root' },
310 statusCodeExpected: HttpStatusCode.CONFLICT_409 307 expectedStatus: HttpStatusCode.CONFLICT_409
311 }) 308 })
312 }) 309 })
313 310
@@ -317,7 +314,7 @@ describe('Test blocklist API validators', function () {
317 token: server.accessToken, 314 token: server.accessToken,
318 path, 315 path,
319 fields: { accountName: 'user1' }, 316 fields: { accountName: 'user1' },
320 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 317 expectedStatus: HttpStatusCode.NO_CONTENT_204
321 }) 318 })
322 }) 319 })
323 }) 320 })
@@ -327,7 +324,7 @@ describe('Test blocklist API validators', function () {
327 await makeDeleteRequest({ 324 await makeDeleteRequest({
328 url: server.url, 325 url: server.url,
329 path: path + '/user1', 326 path: path + '/user1',
330 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 327 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
331 }) 328 })
332 }) 329 })
333 330
@@ -336,7 +333,7 @@ describe('Test blocklist API validators', function () {
336 url: server.url, 333 url: server.url,
337 path: path + '/user1', 334 path: path + '/user1',
338 token: userAccessToken, 335 token: userAccessToken,
339 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 336 expectedStatus: HttpStatusCode.FORBIDDEN_403
340 }) 337 })
341 }) 338 })
342 339
@@ -345,7 +342,7 @@ describe('Test blocklist API validators', function () {
345 url: server.url, 342 url: server.url,
346 path: path + '/user2', 343 path: path + '/user2',
347 token: server.accessToken, 344 token: server.accessToken,
348 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 345 expectedStatus: HttpStatusCode.NOT_FOUND_404
349 }) 346 })
350 }) 347 })
351 348
@@ -354,7 +351,7 @@ describe('Test blocklist API validators', function () {
354 url: server.url, 351 url: server.url,
355 path: path + '/user1', 352 path: path + '/user1',
356 token: server.accessToken, 353 token: server.accessToken,
357 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 354 expectedStatus: HttpStatusCode.NO_CONTENT_204
358 }) 355 })
359 }) 356 })
360 }) 357 })
@@ -368,7 +365,7 @@ describe('Test blocklist API validators', function () {
368 await makeGetRequest({ 365 await makeGetRequest({
369 url: server.url, 366 url: server.url,
370 path, 367 path,
371 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 368 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
372 }) 369 })
373 }) 370 })
374 371
@@ -377,7 +374,7 @@ describe('Test blocklist API validators', function () {
377 url: server.url, 374 url: server.url,
378 token: userAccessToken, 375 token: userAccessToken,
379 path, 376 path,
380 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 377 expectedStatus: HttpStatusCode.FORBIDDEN_403
381 }) 378 })
382 }) 379 })
383 380
@@ -400,7 +397,7 @@ describe('Test blocklist API validators', function () {
400 url: server.url, 397 url: server.url,
401 path, 398 path,
402 fields: { host: 'localhost:' + servers[1].port }, 399 fields: { host: 'localhost:' + servers[1].port },
403 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 400 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
404 }) 401 })
405 }) 402 })
406 403
@@ -410,7 +407,7 @@ describe('Test blocklist API validators', function () {
410 token: userAccessToken, 407 token: userAccessToken,
411 path, 408 path,
412 fields: { host: 'localhost:' + servers[1].port }, 409 fields: { host: 'localhost:' + servers[1].port },
413 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 410 expectedStatus: HttpStatusCode.FORBIDDEN_403
414 }) 411 })
415 }) 412 })
416 413
@@ -420,7 +417,7 @@ describe('Test blocklist API validators', function () {
420 token: server.accessToken, 417 token: server.accessToken,
421 path, 418 path,
422 fields: { host: 'localhost:9003' }, 419 fields: { host: 'localhost:9003' },
423 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 420 expectedStatus: HttpStatusCode.NO_CONTENT_204
424 }) 421 })
425 }) 422 })
426 423
@@ -430,7 +427,7 @@ describe('Test blocklist API validators', function () {
430 token: server.accessToken, 427 token: server.accessToken,
431 path, 428 path,
432 fields: { host: 'localhost:' + server.port }, 429 fields: { host: 'localhost:' + server.port },
433 statusCodeExpected: HttpStatusCode.CONFLICT_409 430 expectedStatus: HttpStatusCode.CONFLICT_409
434 }) 431 })
435 }) 432 })
436 433
@@ -440,7 +437,7 @@ describe('Test blocklist API validators', function () {
440 token: server.accessToken, 437 token: server.accessToken,
441 path, 438 path,
442 fields: { host: 'localhost:' + servers[1].port }, 439 fields: { host: 'localhost:' + servers[1].port },
443 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 440 expectedStatus: HttpStatusCode.NO_CONTENT_204
444 }) 441 })
445 }) 442 })
446 }) 443 })
@@ -450,7 +447,7 @@ describe('Test blocklist API validators', function () {
450 await makeDeleteRequest({ 447 await makeDeleteRequest({
451 url: server.url, 448 url: server.url,
452 path: path + '/localhost:' + servers[1].port, 449 path: path + '/localhost:' + servers[1].port,
453 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 450 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
454 }) 451 })
455 }) 452 })
456 453
@@ -459,7 +456,7 @@ describe('Test blocklist API validators', function () {
459 url: server.url, 456 url: server.url,
460 path: path + '/localhost:' + servers[1].port, 457 path: path + '/localhost:' + servers[1].port,
461 token: userAccessToken, 458 token: userAccessToken,
462 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 459 expectedStatus: HttpStatusCode.FORBIDDEN_403
463 }) 460 })
464 }) 461 })
465 462
@@ -468,7 +465,7 @@ describe('Test blocklist API validators', function () {
468 url: server.url, 465 url: server.url,
469 path: path + '/localhost:9004', 466 path: path + '/localhost:9004',
470 token: server.accessToken, 467 token: server.accessToken,
471 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 468 expectedStatus: HttpStatusCode.NOT_FOUND_404
472 }) 469 })
473 }) 470 })
474 471
@@ -477,7 +474,7 @@ describe('Test blocklist API validators', function () {
477 url: server.url, 474 url: server.url,
478 path: path + '/localhost:' + servers[1].port, 475 path: path + '/localhost:' + servers[1].port,
479 token: server.accessToken, 476 token: server.accessToken,
480 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 477 expectedStatus: HttpStatusCode.NO_CONTENT_204
481 }) 478 })
482 }) 479 })
483 }) 480 })
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts
index a660c3d80..bc9d7784d 100644
--- a/server/tests/api/check-params/bulk.ts
+++ b/server/tests/api/check-params/bulk.ts
@@ -1,14 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { 4import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
5 cleanupTests, 5import { HttpStatusCode } from '@shared/models'
6 createSingleServer,
7 PeerTubeServer,
8 setAccessTokensToServers
9} from '../../../../shared/extra-utils'
10import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests'
11import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
12 6
13describe('Test bulk API validators', function () { 7describe('Test bulk API validators', function () {
14 let server: PeerTubeServer 8 let server: PeerTubeServer
@@ -36,7 +30,7 @@ describe('Test bulk API validators', function () {
36 url: server.url, 30 url: server.url,
37 path, 31 path,
38 fields: { accountName: 'user1', scope: 'my-videos' }, 32 fields: { accountName: 'user1', scope: 'my-videos' },
39 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 33 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
40 }) 34 })
41 }) 35 })
42 36
@@ -46,7 +40,7 @@ describe('Test bulk API validators', function () {
46 token: server.accessToken, 40 token: server.accessToken,
47 path, 41 path,
48 fields: { accountName: 'user2', scope: 'my-videos' }, 42 fields: { accountName: 'user2', scope: 'my-videos' },
49 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 43 expectedStatus: HttpStatusCode.NOT_FOUND_404
50 }) 44 })
51 }) 45 })
52 46
@@ -56,7 +50,7 @@ describe('Test bulk API validators', function () {
56 token: server.accessToken, 50 token: server.accessToken,
57 path, 51 path,
58 fields: { accountName: 'user1', scope: 'my-videoss' }, 52 fields: { accountName: 'user1', scope: 'my-videoss' },
59 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 53 expectedStatus: HttpStatusCode.BAD_REQUEST_400
60 }) 54 })
61 }) 55 })
62 56
@@ -66,7 +60,7 @@ describe('Test bulk API validators', function () {
66 token: userAccessToken, 60 token: userAccessToken,
67 path, 61 path,
68 fields: { accountName: 'user1', scope: 'instance' }, 62 fields: { accountName: 'user1', scope: 'instance' },
69 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 63 expectedStatus: HttpStatusCode.FORBIDDEN_403
70 }) 64 })
71 }) 65 })
72 66
@@ -76,7 +70,7 @@ describe('Test bulk API validators', function () {
76 token: server.accessToken, 70 token: server.accessToken,
77 path, 71 path,
78 fields: { accountName: 'user1', scope: 'instance' }, 72 fields: { accountName: 'user1', scope: 'instance' },
79 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 73 expectedStatus: HttpStatusCode.NO_CONTENT_204
80 }) 74 })
81 }) 75 })
82 }) 76 })
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 1756d58ee..c3438917e 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
@@ -214,7 +214,7 @@ describe('Test config API validators', function () {
214 await makeGetRequest({ 214 await makeGetRequest({
215 url: server.url, 215 url: server.url,
216 path, 216 path,
217 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 217 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
218 }) 218 })
219 }) 219 })
220 220
@@ -223,7 +223,7 @@ describe('Test config API validators', function () {
223 url: server.url, 223 url: server.url,
224 path, 224 path,
225 token: userAccessToken, 225 token: userAccessToken,
226 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 226 expectedStatus: HttpStatusCode.FORBIDDEN_403
227 }) 227 })
228 }) 228 })
229 }) 229 })
@@ -234,7 +234,7 @@ describe('Test config API validators', function () {
234 url: server.url, 234 url: server.url,
235 path, 235 path,
236 fields: updateParams, 236 fields: updateParams,
237 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 237 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
238 }) 238 })
239 }) 239 })
240 240
@@ -244,7 +244,7 @@ describe('Test config API validators', function () {
244 path, 244 path,
245 fields: updateParams, 245 fields: updateParams,
246 token: userAccessToken, 246 token: userAccessToken,
247 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 247 expectedStatus: HttpStatusCode.FORBIDDEN_403
248 }) 248 })
249 }) 249 })
250 250
@@ -256,7 +256,7 @@ describe('Test config API validators', function () {
256 path, 256 path,
257 fields: newUpdateParams, 257 fields: newUpdateParams,
258 token: server.accessToken, 258 token: server.accessToken,
259 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 259 expectedStatus: HttpStatusCode.BAD_REQUEST_400
260 }) 260 })
261 }) 261 })
262 262
@@ -274,7 +274,7 @@ describe('Test config API validators', function () {
274 path, 274 path,
275 fields: newUpdateParams, 275 fields: newUpdateParams,
276 token: server.accessToken, 276 token: server.accessToken,
277 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 277 expectedStatus: HttpStatusCode.BAD_REQUEST_400
278 }) 278 })
279 }) 279 })
280 280
@@ -295,7 +295,7 @@ describe('Test config API validators', function () {
295 path, 295 path,
296 fields: newUpdateParams, 296 fields: newUpdateParams,
297 token: server.accessToken, 297 token: server.accessToken,
298 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 298 expectedStatus: HttpStatusCode.BAD_REQUEST_400
299 }) 299 })
300 }) 300 })
301 301
@@ -318,7 +318,7 @@ describe('Test config API validators', function () {
318 path, 318 path,
319 fields: newUpdateParams, 319 fields: newUpdateParams,
320 token: server.accessToken, 320 token: server.accessToken,
321 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 321 expectedStatus: HttpStatusCode.BAD_REQUEST_400
322 }) 322 })
323 }) 323 })
324 324
@@ -328,7 +328,7 @@ describe('Test config API validators', function () {
328 path, 328 path,
329 fields: updateParams, 329 fields: updateParams,
330 token: server.accessToken, 330 token: server.accessToken,
331 statusCodeExpected: HttpStatusCode.OK_200 331 expectedStatus: HttpStatusCode.OK_200
332 }) 332 })
333 }) 333 })
334 }) 334 })
@@ -338,7 +338,7 @@ describe('Test config API validators', function () {
338 await makeDeleteRequest({ 338 await makeDeleteRequest({
339 url: server.url, 339 url: server.url,
340 path, 340 path,
341 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 341 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
342 }) 342 })
343 }) 343 })
344 344
@@ -347,7 +347,7 @@ describe('Test config API validators', function () {
347 url: server.url, 347 url: server.url,
348 path, 348 path,
349 token: userAccessToken, 349 token: userAccessToken,
350 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 350 expectedStatus: HttpStatusCode.FORBIDDEN_403
351 }) 351 })
352 }) 352 })
353 }) 353 })
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts
index 8c2b2a84b..8e755c69b 100644
--- a/server/tests/api/check-params/contact-form.ts
+++ b/server/tests/api/check-params/contact-form.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { cleanupTests, createSingleServer, killallServers, MockSmtpServer, PeerTubeServer } from '@shared/extra-utils' 5import { cleanupTests, createSingleServer, killallServers, MockSmtpServer, PeerTubeServer } from '@shared/extra-utils'
6import { ContactFormCommand } from '@shared/extra-utils/server' 6import { ContactFormCommand } from '@shared/extra-utils/server'
7 7
diff --git a/server/tests/api/check-params/custom-pages.ts b/server/tests/api/check-params/custom-pages.ts
index 043505e32..9fbbea315 100644
--- a/server/tests/api/check-params/custom-pages.ts
+++ b/server/tests/api/check-params/custom-pages.ts
@@ -1,14 +1,15 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
5import { 4import {
6 cleanupTests, 5 cleanupTests,
7 createSingleServer, 6 createSingleServer,
7 makeGetRequest,
8 makePutBodyRequest,
8 PeerTubeServer, 9 PeerTubeServer,
9 setAccessTokensToServers 10 setAccessTokensToServers
10} from '../../../../shared/extra-utils' 11} from '@shared/extra-utils'
11import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests' 12import { HttpStatusCode } from '@shared/models'
12 13
13describe('Test custom pages validators', function () { 14describe('Test custom pages validators', function () {
14 const path = '/api/v1/custom-pages/homepage/instance' 15 const path = '/api/v1/custom-pages/homepage/instance'
@@ -37,7 +38,7 @@ describe('Test custom pages validators', function () {
37 url: server.url, 38 url: server.url,
38 path, 39 path,
39 fields: { content: 'super content' }, 40 fields: { content: 'super content' },
40 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 41 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
41 }) 42 })
42 }) 43 })
43 44
@@ -47,7 +48,7 @@ describe('Test custom pages validators', function () {
47 path, 48 path,
48 token: userAccessToken, 49 token: userAccessToken,
49 fields: { content: 'super content' }, 50 fields: { content: 'super content' },
50 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 51 expectedStatus: HttpStatusCode.FORBIDDEN_403
51 }) 52 })
52 }) 53 })
53 54
@@ -57,7 +58,7 @@ describe('Test custom pages validators', function () {
57 path, 58 path,
58 token: server.accessToken, 59 token: server.accessToken,
59 fields: { content: 'super content' }, 60 fields: { content: 'super content' },
60 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 61 expectedStatus: HttpStatusCode.NO_CONTENT_204
61 }) 62 })
62 }) 63 })
63 }) 64 })
@@ -68,7 +69,7 @@ describe('Test custom pages validators', function () {
68 await makeGetRequest({ 69 await makeGetRequest({
69 url: server.url, 70 url: server.url,
70 path, 71 path,
71 statusCodeExpected: HttpStatusCode.OK_200 72 expectedStatus: HttpStatusCode.OK_200
72 }) 73 })
73 }) 74 })
74 }) 75 })
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts
index 9c13e9daf..a55786359 100644
--- a/server/tests/api/check-params/debug.ts
+++ b/server/tests/api/check-params/debug.ts
@@ -1,15 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4 4import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
5import { 5import { HttpStatusCode } from '@shared/models'
6 cleanupTests,
7 createSingleServer,
8 PeerTubeServer,
9 setAccessTokensToServers
10} from '../../../../shared/extra-utils'
11import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
12import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
13 6
14describe('Test debug API validators', function () { 7describe('Test debug API validators', function () {
15 const path = '/api/v1/server/debug' 8 const path = '/api/v1/server/debug'
@@ -39,7 +32,7 @@ describe('Test debug API validators', function () {
39 await makeGetRequest({ 32 await makeGetRequest({
40 url: server.url, 33 url: server.url,
41 path, 34 path,
42 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 35 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
43 }) 36 })
44 }) 37 })
45 38
@@ -48,7 +41,7 @@ describe('Test debug API validators', function () {
48 url: server.url, 41 url: server.url,
49 path, 42 path,
50 token: userAccessToken, 43 token: userAccessToken,
51 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 44 expectedStatus: HttpStatusCode.FORBIDDEN_403
52 }) 45 })
53 }) 46 })
54 47
@@ -58,7 +51,7 @@ describe('Test debug API validators', function () {
58 path, 51 path,
59 token: server.accessToken, 52 token: server.accessToken,
60 query: { startDate: new Date().toISOString() }, 53 query: { startDate: new Date().toISOString() },
61 statusCodeExpected: HttpStatusCode.OK_200 54 expectedStatus: HttpStatusCode.OK_200
62 }) 55 })
63 }) 56 })
64 }) 57 })
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index 0fd2b4925..dfe3f226d 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -1,21 +1,19 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4
5import { 4import {
5 checkBadCountPagination,
6 checkBadSortPagination,
7 checkBadStartPagination,
6 cleanupTests, 8 cleanupTests,
7 createSingleServer, 9 createSingleServer,
8 makeDeleteRequest, makeGetRequest, 10 makeDeleteRequest,
11 makeGetRequest,
9 makePostBodyRequest, 12 makePostBodyRequest,
10 PeerTubeServer, 13 PeerTubeServer,
11 setAccessTokensToServers 14 setAccessTokensToServers
12} from '../../../../shared/extra-utils' 15} from '@shared/extra-utils'
13import { 16import { HttpStatusCode } from '@shared/models'
14 checkBadCountPagination,
15 checkBadSortPagination,
16 checkBadStartPagination
17} from '../../../../shared/extra-utils/requests/check-api-params'
18import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
19 17
20describe('Test server follows API validators', function () { 18describe('Test server follows API validators', function () {
21 let server: PeerTubeServer 19 let server: PeerTubeServer
@@ -51,7 +49,7 @@ describe('Test server follows API validators', function () {
51 url: server.url, 49 url: server.url,
52 path, 50 path,
53 token: server.accessToken, 51 token: server.accessToken,
54 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 52 expectedStatus: HttpStatusCode.BAD_REQUEST_400
55 }) 53 })
56 }) 54 })
57 55
@@ -61,7 +59,7 @@ describe('Test server follows API validators', function () {
61 path, 59 path,
62 token: server.accessToken, 60 token: server.accessToken,
63 fields: { hosts: 'localhost:9002' }, 61 fields: { hosts: 'localhost:9002' },
64 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 62 expectedStatus: HttpStatusCode.BAD_REQUEST_400
65 }) 63 })
66 }) 64 })
67 65
@@ -71,7 +69,7 @@ describe('Test server follows API validators', function () {
71 path, 69 path,
72 fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, 70 fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] },
73 token: server.accessToken, 71 token: server.accessToken,
74 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 72 expectedStatus: HttpStatusCode.BAD_REQUEST_400
75 }) 73 })
76 }) 74 })
77 75
@@ -81,7 +79,7 @@ describe('Test server follows API validators', function () {
81 path, 79 path,
82 fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, 80 fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] },
83 token: server.accessToken, 81 token: server.accessToken,
84 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 82 expectedStatus: HttpStatusCode.BAD_REQUEST_400
85 }) 83 })
86 }) 84 })
87 85
@@ -91,7 +89,7 @@ describe('Test server follows API validators', function () {
91 path, 89 path,
92 fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, 90 fields: { urls: [ 'localhost:9002', 'localhost:9002' ] },
93 token: server.accessToken, 91 token: server.accessToken,
94 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 92 expectedStatus: HttpStatusCode.BAD_REQUEST_400
95 }) 93 })
96 }) 94 })
97 95
@@ -101,7 +99,7 @@ describe('Test server follows API validators', function () {
101 path, 99 path,
102 fields: { hosts: [ 'localhost:9002' ] }, 100 fields: { hosts: [ 'localhost:9002' ] },
103 token: 'fake_token', 101 token: 'fake_token',
104 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 102 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
105 }) 103 })
106 }) 104 })
107 105
@@ -111,7 +109,7 @@ describe('Test server follows API validators', function () {
111 path, 109 path,
112 fields: { hosts: [ 'localhost:9002' ] }, 110 fields: { hosts: [ 'localhost:9002' ] },
113 token: userAccessToken, 111 token: userAccessToken,
114 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 112 expectedStatus: HttpStatusCode.FORBIDDEN_403
115 }) 113 })
116 }) 114 })
117 }) 115 })
@@ -155,7 +153,7 @@ describe('Test server follows API validators', function () {
155 await makeGetRequest({ 153 await makeGetRequest({
156 url: server.url, 154 url: server.url,
157 path, 155 path,
158 statusCodeExpected: HttpStatusCode.OK_200, 156 expectedStatus: HttpStatusCode.OK_200,
159 query: { 157 query: {
160 state: 'accepted', 158 state: 'accepted',
161 actorType: 'Application' 159 actorType: 'Application'
@@ -204,7 +202,7 @@ describe('Test server follows API validators', function () {
204 await makeGetRequest({ 202 await makeGetRequest({
205 url: server.url, 203 url: server.url,
206 path, 204 path,
207 statusCodeExpected: HttpStatusCode.OK_200, 205 expectedStatus: HttpStatusCode.OK_200,
208 query: { 206 query: {
209 state: 'accepted' 207 state: 'accepted'
210 } 208 }
@@ -220,7 +218,7 @@ describe('Test server follows API validators', function () {
220 url: server.url, 218 url: server.url,
221 path: path + '/toto@localhost:9002', 219 path: path + '/toto@localhost:9002',
222 token: 'fake_token', 220 token: 'fake_token',
223 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 221 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
224 }) 222 })
225 }) 223 })
226 224
@@ -229,7 +227,7 @@ describe('Test server follows API validators', function () {
229 url: server.url, 227 url: server.url,
230 path: path + '/toto@localhost:9002', 228 path: path + '/toto@localhost:9002',
231 token: userAccessToken, 229 token: userAccessToken,
232 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 230 expectedStatus: HttpStatusCode.FORBIDDEN_403
233 }) 231 })
234 }) 232 })
235 233
@@ -238,7 +236,7 @@ describe('Test server follows API validators', function () {
238 url: server.url, 236 url: server.url,
239 path: path + '/toto', 237 path: path + '/toto',
240 token: server.accessToken, 238 token: server.accessToken,
241 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 239 expectedStatus: HttpStatusCode.BAD_REQUEST_400
242 }) 240 })
243 }) 241 })
244 242
@@ -247,7 +245,7 @@ describe('Test server follows API validators', function () {
247 url: server.url, 245 url: server.url,
248 path: path + '/toto@localhost:9003', 246 path: path + '/toto@localhost:9003',
249 token: server.accessToken, 247 token: server.accessToken,
250 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 248 expectedStatus: HttpStatusCode.NOT_FOUND_404
251 }) 249 })
252 }) 250 })
253 }) 251 })
@@ -260,7 +258,7 @@ describe('Test server follows API validators', function () {
260 url: server.url, 258 url: server.url,
261 path: path + '/toto@localhost:9002/accept', 259 path: path + '/toto@localhost:9002/accept',
262 token: 'fake_token', 260 token: 'fake_token',
263 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 261 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
264 }) 262 })
265 }) 263 })
266 264
@@ -269,7 +267,7 @@ describe('Test server follows API validators', function () {
269 url: server.url, 267 url: server.url,
270 path: path + '/toto@localhost:9002/accept', 268 path: path + '/toto@localhost:9002/accept',
271 token: userAccessToken, 269 token: userAccessToken,
272 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 270 expectedStatus: HttpStatusCode.FORBIDDEN_403
273 }) 271 })
274 }) 272 })
275 273
@@ -278,7 +276,7 @@ describe('Test server follows API validators', function () {
278 url: server.url, 276 url: server.url,
279 path: path + '/toto/accept', 277 path: path + '/toto/accept',
280 token: server.accessToken, 278 token: server.accessToken,
281 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 279 expectedStatus: HttpStatusCode.BAD_REQUEST_400
282 }) 280 })
283 }) 281 })
284 282
@@ -287,7 +285,7 @@ describe('Test server follows API validators', function () {
287 url: server.url, 285 url: server.url,
288 path: path + '/toto@localhost:9003/accept', 286 path: path + '/toto@localhost:9003/accept',
289 token: server.accessToken, 287 token: server.accessToken,
290 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 288 expectedStatus: HttpStatusCode.NOT_FOUND_404
291 }) 289 })
292 }) 290 })
293 }) 291 })
@@ -300,7 +298,7 @@ describe('Test server follows API validators', function () {
300 url: server.url, 298 url: server.url,
301 path: path + '/toto@localhost:9002/reject', 299 path: path + '/toto@localhost:9002/reject',
302 token: 'fake_token', 300 token: 'fake_token',
303 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 301 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
304 }) 302 })
305 }) 303 })
306 304
@@ -309,7 +307,7 @@ describe('Test server follows API validators', function () {
309 url: server.url, 307 url: server.url,
310 path: path + '/toto@localhost:9002/reject', 308 path: path + '/toto@localhost:9002/reject',
311 token: userAccessToken, 309 token: userAccessToken,
312 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 310 expectedStatus: HttpStatusCode.FORBIDDEN_403
313 }) 311 })
314 }) 312 })
315 313
@@ -318,7 +316,7 @@ describe('Test server follows API validators', function () {
318 url: server.url, 316 url: server.url,
319 path: path + '/toto/reject', 317 path: path + '/toto/reject',
320 token: server.accessToken, 318 token: server.accessToken,
321 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 319 expectedStatus: HttpStatusCode.BAD_REQUEST_400
322 }) 320 })
323 }) 321 })
324 322
@@ -327,7 +325,7 @@ describe('Test server follows API validators', function () {
327 url: server.url, 325 url: server.url,
328 path: path + '/toto@localhost:9003/reject', 326 path: path + '/toto@localhost:9003/reject',
329 token: server.accessToken, 327 token: server.accessToken,
330 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 328 expectedStatus: HttpStatusCode.NOT_FOUND_404
331 }) 329 })
332 }) 330 })
333 }) 331 })
@@ -340,7 +338,7 @@ describe('Test server follows API validators', function () {
340 url: server.url, 338 url: server.url,
341 path: path + '/localhost:9002', 339 path: path + '/localhost:9002',
342 token: 'fake_token', 340 token: 'fake_token',
343 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 341 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
344 }) 342 })
345 }) 343 })
346 344
@@ -349,7 +347,7 @@ describe('Test server follows API validators', function () {
349 url: server.url, 347 url: server.url,
350 path: path + '/localhost:9002', 348 path: path + '/localhost:9002',
351 token: userAccessToken, 349 token: userAccessToken,
352 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 350 expectedStatus: HttpStatusCode.FORBIDDEN_403
353 }) 351 })
354 }) 352 })
355 353
@@ -358,7 +356,7 @@ describe('Test server follows API validators', function () {
358 url: server.url, 356 url: server.url,
359 path: path + '/example.com', 357 path: path + '/example.com',
360 token: server.accessToken, 358 token: server.accessToken,
361 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 359 expectedStatus: HttpStatusCode.NOT_FOUND_404
362 }) 360 })
363 }) 361 })
364 }) 362 })
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index a370ec2d3..23d95d8e4 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -1,20 +1,17 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4
5import { 4import {
5 checkBadCountPagination,
6 checkBadSortPagination,
7 checkBadStartPagination,
6 cleanupTests, 8 cleanupTests,
7 createSingleServer, 9 createSingleServer,
10 makeGetRequest,
8 PeerTubeServer, 11 PeerTubeServer,
9 setAccessTokensToServers 12 setAccessTokensToServers
10} from '../../../../shared/extra-utils' 13} from '@shared/extra-utils'
11import { 14import { HttpStatusCode } from '@shared/models'
12 checkBadCountPagination,
13 checkBadSortPagination,
14 checkBadStartPagination
15} from '../../../../shared/extra-utils/requests/check-api-params'
16import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
17import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
18 15
19describe('Test jobs API validators', function () { 16describe('Test jobs API validators', function () {
20 const path = '/api/v1/jobs/failed' 17 const path = '/api/v1/jobs/failed'
@@ -75,7 +72,7 @@ describe('Test jobs API validators', function () {
75 await makeGetRequest({ 72 await makeGetRequest({
76 url: server.url, 73 url: server.url,
77 path, 74 path,
78 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 75 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
79 }) 76 })
80 }) 77 })
81 78
@@ -84,7 +81,7 @@ describe('Test jobs API validators', function () {
84 url: server.url, 81 url: server.url,
85 path, 82 path,
86 token: userAccessToken, 83 token: userAccessToken,
87 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 84 expectedStatus: HttpStatusCode.FORBIDDEN_403
88 }) 85 })
89 }) 86 })
90 87
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index eb5cdd1d8..0ef86a538 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
8 cleanupTests, 8 cleanupTests,
@@ -223,7 +223,7 @@ describe('Test video lives API validator', function () {
223 path, 223 path,
224 token: server.accessToken, 224 token: server.accessToken,
225 fields: baseCorrectParams, 225 fields: baseCorrectParams,
226 statusCodeExpected: HttpStatusCode.OK_200 226 expectedStatus: HttpStatusCode.OK_200
227 }) 227 })
228 228
229 video = res.body.video 229 video = res.body.video
@@ -243,7 +243,7 @@ describe('Test video lives API validator', function () {
243 path, 243 path,
244 token: server.accessToken, 244 token: server.accessToken,
245 fields: baseCorrectParams, 245 fields: baseCorrectParams,
246 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 246 expectedStatus: HttpStatusCode.FORBIDDEN_403
247 }) 247 })
248 }) 248 })
249 249
@@ -264,7 +264,7 @@ describe('Test video lives API validator', function () {
264 path, 264 path,
265 token: server.accessToken, 265 token: server.accessToken,
266 fields, 266 fields,
267 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 267 expectedStatus: HttpStatusCode.FORBIDDEN_403
268 }) 268 })
269 }) 269 })
270 270
@@ -285,7 +285,7 @@ describe('Test video lives API validator', function () {
285 path, 285 path,
286 token: server.accessToken, 286 token: server.accessToken,
287 fields, 287 fields,
288 statusCodeExpected: HttpStatusCode.OK_200 288 expectedStatus: HttpStatusCode.OK_200
289 }) 289 })
290 }) 290 })
291 291
@@ -304,7 +304,7 @@ describe('Test video lives API validator', function () {
304 path, 304 path,
305 token: server.accessToken, 305 token: server.accessToken,
306 fields: baseCorrectParams, 306 fields: baseCorrectParams,
307 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 307 expectedStatus: HttpStatusCode.FORBIDDEN_403
308 }) 308 })
309 }) 309 })
310 310
@@ -324,7 +324,7 @@ describe('Test video lives API validator', function () {
324 path, 324 path,
325 token: server.accessToken, 325 token: server.accessToken,
326 fields: baseCorrectParams, 326 fields: baseCorrectParams,
327 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 327 expectedStatus: HttpStatusCode.FORBIDDEN_403
328 }) 328 })
329 }) 329 })
330 }) 330 })
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts
index 2eb074007..05372257a 100644
--- a/server/tests/api/check-params/logs.ts
+++ b/server/tests/api/check-params/logs.ts
@@ -1,15 +1,8 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4 4import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
5import { 5import { HttpStatusCode } from '@shared/models'
6 cleanupTests,
7 createSingleServer,
8 PeerTubeServer,
9 setAccessTokensToServers
10} from '../../../../shared/extra-utils'
11import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
12import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
13 6
14describe('Test logs API validators', function () { 7describe('Test logs API validators', function () {
15 const path = '/api/v1/server/logs' 8 const path = '/api/v1/server/logs'
@@ -39,7 +32,7 @@ describe('Test logs API validators', function () {
39 await makeGetRequest({ 32 await makeGetRequest({
40 url: server.url, 33 url: server.url,
41 path, 34 path,
42 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 35 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
43 }) 36 })
44 }) 37 })
45 38
@@ -48,7 +41,7 @@ describe('Test logs API validators', function () {
48 url: server.url, 41 url: server.url,
49 path, 42 path,
50 token: userAccessToken, 43 token: userAccessToken,
51 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 44 expectedStatus: HttpStatusCode.FORBIDDEN_403
52 }) 45 })
53 }) 46 })
54 47
@@ -57,7 +50,7 @@ describe('Test logs API validators', function () {
57 url: server.url, 50 url: server.url,
58 path, 51 path,
59 token: server.accessToken, 52 token: server.accessToken,
60 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 53 expectedStatus: HttpStatusCode.BAD_REQUEST_400
61 }) 54 })
62 }) 55 })
63 56
@@ -67,7 +60,7 @@ describe('Test logs API validators', function () {
67 path, 60 path,
68 token: server.accessToken, 61 token: server.accessToken,
69 query: { startDate: 'toto' }, 62 query: { startDate: 'toto' },
70 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 63 expectedStatus: HttpStatusCode.BAD_REQUEST_400
71 }) 64 })
72 }) 65 })
73 66
@@ -77,7 +70,7 @@ describe('Test logs API validators', function () {
77 path, 70 path,
78 token: server.accessToken, 71 token: server.accessToken,
79 query: { startDate: new Date().toISOString(), endDate: 'toto' }, 72 query: { startDate: new Date().toISOString(), endDate: 'toto' },
80 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 73 expectedStatus: HttpStatusCode.BAD_REQUEST_400
81 }) 74 })
82 }) 75 })
83 76
@@ -87,7 +80,7 @@ describe('Test logs API validators', function () {
87 path, 80 path,
88 token: server.accessToken, 81 token: server.accessToken,
89 query: { startDate: new Date().toISOString(), level: 'toto' }, 82 query: { startDate: new Date().toISOString(), level: 'toto' },
90 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 83 expectedStatus: HttpStatusCode.BAD_REQUEST_400
91 }) 84 })
92 }) 85 })
93 86
@@ -97,7 +90,7 @@ describe('Test logs API validators', function () {
97 path, 90 path,
98 token: server.accessToken, 91 token: server.accessToken,
99 query: { startDate: new Date().toISOString() }, 92 query: { startDate: new Date().toISOString() },
100 statusCodeExpected: HttpStatusCode.OK_200 93 expectedStatus: HttpStatusCode.OK_200
101 }) 94 })
102 }) 95 })
103 }) 96 })
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts
index 2b471ee7d..d3dda7fce 100644
--- a/server/tests/api/check-params/plugins.ts
+++ b/server/tests/api/check-params/plugins.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadSortPagination, 7 checkBadSortPagination,
@@ -70,7 +70,7 @@ describe('Test server plugins API validators', function () {
70 ] 70 ]
71 71
72 for (const p of paths) { 72 for (const p of paths) {
73 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 73 await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
74 } 74 }
75 }) 75 })
76 76
@@ -78,7 +78,7 @@ describe('Test server plugins API validators', function () {
78 await makeGetRequest({ 78 await makeGetRequest({
79 url: server.url, 79 url: server.url,
80 path: '/themes/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png', 80 path: '/themes/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png',
81 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 81 expectedStatus: HttpStatusCode.NOT_FOUND_404
82 }) 82 })
83 }) 83 })
84 84
@@ -93,7 +93,7 @@ describe('Test server plugins API validators', function () {
93 ] 93 ]
94 94
95 for (const p of paths) { 95 for (const p of paths) {
96 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 96 await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
97 } 97 }
98 }) 98 })
99 99
@@ -107,14 +107,14 @@ describe('Test server plugins API validators', function () {
107 ] 107 ]
108 108
109 for (const p of paths) { 109 for (const p of paths) {
110 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 110 await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
111 } 111 }
112 }) 112 })
113 113
114 it('Should fail with an unknown auth name', async function () { 114 it('Should fail with an unknown auth name', async function () {
115 const path = '/plugins/' + pluginName + '/' + npmVersion + '/auth/bad-auth' 115 const path = '/plugins/' + pluginName + '/' + npmVersion + '/auth/bad-auth'
116 116
117 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 117 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
118 }) 118 })
119 119
120 it('Should fail with an unknown static file', async function () { 120 it('Should fail with an unknown static file', async function () {
@@ -126,7 +126,7 @@ describe('Test server plugins API validators', function () {
126 ] 126 ]
127 127
128 for (const p of paths) { 128 for (const p of paths) {
129 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 129 await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
130 } 130 }
131 }) 131 })
132 132
@@ -134,7 +134,7 @@ describe('Test server plugins API validators', function () {
134 await makeGetRequest({ 134 await makeGetRequest({
135 url: server.url, 135 url: server.url,
136 path: '/themes/' + themeName + '/' + themeVersion + '/css/assets/fake.css', 136 path: '/themes/' + themeName + '/' + themeVersion + '/css/assets/fake.css',
137 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 137 expectedStatus: HttpStatusCode.NOT_FOUND_404
138 }) 138 })
139 }) 139 })
140 140
@@ -148,11 +148,11 @@ describe('Test server plugins API validators', function () {
148 ] 148 ]
149 149
150 for (const p of paths) { 150 for (const p of paths) {
151 await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.OK_200 }) 151 await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.OK_200 })
152 } 152 }
153 153
154 const authPath = '/plugins/' + pluginName + '/' + npmVersion + '/auth/fake-auth' 154 const authPath = '/plugins/' + pluginName + '/' + npmVersion + '/auth/fake-auth'
155 await makeGetRequest({ url: server.url, path: authPath, statusCodeExpected: HttpStatusCode.FOUND_302 }) 155 await makeGetRequest({ url: server.url, path: authPath, expectedStatus: HttpStatusCode.FOUND_302 })
156 }) 156 })
157 }) 157 })
158 158
@@ -170,7 +170,7 @@ describe('Test server plugins API validators', function () {
170 path, 170 path,
171 token: 'fake_token', 171 token: 'fake_token',
172 query: baseQuery, 172 query: baseQuery,
173 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 173 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
174 }) 174 })
175 }) 175 })
176 176
@@ -180,7 +180,7 @@ describe('Test server plugins API validators', function () {
180 path, 180 path,
181 token: userAccessToken, 181 token: userAccessToken,
182 query: baseQuery, 182 query: baseQuery,
183 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 183 expectedStatus: HttpStatusCode.FORBIDDEN_403
184 }) 184 })
185 }) 185 })
186 186
@@ -224,7 +224,7 @@ describe('Test server plugins API validators', function () {
224 path, 224 path,
225 token: server.accessToken, 225 token: server.accessToken,
226 query: baseQuery, 226 query: baseQuery,
227 statusCodeExpected: HttpStatusCode.OK_200 227 expectedStatus: HttpStatusCode.OK_200
228 }) 228 })
229 }) 229 })
230 }) 230 })
@@ -241,7 +241,7 @@ describe('Test server plugins API validators', function () {
241 path, 241 path,
242 token: 'fake_token', 242 token: 'fake_token',
243 query: baseQuery, 243 query: baseQuery,
244 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 244 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
245 }) 245 })
246 }) 246 })
247 247
@@ -251,7 +251,7 @@ describe('Test server plugins API validators', function () {
251 path, 251 path,
252 token: userAccessToken, 252 token: userAccessToken,
253 query: baseQuery, 253 query: baseQuery,
254 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 254 expectedStatus: HttpStatusCode.FORBIDDEN_403
255 }) 255 })
256 }) 256 })
257 257
@@ -284,7 +284,7 @@ describe('Test server plugins API validators', function () {
284 path, 284 path,
285 token: server.accessToken, 285 token: server.accessToken,
286 query: baseQuery, 286 query: baseQuery,
287 statusCodeExpected: HttpStatusCode.OK_200 287 expectedStatus: HttpStatusCode.OK_200
288 }) 288 })
289 }) 289 })
290 }) 290 })
@@ -298,7 +298,7 @@ describe('Test server plugins API validators', function () {
298 url: server.url, 298 url: server.url,
299 path: path + suffix, 299 path: path + suffix,
300 token: 'fake_token', 300 token: 'fake_token',
301 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 301 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
302 }) 302 })
303 } 303 }
304 }) 304 })
@@ -309,7 +309,7 @@ describe('Test server plugins API validators', function () {
309 url: server.url, 309 url: server.url,
310 path: path + suffix, 310 path: path + suffix,
311 token: userAccessToken, 311 token: userAccessToken,
312 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 312 expectedStatus: HttpStatusCode.FORBIDDEN_403
313 }) 313 })
314 } 314 }
315 }) 315 })
@@ -320,7 +320,7 @@ describe('Test server plugins API validators', function () {
320 url: server.url, 320 url: server.url,
321 path: path + suffix, 321 path: path + suffix,
322 token: server.accessToken, 322 token: server.accessToken,
323 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 323 expectedStatus: HttpStatusCode.BAD_REQUEST_400
324 }) 324 })
325 } 325 }
326 326
@@ -329,7 +329,7 @@ describe('Test server plugins API validators', function () {
329 url: server.url, 329 url: server.url,
330 path: path + suffix, 330 path: path + suffix,
331 token: server.accessToken, 331 token: server.accessToken,
332 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 332 expectedStatus: HttpStatusCode.BAD_REQUEST_400
333 }) 333 })
334 } 334 }
335 }) 335 })
@@ -340,7 +340,7 @@ describe('Test server plugins API validators', function () {
340 url: server.url, 340 url: server.url,
341 path: path + suffix, 341 path: path + suffix,
342 token: server.accessToken, 342 token: server.accessToken,
343 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 343 expectedStatus: HttpStatusCode.NOT_FOUND_404
344 }) 344 })
345 } 345 }
346 }) 346 })
@@ -351,7 +351,7 @@ describe('Test server plugins API validators', function () {
351 url: server.url, 351 url: server.url,
352 path: path + suffix, 352 path: path + suffix,
353 token: server.accessToken, 353 token: server.accessToken,
354 statusCodeExpected: HttpStatusCode.OK_200 354 expectedStatus: HttpStatusCode.OK_200
355 }) 355 })
356 } 356 }
357 }) 357 })
@@ -367,7 +367,7 @@ describe('Test server plugins API validators', function () {
367 path: path + npmPlugin + '/settings', 367 path: path + npmPlugin + '/settings',
368 fields: { settings }, 368 fields: { settings },
369 token: 'fake_token', 369 token: 'fake_token',
370 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 370 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
371 }) 371 })
372 }) 372 })
373 373
@@ -377,7 +377,7 @@ describe('Test server plugins API validators', function () {
377 path: path + npmPlugin + '/settings', 377 path: path + npmPlugin + '/settings',
378 fields: { settings }, 378 fields: { settings },
379 token: userAccessToken, 379 token: userAccessToken,
380 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 380 expectedStatus: HttpStatusCode.FORBIDDEN_403
381 }) 381 })
382 }) 382 })
383 383
@@ -387,7 +387,7 @@ describe('Test server plugins API validators', function () {
387 path: path + 'toto/settings', 387 path: path + 'toto/settings',
388 fields: { settings }, 388 fields: { settings },
389 token: server.accessToken, 389 token: server.accessToken,
390 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 390 expectedStatus: HttpStatusCode.BAD_REQUEST_400
391 }) 391 })
392 392
393 await makePutBodyRequest({ 393 await makePutBodyRequest({
@@ -395,7 +395,7 @@ describe('Test server plugins API validators', function () {
395 path: path + 'peertube-plugin-TOTO/settings', 395 path: path + 'peertube-plugin-TOTO/settings',
396 fields: { settings }, 396 fields: { settings },
397 token: server.accessToken, 397 token: server.accessToken,
398 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 398 expectedStatus: HttpStatusCode.BAD_REQUEST_400
399 }) 399 })
400 }) 400 })
401 401
@@ -405,7 +405,7 @@ describe('Test server plugins API validators', function () {
405 path: path + 'peertube-plugin-toto/settings', 405 path: path + 'peertube-plugin-toto/settings',
406 fields: { settings }, 406 fields: { settings },
407 token: server.accessToken, 407 token: server.accessToken,
408 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 408 expectedStatus: HttpStatusCode.NOT_FOUND_404
409 }) 409 })
410 }) 410 })
411 411
@@ -415,7 +415,7 @@ describe('Test server plugins API validators', function () {
415 path: path + npmPlugin + '/settings', 415 path: path + npmPlugin + '/settings',
416 fields: { settings }, 416 fields: { settings },
417 token: server.accessToken, 417 token: server.accessToken,
418 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 418 expectedStatus: HttpStatusCode.NO_CONTENT_204
419 }) 419 })
420 }) 420 })
421 }) 421 })
@@ -430,7 +430,7 @@ describe('Test server plugins API validators', function () {
430 path: path + suffix, 430 path: path + suffix,
431 fields: { npmName: npmPlugin }, 431 fields: { npmName: npmPlugin },
432 token: 'fake_token', 432 token: 'fake_token',
433 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 433 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
434 }) 434 })
435 } 435 }
436 }) 436 })
@@ -442,7 +442,7 @@ describe('Test server plugins API validators', function () {
442 path: path + suffix, 442 path: path + suffix,
443 fields: { npmName: npmPlugin }, 443 fields: { npmName: npmPlugin },
444 token: userAccessToken, 444 token: userAccessToken,
445 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 445 expectedStatus: HttpStatusCode.FORBIDDEN_403
446 }) 446 })
447 } 447 }
448 }) 448 })
@@ -454,7 +454,7 @@ describe('Test server plugins API validators', function () {
454 path: path + suffix, 454 path: path + suffix,
455 fields: { npmName: 'toto' }, 455 fields: { npmName: 'toto' },
456 token: server.accessToken, 456 token: server.accessToken,
457 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 457 expectedStatus: HttpStatusCode.BAD_REQUEST_400
458 }) 458 })
459 } 459 }
460 460
@@ -464,7 +464,7 @@ describe('Test server plugins API validators', function () {
464 path: path + suffix, 464 path: path + suffix,
465 fields: { npmName: 'peertube-plugin-TOTO' }, 465 fields: { npmName: 'peertube-plugin-TOTO' },
466 token: server.accessToken, 466 token: server.accessToken,
467 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 467 expectedStatus: HttpStatusCode.BAD_REQUEST_400
468 }) 468 })
469 } 469 }
470 }) 470 })
@@ -484,7 +484,7 @@ describe('Test server plugins API validators', function () {
484 path: path + obj.suffix, 484 path: path + obj.suffix,
485 fields: { npmName: npmPlugin }, 485 fields: { npmName: npmPlugin },
486 token: server.accessToken, 486 token: server.accessToken,
487 statusCodeExpected: obj.status 487 expectedStatus: obj.status
488 }) 488 })
489 } 489 }
490 }) 490 })
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index 18b98a0f9..d9f905549 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -1,15 +1,13 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { VideoCreateResult } from '@shared/models'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6import { 4import {
7 checkBadCountPagination, 5 checkBadCountPagination,
8 checkBadSortPagination, 6 checkBadSortPagination,
9 checkBadStartPagination, 7 checkBadStartPagination,
10 cleanupTests, 8 cleanupTests,
11 doubleFollow,
12 createMultipleServers, 9 createMultipleServers,
10 doubleFollow,
13 makeDeleteRequest, 11 makeDeleteRequest,
14 makeGetRequest, 12 makeGetRequest,
15 makePostBodyRequest, 13 makePostBodyRequest,
@@ -17,7 +15,8 @@ import {
17 PeerTubeServer, 15 PeerTubeServer,
18 setAccessTokensToServers, 16 setAccessTokensToServers,
19 waitJobs 17 waitJobs
20} from '../../../../shared/extra-utils' 18} from '@shared/extra-utils'
19import { HttpStatusCode, VideoCreateResult } from '@shared/models'
21 20
22describe('Test server redundancy API validators', function () { 21describe('Test server redundancy API validators', function () {
23 let servers: PeerTubeServer[] 22 let servers: PeerTubeServer[]
@@ -64,11 +63,11 @@ describe('Test server redundancy API validators', function () {
64 }) 63 })
65 64
66 it('Should fail with an invalid token', async function () { 65 it('Should fail with an invalid token', async function () {
67 await makeGetRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 66 await makeGetRequest({ url, path, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
68 }) 67 })
69 68
70 it('Should fail if the user is not an administrator', async function () { 69 it('Should fail if the user is not an administrator', async function () {
71 await makeGetRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 70 await makeGetRequest({ url, path, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
72 }) 71 })
73 72
74 it('Should fail with a bad start pagination', async function () { 73 it('Should fail with a bad start pagination', async function () {
@@ -92,7 +91,7 @@ describe('Test server redundancy API validators', function () {
92 }) 91 })
93 92
94 it('Should succeed with the correct params', async function () { 93 it('Should succeed with the correct params', async function () {
95 await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, statusCodeExpected: HttpStatusCode.OK_200 }) 94 await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, expectedStatus: HttpStatusCode.OK_200 })
96 }) 95 })
97 }) 96 })
98 97
@@ -108,11 +107,11 @@ describe('Test server redundancy API validators', function () {
108 }) 107 })
109 108
110 it('Should fail with an invalid token', async function () { 109 it('Should fail with an invalid token', async function () {
111 await makePostBodyRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 110 await makePostBodyRequest({ url, path, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
112 }) 111 })
113 112
114 it('Should fail if the user is not an administrator', async function () { 113 it('Should fail if the user is not an administrator', async function () {
115 await makePostBodyRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 114 await makePostBodyRequest({ url, path, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
116 }) 115 })
117 116
118 it('Should fail without a video id', async function () { 117 it('Should fail without a video id', async function () {
@@ -124,7 +123,7 @@ describe('Test server redundancy API validators', function () {
124 }) 123 })
125 124
126 it('Should fail with a not found video id', async function () { 125 it('Should fail with a not found video id', async function () {
127 await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 126 await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
128 }) 127 })
129 128
130 it('Should fail with a local a video id', async function () { 129 it('Should fail with a local a video id', async function () {
@@ -137,7 +136,7 @@ describe('Test server redundancy API validators', function () {
137 path, 136 path,
138 token, 137 token,
139 fields: { videoId: videoRemote.shortUUID }, 138 fields: { videoId: videoRemote.shortUUID },
140 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 139 expectedStatus: HttpStatusCode.NO_CONTENT_204
141 }) 140 })
142 }) 141 })
143 142
@@ -151,7 +150,7 @@ describe('Test server redundancy API validators', function () {
151 path, 150 path,
152 token, 151 token,
153 fields: { videoId: videoRemote.uuid }, 152 fields: { videoId: videoRemote.uuid },
154 statusCodeExpected: HttpStatusCode.CONFLICT_409 153 expectedStatus: HttpStatusCode.CONFLICT_409
155 }) 154 })
156 }) 155 })
157 }) 156 })
@@ -168,11 +167,11 @@ describe('Test server redundancy API validators', function () {
168 }) 167 })
169 168
170 it('Should fail with an invalid token', async function () { 169 it('Should fail with an invalid token', async function () {
171 await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 170 await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
172 }) 171 })
173 172
174 it('Should fail if the user is not an administrator', async function () { 173 it('Should fail if the user is not an administrator', async function () {
175 await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 174 await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
176 }) 175 })
177 176
178 it('Should fail with an incorrect video id', async function () { 177 it('Should fail with an incorrect video id', async function () {
@@ -180,7 +179,7 @@ describe('Test server redundancy API validators', function () {
180 }) 179 })
181 180
182 it('Should fail with a not found video redundancy', async function () { 181 it('Should fail with a not found video redundancy', async function () {
183 await makeDeleteRequest({ url, path: path + '454545', token, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 182 await makeDeleteRequest({ url, path: path + '454545', token, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
184 }) 183 })
185 }) 184 })
186 185
@@ -193,7 +192,7 @@ describe('Test server redundancy API validators', function () {
193 path: path + '/localhost:' + servers[1].port, 192 path: path + '/localhost:' + servers[1].port,
194 fields: { redundancyAllowed: true }, 193 fields: { redundancyAllowed: true },
195 token: 'fake_token', 194 token: 'fake_token',
196 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 195 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
197 }) 196 })
198 }) 197 })
199 198
@@ -203,7 +202,7 @@ describe('Test server redundancy API validators', function () {
203 path: path + '/localhost:' + servers[1].port, 202 path: path + '/localhost:' + servers[1].port,
204 fields: { redundancyAllowed: true }, 203 fields: { redundancyAllowed: true },
205 token: userAccessToken, 204 token: userAccessToken,
206 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 205 expectedStatus: HttpStatusCode.FORBIDDEN_403
207 }) 206 })
208 }) 207 })
209 208
@@ -213,7 +212,7 @@ describe('Test server redundancy API validators', function () {
213 path: path + '/example.com', 212 path: path + '/example.com',
214 fields: { redundancyAllowed: true }, 213 fields: { redundancyAllowed: true },
215 token: servers[0].accessToken, 214 token: servers[0].accessToken,
216 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 215 expectedStatus: HttpStatusCode.NOT_FOUND_404
217 }) 216 })
218 }) 217 })
219 218
@@ -223,7 +222,7 @@ describe('Test server redundancy API validators', function () {
223 path: path + '/localhost:' + servers[1].port, 222 path: path + '/localhost:' + servers[1].port,
224 fields: { blabla: true }, 223 fields: { blabla: true },
225 token: servers[0].accessToken, 224 token: servers[0].accessToken,
226 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 225 expectedStatus: HttpStatusCode.BAD_REQUEST_400
227 }) 226 })
228 }) 227 })
229 228
@@ -233,7 +232,7 @@ describe('Test server redundancy API validators', function () {
233 path: path + '/localhost:' + servers[1].port, 232 path: path + '/localhost:' + servers[1].port,
234 fields: { redundancyAllowed: true }, 233 fields: { redundancyAllowed: true },
235 token: servers[0].accessToken, 234 token: servers[0].accessToken,
236 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 235 expectedStatus: HttpStatusCode.NO_CONTENT_204
237 }) 236 })
238 }) 237 })
239 }) 238 })
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts
index 43cd81af9..b49169e38 100644
--- a/server/tests/api/check-params/search.ts
+++ b/server/tests/api/check-params/search.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadSortPagination, 7 checkBadSortPagination,
@@ -58,83 +58,83 @@ describe('Test videos API validator', function () {
58 }) 58 })
59 59
60 it('Should success with the correct parameters', async function () { 60 it('Should success with the correct parameters', async function () {
61 await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) 61 await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
62 }) 62 })
63 63
64 it('Should fail with an invalid category', async function () { 64 it('Should fail with an invalid category', async function () {
65 const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] } 65 const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] }
66 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 66 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
67 67
68 const customQuery2 = { ...query, categoryOneOf: 'a' } 68 const customQuery2 = { ...query, categoryOneOf: 'a' }
69 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 69 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
70 }) 70 })
71 71
72 it('Should succeed with a valid category', async function () { 72 it('Should succeed with a valid category', async function () {
73 const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] } 73 const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] }
74 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 74 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
75 75
76 const customQuery2 = { ...query, categoryOneOf: 1 } 76 const customQuery2 = { ...query, categoryOneOf: 1 }
77 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 77 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
78 }) 78 })
79 79
80 it('Should fail with an invalid licence', async function () { 80 it('Should fail with an invalid licence', async function () {
81 const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] } 81 const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] }
82 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 82 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
83 83
84 const customQuery2 = { ...query, licenceOneOf: 'a' } 84 const customQuery2 = { ...query, licenceOneOf: 'a' }
85 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 85 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
86 }) 86 })
87 87
88 it('Should succeed with a valid licence', async function () { 88 it('Should succeed with a valid licence', async function () {
89 const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] } 89 const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] }
90 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 90 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
91 91
92 const customQuery2 = { ...query, licenceOneOf: 1 } 92 const customQuery2 = { ...query, licenceOneOf: 1 }
93 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 93 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
94 }) 94 })
95 95
96 it('Should succeed with a valid language', async function () { 96 it('Should succeed with a valid language', async function () {
97 const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] } 97 const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] }
98 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 98 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
99 99
100 const customQuery2 = { ...query, languageOneOf: 'fr' } 100 const customQuery2 = { ...query, languageOneOf: 'fr' }
101 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 101 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
102 }) 102 })
103 103
104 it('Should succeed with valid tags', async function () { 104 it('Should succeed with valid tags', async function () {
105 const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] } 105 const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] }
106 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) 106 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
107 107
108 const customQuery2 = { ...query, tagsOneOf: 'tag1' } 108 const customQuery2 = { ...query, tagsOneOf: 'tag1' }
109 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) 109 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
110 110
111 const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] } 111 const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] }
112 await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 }) 112 await makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: HttpStatusCode.OK_200 })
113 113
114 const customQuery4 = { ...query, tagsAllOf: 'tag1' } 114 const customQuery4 = { ...query, tagsAllOf: 'tag1' }
115 await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 }) 115 await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.OK_200 })
116 }) 116 })
117 117
118 it('Should fail with invalid durations', async function () { 118 it('Should fail with invalid durations', async function () {
119 const customQuery1 = { ...query, durationMin: 'hello' } 119 const customQuery1 = { ...query, durationMin: 'hello' }
120 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 120 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
121 121
122 const customQuery2 = { ...query, durationMax: 'hello' } 122 const customQuery2 = { ...query, durationMax: 'hello' }
123 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 123 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
124 }) 124 })
125 125
126 it('Should fail with invalid dates', async function () { 126 it('Should fail with invalid dates', async function () {
127 const customQuery1 = { ...query, startDate: 'hello' } 127 const customQuery1 = { ...query, startDate: 'hello' }
128 await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 128 await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
129 129
130 const customQuery2 = { ...query, endDate: 'hello' } 130 const customQuery2 = { ...query, endDate: 'hello' }
131 await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 131 await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
132 132
133 const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' } 133 const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' }
134 await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 134 await makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
135 135
136 const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' } 136 const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' }
137 await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 137 await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
138 }) 138 })
139 }) 139 })
140 140
@@ -158,7 +158,7 @@ describe('Test videos API validator', function () {
158 }) 158 })
159 159
160 it('Should success with the correct parameters', async function () { 160 it('Should success with the correct parameters', async function () {
161 await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) 161 await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
162 }) 162 })
163 }) 163 })
164 164
@@ -182,7 +182,7 @@ describe('Test videos API validator', function () {
182 }) 182 })
183 183
184 it('Should success with the correct parameters', async function () { 184 it('Should success with the correct parameters', async function () {
185 await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) 185 await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
186 }) 186 })
187 }) 187 })
188 188
@@ -201,41 +201,41 @@ describe('Test videos API validator', function () {
201 for (const path of paths) { 201 for (const path of paths) {
202 { 202 {
203 const customQuery = { ...query, searchTarget: 'hello' } 203 const customQuery = { ...query, searchTarget: 'hello' }
204 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 204 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
205 } 205 }
206 206
207 { 207 {
208 const customQuery = { ...query, searchTarget: undefined } 208 const customQuery = { ...query, searchTarget: undefined }
209 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 209 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
210 } 210 }
211 211
212 { 212 {
213 const customQuery = { ...query, searchTarget: 'local' } 213 const customQuery = { ...query, searchTarget: 'local' }
214 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 214 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
215 } 215 }
216 216
217 { 217 {
218 const customQuery = { ...query, searchTarget: 'search-index' } 218 const customQuery = { ...query, searchTarget: 'search-index' }
219 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 219 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
220 } 220 }
221 221
222 await updateSearchIndex(server, true, true) 222 await updateSearchIndex(server, true, true)
223 223
224 { 224 {
225 const customQuery = { ...query, searchTarget: 'local' } 225 const customQuery = { ...query, searchTarget: 'local' }
226 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) 226 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
227 } 227 }
228 228
229 { 229 {
230 const customQuery = { ...query, searchTarget: 'search-index' } 230 const customQuery = { ...query, searchTarget: 'search-index' }
231 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 231 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
232 } 232 }
233 233
234 await updateSearchIndex(server, true, false) 234 await updateSearchIndex(server, true, false)
235 235
236 { 236 {
237 const customQuery = { ...query, searchTarget: 'local' } 237 const customQuery = { ...query, searchTarget: 'local' }
238 await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) 238 await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
239 } 239 }
240 240
241 await updateSearchIndex(server, false, false) 241 await updateSearchIndex(server, false, false)
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index c623240b7..973b25598 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 cleanupTests, 6 cleanupTests,
7 createSingleServer, 7 createSingleServer,
@@ -120,13 +120,13 @@ describe('Test services API validators', function () {
120 }) 120 })
121}) 121})
122 122
123function checkParamEmbed (server: PeerTubeServer, embedUrl: string, statusCodeExpected = HttpStatusCode.BAD_REQUEST_400, query = {}) { 123function checkParamEmbed (server: PeerTubeServer, embedUrl: string, expectedStatus = HttpStatusCode.BAD_REQUEST_400, query = {}) {
124 const path = '/services/oembed' 124 const path = '/services/oembed'
125 125
126 return makeGetRequest({ 126 return makeGetRequest({
127 url: server.url, 127 url: server.url,
128 path, 128 path,
129 query: Object.assign(query, { url: embedUrl }), 129 query: Object.assign(query, { url: embedUrl }),
130 statusCodeExpected 130 expectedStatus
131 }) 131 })
132} 132}
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts
index bd8dce975..322e93d0d 100644
--- a/server/tests/api/check-params/upload-quota.ts
+++ b/server/tests/api/check-params/upload-quota.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode, randomInt } from '@shared/core-utils' 5import { randomInt } from '@shared/core-utils'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
@@ -13,7 +13,7 @@ import {
13 VideosCommand, 13 VideosCommand,
14 waitJobs 14 waitJobs
15} from '@shared/extra-utils' 15} from '@shared/extra-utils'
16import { VideoImportState, VideoPrivacy } from '@shared/models' 16import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models'
17 17
18describe('Test upload quota', function () { 18describe('Test upload quota', function () {
19 let server: PeerTubeServer 19 let server: PeerTubeServer
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts
index 038c444b3..3b709ee5a 100644
--- a/server/tests/api/check-params/user-notifications.ts
+++ b/server/tests/api/check-params/user-notifications.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { io } from 'socket.io-client' 4import { io } from 'socket.io-client'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 checkBadCountPagination, 7 checkBadCountPagination,
8 checkBadSortPagination, 8 checkBadSortPagination,
@@ -54,7 +54,7 @@ describe('Test user notifications API validators', function () {
54 unread: 'toto' 54 unread: 'toto'
55 }, 55 },
56 token: server.accessToken, 56 token: server.accessToken,
57 statusCodeExpected: HttpStatusCode.OK_200 57 expectedStatus: HttpStatusCode.OK_200
58 }) 58 })
59 }) 59 })
60 60
@@ -62,7 +62,7 @@ describe('Test user notifications API validators', function () {
62 await makeGetRequest({ 62 await makeGetRequest({
63 url: server.url, 63 url: server.url,
64 path, 64 path,
65 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 65 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
66 }) 66 })
67 }) 67 })
68 68
@@ -71,7 +71,7 @@ describe('Test user notifications API validators', function () {
71 url: server.url, 71 url: server.url,
72 path, 72 path,
73 token: server.accessToken, 73 token: server.accessToken,
74 statusCodeExpected: HttpStatusCode.OK_200 74 expectedStatus: HttpStatusCode.OK_200
75 }) 75 })
76 }) 76 })
77 }) 77 })
@@ -87,7 +87,7 @@ describe('Test user notifications API validators', function () {
87 ids: [ 'hello' ] 87 ids: [ 'hello' ]
88 }, 88 },
89 token: server.accessToken, 89 token: server.accessToken,
90 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 90 expectedStatus: HttpStatusCode.BAD_REQUEST_400
91 }) 91 })
92 92
93 await makePostBodyRequest({ 93 await makePostBodyRequest({
@@ -97,7 +97,7 @@ describe('Test user notifications API validators', function () {
97 ids: [ ] 97 ids: [ ]
98 }, 98 },
99 token: server.accessToken, 99 token: server.accessToken,
100 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 100 expectedStatus: HttpStatusCode.BAD_REQUEST_400
101 }) 101 })
102 102
103 await makePostBodyRequest({ 103 await makePostBodyRequest({
@@ -107,7 +107,7 @@ describe('Test user notifications API validators', function () {
107 ids: 5 107 ids: 5
108 }, 108 },
109 token: server.accessToken, 109 token: server.accessToken,
110 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 110 expectedStatus: HttpStatusCode.BAD_REQUEST_400
111 }) 111 })
112 }) 112 })
113 113
@@ -118,7 +118,7 @@ describe('Test user notifications API validators', function () {
118 fields: { 118 fields: {
119 ids: [ 5 ] 119 ids: [ 5 ]
120 }, 120 },
121 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 121 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
122 }) 122 })
123 }) 123 })
124 124
@@ -130,7 +130,7 @@ describe('Test user notifications API validators', function () {
130 ids: [ 5 ] 130 ids: [ 5 ]
131 }, 131 },
132 token: server.accessToken, 132 token: server.accessToken,
133 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 133 expectedStatus: HttpStatusCode.NO_CONTENT_204
134 }) 134 })
135 }) 135 })
136 }) 136 })
@@ -142,7 +142,7 @@ describe('Test user notifications API validators', function () {
142 await makePostBodyRequest({ 142 await makePostBodyRequest({
143 url: server.url, 143 url: server.url,
144 path, 144 path,
145 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 145 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
146 }) 146 })
147 }) 147 })
148 148
@@ -151,7 +151,7 @@ describe('Test user notifications API validators', function () {
151 url: server.url, 151 url: server.url,
152 path, 152 path,
153 token: server.accessToken, 153 token: server.accessToken,
154 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 154 expectedStatus: HttpStatusCode.NO_CONTENT_204
155 }) 155 })
156 }) 156 })
157 }) 157 })
@@ -183,7 +183,7 @@ describe('Test user notifications API validators', function () {
183 path, 183 path,
184 token: server.accessToken, 184 token: server.accessToken,
185 fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB }, 185 fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB },
186 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 186 expectedStatus: HttpStatusCode.BAD_REQUEST_400
187 }) 187 })
188 }) 188 })
189 189
@@ -196,7 +196,7 @@ describe('Test user notifications API validators', function () {
196 path, 196 path,
197 token: server.accessToken, 197 token: server.accessToken,
198 fields, 198 fields,
199 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 199 expectedStatus: HttpStatusCode.BAD_REQUEST_400
200 }) 200 })
201 } 201 }
202 202
@@ -208,7 +208,7 @@ describe('Test user notifications API validators', function () {
208 path, 208 path,
209 fields, 209 fields,
210 token: server.accessToken, 210 token: server.accessToken,
211 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 211 expectedStatus: HttpStatusCode.BAD_REQUEST_400
212 }) 212 })
213 } 213 }
214 }) 214 })
@@ -218,7 +218,7 @@ describe('Test user notifications API validators', function () {
218 url: server.url, 218 url: server.url,
219 path, 219 path,
220 fields: correctFields, 220 fields: correctFields,
221 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 221 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
222 }) 222 })
223 }) 223 })
224 224
@@ -228,7 +228,7 @@ describe('Test user notifications API validators', function () {
228 path, 228 path,
229 token: server.accessToken, 229 token: server.accessToken,
230 fields: correctFields, 230 fields: correctFields,
231 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 231 expectedStatus: HttpStatusCode.NO_CONTENT_204
232 }) 232 })
233 }) 233 })
234 }) 234 })
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 22cf130c2..624069c80 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -1,24 +1,20 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4
5import { 4import {
5 checkBadCountPagination,
6 checkBadSortPagination,
7 checkBadStartPagination,
6 cleanupTests, 8 cleanupTests,
7 createSingleServer, 9 createSingleServer,
8 makeDeleteRequest, 10 makeDeleteRequest,
9 makeGetRequest, 11 makeGetRequest,
10 makePostBodyRequest, 12 makePostBodyRequest,
11 PeerTubeServer, 13 PeerTubeServer,
12 setAccessTokensToServers 14 setAccessTokensToServers,
13} from '../../../../shared/extra-utils' 15 waitJobs
14 16} from '@shared/extra-utils'
15import { 17import { HttpStatusCode } from '@shared/models'
16 checkBadCountPagination,
17 checkBadSortPagination,
18 checkBadStartPagination
19} from '../../../../shared/extra-utils/requests/check-api-params'
20import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
21import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
22 18
23describe('Test user subscriptions API validators', function () { 19describe('Test user subscriptions API validators', function () {
24 const path = '/api/v1/users/me/subscriptions' 20 const path = '/api/v1/users/me/subscriptions'
@@ -59,7 +55,7 @@ describe('Test user subscriptions API validators', function () {
59 await makeGetRequest({ 55 await makeGetRequest({
60 url: server.url, 56 url: server.url,
61 path, 57 path,
62 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 58 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
63 }) 59 })
64 }) 60 })
65 61
@@ -68,7 +64,7 @@ describe('Test user subscriptions API validators', function () {
68 url: server.url, 64 url: server.url,
69 path, 65 path,
70 token: userAccessToken, 66 token: userAccessToken,
71 statusCodeExpected: HttpStatusCode.OK_200 67 expectedStatus: HttpStatusCode.OK_200
72 }) 68 })
73 }) 69 })
74 }) 70 })
@@ -92,7 +88,7 @@ describe('Test user subscriptions API validators', function () {
92 await makeGetRequest({ 88 await makeGetRequest({
93 url: server.url, 89 url: server.url,
94 path, 90 path,
95 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 91 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
96 }) 92 })
97 }) 93 })
98 94
@@ -101,7 +97,7 @@ describe('Test user subscriptions API validators', function () {
101 url: server.url, 97 url: server.url,
102 path, 98 path,
103 token: userAccessToken, 99 token: userAccessToken,
104 statusCodeExpected: HttpStatusCode.OK_200 100 expectedStatus: HttpStatusCode.OK_200
105 }) 101 })
106 }) 102 })
107 }) 103 })
@@ -112,7 +108,7 @@ describe('Test user subscriptions API validators', function () {
112 url: server.url, 108 url: server.url,
113 path, 109 path,
114 fields: { uri: 'user1_channel@localhost:' + server.port }, 110 fields: { uri: 'user1_channel@localhost:' + server.port },
115 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 111 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
116 }) 112 })
117 }) 113 })
118 114
@@ -122,7 +118,7 @@ describe('Test user subscriptions API validators', function () {
122 path, 118 path,
123 token: server.accessToken, 119 token: server.accessToken,
124 fields: { uri: 'root' }, 120 fields: { uri: 'root' },
125 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 121 expectedStatus: HttpStatusCode.BAD_REQUEST_400
126 }) 122 })
127 123
128 await makePostBodyRequest({ 124 await makePostBodyRequest({
@@ -130,7 +126,7 @@ describe('Test user subscriptions API validators', function () {
130 path, 126 path,
131 token: server.accessToken, 127 token: server.accessToken,
132 fields: { uri: 'root@' }, 128 fields: { uri: 'root@' },
133 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 129 expectedStatus: HttpStatusCode.BAD_REQUEST_400
134 }) 130 })
135 131
136 await makePostBodyRequest({ 132 await makePostBodyRequest({
@@ -138,7 +134,7 @@ describe('Test user subscriptions API validators', function () {
138 path, 134 path,
139 token: server.accessToken, 135 token: server.accessToken,
140 fields: { uri: 'root@hello@' }, 136 fields: { uri: 'root@hello@' },
141 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 137 expectedStatus: HttpStatusCode.BAD_REQUEST_400
142 }) 138 })
143 }) 139 })
144 140
@@ -150,7 +146,7 @@ describe('Test user subscriptions API validators', function () {
150 path, 146 path,
151 token: server.accessToken, 147 token: server.accessToken,
152 fields: { uri: 'user1_channel@localhost:' + server.port }, 148 fields: { uri: 'user1_channel@localhost:' + server.port },
153 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 149 expectedStatus: HttpStatusCode.NO_CONTENT_204
154 }) 150 })
155 151
156 await waitJobs([ server ]) 152 await waitJobs([ server ])
@@ -162,7 +158,7 @@ describe('Test user subscriptions API validators', function () {
162 await makeGetRequest({ 158 await makeGetRequest({
163 url: server.url, 159 url: server.url,
164 path: path + '/user1_channel@localhost:' + server.port, 160 path: path + '/user1_channel@localhost:' + server.port,
165 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 161 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
166 }) 162 })
167 }) 163 })
168 164
@@ -171,21 +167,21 @@ describe('Test user subscriptions API validators', function () {
171 url: server.url, 167 url: server.url,
172 path: path + '/root', 168 path: path + '/root',
173 token: server.accessToken, 169 token: server.accessToken,
174 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 170 expectedStatus: HttpStatusCode.BAD_REQUEST_400
175 }) 171 })
176 172
177 await makeGetRequest({ 173 await makeGetRequest({
178 url: server.url, 174 url: server.url,
179 path: path + '/root@', 175 path: path + '/root@',
180 token: server.accessToken, 176 token: server.accessToken,
181 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 177 expectedStatus: HttpStatusCode.BAD_REQUEST_400
182 }) 178 })
183 179
184 await makeGetRequest({ 180 await makeGetRequest({
185 url: server.url, 181 url: server.url,
186 path: path + '/root@hello@', 182 path: path + '/root@hello@',
187 token: server.accessToken, 183 token: server.accessToken,
188 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 184 expectedStatus: HttpStatusCode.BAD_REQUEST_400
189 }) 185 })
190 }) 186 })
191 187
@@ -194,7 +190,7 @@ describe('Test user subscriptions API validators', function () {
194 url: server.url, 190 url: server.url,
195 path: path + '/root1@localhost:' + server.port, 191 path: path + '/root1@localhost:' + server.port,
196 token: server.accessToken, 192 token: server.accessToken,
197 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 193 expectedStatus: HttpStatusCode.NOT_FOUND_404
198 }) 194 })
199 }) 195 })
200 196
@@ -203,7 +199,7 @@ describe('Test user subscriptions API validators', function () {
203 url: server.url, 199 url: server.url,
204 path: path + '/user1_channel@localhost:' + server.port, 200 path: path + '/user1_channel@localhost:' + server.port,
205 token: server.accessToken, 201 token: server.accessToken,
206 statusCodeExpected: HttpStatusCode.OK_200 202 expectedStatus: HttpStatusCode.OK_200
207 }) 203 })
208 }) 204 })
209 }) 205 })
@@ -215,7 +211,7 @@ describe('Test user subscriptions API validators', function () {
215 await makeGetRequest({ 211 await makeGetRequest({
216 url: server.url, 212 url: server.url,
217 path: existPath, 213 path: existPath,
218 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 214 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
219 }) 215 })
220 }) 216 })
221 217
@@ -225,7 +221,7 @@ describe('Test user subscriptions API validators', function () {
225 path: existPath, 221 path: existPath,
226 query: { uris: 'toto' }, 222 query: { uris: 'toto' },
227 token: server.accessToken, 223 token: server.accessToken,
228 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 224 expectedStatus: HttpStatusCode.BAD_REQUEST_400
229 }) 225 })
230 226
231 await makeGetRequest({ 227 await makeGetRequest({
@@ -233,7 +229,7 @@ describe('Test user subscriptions API validators', function () {
233 path: existPath, 229 path: existPath,
234 query: { 'uris[]': 1 }, 230 query: { 'uris[]': 1 },
235 token: server.accessToken, 231 token: server.accessToken,
236 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 232 expectedStatus: HttpStatusCode.BAD_REQUEST_400
237 }) 233 })
238 }) 234 })
239 235
@@ -243,7 +239,7 @@ describe('Test user subscriptions API validators', function () {
243 path: existPath, 239 path: existPath,
244 query: { 'uris[]': 'coucou@localhost:' + server.port }, 240 query: { 'uris[]': 'coucou@localhost:' + server.port },
245 token: server.accessToken, 241 token: server.accessToken,
246 statusCodeExpected: HttpStatusCode.OK_200 242 expectedStatus: HttpStatusCode.OK_200
247 }) 243 })
248 }) 244 })
249 }) 245 })
@@ -253,7 +249,7 @@ describe('Test user subscriptions API validators', function () {
253 await makeDeleteRequest({ 249 await makeDeleteRequest({
254 url: server.url, 250 url: server.url,
255 path: path + '/user1_channel@localhost:' + server.port, 251 path: path + '/user1_channel@localhost:' + server.port,
256 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 252 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
257 }) 253 })
258 }) 254 })
259 255
@@ -262,21 +258,21 @@ describe('Test user subscriptions API validators', function () {
262 url: server.url, 258 url: server.url,
263 path: path + '/root', 259 path: path + '/root',
264 token: server.accessToken, 260 token: server.accessToken,
265 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 261 expectedStatus: HttpStatusCode.BAD_REQUEST_400
266 }) 262 })
267 263
268 await makeDeleteRequest({ 264 await makeDeleteRequest({
269 url: server.url, 265 url: server.url,
270 path: path + '/root@', 266 path: path + '/root@',
271 token: server.accessToken, 267 token: server.accessToken,
272 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 268 expectedStatus: HttpStatusCode.BAD_REQUEST_400
273 }) 269 })
274 270
275 await makeDeleteRequest({ 271 await makeDeleteRequest({
276 url: server.url, 272 url: server.url,
277 path: path + '/root@hello@', 273 path: path + '/root@hello@',
278 token: server.accessToken, 274 token: server.accessToken,
279 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 275 expectedStatus: HttpStatusCode.BAD_REQUEST_400
280 }) 276 })
281 }) 277 })
282 278
@@ -285,7 +281,7 @@ describe('Test user subscriptions API validators', function () {
285 url: server.url, 281 url: server.url,
286 path: path + '/root1@localhost:' + server.port, 282 path: path + '/root1@localhost:' + server.port,
287 token: server.accessToken, 283 token: server.accessToken,
288 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 284 expectedStatus: HttpStatusCode.NOT_FOUND_404
289 }) 285 })
290 }) 286 })
291 287
@@ -294,7 +290,7 @@ describe('Test user subscriptions API validators', function () {
294 url: server.url, 290 url: server.url,
295 path: path + '/user1_channel@localhost:' + server.port, 291 path: path + '/user1_channel@localhost:' + server.port,
296 token: server.accessToken, 292 token: server.accessToken,
297 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 293 expectedStatus: HttpStatusCode.NO_CONTENT_204
298 }) 294 })
299 }) 295 })
300 }) 296 })
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index c2c98f429..34fe309f9 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
8 checkBadCountPagination, 8 checkBadCountPagination,
@@ -103,7 +103,7 @@ describe('Test users API validators', function () {
103 await makeGetRequest({ 103 await makeGetRequest({
104 url: server.url, 104 url: server.url,
105 path, 105 path,
106 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 106 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
107 }) 107 })
108 }) 108 })
109 109
@@ -112,7 +112,7 @@ describe('Test users API validators', function () {
112 url: server.url, 112 url: server.url,
113 path, 113 path,
114 token: userToken, 114 token: userToken,
115 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 115 expectedStatus: HttpStatusCode.FORBIDDEN_403
116 }) 116 })
117 }) 117 })
118 }) 118 })
@@ -210,7 +210,7 @@ describe('Test users API validators', function () {
210 path: path, 210 path: path,
211 token: server.accessToken, 211 token: server.accessToken,
212 fields, 212 fields,
213 statusCodeExpected: HttpStatusCode.OK_200 213 expectedStatus: HttpStatusCode.OK_200
214 }) 214 })
215 }) 215 })
216 216
@@ -226,7 +226,7 @@ describe('Test users API validators', function () {
226 path, 226 path,
227 token: 'super token', 227 token: 'super token',
228 fields: baseCorrectParams, 228 fields: baseCorrectParams,
229 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 229 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
230 }) 230 })
231 }) 231 })
232 232
@@ -238,7 +238,7 @@ describe('Test users API validators', function () {
238 path, 238 path,
239 token: server.accessToken, 239 token: server.accessToken,
240 fields, 240 fields,
241 statusCodeExpected: HttpStatusCode.CONFLICT_409 241 expectedStatus: HttpStatusCode.CONFLICT_409
242 }) 242 })
243 }) 243 })
244 244
@@ -250,7 +250,7 @@ describe('Test users API validators', function () {
250 path, 250 path,
251 token: server.accessToken, 251 token: server.accessToken,
252 fields, 252 fields,
253 statusCodeExpected: HttpStatusCode.CONFLICT_409 253 expectedStatus: HttpStatusCode.CONFLICT_409
254 }) 254 })
255 }) 255 })
256 256
@@ -298,7 +298,7 @@ describe('Test users API validators', function () {
298 path, 298 path,
299 token: server.accessToken, 299 token: server.accessToken,
300 fields, 300 fields,
301 statusCodeExpected: HttpStatusCode.CONFLICT_409 301 expectedStatus: HttpStatusCode.CONFLICT_409
302 }) 302 })
303 }) 303 })
304 304
@@ -311,7 +311,7 @@ describe('Test users API validators', function () {
311 path, 311 path,
312 token: moderatorToken, 312 token: moderatorToken,
313 fields, 313 fields,
314 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 314 expectedStatus: HttpStatusCode.FORBIDDEN_403
315 }) 315 })
316 } 316 }
317 }) 317 })
@@ -324,7 +324,7 @@ describe('Test users API validators', function () {
324 path, 324 path,
325 token: moderatorToken, 325 token: moderatorToken,
326 fields, 326 fields,
327 statusCodeExpected: HttpStatusCode.OK_200 327 expectedStatus: HttpStatusCode.OK_200
328 }) 328 })
329 }) 329 })
330 330
@@ -334,7 +334,7 @@ describe('Test users API validators', function () {
334 path, 334 path,
335 token: server.accessToken, 335 token: server.accessToken,
336 fields: baseCorrectParams, 336 fields: baseCorrectParams,
337 statusCodeExpected: HttpStatusCode.OK_200 337 expectedStatus: HttpStatusCode.OK_200
338 }) 338 })
339 }) 339 })
340 340
@@ -348,7 +348,7 @@ describe('Test users API validators', function () {
348 password: 'my super password', 348 password: 'my super password',
349 videoQuota: 42000000 349 videoQuota: 42000000
350 } 350 }
351 await makePostBodyRequest({ url: server.url, path, token: userToken, fields, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 351 await makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
352 }) 352 })
353 }) 353 })
354 354
@@ -400,7 +400,7 @@ describe('Test users API validators', function () {
400 path: path + 'me', 400 path: path + 'me',
401 token: userToken, 401 token: userToken,
402 fields, 402 fields,
403 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 403 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
404 }) 404 })
405 }) 405 })
406 406
@@ -447,7 +447,7 @@ describe('Test users API validators', function () {
447 path: path + 'me', 447 path: path + 'me',
448 token: 'super token', 448 token: 'super token',
449 fields, 449 fields,
450 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 450 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
451 }) 451 })
452 }) 452 })
453 453
@@ -525,7 +525,7 @@ describe('Test users API validators', function () {
525 path: path + 'me', 525 path: path + 'me',
526 token: userToken, 526 token: userToken,
527 fields, 527 fields,
528 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 528 expectedStatus: HttpStatusCode.NO_CONTENT_204
529 }) 529 })
530 }) 530 })
531 531
@@ -540,7 +540,7 @@ describe('Test users API validators', function () {
540 path: path + 'me', 540 path: path + 'me',
541 token: userToken, 541 token: userToken,
542 fields, 542 fields,
543 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 543 expectedStatus: HttpStatusCode.NO_CONTENT_204
544 }) 544 })
545 }) 545 })
546 }) 546 })
@@ -572,7 +572,7 @@ describe('Test users API validators', function () {
572 path: path + '/me/avatar/pick', 572 path: path + '/me/avatar/pick',
573 fields, 573 fields,
574 attaches, 574 attaches,
575 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 575 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
576 }) 576 })
577 }) 577 })
578 578
@@ -587,7 +587,7 @@ describe('Test users API validators', function () {
587 token: server.accessToken, 587 token: server.accessToken,
588 fields, 588 fields,
589 attaches, 589 attaches,
590 statusCodeExpected: HttpStatusCode.OK_200 590 expectedStatus: HttpStatusCode.OK_200
591 }) 591 })
592 }) 592 })
593 }) 593 })
@@ -627,16 +627,16 @@ describe('Test users API validators', function () {
627 url: server.url, 627 url: server.url,
628 path: path + userId, 628 path: path + userId,
629 token: 'super token', 629 token: 'super token',
630 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 630 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
631 }) 631 })
632 }) 632 })
633 633
634 it('Should fail with a non admin user', async function () { 634 it('Should fail with a non admin user', async function () {
635 await makeGetRequest({ url: server.url, path, token: userToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 635 await makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
636 }) 636 })
637 637
638 it('Should succeed with the correct params', async function () { 638 it('Should succeed with the correct params', async function () {
639 await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: HttpStatusCode.OK_200 }) 639 await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 })
640 }) 640 })
641 }) 641 })
642 642
@@ -702,7 +702,7 @@ describe('Test users API validators', function () {
702 path: path + userId, 702 path: path + userId,
703 token: 'super token', 703 token: 'super token',
704 fields, 704 fields,
705 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 705 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
706 }) 706 })
707 }) 707 })
708 708
@@ -730,7 +730,7 @@ describe('Test users API validators', function () {
730 path: path + moderatorId, 730 path: path + moderatorId,
731 token: moderatorToken, 731 token: moderatorToken,
732 fields, 732 fields,
733 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 733 expectedStatus: HttpStatusCode.FORBIDDEN_403
734 }) 734 })
735 }) 735 })
736 736
@@ -744,7 +744,7 @@ describe('Test users API validators', function () {
744 path: path + userId, 744 path: path + userId,
745 token: moderatorToken, 745 token: moderatorToken,
746 fields, 746 fields,
747 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 747 expectedStatus: HttpStatusCode.NO_CONTENT_204
748 }) 748 })
749 }) 749 })
750 750
@@ -761,7 +761,7 @@ describe('Test users API validators', function () {
761 path: path + userId, 761 path: path + userId,
762 token: server.accessToken, 762 token: server.accessToken,
763 fields, 763 fields,
764 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 764 expectedStatus: HttpStatusCode.NO_CONTENT_204
765 }) 765 })
766 }) 766 })
767 }) 767 })
@@ -818,11 +818,11 @@ describe('Test users API validators', function () {
818 }) 818 })
819 819
820 it('Should fail with a unauthenticated user', async function () { 820 it('Should fail with a unauthenticated user', async function () {
821 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 821 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
822 }) 822 })
823 823
824 it('Should fail with a another user', async function () { 824 it('Should fail with a another user', async function () {
825 await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 825 await makeGetRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
826 }) 826 })
827 827
828 it('Should fail with a bad type', async function () { 828 it('Should fail with a bad type', async function () {
@@ -831,12 +831,12 @@ describe('Test users API validators', function () {
831 path, 831 path,
832 token: userToken, 832 token: userToken,
833 query: { rating: 'toto ' }, 833 query: { rating: 'toto ' },
834 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 834 expectedStatus: HttpStatusCode.BAD_REQUEST_400
835 }) 835 })
836 }) 836 })
837 837
838 it('Should succeed with the correct params', async function () { 838 it('Should succeed with the correct params', async function () {
839 await makeGetRequest({ url: server.url, path, token: userToken, statusCodeExpected: HttpStatusCode.OK_200 }) 839 await makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: HttpStatusCode.OK_200 })
840 }) 840 })
841 }) 841 })
842 842
@@ -955,7 +955,7 @@ describe('Test users API validators', function () {
955 path: registrationPath, 955 path: registrationPath,
956 token: server.accessToken, 956 token: server.accessToken,
957 fields, 957 fields,
958 statusCodeExpected: HttpStatusCode.CONFLICT_409 958 expectedStatus: HttpStatusCode.CONFLICT_409
959 }) 959 })
960 }) 960 })
961 961
@@ -967,7 +967,7 @@ describe('Test users API validators', function () {
967 path: registrationPath, 967 path: registrationPath,
968 token: server.accessToken, 968 token: server.accessToken,
969 fields, 969 fields,
970 statusCodeExpected: HttpStatusCode.CONFLICT_409 970 expectedStatus: HttpStatusCode.CONFLICT_409
971 }) 971 })
972 }) 972 })
973 973
@@ -979,7 +979,7 @@ describe('Test users API validators', function () {
979 path: registrationPath, 979 path: registrationPath,
980 token: server.accessToken, 980 token: server.accessToken,
981 fields, 981 fields,
982 statusCodeExpected: HttpStatusCode.CONFLICT_409 982 expectedStatus: HttpStatusCode.CONFLICT_409
983 }) 983 })
984 }) 984 })
985 985
@@ -1019,7 +1019,7 @@ describe('Test users API validators', function () {
1019 path: registrationPath, 1019 path: registrationPath,
1020 token: server.accessToken, 1020 token: server.accessToken,
1021 fields, 1021 fields,
1022 statusCodeExpected: HttpStatusCode.CONFLICT_409 1022 expectedStatus: HttpStatusCode.CONFLICT_409
1023 }) 1023 })
1024 }) 1024 })
1025 1025
@@ -1031,7 +1031,7 @@ describe('Test users API validators', function () {
1031 path: registrationPath, 1031 path: registrationPath,
1032 token: server.accessToken, 1032 token: server.accessToken,
1033 fields: fields, 1033 fields: fields,
1034 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 1034 expectedStatus: HttpStatusCode.NO_CONTENT_204
1035 }) 1035 })
1036 }) 1036 })
1037 1037
@@ -1047,7 +1047,7 @@ describe('Test users API validators', function () {
1047 path: registrationPath, 1047 path: registrationPath,
1048 token: serverWithRegistrationDisabled.accessToken, 1048 token: serverWithRegistrationDisabled.accessToken,
1049 fields, 1049 fields,
1050 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 1050 expectedStatus: HttpStatusCode.FORBIDDEN_403
1051 }) 1051 })
1052 }) 1052 })
1053 }) 1053 })
@@ -1081,7 +1081,7 @@ describe('Test users API validators', function () {
1081 path, 1081 path,
1082 token: server.accessToken, 1082 token: server.accessToken,
1083 fields, 1083 fields,
1084 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 1084 expectedStatus: HttpStatusCode.NO_CONTENT_204
1085 }) 1085 })
1086 }) 1086 })
1087 }) 1087 })
@@ -1109,7 +1109,7 @@ describe('Test users API validators', function () {
1109 path, 1109 path,
1110 token: server.accessToken, 1110 token: server.accessToken,
1111 fields, 1111 fields,
1112 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 1112 expectedStatus: HttpStatusCode.NO_CONTENT_204
1113 }) 1113 })
1114 }) 1114 })
1115 }) 1115 })
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index b5d0e0778..2072df4b6 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 BlacklistCommand, 7 BlacklistCommand,
8 checkBadCountPagination, 8 checkBadCountPagination,
@@ -88,7 +88,7 @@ describe('Test video blacklist API validators', function () {
88 it('Should fail with a non authenticated user', async function () { 88 it('Should fail with a non authenticated user', async function () {
89 const path = basePath + servers[0].store.video + '/blacklist' 89 const path = basePath + servers[0].store.video + '/blacklist'
90 const fields = {} 90 const fields = {}
91 await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 91 await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
92 }) 92 })
93 93
94 it('Should fail with a non admin user', async function () { 94 it('Should fail with a non admin user', async function () {
@@ -99,7 +99,7 @@ describe('Test video blacklist API validators', function () {
99 path, 99 path,
100 token: userAccessToken2, 100 token: userAccessToken2,
101 fields, 101 fields,
102 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 102 expectedStatus: HttpStatusCode.FORBIDDEN_403
103 }) 103 })
104 }) 104 })
105 105
@@ -119,7 +119,7 @@ describe('Test video blacklist API validators', function () {
119 path, 119 path,
120 token: servers[0].accessToken, 120 token: servers[0].accessToken,
121 fields, 121 fields,
122 statusCodeExpected: HttpStatusCode.CONFLICT_409 122 expectedStatus: HttpStatusCode.CONFLICT_409
123 }) 123 })
124 }) 124 })
125 125
@@ -132,7 +132,7 @@ describe('Test video blacklist API validators', function () {
132 path, 132 path,
133 token: servers[0].accessToken, 133 token: servers[0].accessToken,
134 fields, 134 fields,
135 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 135 expectedStatus: HttpStatusCode.NO_CONTENT_204
136 }) 136 })
137 }) 137 })
138 }) 138 })
@@ -154,14 +154,14 @@ describe('Test video blacklist API validators', function () {
154 path, 154 path,
155 token: servers[0].accessToken, 155 token: servers[0].accessToken,
156 fields, 156 fields,
157 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 157 expectedStatus: HttpStatusCode.NOT_FOUND_404
158 }) 158 })
159 }) 159 })
160 160
161 it('Should fail with a non authenticated user', async function () { 161 it('Should fail with a non authenticated user', async function () {
162 const path = basePath + servers[0].store.video + '/blacklist' 162 const path = basePath + servers[0].store.video + '/blacklist'
163 const fields = {} 163 const fields = {}
164 await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 164 await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
165 }) 165 })
166 166
167 it('Should fail with a non admin user', async function () { 167 it('Should fail with a non admin user', async function () {
@@ -172,7 +172,7 @@ describe('Test video blacklist API validators', function () {
172 path, 172 path,
173 token: userAccessToken2, 173 token: userAccessToken2,
174 fields, 174 fields,
175 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 175 expectedStatus: HttpStatusCode.FORBIDDEN_403
176 }) 176 })
177 }) 177 })
178 178
@@ -192,7 +192,7 @@ describe('Test video blacklist API validators', function () {
192 path, 192 path,
193 token: servers[0].accessToken, 193 token: servers[0].accessToken,
194 fields, 194 fields,
195 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 195 expectedStatus: HttpStatusCode.NO_CONTENT_204
196 }) 196 })
197 }) 197 })
198 }) 198 })
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index 26aab79e7..1b3d1aa95 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 buildAbsoluteFixturePath, 6 buildAbsoluteFixturePath,
7 cleanupTests, 7 cleanupTests,
@@ -67,7 +67,7 @@ describe('Test video captions API validator', function () {
67 token: server.accessToken, 67 token: server.accessToken,
68 fields, 68 fields,
69 attaches, 69 attaches,
70 statusCodeExpected: 404 70 expectedStatus: 404
71 }) 71 })
72 }) 72 })
73 73
@@ -103,7 +103,7 @@ describe('Test video captions API validator', function () {
103 path: captionPath, 103 path: captionPath,
104 fields, 104 fields,
105 attaches, 105 attaches,
106 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 106 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
107 }) 107 })
108 }) 108 })
109 109
@@ -116,7 +116,7 @@ describe('Test video captions API validator', function () {
116 token: 'blabla', 116 token: 'blabla',
117 fields, 117 fields,
118 attaches, 118 attaches,
119 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 119 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
120 }) 120 })
121 }) 121 })
122 122
@@ -134,7 +134,7 @@ describe('Test video captions API validator', function () {
134 // token: server.accessToken, 134 // token: server.accessToken,
135 // fields, 135 // fields,
136 // attaches, 136 // attaches,
137 // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 137 // expectedStatus: HttpStatusCode.BAD_REQUEST_400
138 // }) 138 // })
139 // }) 139 // })
140 140
@@ -147,7 +147,7 @@ describe('Test video captions API validator', function () {
147 // videoId: video.uuid, 147 // videoId: video.uuid,
148 // fixture: 'subtitle-bad.txt', 148 // fixture: 'subtitle-bad.txt',
149 // mimeType: 'application/octet-stream', 149 // mimeType: 'application/octet-stream',
150 // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 150 // expectedStatus: HttpStatusCode.BAD_REQUEST_400
151 // }) 151 // })
152 // }) 152 // })
153 153
@@ -174,7 +174,7 @@ describe('Test video captions API validator', function () {
174 // token: server.accessToken, 174 // token: server.accessToken,
175 // fields, 175 // fields,
176 // attaches, 176 // attaches,
177 // statusCodeExpected: HttpStatusCode.INTERNAL_SERVER_ERROR_500 177 // expectedStatus: HttpStatusCode.INTERNAL_SERVER_ERROR_500
178 // }) 178 // })
179 // }) 179 // })
180 180
@@ -187,7 +187,7 @@ describe('Test video captions API validator', function () {
187 token: server.accessToken, 187 token: server.accessToken,
188 fields, 188 fields,
189 attaches, 189 attaches,
190 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 190 expectedStatus: HttpStatusCode.NO_CONTENT_204
191 }) 191 })
192 }) 192 })
193 }) 193 })
@@ -201,12 +201,12 @@ describe('Test video captions API validator', function () {
201 await makeGetRequest({ 201 await makeGetRequest({
202 url: server.url, 202 url: server.url,
203 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions', 203 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions',
204 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 204 expectedStatus: HttpStatusCode.NOT_FOUND_404
205 }) 205 })
206 }) 206 })
207 207
208 it('Should success with the correct parameters', async function () { 208 it('Should success with the correct parameters', async function () {
209 await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 }) 209 await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', expectedStatus: HttpStatusCode.OK_200 })
210 }) 210 })
211 }) 211 })
212 212
@@ -224,7 +224,7 @@ describe('Test video captions API validator', function () {
224 url: server.url, 224 url: server.url,
225 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr', 225 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr',
226 token: server.accessToken, 226 token: server.accessToken,
227 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 227 expectedStatus: HttpStatusCode.NOT_FOUND_404
228 }) 228 })
229 }) 229 })
230 230
@@ -248,12 +248,12 @@ describe('Test video captions API validator', function () {
248 248
249 it('Should fail without access token', async function () { 249 it('Should fail without access token', async function () {
250 const captionPath = path + video.shortUUID + '/captions/fr' 250 const captionPath = path + video.shortUUID + '/captions/fr'
251 await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 251 await makeDeleteRequest({ url: server.url, path: captionPath, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
252 }) 252 })
253 253
254 it('Should fail with a bad access token', async function () { 254 it('Should fail with a bad access token', async function () {
255 const captionPath = path + video.shortUUID + '/captions/fr' 255 const captionPath = path + video.shortUUID + '/captions/fr'
256 await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 256 await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
257 }) 257 })
258 258
259 it('Should fail with another user', async function () { 259 it('Should fail with another user', async function () {
@@ -262,7 +262,7 @@ describe('Test video captions API validator', function () {
262 url: server.url, 262 url: server.url,
263 path: captionPath, 263 path: captionPath,
264 token: userAccessToken, 264 token: userAccessToken,
265 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 265 expectedStatus: HttpStatusCode.FORBIDDEN_403
266 }) 266 })
267 }) 267 })
268 268
@@ -272,7 +272,7 @@ describe('Test video captions API validator', function () {
272 url: server.url, 272 url: server.url,
273 path: captionPath, 273 path: captionPath,
274 token: server.accessToken, 274 token: server.accessToken,
275 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 275 expectedStatus: HttpStatusCode.NO_CONTENT_204
276 }) 276 })
277 }) 277 })
278 }) 278 })
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 62b8fa4f6..bbe42e43d 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { HttpStatusCode } from '@shared/core-utils' 6import { HttpStatusCode } from '@shared/models'
7import { 7import {
8 buildAbsoluteFixturePath, 8 buildAbsoluteFixturePath,
9 ChannelsCommand, 9 ChannelsCommand,
@@ -88,7 +88,7 @@ describe('Test video channels API validator', function () {
88 await makeGetRequest({ 88 await makeGetRequest({
89 url: server.url, 89 url: server.url,
90 path: accountChannelPath, 90 path: accountChannelPath,
91 statusCodeExpected: HttpStatusCode.OK_200 91 expectedStatus: HttpStatusCode.OK_200
92 }) 92 })
93 }) 93 })
94 }) 94 })
@@ -107,7 +107,7 @@ describe('Test video channels API validator', function () {
107 path: videoChannelPath, 107 path: videoChannelPath,
108 token: 'none', 108 token: 'none',
109 fields: baseCorrectParams, 109 fields: baseCorrectParams,
110 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 110 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
111 }) 111 })
112 }) 112 })
113 113
@@ -152,7 +152,7 @@ describe('Test video channels API validator', function () {
152 path: videoChannelPath, 152 path: videoChannelPath,
153 token: server.accessToken, 153 token: server.accessToken,
154 fields: baseCorrectParams, 154 fields: baseCorrectParams,
155 statusCodeExpected: HttpStatusCode.OK_200 155 expectedStatus: HttpStatusCode.OK_200
156 }) 156 })
157 }) 157 })
158 158
@@ -162,7 +162,7 @@ describe('Test video channels API validator', function () {
162 path: videoChannelPath, 162 path: videoChannelPath,
163 token: server.accessToken, 163 token: server.accessToken,
164 fields: baseCorrectParams, 164 fields: baseCorrectParams,
165 statusCodeExpected: HttpStatusCode.CONFLICT_409 165 expectedStatus: HttpStatusCode.CONFLICT_409
166 }) 166 })
167 }) 167 })
168 }) 168 })
@@ -186,7 +186,7 @@ describe('Test video channels API validator', function () {
186 path, 186 path,
187 token: 'hi', 187 token: 'hi',
188 fields: baseCorrectParams, 188 fields: baseCorrectParams,
189 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 189 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
190 }) 190 })
191 }) 191 })
192 192
@@ -196,7 +196,7 @@ describe('Test video channels API validator', function () {
196 path, 196 path,
197 token: accessTokenUser, 197 token: accessTokenUser,
198 fields: baseCorrectParams, 198 fields: baseCorrectParams,
199 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 199 expectedStatus: HttpStatusCode.FORBIDDEN_403
200 }) 200 })
201 }) 201 })
202 202
@@ -226,7 +226,7 @@ describe('Test video channels API validator', function () {
226 path, 226 path,
227 token: server.accessToken, 227 token: server.accessToken,
228 fields: baseCorrectParams, 228 fields: baseCorrectParams,
229 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 229 expectedStatus: HttpStatusCode.NO_CONTENT_204
230 }) 230 })
231 }) 231 })
232 }) 232 })
@@ -271,7 +271,7 @@ describe('Test video channels API validator', function () {
271 path: `${path}/${type}/pick`, 271 path: `${path}/${type}/pick`,
272 fields, 272 fields,
273 attaches, 273 attaches,
274 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 274 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
275 }) 275 })
276 } 276 }
277 }) 277 })
@@ -288,7 +288,7 @@ describe('Test video channels API validator', function () {
288 token: server.accessToken, 288 token: server.accessToken,
289 fields, 289 fields,
290 attaches, 290 attaches,
291 statusCodeExpected: HttpStatusCode.OK_200 291 expectedStatus: HttpStatusCode.OK_200
292 }) 292 })
293 } 293 }
294 }) 294 })
@@ -299,7 +299,7 @@ describe('Test video channels API validator', function () {
299 const res = await makeGetRequest({ 299 const res = await makeGetRequest({
300 url: server.url, 300 url: server.url,
301 path: videoChannelPath, 301 path: videoChannelPath,
302 statusCodeExpected: HttpStatusCode.OK_200 302 expectedStatus: HttpStatusCode.OK_200
303 }) 303 })
304 304
305 expect(res.body.data).to.be.an('array') 305 expect(res.body.data).to.be.an('array')
@@ -309,7 +309,7 @@ describe('Test video channels API validator', function () {
309 await makeGetRequest({ 309 await makeGetRequest({
310 url: server.url, 310 url: server.url,
311 path: videoChannelPath + '/super_channel2', 311 path: videoChannelPath + '/super_channel2',
312 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 312 expectedStatus: HttpStatusCode.NOT_FOUND_404
313 }) 313 })
314 }) 314 })
315 315
@@ -317,7 +317,7 @@ describe('Test video channels API validator', function () {
317 await makeGetRequest({ 317 await makeGetRequest({
318 url: server.url, 318 url: server.url,
319 path: videoChannelPath + '/super_channel', 319 path: videoChannelPath + '/super_channel',
320 statusCodeExpected: HttpStatusCode.OK_200 320 expectedStatus: HttpStatusCode.OK_200
321 }) 321 })
322 }) 322 })
323 }) 323 })
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index 92c29da0e..bfd9e0172 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 checkBadCountPagination, 7 checkBadCountPagination,
8 checkBadSortPagination, 8 checkBadSortPagination,
@@ -78,7 +78,7 @@ describe('Test video comments API validator', function () {
78 await makeGetRequest({ 78 await makeGetRequest({
79 url: server.url, 79 url: server.url,
80 path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads', 80 path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads',
81 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 81 expectedStatus: HttpStatusCode.NOT_FOUND_404
82 }) 82 })
83 }) 83 })
84 }) 84 })
@@ -88,7 +88,7 @@ describe('Test video comments API validator', function () {
88 await makeGetRequest({ 88 await makeGetRequest({
89 url: server.url, 89 url: server.url,
90 path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads/' + commentId, 90 path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads/' + commentId,
91 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 91 expectedStatus: HttpStatusCode.NOT_FOUND_404
92 }) 92 })
93 }) 93 })
94 94
@@ -96,7 +96,7 @@ describe('Test video comments API validator', function () {
96 await makeGetRequest({ 96 await makeGetRequest({
97 url: server.url, 97 url: server.url,
98 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156', 98 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156',
99 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 99 expectedStatus: HttpStatusCode.NOT_FOUND_404
100 }) 100 })
101 }) 101 })
102 102
@@ -104,7 +104,7 @@ describe('Test video comments API validator', function () {
104 await makeGetRequest({ 104 await makeGetRequest({
105 url: server.url, 105 url: server.url,
106 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId, 106 path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId,
107 statusCodeExpected: HttpStatusCode.OK_200 107 expectedStatus: HttpStatusCode.OK_200
108 }) 108 })
109 }) 109 })
110 }) 110 })
@@ -120,7 +120,7 @@ describe('Test video comments API validator', function () {
120 path: pathThread, 120 path: pathThread,
121 token: 'none', 121 token: 'none',
122 fields, 122 fields,
123 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 123 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
124 }) 124 })
125 }) 125 })
126 126
@@ -153,7 +153,7 @@ describe('Test video comments API validator', function () {
153 path, 153 path,
154 token: server.accessToken, 154 token: server.accessToken,
155 fields, 155 fields,
156 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 156 expectedStatus: HttpStatusCode.NOT_FOUND_404
157 }) 157 })
158 }) 158 })
159 159
@@ -166,7 +166,7 @@ describe('Test video comments API validator', function () {
166 path: pathThread, 166 path: pathThread,
167 token: server.accessToken, 167 token: server.accessToken,
168 fields, 168 fields,
169 statusCodeExpected: HttpStatusCode.OK_200 169 expectedStatus: HttpStatusCode.OK_200
170 }) 170 })
171 }) 171 })
172 }) 172 })
@@ -181,7 +181,7 @@ describe('Test video comments API validator', function () {
181 path: pathComment, 181 path: pathComment,
182 token: 'none', 182 token: 'none',
183 fields, 183 fields,
184 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 184 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
185 }) 185 })
186 }) 186 })
187 187
@@ -214,7 +214,7 @@ describe('Test video comments API validator', function () {
214 path, 214 path,
215 token: server.accessToken, 215 token: server.accessToken,
216 fields, 216 fields,
217 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 217 expectedStatus: HttpStatusCode.NOT_FOUND_404
218 }) 218 })
219 }) 219 })
220 220
@@ -228,7 +228,7 @@ describe('Test video comments API validator', function () {
228 path, 228 path,
229 token: server.accessToken, 229 token: server.accessToken,
230 fields, 230 fields,
231 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 231 expectedStatus: HttpStatusCode.NOT_FOUND_404
232 }) 232 })
233 }) 233 })
234 234
@@ -241,14 +241,14 @@ describe('Test video comments API validator', function () {
241 path: pathComment, 241 path: pathComment,
242 token: server.accessToken, 242 token: server.accessToken,
243 fields, 243 fields,
244 statusCodeExpected: HttpStatusCode.OK_200 244 expectedStatus: HttpStatusCode.OK_200
245 }) 245 })
246 }) 246 })
247 }) 247 })
248 248
249 describe('When removing video comments', function () { 249 describe('When removing video comments', function () {
250 it('Should fail with a non authenticated user', async function () { 250 it('Should fail with a non authenticated user', async function () {
251 await makeDeleteRequest({ url: server.url, path: pathComment, token: 'none', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 251 await makeDeleteRequest({ url: server.url, path: pathComment, token: 'none', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
252 }) 252 })
253 253
254 it('Should fail with another user', async function () { 254 it('Should fail with another user', async function () {
@@ -256,18 +256,18 @@ describe('Test video comments API validator', function () {
256 url: server.url, 256 url: server.url,
257 path: pathComment, 257 path: pathComment,
258 token: userAccessToken, 258 token: userAccessToken,
259 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 259 expectedStatus: HttpStatusCode.FORBIDDEN_403
260 }) 260 })
261 }) 261 })
262 262
263 it('Should fail with an incorrect video', async function () { 263 it('Should fail with an incorrect video', async function () {
264 const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comments/' + commentId 264 const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comments/' + commentId
265 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 265 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
266 }) 266 })
267 267
268 it('Should fail with an incorrect comment', async function () { 268 it('Should fail with an incorrect comment', async function () {
269 const path = '/api/v1/videos/' + video.uuid + '/comments/124' 269 const path = '/api/v1/videos/' + video.uuid + '/comments/124'
270 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) 270 await makeDeleteRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
271 }) 271 })
272 272
273 it('Should succeed with the same user', async function () { 273 it('Should succeed with the same user', async function () {
@@ -280,8 +280,8 @@ describe('Test video comments API validator', function () {
280 280
281 const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete 281 const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete
282 282
283 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 283 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
284 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) 284 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
285 }) 285 })
286 286
287 it('Should succeed with the owner of the video', async function () { 287 it('Should succeed with the owner of the video', async function () {
@@ -300,8 +300,8 @@ describe('Test video comments API validator', function () {
300 300
301 const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete 301 const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete
302 302
303 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) 303 await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
304 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) 304 await makeDeleteRequest({ url: server.url, path, token: userAccessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
305 }) 305 })
306 306
307 it('Should succeed with the correct parameters', async function () { 307 it('Should succeed with the correct parameters', async function () {
@@ -309,7 +309,7 @@ describe('Test video comments API validator', function () {
309 url: server.url, 309 url: server.url,
310 path: pathComment, 310 path: pathComment,
311 token: server.accessToken, 311 token: server.accessToken,
312 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 312 expectedStatus: HttpStatusCode.NO_CONTENT_204
313 }) 313 })
314 }) 314 })
315 }) 315 })
@@ -324,7 +324,7 @@ describe('Test video comments API validator', function () {
324 const res = await makeGetRequest({ 324 const res = await makeGetRequest({
325 url: server.url, 325 url: server.url,
326 path: pathThread, 326 path: pathThread,
327 statusCodeExpected: HttpStatusCode.OK_200 327 expectedStatus: HttpStatusCode.OK_200
328 }) 328 })
329 expect(res.body.total).to.equal(0) 329 expect(res.body.total).to.equal(0)
330 expect(res.body.data).to.have.lengthOf(0) 330 expect(res.body.data).to.have.lengthOf(0)
@@ -341,7 +341,7 @@ describe('Test video comments API validator', function () {
341 path: pathThread, 341 path: pathThread,
342 token: server.accessToken, 342 token: server.accessToken,
343 fields, 343 fields,
344 statusCodeExpected: HttpStatusCode.CONFLICT_409 344 expectedStatus: HttpStatusCode.CONFLICT_409
345 }) 345 })
346 }) 346 })
347 347
@@ -367,7 +367,7 @@ describe('Test video comments API validator', function () {
367 await makeGetRequest({ 367 await makeGetRequest({
368 url: server.url, 368 url: server.url,
369 path, 369 path,
370 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 370 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
371 }) 371 })
372 }) 372 })
373 373
@@ -376,7 +376,7 @@ describe('Test video comments API validator', function () {
376 url: server.url, 376 url: server.url,
377 path, 377 path,
378 token: userAccessToken, 378 token: userAccessToken,
379 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 379 expectedStatus: HttpStatusCode.FORBIDDEN_403
380 }) 380 })
381 }) 381 })
382 382
@@ -391,7 +391,7 @@ describe('Test video comments API validator', function () {
391 searchAccount: 'toto', 391 searchAccount: 'toto',
392 searchVideo: 'toto' 392 searchVideo: 'toto'
393 }, 393 },
394 statusCodeExpected: HttpStatusCode.OK_200 394 expectedStatus: HttpStatusCode.OK_200
395 }) 395 })
396 }) 396 })
397 }) 397 })
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 0209275ac..957556c9b 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { omit } from 'lodash' 4import { omit } from 'lodash'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 buildAbsoluteFixturePath, 7 buildAbsoluteFixturePath,
8 checkBadCountPagination, 8 checkBadCountPagination,
@@ -61,7 +61,7 @@ describe('Test video imports API validator', function () {
61 }) 61 })
62 62
63 it('Should success with the correct parameters', async function () { 63 it('Should success with the correct parameters', async function () {
64 await makeGetRequest({ url: server.url, path: myPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) 64 await makeGetRequest({ url: server.url, path: myPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken })
65 }) 65 })
66 }) 66 })
67 67
@@ -99,7 +99,7 @@ describe('Test video imports API validator', function () {
99 path, 99 path,
100 token: server.accessToken, 100 token: server.accessToken,
101 fields, 101 fields,
102 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 102 expectedStatus: HttpStatusCode.BAD_REQUEST_400
103 }) 103 })
104 }) 104 })
105 105
@@ -251,7 +251,7 @@ describe('Test video imports API validator', function () {
251 path, 251 path,
252 token: server.accessToken, 252 token: server.accessToken,
253 fields: baseCorrectParams, 253 fields: baseCorrectParams,
254 statusCodeExpected: HttpStatusCode.OK_200 254 expectedStatus: HttpStatusCode.OK_200
255 }) 255 })
256 }) 256 })
257 257
@@ -276,7 +276,7 @@ describe('Test video imports API validator', function () {
276 path, 276 path,
277 token: server.accessToken, 277 token: server.accessToken,
278 fields: baseCorrectParams, 278 fields: baseCorrectParams,
279 statusCodeExpected: HttpStatusCode.CONFLICT_409 279 expectedStatus: HttpStatusCode.CONFLICT_409
280 }) 280 })
281 }) 281 })
282 282
@@ -304,7 +304,7 @@ describe('Test video imports API validator', function () {
304 path, 304 path,
305 token: server.accessToken, 305 token: server.accessToken,
306 fields, 306 fields,
307 statusCodeExpected: HttpStatusCode.CONFLICT_409 307 expectedStatus: HttpStatusCode.CONFLICT_409
308 }) 308 })
309 309
310 fields = omit(fields, 'magnetUri') 310 fields = omit(fields, 'magnetUri')
@@ -318,7 +318,7 @@ describe('Test video imports API validator', function () {
318 token: server.accessToken, 318 token: server.accessToken,
319 fields, 319 fields,
320 attaches, 320 attaches,
321 statusCodeExpected: HttpStatusCode.CONFLICT_409 321 expectedStatus: HttpStatusCode.CONFLICT_409
322 }) 322 })
323 }) 323 })
324 }) 324 })
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index 9d054b176..7dcb4935a 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadSortPagination, 7 checkBadSortPagination,
@@ -119,7 +119,7 @@ describe('Test video playlists API validator', function () {
119 await makeGetRequest({ 119 await makeGetRequest({
120 url: server.url, 120 url: server.url,
121 path: accountPath, 121 path: accountPath,
122 statusCodeExpected: HttpStatusCode.NOT_FOUND_404, 122 expectedStatus: HttpStatusCode.NOT_FOUND_404,
123 token: server.accessToken 123 token: server.accessToken
124 }) 124 })
125 }) 125 })
@@ -130,18 +130,18 @@ describe('Test video playlists API validator', function () {
130 await makeGetRequest({ 130 await makeGetRequest({
131 url: server.url, 131 url: server.url,
132 path: accountPath, 132 path: accountPath,
133 statusCodeExpected: HttpStatusCode.NOT_FOUND_404, 133 expectedStatus: HttpStatusCode.NOT_FOUND_404,
134 token: server.accessToken 134 token: server.accessToken
135 }) 135 })
136 }) 136 })
137 137
138 it('Should success with the correct parameters', async function () { 138 it('Should success with the correct parameters', async function () {
139 await makeGetRequest({ url: server.url, path: globalPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) 139 await makeGetRequest({ url: server.url, path: globalPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken })
140 await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) 140 await makeGetRequest({ url: server.url, path: accountPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken })
141 await makeGetRequest({ 141 await makeGetRequest({
142 url: server.url, 142 url: server.url,
143 path: videoChannelPath, 143 path: videoChannelPath,
144 statusCodeExpected: HttpStatusCode.OK_200, 144 expectedStatus: HttpStatusCode.OK_200,
145 token: server.accessToken 145 token: server.accessToken
146 }) 146 })
147 }) 147 })
@@ -159,7 +159,7 @@ describe('Test video playlists API validator', function () {
159 }) 159 })
160 160
161 it('Should success with the correct parameters', async function () { 161 it('Should success with the correct parameters', async function () {
162 await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) 162 await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', expectedStatus: HttpStatusCode.OK_200 })
163 }) 163 })
164 }) 164 })
165 165
@@ -580,7 +580,7 @@ describe('Test video playlists API validator', function () {
580 url: server.url, 580 url: server.url,
581 path, 581 path,
582 query: { videoIds: [ 1, 2 ] }, 582 query: { videoIds: [ 1, 2 ] },
583 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 583 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
584 }) 584 })
585 }) 585 })
586 586
@@ -613,7 +613,7 @@ describe('Test video playlists API validator', function () {
613 token: server.accessToken, 613 token: server.accessToken,
614 path, 614 path,
615 query: { videoIds: [ 1, 2 ] }, 615 query: { videoIds: [ 1, 2 ] },
616 statusCodeExpected: HttpStatusCode.OK_200 616 expectedStatus: HttpStatusCode.OK_200
617 }) 617 })
618 }) 618 })
619 }) 619 })
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts
index e4e799cc7..c2c69904f 100644
--- a/server/tests/api/check-params/videos-filter.ts
+++ b/server/tests/api/check-params/videos-filter.ts
@@ -1,6 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/models'
4import { 5import {
5 cleanupTests, 6 cleanupTests,
6 createSingleServer, 7 createSingleServer,
@@ -8,11 +9,10 @@ import {
8 PeerTubeServer, 9 PeerTubeServer,
9 setAccessTokensToServers, 10 setAccessTokensToServers,
10 setDefaultVideoChannel 11 setDefaultVideoChannel
11} from '../../../../shared/extra-utils' 12} from '@shared/extra-utils'
12import { UserRole } from '../../../../shared/models/users' 13import { UserRole } from '@shared/models'
13import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
14 14
15async function testEndpoints (server: PeerTubeServer, token: string, filter: string, statusCodeExpected: HttpStatusCode) { 15async function testEndpoints (server: PeerTubeServer, token: string, filter: string, expectedStatus: HttpStatusCode) {
16 const paths = [ 16 const paths = [
17 '/api/v1/video-channels/root_channel/videos', 17 '/api/v1/video-channels/root_channel/videos',
18 '/api/v1/accounts/root/videos', 18 '/api/v1/accounts/root/videos',
@@ -28,7 +28,7 @@ async function testEndpoints (server: PeerTubeServer, token: string, filter: str
28 query: { 28 query: {
29 filter 29 filter
30 }, 30 },
31 statusCodeExpected 31 expectedStatus
32 }) 32 })
33 } 33 }
34} 34}
@@ -89,7 +89,7 @@ describe('Test video filters validators', function () {
89 await makeGetRequest({ 89 await makeGetRequest({
90 url: server.url, 90 url: server.url,
91 path: '/feeds/videos.json', 91 path: '/feeds/videos.json',
92 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401, 92 expectedStatus: HttpStatusCode.UNAUTHORIZED_401,
93 query: { 93 query: {
94 filter 94 filter
95 } 95 }
@@ -101,7 +101,7 @@ describe('Test video filters validators', function () {
101 await makeGetRequest({ 101 await makeGetRequest({
102 url: server.url, 102 url: server.url,
103 path: '/feeds/videos.json', 103 path: '/feeds/videos.json',
104 statusCodeExpected: HttpStatusCode.OK_200, 104 expectedStatus: HttpStatusCode.OK_200,
105 query: { 105 query: {
106 filter: 'local' 106 filter: 'local'
107 } 107 }
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts
index 3c1f479e4..7283a4d28 100644
--- a/server/tests/api/check-params/videos-history.ts
+++ b/server/tests/api/check-params/videos-history.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import 'mocha' 3import 'mocha'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { 5import {
6 checkBadCountPagination, 6 checkBadCountPagination,
7 checkBadStartPagination, 7 checkBadStartPagination,
@@ -37,7 +37,7 @@ describe('Test videos history API validator', function () {
37 37
38 it('Should fail with an unauthenticated user', async function () { 38 it('Should fail with an unauthenticated user', async function () {
39 const fields = { currentTime: 5 } 39 const fields = { currentTime: 5 }
40 await makePutBodyRequest({ url: server.url, path: watchingPath, fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 40 await makePutBodyRequest({ url: server.url, path: watchingPath, fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
41 }) 41 })
42 42
43 it('Should fail with an incorrect video id', async function () { 43 it('Should fail with an incorrect video id', async function () {
@@ -48,7 +48,7 @@ describe('Test videos history API validator', function () {
48 path, 48 path,
49 fields, 49 fields,
50 token: server.accessToken, 50 token: server.accessToken,
51 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 51 expectedStatus: HttpStatusCode.BAD_REQUEST_400
52 }) 52 })
53 }) 53 })
54 54
@@ -61,7 +61,7 @@ describe('Test videos history API validator', function () {
61 path, 61 path,
62 fields, 62 fields,
63 token: server.accessToken, 63 token: server.accessToken,
64 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 64 expectedStatus: HttpStatusCode.NOT_FOUND_404
65 }) 65 })
66 }) 66 })
67 67
@@ -72,7 +72,7 @@ describe('Test videos history API validator', function () {
72 path: watchingPath, 72 path: watchingPath,
73 fields, 73 fields,
74 token: server.accessToken, 74 token: server.accessToken,
75 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 75 expectedStatus: HttpStatusCode.BAD_REQUEST_400
76 }) 76 })
77 }) 77 })
78 78
@@ -84,7 +84,7 @@ describe('Test videos history API validator', function () {
84 path: watchingPath, 84 path: watchingPath,
85 fields, 85 fields,
86 token: server.accessToken, 86 token: server.accessToken,
87 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 87 expectedStatus: HttpStatusCode.NO_CONTENT_204
88 }) 88 })
89 }) 89 })
90 }) 90 })
@@ -99,17 +99,17 @@ describe('Test videos history API validator', function () {
99 }) 99 })
100 100
101 it('Should fail with an unauthenticated user', async function () { 101 it('Should fail with an unauthenticated user', async function () {
102 await makeGetRequest({ url: server.url, path: myHistoryPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 102 await makeGetRequest({ url: server.url, path: myHistoryPath, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
103 }) 103 })
104 104
105 it('Should succeed with the correct params', async function () { 105 it('Should succeed with the correct params', async function () {
106 await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, statusCodeExpected: HttpStatusCode.OK_200 }) 106 await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, expectedStatus: HttpStatusCode.OK_200 })
107 }) 107 })
108 }) 108 })
109 109
110 describe('When removing user videos history', function () { 110 describe('When removing user videos history', function () {
111 it('Should fail with an unauthenticated user', async function () { 111 it('Should fail with an unauthenticated user', async function () {
112 await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) 112 await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
113 }) 113 })
114 114
115 it('Should fail with a bad beforeDate parameter', async function () { 115 it('Should fail with a bad beforeDate parameter', async function () {
@@ -119,7 +119,7 @@ describe('Test videos history API validator', function () {
119 token: server.accessToken, 119 token: server.accessToken,
120 path: myHistoryRemove, 120 path: myHistoryRemove,
121 fields: body, 121 fields: body,
122 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 122 expectedStatus: HttpStatusCode.BAD_REQUEST_400
123 }) 123 })
124 }) 124 })
125 125
@@ -130,7 +130,7 @@ describe('Test videos history API validator', function () {
130 token: server.accessToken, 130 token: server.accessToken,
131 path: myHistoryRemove, 131 path: myHistoryRemove,
132 fields: body, 132 fields: body,
133 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 133 expectedStatus: HttpStatusCode.NO_CONTENT_204
134 }) 134 })
135 }) 135 })
136 136
@@ -139,7 +139,7 @@ describe('Test videos history API validator', function () {
139 url: server.url, 139 url: server.url,
140 token: server.accessToken, 140 token: server.accessToken,
141 path: myHistoryRemove, 141 path: myHistoryRemove,
142 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 142 expectedStatus: HttpStatusCode.NO_CONTENT_204
143 }) 143 })
144 }) 144 })
145 }) 145 })
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index c60de2640..e11ca0c82 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -4,7 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { join } from 'path' 6import { join } from 'path'
7import { HttpStatusCode, randomInt } from '@shared/core-utils' 7import { randomInt } from '@shared/core-utils'
8import { 8import {
9 checkBadCountPagination, 9 checkBadCountPagination,
10 checkBadSortPagination, 10 checkBadSortPagination,
@@ -16,11 +16,11 @@ import {
16 makeGetRequest, 16 makeGetRequest,
17 makePutBodyRequest, 17 makePutBodyRequest,
18 makeUploadRequest, 18 makeUploadRequest,
19 root,
20 PeerTubeServer, 19 PeerTubeServer,
20 root,
21 setAccessTokensToServers 21 setAccessTokensToServers
22} from '@shared/extra-utils' 22} from '@shared/extra-utils'
23import { PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' 23import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
24 24
25const expect = chai.expect 25const expect = chai.expect
26 26
@@ -69,11 +69,11 @@ describe('Test videos API validator', function () {
69 }) 69 })
70 70
71 it('Should fail with a bad skipVideos query', async function () { 71 it('Should fail with a bad skipVideos query', async function () {
72 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: 'toto' } }) 72 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: 'toto' } })
73 }) 73 })
74 74
75 it('Should success with the correct parameters', async function () { 75 it('Should success with the correct parameters', async function () {
76 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: false } }) 76 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: false } })
77 }) 77 })
78 }) 78 })
79 79
@@ -83,7 +83,7 @@ describe('Test videos API validator', function () {
83 await makeGetRequest({ 83 await makeGetRequest({
84 url: server.url, 84 url: server.url,
85 path: join(path, 'search'), 85 path: join(path, 'search'),
86 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 86 expectedStatus: HttpStatusCode.BAD_REQUEST_400
87 }) 87 })
88 }) 88 })
89 89
@@ -100,7 +100,7 @@ describe('Test videos API validator', function () {
100 }) 100 })
101 101
102 it('Should success with the correct parameters', async function () { 102 it('Should success with the correct parameters', async function () {
103 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) 103 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
104 }) 104 })
105 }) 105 })
106 106
@@ -120,7 +120,7 @@ describe('Test videos API validator', function () {
120 }) 120 })
121 121
122 it('Should success with the correct parameters', async function () { 122 it('Should success with the correct parameters', async function () {
123 await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: HttpStatusCode.OK_200 }) 123 await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 })
124 }) 124 })
125 }) 125 })
126 126
@@ -144,7 +144,7 @@ describe('Test videos API validator', function () {
144 }) 144 })
145 145
146 it('Should success with the correct parameters', async function () { 146 it('Should success with the correct parameters', async function () {
147 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) 147 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
148 }) 148 })
149 }) 149 })
150 150
@@ -168,7 +168,7 @@ describe('Test videos API validator', function () {
168 }) 168 })
169 169
170 it('Should success with the correct parameters', async function () { 170 it('Should success with the correct parameters', async function () {
171 await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) 171 await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
172 }) 172 })
173 }) 173 })
174 174
@@ -506,7 +506,7 @@ describe('Test videos API validator', function () {
506 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', 506 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
507 token: server.accessToken, 507 token: server.accessToken,
508 fields, 508 fields,
509 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 509 expectedStatus: HttpStatusCode.NOT_FOUND_404
510 }) 510 })
511 }) 511 })
512 512
@@ -660,7 +660,7 @@ describe('Test videos API validator', function () {
660 path: path + video.shortUUID, 660 path: path + video.shortUUID,
661 token: userAccessToken, 661 token: userAccessToken,
662 fields, 662 fields,
663 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 663 expectedStatus: HttpStatusCode.FORBIDDEN_403
664 }) 664 })
665 }) 665 })
666 666
@@ -692,7 +692,7 @@ describe('Test videos API validator', function () {
692 path: path + video.shortUUID, 692 path: path + video.shortUUID,
693 token: server.accessToken, 693 token: server.accessToken,
694 fields, 694 fields,
695 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 695 expectedStatus: HttpStatusCode.NO_CONTENT_204
696 }) 696 })
697 }) 697 })
698 }) 698 })
@@ -702,7 +702,7 @@ describe('Test videos API validator', function () {
702 const res = await makeGetRequest({ 702 const res = await makeGetRequest({
703 url: server.url, 703 url: server.url,
704 path, 704 path,
705 statusCodeExpected: HttpStatusCode.OK_200 705 expectedStatus: HttpStatusCode.OK_200
706 }) 706 })
707 707
708 expect(res.body.data).to.be.an('array') 708 expect(res.body.data).to.be.an('array')
@@ -762,7 +762,7 @@ describe('Test videos API validator', function () {
762 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', 762 path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
763 token: server.accessToken, 763 token: server.accessToken,
764 fields, 764 fields,
765 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 765 expectedStatus: HttpStatusCode.NOT_FOUND_404
766 }) 766 })
767 }) 767 })
768 768
@@ -782,7 +782,7 @@ describe('Test videos API validator', function () {
782 path: path + videoId + '/rate', 782 path: path + videoId + '/rate',
783 token: server.accessToken, 783 token: server.accessToken,
784 fields, 784 fields,
785 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 785 expectedStatus: HttpStatusCode.NO_CONTENT_204
786 }) 786 })
787 }) 787 })
788 }) 788 })
@@ -792,7 +792,7 @@ describe('Test videos API validator', function () {
792 await makeDeleteRequest({ 792 await makeDeleteRequest({
793 url: server.url, 793 url: server.url,
794 path, 794 path,
795 statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 795 expectedStatus: HttpStatusCode.BAD_REQUEST_400
796 }) 796 })
797 }) 797 })
798 798
@@ -812,7 +812,7 @@ describe('Test videos API validator', function () {
812 812
813 it('Shoud report the appropriate error', async function () { 813 it('Shoud report the appropriate error', async function () {
814 const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 814 const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
815 const error = body as unknown as PeerTubeProblemDocument 815 const error = body as PeerTubeProblemDocument
816 816
817 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') 817 expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
818 818
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index d403f27bf..095c51b97 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { FfmpegCommand } from 'fluent-ffmpeg' 5import { FfmpegCommand } from 'fluent-ffmpeg'
6import { HttpStatusCode } from '@shared/core-utils' 6import { HttpStatusCode } from '@shared/models'
7import { 7import {
8 checkLiveCleanup, 8 checkLiveCleanup,
9 cleanupTests, 9 cleanupTests,
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 7cfac522c..88995910c 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -4,7 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' 6import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/models'
8import { 8import {
9 checkLiveCleanup, 9 checkLiveCleanup,
10 checkLiveSegmentHash, 10 checkLiveSegmentHash,
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts
index 360b9de35..8d6360eb3 100644
--- a/server/tests/api/moderation/abuses.ts
+++ b/server/tests/api/moderation/abuses.ts
@@ -5,8 +5,8 @@ import * as chai from 'chai'
5import { 5import {
6 AbusesCommand, 6 AbusesCommand,
7 cleanupTests, 7 cleanupTests,
8 doubleFollow,
9 createMultipleServers, 8 createMultipleServers,
9 doubleFollow,
10 PeerTubeServer, 10 PeerTubeServer,
11 setAccessTokensToServers, 11 setAccessTokensToServers,
12 waitJobs 12 waitJobs
@@ -65,7 +65,7 @@ describe('Test abuses', function () {
65 expect(data.length).to.equal(2) 65 expect(data.length).to.equal(2)
66 66
67 servers[0].store.video = data.find(video => video.name === 'my super name for server 1') 67 servers[0].store.video = data.find(video => video.name === 'my super name for server 1')
68 servers[1].store.video = data.find(video => video.name === 'my super name for server 2') 68 servers[1].store.video = data.find(video => video.name === 'my super name for server 2')
69 }) 69 })
70 70
71 it('Should not have abuses', async function () { 71 it('Should not have abuses', async function () {
@@ -402,8 +402,8 @@ describe('Test abuses', function () {
402 before(async function () { 402 before(async function () {
403 this.timeout(50000) 403 this.timeout(50000)
404 404
405 servers[0].store.video = await await servers[0].videos.quickUpload({ name: 'server 1' }) 405 servers[0].store.video = await servers[0].videos.quickUpload({ name: 'server 1' })
406 servers[1].store.video = await await servers[1].videos.quickUpload({ name: 'server 2' }) 406 servers[1].store.video = await servers[1].videos.quickUpload({ name: 'server 2' })
407 407
408 await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' }) 408 await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' })
409 await servers[1].comments.createThread({ videoId: servers[1].store.video.id, text: 'comment server 2' }) 409 await servers[1].comments.createThread({ videoId: servers[1].store.video.id, text: 'comment server 2' })
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts
index 217691fb6..71b93901e 100644
--- a/server/tests/api/redundancy/redundancy-constraints.ts
+++ b/server/tests/api/redundancy/redundancy-constraints.ts
@@ -117,7 +117,7 @@ describe('Test redundancy constraints', function () {
117 } 117 }
118 } 118 }
119 } 119 }
120 await await killallServers([ localServer ]) 120 await killallServers([ localServer ])
121 await localServer.run(config) 121 await localServer.run(config)
122 122
123 await uploadWrapper('video 2 server 2') 123 await uploadWrapper('video 2 server 2')
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 9d5d96efd..921a48856 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -5,7 +5,7 @@ import * as chai from 'chai'
5import { readdir } from 'fs-extra' 5import { readdir } from 'fs-extra'
6import * as magnetUtil from 'magnet-uri' 6import * as magnetUtil from 'magnet-uri'
7import { join } from 'path' 7import { join } from 'path'
8import { HttpStatusCode } from '@shared/core-utils' 8import { HttpStatusCode } from '@shared/models'
9import { 9import {
10 checkSegmentHash, 10 checkSegmentHash,
11 checkVideoFilesWereRemoved, 11 checkVideoFilesWereRemoved,
@@ -129,13 +129,13 @@ async function check2Webseeds (videoUUID?: string) {
129 129
130 await makeGetRequest({ 130 await makeGetRequest({
131 url: servers[0].url, 131 url: servers[0].url,
132 statusCodeExpected: HttpStatusCode.OK_200, 132 expectedStatus: HttpStatusCode.OK_200,
133 path: '/static/redundancy/' + `${videoUUID}-${file.resolution.id}.mp4`, 133 path: '/static/redundancy/' + `${videoUUID}-${file.resolution.id}.mp4`,
134 contentType: null 134 contentType: null
135 }) 135 })
136 await makeGetRequest({ 136 await makeGetRequest({
137 url: servers[1].url, 137 url: servers[1].url,
138 statusCodeExpected: HttpStatusCode.OK_200, 138 expectedStatus: HttpStatusCode.OK_200,
139 path: `/static/webseed/${videoUUID}-${file.resolution.id}.mp4`, 139 path: `/static/webseed/${videoUUID}-${file.resolution.id}.mp4`,
140 contentType: null 140 contentType: null
141 }) 141 })
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts
index f5896ec25..b33f28266 100644
--- a/server/tests/api/search/search-activitypub-video-channels.ts
+++ b/server/tests/api/search/search-activitypub-video-channels.ts
@@ -149,7 +149,7 @@ describe('Test ActivityPub video channels search', function () {
149 149
150 const { total, data } = await servers[0].videos.listByChannel({ 150 const { total, data } = await servers[0].videos.listByChannel({
151 token: null, 151 token: null,
152 videoChannelName: 'channel1_server2@localhost:' + servers[1].port 152 handle: 'channel1_server2@localhost:' + servers[1].port
153 }) 153 })
154 expect(total).to.equal(0) 154 expect(total).to.equal(0)
155 expect(data).to.have.lengthOf(0) 155 expect(data).to.have.lengthOf(0)
@@ -157,7 +157,7 @@ describe('Test ActivityPub video channels search', function () {
157 157
158 it('Should list video channel videos of server 2 with token', async function () { 158 it('Should list video channel videos of server 2 with token', async function () {
159 const { total, data } = await servers[0].videos.listByChannel({ 159 const { total, data } = await servers[0].videos.listByChannel({
160 videoChannelName: 'channel1_server2@localhost:' + servers[1].port 160 handle: 'channel1_server2@localhost:' + servers[1].port
161 }) 161 })
162 162
163 expect(total).to.equal(1) 163 expect(total).to.equal(1)
@@ -206,8 +206,8 @@ describe('Test ActivityPub video channels search', function () {
206 206
207 await waitJobs(servers) 207 await waitJobs(servers)
208 208
209 const videoChannelName = 'channel1_server2@localhost:' + servers[1].port 209 const handle = 'channel1_server2@localhost:' + servers[1].port
210 const { total, data } = await servers[0].videos.listByChannel({ videoChannelName, sort: '-createdAt' }) 210 const { total, data } = await servers[0].videos.listByChannel({ handle, sort: '-createdAt' })
211 211
212 expect(total).to.equal(2) 212 expect(total).to.equal(2)
213 expect(data[0].name).to.equal('video 2 server 2') 213 expect(data[0].name).to.equal('video 2 server 2')
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts
index a7191c5ef..a1c2f0f39 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
@@ -498,7 +498,7 @@ describe('Test config', function () {
498 const res = await makeGetRequest({ 498 const res = await makeGetRequest({
499 url: server.url, 499 url: server.url,
500 path: '/api/v1/config', 500 path: '/api/v1/config',
501 statusCodeExpected: 200 501 expectedStatus: 200
502 }) 502 })
503 503
504 expect(res.headers['x-frame-options']).to.exist 504 expect(res.headers['x-frame-options']).to.exist
@@ -517,7 +517,7 @@ describe('Test config', function () {
517 const res = await makeGetRequest({ 517 const res = await makeGetRequest({
518 url: server.url, 518 url: server.url,
519 path: '/api/v1/config', 519 path: '/api/v1/config',
520 statusCodeExpected: 200 520 expectedStatus: 200
521 }) 521 })
522 522
523 expect(res.headers['x-frame-options']).to.not.exist 523 expect(res.headers['x-frame-options']).to.not.exist
diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts
index f0905bb3b..fc5d0ad6a 100644
--- a/server/tests/api/server/contact-form.ts
+++ b/server/tests/api/server/contact-form.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 ContactFormCommand, 8 ContactFormCommand,
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index b202cf8a7..4c5b296ee 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' 6import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
7 7
8const expect = chai.expect 8const expect = chai.expect
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts
index 4ed593b76..bd7b215db 100644
--- a/server/tests/api/server/follow-constraints.ts
+++ b/server/tests/api/server/follow-constraints.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' 6import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
7import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' 7import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models'
8 8
@@ -54,30 +54,30 @@ describe('Test follow constraints', function () {
54 }) 54 })
55 55
56 it('Should list local account videos', async function () { 56 it('Should list local account videos', async function () {
57 const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[0].port }) 57 const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[0].port })
58 58
59 expect(total).to.equal(1) 59 expect(total).to.equal(1)
60 expect(data).to.have.lengthOf(1) 60 expect(data).to.have.lengthOf(1)
61 }) 61 })
62 62
63 it('Should list remote account videos', async function () { 63 it('Should list remote account videos', async function () {
64 const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[1].port }) 64 const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[1].port })
65 65
66 expect(total).to.equal(1) 66 expect(total).to.equal(1)
67 expect(data).to.have.lengthOf(1) 67 expect(data).to.have.lengthOf(1)
68 }) 68 })
69 69
70 it('Should list local channel videos', async function () { 70 it('Should list local channel videos', async function () {
71 const videoChannelName = 'root_channel@localhost:' + servers[0].port 71 const handle = 'root_channel@localhost:' + servers[0].port
72 const { total, data } = await servers[0].videos.listByChannel({ videoChannelName }) 72 const { total, data } = await servers[0].videos.listByChannel({ handle })
73 73
74 expect(total).to.equal(1) 74 expect(total).to.equal(1)
75 expect(data).to.have.lengthOf(1) 75 expect(data).to.have.lengthOf(1)
76 }) 76 })
77 77
78 it('Should list remote channel videos', async function () { 78 it('Should list remote channel videos', async function () {
79 const videoChannelName = 'root_channel@localhost:' + servers[1].port 79 const handle = 'root_channel@localhost:' + servers[1].port
80 const { total, data } = await servers[0].videos.listByChannel({ videoChannelName }) 80 const { total, data } = await servers[0].videos.listByChannel({ handle })
81 81
82 expect(total).to.equal(1) 82 expect(total).to.equal(1)
83 expect(data).to.have.lengthOf(1) 83 expect(data).to.have.lengthOf(1)
@@ -94,30 +94,30 @@ describe('Test follow constraints', function () {
94 }) 94 })
95 95
96 it('Should list local account videos', async function () { 96 it('Should list local account videos', async function () {
97 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port }) 97 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port })
98 98
99 expect(total).to.equal(1) 99 expect(total).to.equal(1)
100 expect(data).to.have.lengthOf(1) 100 expect(data).to.have.lengthOf(1)
101 }) 101 })
102 102
103 it('Should list remote account videos', async function () { 103 it('Should list remote account videos', async function () {
104 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port }) 104 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port })
105 105
106 expect(total).to.equal(1) 106 expect(total).to.equal(1)
107 expect(data).to.have.lengthOf(1) 107 expect(data).to.have.lengthOf(1)
108 }) 108 })
109 109
110 it('Should list local channel videos', async function () { 110 it('Should list local channel videos', async function () {
111 const videoChannelName = 'root_channel@localhost:' + servers[0].port 111 const handle = 'root_channel@localhost:' + servers[0].port
112 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName }) 112 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
113 113
114 expect(total).to.equal(1) 114 expect(total).to.equal(1)
115 expect(data).to.have.lengthOf(1) 115 expect(data).to.have.lengthOf(1)
116 }) 116 })
117 117
118 it('Should list remote channel videos', async function () { 118 it('Should list remote channel videos', async function () {
119 const videoChannelName = 'root_channel@localhost:' + servers[1].port 119 const handle = 'root_channel@localhost:' + servers[1].port
120 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName }) 120 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
121 121
122 expect(total).to.equal(1) 122 expect(total).to.equal(1)
123 expect(data).to.have.lengthOf(1) 123 expect(data).to.have.lengthOf(1)
@@ -158,7 +158,7 @@ describe('Test follow constraints', function () {
158 it('Should list local account videos', async function () { 158 it('Should list local account videos', async function () {
159 const { total, data } = await servers[0].videos.listByAccount({ 159 const { total, data } = await servers[0].videos.listByAccount({
160 token: undefined, 160 token: undefined,
161 accountName: 'root@localhost:' + servers[0].port 161 handle: 'root@localhost:' + servers[0].port
162 }) 162 })
163 163
164 expect(total).to.equal(1) 164 expect(total).to.equal(1)
@@ -168,7 +168,7 @@ describe('Test follow constraints', function () {
168 it('Should not list remote account videos', async function () { 168 it('Should not list remote account videos', async function () {
169 const { total, data } = await servers[0].videos.listByAccount({ 169 const { total, data } = await servers[0].videos.listByAccount({
170 token: undefined, 170 token: undefined,
171 accountName: 'root@localhost:' + servers[1].port 171 handle: 'root@localhost:' + servers[1].port
172 }) 172 })
173 173
174 expect(total).to.equal(0) 174 expect(total).to.equal(0)
@@ -176,16 +176,16 @@ describe('Test follow constraints', function () {
176 }) 176 })
177 177
178 it('Should list local channel videos', async function () { 178 it('Should list local channel videos', async function () {
179 const videoChannelName = 'root_channel@localhost:' + servers[0].port 179 const handle = 'root_channel@localhost:' + servers[0].port
180 const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName }) 180 const { total, data } = await servers[0].videos.listByChannel({ token: undefined, handle })
181 181
182 expect(total).to.equal(1) 182 expect(total).to.equal(1)
183 expect(data).to.have.lengthOf(1) 183 expect(data).to.have.lengthOf(1)
184 }) 184 })
185 185
186 it('Should not list remote channel videos', async function () { 186 it('Should not list remote channel videos', async function () {
187 const videoChannelName = 'root_channel@localhost:' + servers[1].port 187 const handle = 'root_channel@localhost:' + servers[1].port
188 const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName }) 188 const { total, data } = await servers[0].videos.listByChannel({ token: undefined, handle })
189 189
190 expect(total).to.equal(0) 190 expect(total).to.equal(0)
191 expect(data).to.have.lengthOf(0) 191 expect(data).to.have.lengthOf(0)
@@ -202,30 +202,30 @@ describe('Test follow constraints', function () {
202 }) 202 })
203 203
204 it('Should list local account videos', async function () { 204 it('Should list local account videos', async function () {
205 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port }) 205 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port })
206 206
207 expect(total).to.equal(1) 207 expect(total).to.equal(1)
208 expect(data).to.have.lengthOf(1) 208 expect(data).to.have.lengthOf(1)
209 }) 209 })
210 210
211 it('Should list remote account videos', async function () { 211 it('Should list remote account videos', async function () {
212 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port }) 212 const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port })
213 213
214 expect(total).to.equal(1) 214 expect(total).to.equal(1)
215 expect(data).to.have.lengthOf(1) 215 expect(data).to.have.lengthOf(1)
216 }) 216 })
217 217
218 it('Should list local channel videos', async function () { 218 it('Should list local channel videos', async function () {
219 const videoChannelName = 'root_channel@localhost:' + servers[0].port 219 const handle = 'root_channel@localhost:' + servers[0].port
220 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName }) 220 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
221 221
222 expect(total).to.equal(1) 222 expect(total).to.equal(1)
223 expect(data).to.have.lengthOf(1) 223 expect(data).to.have.lengthOf(1)
224 }) 224 })
225 225
226 it('Should list remote channel videos', async function () { 226 it('Should list remote channel videos', async function () {
227 const videoChannelName = 'root_channel@localhost:' + servers[1].port 227 const handle = 'root_channel@localhost:' + servers[1].port
228 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName }) 228 const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
229 229
230 expect(total).to.equal(1) 230 expect(total).to.equal(1)
231 expect(data).to.have.lengthOf(1) 231 expect(data).to.have.lengthOf(1)
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts
index 5f20b0093..d22e843e0 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 CommentsCommand, 8 CommentsCommand,
diff --git a/server/tests/api/server/homepage.ts b/server/tests/api/server/homepage.ts
index c291037f2..7eae3df20 100644
--- a/server/tests/api/server/homepage.ts
+++ b/server/tests/api/server/homepage.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 CustomPagesCommand, 8 CustomPagesCommand,
diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts
index f45222f2f..efa890ad4 100644
--- a/server/tests/api/server/no-client.ts
+++ b/server/tests/api/server/no-client.ts
@@ -1,8 +1,7 @@
1import 'mocha' 1import 'mocha'
2import * as request from 'supertest' 2import * as request from 'supertest'
3import { PeerTubeServer } from '../../../../shared/extra-utils' 3import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/extra-utils'
4import { cleanupTests, createSingleServer } from '../../../../shared/extra-utils/server/servers' 4import { HttpStatusCode } from '@shared/models'
5import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
6 5
7describe('Start and stop server without web client routes', function () { 6describe('Start and stop server without web client routes', function () {
8 let server: PeerTubeServer 7 let server: PeerTubeServer
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
index db03d026a..334adfe9d 100644
--- a/server/tests/api/server/plugins.ts
+++ b/server/tests/api/server/plugins.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts
index c20b7a5f0..13b22bc0e 100644
--- a/server/tests/api/server/reverse-proxy.ts
+++ b/server/tests/api/server/reverse-proxy.ts
@@ -1,7 +1,7 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ 1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2 2
3import { expect } from 'chai' 3import { expect } from 'chai'
4import { HttpStatusCode } from '@shared/core-utils' 4import { HttpStatusCode } from '@shared/models'
5import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' 5import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils'
6 6
7describe('Test application behind a reverse proxy', function () { 7describe('Test application behind a reverse proxy', function () {
diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts
index e629966bb..e304e5d67 100644
--- a/server/tests/api/users/users-multiple-servers.ts
+++ b/server/tests/api/users/users-multiple-servers.ts
@@ -131,7 +131,7 @@ describe('Test users with multiple servers', function () {
131 131
132 it('Should list account videos', async function () { 132 it('Should list account videos', async function () {
133 for (const server of servers) { 133 for (const server of servers) {
134 const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port }) 134 const { total, data } = await server.videos.listByAccount({ handle: 'user1@localhost:' + servers[0].port })
135 135
136 expect(total).to.equal(1) 136 expect(total).to.equal(1)
137 expect(data).to.be.an('array') 137 expect(data).to.be.an('array')
@@ -148,7 +148,7 @@ describe('Test users with multiple servers', function () {
148 await waitJobs(servers) 148 await waitJobs(servers)
149 149
150 for (const server of servers) { 150 for (const server of servers) {
151 const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port, search: 'Kami' }) 151 const { total, data } = await server.videos.listByAccount({ handle: 'user1@localhost:' + servers[0].port, search: 'Kami' })
152 152
153 expect(total).to.equal(1) 153 expect(total).to.equal(1)
154 expect(data).to.be.an('array') 154 expect(data).to.be.an('array')
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts
index 5dbe2af59..56fc25048 100644
--- a/server/tests/api/users/users-verification.ts
+++ b/server/tests/api/users/users-verification.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' 6import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
7 7
8const expect = chai.expect 8const expect = chai.expect
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 6ae5410b3..be80c2616 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
@@ -215,7 +215,7 @@ describe('Test users', function () {
215 path: path + videoId, 215 path: path + videoId,
216 token: 'wrong token', 216 token: 'wrong token',
217 fields: data, 217 fields: data,
218 statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 218 expectedStatus: HttpStatusCode.UNAUTHORIZED_401
219 } 219 }
220 await makePutBodyRequest(options) 220 await makePutBodyRequest(options)
221 }) 221 })
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 562079a15..edf2773cd 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import * as request from 'supertest' 5import * as request from 'supertest'
6import { HttpStatusCode } from '@shared/core-utils' 6import { HttpStatusCode } from '@shared/models'
7import { 7import {
8 buildAbsoluteFixturePath, 8 buildAbsoluteFixturePath,
9 checkTmpIsEmpty, 9 checkTmpIsEmpty,
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index b4fc5ee09..0e62972c2 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -4,7 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { pathExists, readdir, stat } from 'fs-extra' 5import { pathExists, readdir, stat } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/models'
8import { 8import {
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
10 cleanupTests, 10 cleanupTests,
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index cefddb68e..792550101 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 ChangeOwnershipCommand, 7 ChangeOwnershipCommand,
8 cleanupTests, 8 cleanupTests,
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 140fee7fe..eeaec5ad2 100644
--- a/server/tests/api/videos/video-channels.ts
+++ b/server/tests/api/videos/video-channels.ts
@@ -324,7 +324,7 @@ describe('Test video channels', function () {
324 324
325 for (const server of servers) { 325 for (const server of servers) {
326 const channelURI = 'second_video_channel@localhost:' + servers[0].port 326 const channelURI = 'second_video_channel@localhost:' + servers[0].port
327 const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI }) 327 const { total, data } = await server.videos.listByChannel({ handle: channelURI })
328 328
329 expect(total).to.equal(1) 329 expect(total).to.equal(1)
330 expect(data).to.be.an('array') 330 expect(data).to.be.an('array')
@@ -347,13 +347,13 @@ describe('Test video channels', function () {
347 for (const server of servers) { 347 for (const server of servers) {
348 { 348 {
349 const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port 349 const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port
350 const { total } = await server.videos.listByChannel({ videoChannelName: secondChannelURI }) 350 const { total } = await server.videos.listByChannel({ handle: secondChannelURI })
351 expect(total).to.equal(0) 351 expect(total).to.equal(0)
352 } 352 }
353 353
354 { 354 {
355 const channelURI = 'root_channel@localhost:' + servers[0].port 355 const channelURI = 'root_channel@localhost:' + servers[0].port
356 const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI }) 356 const { total, data } = await server.videos.listByChannel({ handle: channelURI })
357 expect(total).to.equal(1) 357 expect(total).to.equal(1)
358 358
359 expect(data).to.be.an('array') 359 expect(data).to.be.an('array')
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts
index 4c4b18887..df030110b 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { join } from 'path' 5import { join } from 'path'
6import { HttpStatusCode } from '@shared/core-utils' 6import { HttpStatusCode } from '@shared/models'
7import { 7import {
8 checkDirectoryIsEmpty, 8 checkDirectoryIsEmpty,
9 checkResolutionsInMasterPlaylist, 9 checkResolutionsInMasterPlaylist,
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index b25dcda20..0a9e5ce3f 100644
--- a/server/tests/api/videos/video-nsfw.ts
+++ b/server/tests/api/videos/video-nsfw.ts
@@ -19,8 +19,10 @@ describe('Test video NSFW policy', function () {
19 19
20 async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) { 20 async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) {
21 const user = await server.users.getMyInfo() 21 const user = await server.users.getMyInfo()
22 const videoChannelName = user.videoChannels[0].name 22
23 const channelName = user.videoChannels[0].name
23 const accountName = user.account.name + '@' + user.account.host 24 const accountName = user.account.name + '@' + user.account.host
25
24 const hasQuery = Object.keys(query).length !== 0 26 const hasQuery = Object.keys(query).length !== 0
25 let promises: Promise<ResultList<Video>>[] 27 let promises: Promise<ResultList<Video>>[]
26 28
@@ -28,8 +30,8 @@ describe('Test video NSFW policy', function () {
28 promises = [ 30 promises = [
29 server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }), 31 server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }),
30 server.videos.listWithToken({ token, ...query }), 32 server.videos.listWithToken({ token, ...query }),
31 server.videos.listByAccount({ token, accountName, ...query }), 33 server.videos.listByAccount({ token, handle: channelName, ...query }),
32 server.videos.listByChannel({ token, videoChannelName, ...query }) 34 server.videos.listByChannel({ token, handle: accountName, ...query })
33 ] 35 ]
34 36
35 // Overviews do not support video filters 37 // Overviews do not support video filters
@@ -45,8 +47,8 @@ describe('Test video NSFW policy', function () {
45 promises = [ 47 promises = [
46 server.search.searchVideos({ search: 'n', sort: '-publishedAt' }), 48 server.search.searchVideos({ search: 'n', sort: '-publishedAt' }),
47 server.videos.list(), 49 server.videos.list(),
48 server.videos.listByAccount({ accountName }), 50 server.videos.listByAccount({ handle: channelName }),
49 server.videos.listByChannel({ videoChannelName }) 51 server.videos.listByChannel({ handle: accountName })
50 ] 52 ]
51 53
52 // Overviews do not support video filters 54 // Overviews do not support video filters
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts
index 71ca3e63a..9a28a421a 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 checkPlaylistFilesWereRemoved, 7 checkPlaylistFilesWereRemoved,
8 cleanupTests, 8 cleanupTests,
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
index 5ec626155..06011082d 100644
--- a/server/tests/api/videos/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { cleanupTests, doubleFollow, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' 6import { cleanupTests, doubleFollow, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
7import { VideoCreateResult, VideoPrivacy } from '@shared/models' 7import { VideoCreateResult, VideoPrivacy } from '@shared/models'
8 8
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 2465d2d89..7510472e3 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -4,7 +4,7 @@ import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { join } from 'path' 6import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/models'
8import { 8import {
9 buildAbsoluteFixturePath, 9 buildAbsoluteFixturePath,
10 cleanupTests, 10 cleanupTests,
@@ -384,8 +384,8 @@ describe('Test video transcoding', function () {
384 384
385 expect(videoDetails.files).to.have.lengthOf(1) 385 expect(videoDetails.files).to.have.lengthOf(1)
386 386
387 await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 }) 387 await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 })
388 await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 }) 388 await makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: HttpStatusCode.OK_200 })
389 389
390 const magnetUri = videoDetails.files[0].magnetUri 390 const magnetUri = videoDetails.files[0].magnetUri
391 expect(magnetUri).to.contain('.mp4') 391 expect(magnetUri).to.contain('.mp4')
@@ -408,8 +408,8 @@ describe('Test video transcoding', function () {
408 408
409 expect(videoDetails.files).to.have.lengthOf(1) 409 expect(videoDetails.files).to.have.lengthOf(1)
410 410
411 await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 }) 411 await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 })
412 await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 }) 412 await makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: HttpStatusCode.OK_200 })
413 413
414 const magnetUri = videoDetails.files[0].magnetUri 414 const magnetUri = videoDetails.files[0].magnetUri
415 expect(magnetUri).to.contain('.mp4') 415 expect(magnetUri).to.contain('.mp4')
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts
index db9150655..88dff3e7f 100644
--- a/server/tests/api/videos/videos-filter.ts
+++ b/server/tests/api/videos/videos-filter.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
@@ -13,7 +13,7 @@ import {
13} from '@shared/extra-utils' 13} from '@shared/extra-utils'
14import { UserRole, Video, VideoPrivacy } from '@shared/models' 14import { UserRole, Video, VideoPrivacy } from '@shared/models'
15 15
16async function getVideosNames (server: PeerTubeServer, token: string, filter: string, statusCodeExpected = HttpStatusCode.OK_200) { 16async function getVideosNames (server: PeerTubeServer, token: string, filter: string, expectedStatus = HttpStatusCode.OK_200) {
17 const paths = [ 17 const paths = [
18 '/api/v1/video-channels/root_channel/videos', 18 '/api/v1/video-channels/root_channel/videos',
19 '/api/v1/accounts/root/videos', 19 '/api/v1/accounts/root/videos',
@@ -32,7 +32,7 @@ async function getVideosNames (server: PeerTubeServer, token: string, filter: st
32 sort: 'createdAt', 32 sort: 'createdAt',
33 filter 33 filter
34 }, 34 },
35 statusCodeExpected 35 expectedStatus
36 }) 36 })
37 37
38 videosResults.push(res.body.data.map(v => v.name)) 38 videosResults.push(res.body.data.map(v => v.name))
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts
index 55e53cb94..acb9d1a46 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
index 5bf86462b..2bd4a466b 100644
--- a/server/tests/cli/prune-storage.ts
+++ b/server/tests/cli/prune-storage.ts
@@ -5,7 +5,7 @@ import * as chai from 'chai'
5import { createFile, readdir } from 'fs-extra' 5import { createFile, readdir } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { buildUUID } from '@server/helpers/uuid' 7import { buildUUID } from '@server/helpers/uuid'
8import { HttpStatusCode } from '@shared/core-utils' 8import { HttpStatusCode } from '@shared/models'
9import { 9import {
10 cleanupTests, 10 cleanupTests,
11 CLICommand, 11 CLICommand,
@@ -91,7 +91,7 @@ describe('Test prune storage scripts', function () {
91 await makeGetRequest({ 91 await makeGetRequest({
92 url: servers[0].url, 92 url: servers[0].url,
93 path: account.avatar.path, 93 path: account.avatar.path,
94 statusCodeExpected: HttpStatusCode.OK_200 94 expectedStatus: HttpStatusCode.OK_200
95 }) 95 })
96 } 96 }
97 97
@@ -100,7 +100,7 @@ describe('Test prune storage scripts', function () {
100 await makeGetRequest({ 100 await makeGetRequest({
101 url: servers[1].url, 101 url: servers[1].url,
102 path: account.avatar.path, 102 path: account.avatar.path,
103 statusCodeExpected: HttpStatusCode.OK_200 103 expectedStatus: HttpStatusCode.OK_200
104 }) 104 })
105 } 105 }
106 106
diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts
index d532a5c2b..595d842ef 100644
--- a/server/tests/cli/regenerate-thumbnails.ts
+++ b/server/tests/cli/regenerate-thumbnails.ts
@@ -2,7 +2,7 @@ import 'mocha'
2import { expect } from 'chai' 2import { expect } from 'chai'
3import { writeFile } from 'fs-extra' 3import { writeFile } from 'fs-extra'
4import { basename, join } from 'path' 4import { basename, join } from 'path'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { Video } from '@shared/models' 6import { Video } from '@shared/models'
7import { 7import {
8 cleanupTests, 8 cleanupTests,
diff --git a/server/tests/client.ts b/server/tests/client.ts
index 959b34653..6255c6961 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { omit } from 'lodash' 5import { omit } from 'lodash'
6import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 6import { HttpStatusCode } from '@shared/models'
7import { Account, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models' 7import { Account, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models'
8import { 8import {
9 cleanupTests, 9 cleanupTests,
@@ -114,7 +114,7 @@ describe('Test a client controllers', function () {
114 url: servers[0].url, 114 url: servers[0].url,
115 path: basePath + id, 115 path: basePath + id,
116 accept: 'text/html', 116 accept: 'text/html',
117 statusCodeExpected: HttpStatusCode.OK_200 117 expectedStatus: HttpStatusCode.OK_200
118 }) 118 })
119 119
120 const port = servers[0].port 120 const port = servers[0].port
@@ -135,7 +135,7 @@ describe('Test a client controllers', function () {
135 url: servers[0].url, 135 url: servers[0].url,
136 path: basePath + id, 136 path: basePath + id,
137 accept: 'text/html', 137 accept: 'text/html',
138 statusCodeExpected: HttpStatusCode.OK_200 138 expectedStatus: HttpStatusCode.OK_200
139 }) 139 })
140 140
141 const port = servers[0].port 141 const port = servers[0].port
@@ -153,7 +153,7 @@ describe('Test a client controllers', function () {
153 describe('Open Graph', function () { 153 describe('Open Graph', function () {
154 154
155 async function accountPageTest (path: string) { 155 async function accountPageTest (path: string) {
156 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 156 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
157 const text = res.text 157 const text = res.text
158 158
159 expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`) 159 expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`)
@@ -163,7 +163,7 @@ describe('Test a client controllers', function () {
163 } 163 }
164 164
165 async function channelPageTest (path: string) { 165 async function channelPageTest (path: string) {
166 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 166 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
167 const text = res.text 167 const text = res.text
168 168
169 expect(text).to.contain(`<meta property="og:title" content="${servers[0].store.channel.displayName}" />`) 169 expect(text).to.contain(`<meta property="og:title" content="${servers[0].store.channel.displayName}" />`)
@@ -173,7 +173,7 @@ describe('Test a client controllers', function () {
173 } 173 }
174 174
175 async function watchVideoPageTest (path: string) { 175 async function watchVideoPageTest (path: string) {
176 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 176 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
177 const text = res.text 177 const text = res.text
178 178
179 expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`) 179 expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`)
@@ -183,7 +183,7 @@ describe('Test a client controllers', function () {
183 } 183 }
184 184
185 async function watchPlaylistPageTest (path: string) { 185 async function watchPlaylistPageTest (path: string) {
186 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 186 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
187 const text = res.text 187 const text = res.text
188 188
189 expect(text).to.contain(`<meta property="og:title" content="${playlistName}" />`) 189 expect(text).to.contain(`<meta property="og:title" content="${playlistName}" />`)
@@ -226,7 +226,7 @@ describe('Test a client controllers', function () {
226 describe('Not whitelisted', function () { 226 describe('Not whitelisted', function () {
227 227
228 async function accountPageTest (path: string) { 228 async function accountPageTest (path: string) {
229 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 229 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
230 const text = res.text 230 const text = res.text
231 231
232 expect(text).to.contain('<meta property="twitter:card" content="summary" />') 232 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
@@ -236,7 +236,7 @@ describe('Test a client controllers', function () {
236 } 236 }
237 237
238 async function channelPageTest (path: string) { 238 async function channelPageTest (path: string) {
239 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 239 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
240 const text = res.text 240 const text = res.text
241 241
242 expect(text).to.contain('<meta property="twitter:card" content="summary" />') 242 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
@@ -246,7 +246,7 @@ describe('Test a client controllers', function () {
246 } 246 }
247 247
248 async function watchVideoPageTest (path: string) { 248 async function watchVideoPageTest (path: string) {
249 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 249 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
250 const text = res.text 250 const text = res.text
251 251
252 expect(text).to.contain('<meta property="twitter:card" content="summary_large_image" />') 252 expect(text).to.contain('<meta property="twitter:card" content="summary_large_image" />')
@@ -256,7 +256,7 @@ describe('Test a client controllers', function () {
256 } 256 }
257 257
258 async function watchPlaylistPageTest (path: string) { 258 async function watchPlaylistPageTest (path: string) {
259 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 259 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
260 const text = res.text 260 const text = res.text
261 261
262 expect(text).to.contain('<meta property="twitter:card" content="summary" />') 262 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
@@ -307,7 +307,7 @@ describe('Test a client controllers', function () {
307 }) 307 })
308 308
309 async function accountPageTest (path: string) { 309 async function accountPageTest (path: string) {
310 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 310 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
311 const text = res.text 311 const text = res.text
312 312
313 expect(text).to.contain('<meta property="twitter:card" content="summary" />') 313 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
@@ -315,7 +315,7 @@ describe('Test a client controllers', function () {
315 } 315 }
316 316
317 async function channelPageTest (path: string) { 317 async function channelPageTest (path: string) {
318 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 318 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
319 const text = res.text 319 const text = res.text
320 320
321 expect(text).to.contain('<meta property="twitter:card" content="summary" />') 321 expect(text).to.contain('<meta property="twitter:card" content="summary" />')
@@ -323,7 +323,7 @@ describe('Test a client controllers', function () {
323 } 323 }
324 324
325 async function watchVideoPageTest (path: string) { 325 async function watchVideoPageTest (path: string) {
326 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 326 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
327 const text = res.text 327 const text = res.text
328 328
329 expect(text).to.contain('<meta property="twitter:card" content="player" />') 329 expect(text).to.contain('<meta property="twitter:card" content="player" />')
@@ -331,7 +331,7 @@ describe('Test a client controllers', function () {
331 } 331 }
332 332
333 async function watchPlaylistPageTest (path: string) { 333 async function watchPlaylistPageTest (path: string) {
334 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) 334 const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
335 const text = res.text 335 const text = res.text
336 336
337 expect(text).to.contain('<meta property="twitter:card" content="player" />') 337 expect(text).to.contain('<meta property="twitter:card" content="player" />')
diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts
index aaaf23278..12b4a1b8d 100644
--- a/server/tests/external-plugins/auth-ldap.ts
+++ b/server/tests/external-plugins/auth-ldap.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' 6import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
7 7
8describe('Official plugin auth-ldap', function () { 8describe('Official plugin auth-ldap', function () {
diff --git a/server/tests/external-plugins/auto-block-videos.ts b/server/tests/external-plugins/auto-block-videos.ts
index 9cb86310b..78b13eded 100644
--- a/server/tests/external-plugins/auto-block-videos.ts
+++ b/server/tests/external-plugins/auto-block-videos.ts
@@ -43,10 +43,10 @@ describe('Official plugin auto-block videos', function () {
43 blocklistServer = new MockBlocklist() 43 blocklistServer = new MockBlocklist()
44 port = await blocklistServer.initialize() 44 port = await blocklistServer.initialize()
45 45
46 await await servers[0].videos.quickUpload({ name: 'video server 1' }) 46 await servers[0].videos.quickUpload({ name: 'video server 1' })
47 await await servers[1].videos.quickUpload({ name: 'video server 2' }) 47 await servers[1].videos.quickUpload({ name: 'video server 2' })
48 await await servers[1].videos.quickUpload({ name: 'video 2 server 2' }) 48 await servers[1].videos.quickUpload({ name: 'video 2 server 2' })
49 await await servers[1].videos.quickUpload({ name: 'video 3 server 2' }) 49 await servers[1].videos.quickUpload({ name: 'video 3 server 2' })
50 50
51 { 51 {
52 const { data } = await servers[0].videos.list() 52 const { data } = await servers[0].videos.list()
diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts
index 771201505..b2046313b 100644
--- a/server/tests/external-plugins/auto-mute.ts
+++ b/server/tests/external-plugins/auto-mute.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 doubleFollow, 8 doubleFollow,
@@ -34,8 +34,8 @@ describe('Official plugin auto-mute', function () {
34 blocklistServer = new MockBlocklist() 34 blocklistServer = new MockBlocklist()
35 port = await blocklistServer.initialize() 35 port = await blocklistServer.initialize()
36 36
37 await await servers[0].videos.quickUpload({ name: 'video server 1' }) 37 await servers[0].videos.quickUpload({ name: 'video server 1' })
38 await await servers[1].videos.quickUpload({ name: 'video server 2' }) 38 await servers[1].videos.quickUpload({ name: 'video server 2' })
39 39
40 await doubleFollow(servers[0], servers[1]) 40 await doubleFollow(servers[0], servers[1])
41 }) 41 })
@@ -162,7 +162,7 @@ describe('Official plugin auto-mute', function () {
162 await makeGetRequest({ 162 await makeGetRequest({
163 url: servers[0].url, 163 url: servers[0].url,
164 path: '/plugins/auto-mute/router/api/v1/mute-list', 164 path: '/plugins/auto-mute/router/api/v1/mute-list',
165 statusCodeExpected: HttpStatusCode.FORBIDDEN_403 165 expectedStatus: HttpStatusCode.FORBIDDEN_403
166 }) 166 })
167 }) 167 })
168 168
@@ -179,7 +179,7 @@ describe('Official plugin auto-mute', function () {
179 await makeGetRequest({ 179 await makeGetRequest({
180 url: servers[0].url, 180 url: servers[0].url,
181 path: '/plugins/auto-mute/router/api/v1/mute-list', 181 path: '/plugins/auto-mute/router/api/v1/mute-list',
182 statusCodeExpected: HttpStatusCode.OK_200 182 expectedStatus: HttpStatusCode.OK_200
183 }) 183 })
184 }) 184 })
185 185
@@ -201,7 +201,7 @@ describe('Official plugin auto-mute', function () {
201 const res = await makeGetRequest({ 201 const res = await makeGetRequest({
202 url: servers[0].url, 202 url: servers[0].url,
203 path: '/plugins/auto-mute/router/api/v1/mute-list', 203 path: '/plugins/auto-mute/router/api/v1/mute-list',
204 statusCodeExpected: HttpStatusCode.OK_200 204 expectedStatus: HttpStatusCode.OK_200
205 }) 205 })
206 206
207 const data = res.body.data 207 const data = res.body.data
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index 7735299d3..543c431dd 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -3,7 +3,7 @@
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import * as xmlParser from 'fast-xml-parser' 5import * as xmlParser from 'fast-xml-parser'
6import { HttpStatusCode } from '@shared/core-utils' 6import { HttpStatusCode } from '@shared/models'
7import { 7import {
8 cleanupTests, 8 cleanupTests,
9 doubleFollow, 9 doubleFollow,
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts
index a4f344fcc..4d9c07f1a 100644
--- a/server/tests/misc-endpoints.ts
+++ b/server/tests/misc-endpoints.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' 6import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
7import { VideoPrivacy } from '@shared/models' 7import { VideoPrivacy } from '@shared/models'
8 8
@@ -24,7 +24,7 @@ describe('Test misc endpoints', function () {
24 const res = await makeGetRequest({ 24 const res = await makeGetRequest({
25 url: server.url, 25 url: server.url,
26 path: '/.well-known/security.txt', 26 path: '/.well-known/security.txt',
27 statusCodeExpected: HttpStatusCode.OK_200 27 expectedStatus: HttpStatusCode.OK_200
28 }) 28 })
29 29
30 expect(res.text).to.contain('security issue') 30 expect(res.text).to.contain('security issue')
@@ -34,7 +34,7 @@ describe('Test misc endpoints', function () {
34 const res = await makeGetRequest({ 34 const res = await makeGetRequest({
35 url: server.url, 35 url: server.url,
36 path: '/.well-known/nodeinfo', 36 path: '/.well-known/nodeinfo',
37 statusCodeExpected: HttpStatusCode.OK_200 37 expectedStatus: HttpStatusCode.OK_200
38 }) 38 })
39 39
40 expect(res.body.links).to.be.an('array') 40 expect(res.body.links).to.be.an('array')
@@ -46,7 +46,7 @@ describe('Test misc endpoints', function () {
46 const res = await makeGetRequest({ 46 const res = await makeGetRequest({
47 url: server.url, 47 url: server.url,
48 path: '/.well-known/dnt-policy.txt', 48 path: '/.well-known/dnt-policy.txt',
49 statusCodeExpected: HttpStatusCode.OK_200 49 expectedStatus: HttpStatusCode.OK_200
50 }) 50 })
51 51
52 expect(res.text).to.contain('http://www.w3.org/TR/tracking-dnt') 52 expect(res.text).to.contain('http://www.w3.org/TR/tracking-dnt')
@@ -56,7 +56,7 @@ describe('Test misc endpoints', function () {
56 const res = await makeGetRequest({ 56 const res = await makeGetRequest({
57 url: server.url, 57 url: server.url,
58 path: '/.well-known/dnt', 58 path: '/.well-known/dnt',
59 statusCodeExpected: HttpStatusCode.OK_200 59 expectedStatus: HttpStatusCode.OK_200
60 }) 60 })
61 61
62 expect(res.body.tracking).to.equal('N') 62 expect(res.body.tracking).to.equal('N')
@@ -66,7 +66,7 @@ describe('Test misc endpoints', function () {
66 const res = await makeGetRequest({ 66 const res = await makeGetRequest({
67 url: server.url, 67 url: server.url,
68 path: '/.well-known/change-password', 68 path: '/.well-known/change-password',
69 statusCodeExpected: HttpStatusCode.FOUND_302 69 expectedStatus: HttpStatusCode.FOUND_302
70 }) 70 })
71 71
72 expect(res.header.location).to.equal('/my-account/settings') 72 expect(res.header.location).to.equal('/my-account/settings')
@@ -79,7 +79,7 @@ describe('Test misc endpoints', function () {
79 const res = await makeGetRequest({ 79 const res = await makeGetRequest({
80 url: server.url, 80 url: server.url,
81 path: '/.well-known/webfinger?resource=' + resource, 81 path: '/.well-known/webfinger?resource=' + resource,
82 statusCodeExpected: HttpStatusCode.OK_200 82 expectedStatus: HttpStatusCode.OK_200
83 }) 83 })
84 84
85 const data = res.body 85 const data = res.body
@@ -104,7 +104,7 @@ describe('Test misc endpoints', function () {
104 const res = await makeGetRequest({ 104 const res = await makeGetRequest({
105 url: server.url, 105 url: server.url,
106 path: '/robots.txt', 106 path: '/robots.txt',
107 statusCodeExpected: HttpStatusCode.OK_200 107 expectedStatus: HttpStatusCode.OK_200
108 }) 108 })
109 109
110 expect(res.text).to.contain('User-agent') 110 expect(res.text).to.contain('User-agent')
@@ -114,7 +114,7 @@ describe('Test misc endpoints', function () {
114 await makeGetRequest({ 114 await makeGetRequest({
115 url: server.url, 115 url: server.url,
116 path: '/security.txt', 116 path: '/security.txt',
117 statusCodeExpected: HttpStatusCode.MOVED_PERMANENTLY_301 117 expectedStatus: HttpStatusCode.MOVED_PERMANENTLY_301
118 }) 118 })
119 }) 119 })
120 120
@@ -122,7 +122,7 @@ describe('Test misc endpoints', function () {
122 const res = await makeGetRequest({ 122 const res = await makeGetRequest({
123 url: server.url, 123 url: server.url,
124 path: '/nodeinfo/2.0.json', 124 path: '/nodeinfo/2.0.json',
125 statusCodeExpected: HttpStatusCode.OK_200 125 expectedStatus: HttpStatusCode.OK_200
126 }) 126 })
127 127
128 expect(res.body.software.name).to.equal('peertube') 128 expect(res.body.software.name).to.equal('peertube')
@@ -137,7 +137,7 @@ describe('Test misc endpoints', function () {
137 const res = await makeGetRequest({ 137 const res = await makeGetRequest({
138 url: server.url, 138 url: server.url,
139 path: '/sitemap.xml', 139 path: '/sitemap.xml',
140 statusCodeExpected: HttpStatusCode.OK_200 140 expectedStatus: HttpStatusCode.OK_200
141 }) 141 })
142 142
143 expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') 143 expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"')
@@ -148,7 +148,7 @@ describe('Test misc endpoints', function () {
148 const res = await makeGetRequest({ 148 const res = await makeGetRequest({
149 url: server.url, 149 url: server.url,
150 path: '/sitemap.xml', 150 path: '/sitemap.xml',
151 statusCodeExpected: HttpStatusCode.OK_200 151 expectedStatus: HttpStatusCode.OK_200
152 }) 152 })
153 153
154 expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') 154 expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"')
@@ -171,7 +171,7 @@ describe('Test misc endpoints', function () {
171 const res = await makeGetRequest({ 171 const res = await makeGetRequest({
172 url: server.url, 172 url: server.url,
173 path: '/sitemap.xml?t=1', // avoid using cache 173 path: '/sitemap.xml?t=1', // avoid using cache
174 statusCodeExpected: HttpStatusCode.OK_200 174 expectedStatus: HttpStatusCode.OK_200
175 }) 175 })
176 176
177 expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') 177 expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"')
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts
index c0834a14c..a2828603a 100644
--- a/server/tests/plugins/external-auth.ts
+++ b/server/tests/plugins/external-auth.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 decodeQueryString, 8 decodeQueryString,
@@ -20,15 +20,15 @@ async function loginExternal (options: {
20 authName: string 20 authName: string
21 username: string 21 username: string
22 query?: any 22 query?: any
23 statusCodeExpected?: HttpStatusCode 23 expectedStatus?: HttpStatusCode
24 statusCodeExpectedStep2?: HttpStatusCode 24 expectedStatusStep2?: HttpStatusCode
25}) { 25}) {
26 const res = await options.server.plugins.getExternalAuth({ 26 const res = await options.server.plugins.getExternalAuth({
27 npmName: options.npmName, 27 npmName: options.npmName,
28 npmVersion: '0.0.1', 28 npmVersion: '0.0.1',
29 authName: options.authName, 29 authName: options.authName,
30 query: options.query, 30 query: options.query,
31 expectedStatus: options.statusCodeExpected || HttpStatusCode.FOUND_302 31 expectedStatus: options.expectedStatus || HttpStatusCode.FOUND_302
32 }) 32 })
33 33
34 if (res.status !== HttpStatusCode.FOUND_302) return 34 if (res.status !== HttpStatusCode.FOUND_302) return
@@ -39,7 +39,7 @@ async function loginExternal (options: {
39 const resLogin = await options.server.login.loginUsingExternalToken({ 39 const resLogin = await options.server.login.loginUsingExternalToken({
40 username: options.username, 40 username: options.username,
41 externalAuthToken: externalAuthToken as string, 41 externalAuthToken: externalAuthToken as string,
42 expectedStatus: options.statusCodeExpectedStep2 42 expectedStatus: options.expectedStatusStep2
43 }) 43 })
44 44
45 return resLogin.body 45 return resLogin.body
@@ -268,7 +268,7 @@ describe('Test external auth plugins', function () {
268 username: 'kefka' 268 username: 'kefka'
269 }, 269 },
270 username: 'kefka', 270 username: 'kefka',
271 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 271 expectedStatus: HttpStatusCode.NOT_FOUND_404
272 }) 272 })
273 }) 273 })
274 274
@@ -293,7 +293,7 @@ describe('Test external auth plugins', function () {
293 username: 'cyan' 293 username: 'cyan'
294 }, 294 },
295 username: 'cyan', 295 username: 'cyan',
296 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 296 expectedStatus: HttpStatusCode.NOT_FOUND_404
297 }) 297 })
298 298
299 await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 299 await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
@@ -307,7 +307,7 @@ describe('Test external auth plugins', function () {
307 npmName: 'test-external-auth-two', 307 npmName: 'test-external-auth-two',
308 authName: 'external-auth-4', 308 authName: 'external-auth-4',
309 username: 'kefka2', 309 username: 'kefka2',
310 statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 310 expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
311 }) 311 })
312 312
313 await loginExternal({ 313 await loginExternal({
@@ -315,7 +315,7 @@ describe('Test external auth plugins', function () {
315 npmName: 'test-external-auth-two', 315 npmName: 'test-external-auth-two',
316 authName: 'external-auth-4', 316 authName: 'external-auth-4',
317 username: 'kefka', 317 username: 'kefka',
318 statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 318 expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
319 }) 319 })
320 }) 320 })
321 321
@@ -327,7 +327,7 @@ describe('Test external auth plugins', function () {
327 npmName: 'test-external-auth-two', 327 npmName: 'test-external-auth-two',
328 authName: 'external-auth-6', 328 authName: 'external-auth-6',
329 username: 'existing_user', 329 username: 'existing_user',
330 statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 330 expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
331 }) 331 })
332 }) 332 })
333 333
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index df52bb3b5..ba84dd27a 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createMultipleServers, 8 createMultipleServers,
@@ -71,28 +71,28 @@ describe('Test plugin filter hooks', function () {
71 }) 71 })
72 72
73 it('Should run filter:api.accounts.videos.list.params', async function () { 73 it('Should run filter:api.accounts.videos.list.params', async function () {
74 const { data } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 }) 74 const { data } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 })
75 75
76 // 1 plugin do +1 to the count parameter 76 // 1 plugin do +1 to the count parameter
77 expect(data).to.have.lengthOf(3) 77 expect(data).to.have.lengthOf(3)
78 }) 78 })
79 79
80 it('Should run filter:api.accounts.videos.list.result', async function () { 80 it('Should run filter:api.accounts.videos.list.result', async function () {
81 const { total } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 }) 81 const { total } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 })
82 82
83 // Plugin do +2 to the total result 83 // Plugin do +2 to the total result
84 expect(total).to.equal(12) 84 expect(total).to.equal(12)
85 }) 85 })
86 86
87 it('Should run filter:api.video-channels.videos.list.params', async function () { 87 it('Should run filter:api.video-channels.videos.list.params', async function () {
88 const { data } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 }) 88 const { data } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 })
89 89
90 // 1 plugin do +3 to the count parameter 90 // 1 plugin do +3 to the count parameter
91 expect(data).to.have.lengthOf(5) 91 expect(data).to.have.lengthOf(5)
92 }) 92 })
93 93
94 it('Should run filter:api.video-channels.videos.list.result', async function () { 94 it('Should run filter:api.video-channels.videos.list.result', async function () {
95 const { total } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 }) 95 const { total } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 })
96 96
97 // Plugin do +3 to the total result 97 // Plugin do +3 to the total result
98 expect(total).to.equal(13) 98 expect(total).to.equal(13)
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts
index 981bcad91..a73d76caa 100644
--- a/server/tests/plugins/id-and-pass-auth.ts
+++ b/server/tests/plugins/id-and-pass-auth.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' 6import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils'
7import { UserRole } from '@shared/models' 7import { UserRole } from '@shared/models'
8 8
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index 1d87b84ae..5cb664bda 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 checkVideoFilesWereRemoved, 7 checkVideoFilesWereRemoved,
8 cleanupTests, 8 cleanupTests,
@@ -24,7 +24,7 @@ function postCommand (server: PeerTubeServer, command: string, bodyArg?: object)
24 url: server.url, 24 url: server.url,
25 path: '/plugins/test-four/router/commander', 25 path: '/plugins/test-four/router/commander',
26 fields: body, 26 fields: body,
27 statusCodeExpected: HttpStatusCode.NO_CONTENT_204 27 expectedStatus: HttpStatusCode.NO_CONTENT_204
28 }) 28 })
29} 29}
30 30
@@ -67,7 +67,7 @@ describe('Test plugin helpers', function () {
67 const res = await makeGetRequest({ 67 const res = await makeGetRequest({
68 url: servers[0].url, 68 url: servers[0].url,
69 path: '/plugins/test-four/router/server-config', 69 path: '/plugins/test-four/router/server-config',
70 statusCodeExpected: HttpStatusCode.OK_200 70 expectedStatus: HttpStatusCode.OK_200
71 }) 71 })
72 72
73 expect(res.body.serverConfig).to.exist 73 expect(res.body.serverConfig).to.exist
@@ -88,7 +88,7 @@ describe('Test plugin helpers', function () {
88 const res = await makeGetRequest({ 88 const res = await makeGetRequest({
89 url: servers[0].url, 89 url: servers[0].url,
90 path: '/plugins/test-four/router/static-route', 90 path: '/plugins/test-four/router/static-route',
91 statusCodeExpected: HttpStatusCode.OK_200 91 expectedStatus: HttpStatusCode.OK_200
92 }) 92 })
93 93
94 expect(res.body.staticRoute).to.equal('/plugins/test-four/0.0.1/static/') 94 expect(res.body.staticRoute).to.equal('/plugins/test-four/0.0.1/static/')
@@ -100,7 +100,7 @@ describe('Test plugin helpers', function () {
100 const res = await makeGetRequest({ 100 const res = await makeGetRequest({
101 url: servers[0].url, 101 url: servers[0].url,
102 path: baseRouter + 'router-route', 102 path: baseRouter + 'router-route',
103 statusCodeExpected: HttpStatusCode.OK_200 103 expectedStatus: HttpStatusCode.OK_200
104 }) 104 })
105 105
106 expect(res.body.routerRoute).to.equal(baseRouter) 106 expect(res.body.routerRoute).to.equal(baseRouter)
@@ -113,7 +113,7 @@ describe('Test plugin helpers', function () {
113 await makeGetRequest({ 113 await makeGetRequest({
114 url: servers[0].url, 114 url: servers[0].url,
115 path: '/plugins/test-four/router/user', 115 path: '/plugins/test-four/router/user',
116 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 116 expectedStatus: HttpStatusCode.NOT_FOUND_404
117 }) 117 })
118 }) 118 })
119 119
@@ -122,7 +122,7 @@ describe('Test plugin helpers', function () {
122 url: servers[0].url, 122 url: servers[0].url,
123 token: servers[0].accessToken, 123 token: servers[0].accessToken,
124 path: '/plugins/test-four/router/user', 124 path: '/plugins/test-four/router/user',
125 statusCodeExpected: HttpStatusCode.OK_200 125 expectedStatus: HttpStatusCode.OK_200
126 }) 126 })
127 127
128 expect(res.body.username).to.equal('root') 128 expect(res.body.username).to.equal('root')
@@ -140,12 +140,12 @@ describe('Test plugin helpers', function () {
140 this.timeout(60000) 140 this.timeout(60000)
141 141
142 { 142 {
143 const res = await await servers[0].videos.quickUpload({ name: 'video server 1' }) 143 const res = await servers[0].videos.quickUpload({ name: 'video server 1' })
144 videoUUIDServer1 = res.uuid 144 videoUUIDServer1 = res.uuid
145 } 145 }
146 146
147 { 147 {
148 await await servers[1].videos.quickUpload({ name: 'video server 2' }) 148 await servers[1].videos.quickUpload({ name: 'video server 2' })
149 } 149 }
150 150
151 await waitJobs(servers) 151 await waitJobs(servers)
@@ -224,7 +224,7 @@ describe('Test plugin helpers', function () {
224 let videoUUID: string 224 let videoUUID: string
225 225
226 before(async () => { 226 before(async () => {
227 const res = await await servers[0].videos.quickUpload({ name: 'video1' }) 227 const res = await servers[0].videos.quickUpload({ name: 'video1' })
228 videoUUID = res.uuid 228 videoUUID = res.uuid
229 }) 229 })
230 230
diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts
index dec8ca4bb..becb7c47b 100644
--- a/server/tests/plugins/plugin-router.ts
+++ b/server/tests/plugins/plugin-router.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
@@ -34,7 +34,7 @@ describe('Test plugin helpers', function () {
34 const res = await makeGetRequest({ 34 const res = await makeGetRequest({
35 url: server.url, 35 url: server.url,
36 path: path + 'ping', 36 path: path + 'ping',
37 statusCodeExpected: HttpStatusCode.OK_200 37 expectedStatus: HttpStatusCode.OK_200
38 }) 38 })
39 39
40 expect(res.body.message).to.equal('pong') 40 expect(res.body.message).to.equal('pong')
@@ -47,7 +47,7 @@ describe('Test plugin helpers', function () {
47 url: server.url, 47 url: server.url,
48 path: path + 'is-authenticated', 48 path: path + 'is-authenticated',
49 token: server.accessToken, 49 token: server.accessToken,
50 statusCodeExpected: 200 50 expectedStatus: 200
51 }) 51 })
52 52
53 expect(res.body.isAuthenticated).to.equal(true) 53 expect(res.body.isAuthenticated).to.equal(true)
@@ -55,7 +55,7 @@ describe('Test plugin helpers', function () {
55 const secRes = await makeGetRequest({ 55 const secRes = await makeGetRequest({
56 url: server.url, 56 url: server.url,
57 path: path + 'is-authenticated', 57 path: path + 'is-authenticated',
58 statusCodeExpected: 200 58 expectedStatus: 200
59 }) 59 })
60 60
61 expect(secRes.body.isAuthenticated).to.equal(false) 61 expect(secRes.body.isAuthenticated).to.equal(false)
@@ -74,7 +74,7 @@ describe('Test plugin helpers', function () {
74 url: server.url, 74 url: server.url,
75 path: path + 'form/post/mirror', 75 path: path + 'form/post/mirror',
76 fields: body, 76 fields: body,
77 statusCodeExpected: HttpStatusCode.OK_200 77 expectedStatus: HttpStatusCode.OK_200
78 }) 78 })
79 79
80 expect(res.body).to.deep.equal(body) 80 expect(res.body).to.deep.equal(body)
@@ -88,14 +88,14 @@ describe('Test plugin helpers', function () {
88 await makeGetRequest({ 88 await makeGetRequest({
89 url: server.url, 89 url: server.url,
90 path: path + 'ping', 90 path: path + 'ping',
91 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 91 expectedStatus: HttpStatusCode.NOT_FOUND_404
92 }) 92 })
93 93
94 await makePostBodyRequest({ 94 await makePostBodyRequest({
95 url: server.url, 95 url: server.url,
96 path: path + 'ping', 96 path: path + 'ping',
97 fields: {}, 97 fields: {},
98 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 98 expectedStatus: HttpStatusCode.NOT_FOUND_404
99 }) 99 })
100 } 100 }
101 }) 101 })
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts
index 5745914a5..90dafa3e1 100644
--- a/server/tests/plugins/plugin-storage.ts
+++ b/server/tests/plugins/plugin-storage.ts
@@ -4,7 +4,7 @@ import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { pathExists, readdir, readFile } from 'fs-extra' 5import { pathExists, readdir, readFile } from 'fs-extra'
6import { join } from 'path' 6import { join } from 'path'
7import { HttpStatusCode } from '@shared/core-utils' 7import { HttpStatusCode } from '@shared/models'
8import { 8import {
9 cleanupTests, 9 cleanupTests,
10 createSingleServer, 10 createSingleServer,
@@ -63,7 +63,7 @@ describe('Test plugin storage', function () {
63 url: server.url, 63 url: server.url,
64 token: server.accessToken, 64 token: server.accessToken,
65 path: '/plugins/test-six/router/create-file', 65 path: '/plugins/test-six/router/create-file',
66 statusCodeExpected: HttpStatusCode.OK_200 66 expectedStatus: HttpStatusCode.OK_200
67 }) 67 })
68 68
69 const content = await getFileContent() 69 const content = await getFileContent()
diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts
index 6c405b7f5..faf9cc599 100644
--- a/server/tests/plugins/plugin-unloading.ts
+++ b/server/tests/plugins/plugin-unloading.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 createSingleServer, 8 createSingleServer,
@@ -30,7 +30,7 @@ describe('Test plugins module unloading', function () {
30 const res = await makeGetRequest({ 30 const res = await makeGetRequest({
31 url: server.url, 31 url: server.url,
32 path: requestPath, 32 path: requestPath,
33 statusCodeExpected: HttpStatusCode.OK_200 33 expectedStatus: HttpStatusCode.OK_200
34 }) 34 })
35 35
36 expect(res.body.message).to.match(/^\d+$/) 36 expect(res.body.message).to.match(/^\d+$/)
@@ -41,7 +41,7 @@ describe('Test plugins module unloading', function () {
41 const res = await makeGetRequest({ 41 const res = await makeGetRequest({
42 url: server.url, 42 url: server.url,
43 path: requestPath, 43 path: requestPath,
44 statusCodeExpected: HttpStatusCode.OK_200 44 expectedStatus: HttpStatusCode.OK_200
45 }) 45 })
46 46
47 expect(res.body.message).to.be.equal(value) 47 expect(res.body.message).to.be.equal(value)
@@ -53,7 +53,7 @@ describe('Test plugins module unloading', function () {
53 await makeGetRequest({ 53 await makeGetRequest({
54 url: server.url, 54 url: server.url,
55 path: requestPath, 55 path: requestPath,
56 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 56 expectedStatus: HttpStatusCode.NOT_FOUND_404
57 }) 57 })
58 }) 58 })
59 59
@@ -63,7 +63,7 @@ describe('Test plugins module unloading', function () {
63 const res = await makeGetRequest({ 63 const res = await makeGetRequest({
64 url: server.url, 64 url: server.url,
65 path: requestPath, 65 path: requestPath,
66 statusCodeExpected: HttpStatusCode.OK_200 66 expectedStatus: HttpStatusCode.OK_200
67 }) 67 })
68 68
69 expect(res.body.message).to.match(/^\d+$/) 69 expect(res.body.message).to.match(/^\d+$/)
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts
index 953916e8e..dd3b40225 100644
--- a/server/tests/plugins/video-constants.ts
+++ b/server/tests/plugins/video-constants.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import * as chai from 'chai' 4import * as chai from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' 6import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
7import { VideoPlaylistPrivacy } from '@shared/models' 7import { VideoPlaylistPrivacy } from '@shared/models'
8 8
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts
index 5fda68c8e..bcaae63a3 100644
--- a/server/tools/peertube-redundancy.ts
+++ b/server/tools/peertube-redundancy.ts
@@ -6,7 +6,7 @@ import { Command, program } from 'commander'
6import { uniq } from 'lodash' 6import { uniq } from 'lodash'
7import { URL } from 'url' 7import { URL } from 'url'
8import validator from 'validator' 8import validator from 'validator'
9import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' 9import { HttpStatusCode } from '@shared/models'
10import { VideoRedundanciesTarget } from '@shared/models' 10import { VideoRedundanciesTarget } from '@shared/models'
11import { assignToken, buildServer, getServerCredentials } from './cli' 11import { assignToken, buildServer, getServerCredentials } from './cli'
12 12
diff --git a/server/typings/express/index.d.ts b/server/typings/express/index.d.ts
index 1a8dc3430..5469f3b83 100644
--- a/server/typings/express/index.d.ts
+++ b/server/typings/express/index.d.ts
@@ -22,8 +22,7 @@ import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server'
22import { MVideoImportDefault } from '@server/types/models/video/video-import' 22import { MVideoImportDefault } from '@server/types/models/video/video-import'
23import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element' 23import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
24import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate' 24import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
25import { HttpMethod } from '@shared/core-utils/miscs/http-methods' 25import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
26import { PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
27import { File as UploadXFile, Metadata } from '@uploadx/core' 26import { File as UploadXFile, Metadata } from '@uploadx/core'
28import { RegisteredPlugin } from '../../lib/plugins/plugin-manager' 27import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
29import { 28import {