Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Refactor requests

Chocobozzzc0e8b12e7fd5
diff --git a/client/src/app/+about/about-instance/contact-admin-modal.component.ts b/client/src/app/+about/about-instance/contact-admin-modal.component.ts
index a528faa204..37e9feacb0 100644
--- a/client/src/app/+about/about-instance/contact-admin-modal.component.ts
+++ b/client/src/app/+about/about-instance/contact-admin-modal.component.ts
@@ -11,8 +11,7 @@ import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { InstanceService } from '@app/shared/shared-instance'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
-import { HTMLServerConfig } from '@shared/models'
+import { HTMLServerConfig, HttpStatusCode } from '@shared/models'
type Prefill = {
subject?: string
diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts
index c69b04a01b..5b59f3cd0e 100644
--- a/client/src/app/+accounts/accounts.component.ts
+++ b/client/src/app/+accounts/accounts.component.ts
@@ -13,8 +13,7 @@ import {
VideoService
} from '@app/shared/shared-main'
import { AccountReportComponent } from '@app/shared/shared-moderation'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
-import { User, UserRight } from '@shared/models'
+import { HttpStatusCode, User, UserRight } from '@shared/models'
import { AccountSearchComponent } from './account-search/account-search.component'
@Component({
diff --git a/client/src/app/+my-library/+my-video-channels/my-video-channel-create.component.ts b/client/src/app/+my-library/+my-video-channels/my-video-channel-create.component.ts
index b3265210fd..433475f666 100644
--- a/client/src/app/+my-library/+my-video-channels/my-video-channel-create.component.ts
+++ b/client/src/app/+my-library/+my-video-channels/my-video-channel-create.component.ts
@@ -1,3 +1,5 @@
+import { of } from 'rxjs'
+import { switchMap } from 'rxjs/operators'
import { Component, OnInit } from '@angular/core'
import { Router } from '@angular/router'
import { AuthService, Notifier } from '@app/core'
@@ -9,11 +11,8 @@ import {
} from '@app/shared/form-validators/video-channel-validators'
import { FormValidatorService } from '@app/shared/shared-forms'
import { VideoChannel, VideoChannelService } from '@app/shared/shared-main'
-import { VideoChannelCreate } from '@shared/models'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode, VideoChannelCreate } from '@shared/models'
import { MyVideoChannelEdit } from './my-video-channel-edit'
-import { switchMap } from 'rxjs/operators'
-import { of } from 'rxjs'
@Component({
templateUrl: './my-video-channel-edit.component.html',
diff --git a/client/src/app/+page-not-found/page-not-found.component.ts b/client/src/app/+page-not-found/page-not-found.component.ts
index 639e5db78c..10645a6345 100644
--- a/client/src/app/+page-not-found/page-not-found.component.ts
+++ b/client/src/app/+page-not-found/page-not-found.component.ts
@@ -1,7 +1,8 @@
import { Component, OnInit } from '@angular/core'
import { Title } from '@angular/platform-browser'
import { Router } from '@angular/router'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
+
@Component({
selector: 'my-page-not-found',
templateUrl: './page-not-found.component.html',
diff --git a/client/src/app/+video-channels/video-channels.component.ts b/client/src/app/+video-channels/video-channels.component.ts
index 3833d9c542..6479644f13 100644
--- a/client/src/app/+video-channels/video-channels.component.ts
+++ b/client/src/app/+video-channels/video-channels.component.ts
@@ -7,7 +7,7 @@ import { AuthService, MarkdownService, Notifier, RestExtractor, ScreenService }
import { ListOverflowItem, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
import { SupportModalComponent } from '@app/shared/shared-support-modal'
import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
@Component({
templateUrl: './video-channels.component.html',
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
index 627de33c04..e9420fe62b 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
@@ -7,8 +7,7 @@ import { genericUploadErrorHandler, scrollToTop } from '@app/helpers'
import { FormValidatorService } from '@app/shared/shared-forms'
import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
-import { VideoPrivacy } from '@shared/models'
+import { HttpStatusCode, VideoPrivacy } from '@shared/models'
import { UploaderXFormData } from './uploaderx-form-data'
import { VideoSend } from './video-send'
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts
index d078844c3e..7460ae3fc8 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/+videos/+video-watch/video-watch.component.ts
@@ -21,8 +21,15 @@ import { isXPercentInViewport, scrollToTop } from '@app/helpers'
import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main'
import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription'
import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
-import { HTMLServerConfig, PeerTubeProblemDocument, ServerErrorCode, VideoCaption, VideoPrivacy, VideoState } from '@shared/models'
+import {
+ HTMLServerConfig,
+ HttpStatusCode,
+ PeerTubeProblemDocument,
+ ServerErrorCode,
+ VideoCaption,
+ VideoPrivacy,
+ VideoState
+} from '@shared/models'
import { cleanupVideoWatch, getStoredTheater, getStoredVideoWatchHistory } from '../../../assets/player/peertube-player-local-storage'
import {
CustomizationOptions,
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index cdf13186b6..60bd72c607 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -6,12 +6,11 @@ import { Injectable } from '@angular/core'
import { Router } from '@angular/router'
import { Notifier } from '@app/core/notification/notifier.service'
import { objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index'
-import { MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models'
+import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models'
import { environment } from '../../../environments/environment'
import { RestExtractor } from '../rest/rest-extractor.service'
import { AuthStatus } from './auth-status.model'
import { AuthUser } from './auth-user.model'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
interface UserLoginWithUsername extends UserLogin {
access_token: string
diff --git a/client/src/app/core/rest/rest-extractor.service.ts b/client/src/app/core/rest/rest-extractor.service.ts
index 08ab495124..2a926e68f1 100644
--- a/client/src/app/core/rest/rest-extractor.service.ts
+++ b/client/src/app/core/rest/rest-extractor.service.ts
@@ -2,8 +2,7 @@ import { throwError as observableThrowError } from 'rxjs'
import { Injectable } from '@angular/core'
import { Router } from '@angular/router'
import { dateToHuman } from '@app/helpers'
-import { ResultList } from '@shared/models'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode, ResultList } from '@shared/models'
@Injectable()
export class RestExtractor {
diff --git a/client/src/app/helpers/utils.ts b/client/src/app/helpers/utils.ts
index 94f6def267..edcaf50e00 100644
--- a/client/src/app/helpers/utils.ts
+++ b/client/src/app/helpers/utils.ts
@@ -3,7 +3,7 @@ import { SelectChannelItem } from 'src/types/select-options-item.model'
import { DatePipe } from '@angular/common'
import { HttpErrorResponse } from '@angular/common/http'
import { Notifier } from '@app/core'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { environment } from '../../environments/environment'
import { AuthService } from '../core/auth'
diff --git a/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts b/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts
index 5bcad36d01..a75c8a25c7 100644
--- a/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts
+++ b/client/src/app/shared/shared-main/auth/auth-interceptor.service.ts
@@ -1,11 +1,11 @@
import { Observable, of, throwError as observableThrowError } from 'rxjs'
import { catchError, switchMap } from 'rxjs/operators'
-import { HTTP_INTERCEPTORS, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpErrorResponse } from '@angular/common/http'
+import { HTTP_INTERCEPTORS, HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'
import { Injectable, Injector } from '@angular/core'
-import { AuthService } from '@app/core/auth/auth.service'
import { Router } from '@angular/router'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
-import { OAuth2ErrorCode, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models/server'
+import { AuthService } from '@app/core/auth/auth.service'
+import { HttpStatusCode } from '@shared/models'
+import { OAuth2ErrorCode, PeerTubeProblemDocument } from '@shared/models/server'
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index e59d8b9407..97437ce45b 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -1,9 +1,9 @@
import './embed.scss'
import videojs from 'video.js'
import { peertubeTranslate } from '../../../../shared/core-utils/i18n'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import {
HTMLServerConfig,
+ HttpStatusCode,
OAuth2ErrorCode,
ResultList,
UserRefreshToken,
diff --git a/server.ts b/server.ts
index e46300dcef..582321a5b8 100644
--- a/server.ts
+++ b/server.ts
@@ -125,7 +125,7 @@ import { PeerTubeVersionCheckScheduler } from './server/lib/schedulers/peertube-
import { Hooks } from './server/lib/plugins/hooks'
import { PluginManager } from './server/lib/plugins/plugin-manager'
import { LiveManager } from './server/lib/live'
-import { HttpStatusCode } from './shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from './shared/models/http/http-error-codes'
import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
import { ServerConfigManager } from '@server/lib/server-config-manager'
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts
index 14f301ab72..30662990a0 100644
--- a/server/controllers/activitypub/inbox.ts
+++ b/server/controllers/activitypub/inbox.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { InboxManager } from '@server/lib/activitypub/inbox-manager'
import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity'
import { logger } from '../../helpers/logger'
import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares'
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts
index ba5b948405..e851365e92 100644
--- a/server/controllers/api/abuse.ts
+++ b/server/controllers/api/abuse.ts
@@ -6,7 +6,7 @@ import { AbuseModel } from '@server/models/abuse/abuse'
import { AbuseMessageModel } from '@server/models/abuse/abuse-message'
import { getServerActor } from '@server/models/application/application'
import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbuseCreate, AbuseState, UserRight } from '../../../shared'
import { getFormattedObjects } from '../../helpers/utils'
import { sequelizeTypescript } from '../../initializers/database'
diff --git a/server/controllers/api/bulk.ts b/server/controllers/api/bulk.ts
index 192daccde8..10d83571de 100644
--- a/server/controllers/api/bulk.ts
+++ b/server/controllers/api/bulk.ts
@@ -4,7 +4,7 @@ import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bu
import { VideoCommentModel } from '@server/models/video/video-comment'
import { removeComment } from '@server/lib/video-comment'
import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
const bulkRouter = express.Router()
diff --git a/server/controllers/api/custom-page.ts b/server/controllers/api/custom-page.ts
index c19f03c560..cc1aa84272 100644
--- a/server/controllers/api/custom-page.ts
+++ b/server/controllers/api/custom-page.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { ServerConfigManager } from '@server/lib/server-config-manager'
import { ActorCustomPageModel } from '@server/models/account/actor-custom-page'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { UserRight } from '@shared/models'
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts
index 28378654ab..93b14dadba 100644
--- a/server/controllers/api/index.ts
+++ b/server/controllers/api/index.ts
@@ -1,7 +1,7 @@
import * as cors from 'cors'
import * as express from 'express'
import * as RateLimit from 'express-rate-limit'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models'
import { badRequest } from '../../helpers/express-utils'
import { CONFIG } from '../../initializers/config'
import { abuseRouter } from './abuse'
diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts
index 15bbf5c4df..f95f06864d 100644
--- a/server/controllers/api/oauth-clients.ts
+++ b/server/controllers/api/oauth-clients.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { OAuthClientLocal } from '../../../shared'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { logger } from '../../helpers/logger'
import { CONFIG } from '../../initializers/config'
import { asyncMiddleware, openapiOperationDoc } from '../../middlewares'
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts
index 1e6a02c496..4b213c2461 100644
--- a/server/controllers/api/plugins.ts
+++ b/server/controllers/api/plugins.ts
@@ -23,7 +23,7 @@ import {
updatePluginSettingsValidator
} from '@server/middlewares/validators/plugins'
import { PluginModel } from '@server/models/server/plugin'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
InstallOrUpdatePlugin,
ManagePlugin,
diff --git a/server/controllers/api/search/search-video-channels.ts b/server/controllers/api/search/search-video-channels.ts
index 16beeed60a..fe9178e691 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'
import { Hooks } from '@server/lib/plugins/hooks'
import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search'
import { getServerActor } from '@server/models/application/application'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { ResultList, VideoChannel } from '@shared/models'
import { VideoChannelsSearchQuery } from '../../../../shared/models/search'
import { 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 b231ff1e20..a0e2c17476 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
import { getServerActor } from '@server/models/application/application'
import { VideoPlaylistModel } from '@server/models/video/video-playlist'
import { MVideoPlaylistFullSummary } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models'
import {
asyncMiddleware,
diff --git a/server/controllers/api/search/search-videos.ts b/server/controllers/api/search/search-videos.ts
index b626baa284..0e6fd9c721 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'
import { getOrCreateAPVideo } from '@server/lib/activitypub/videos'
import { Hooks } from '@server/lib/plugins/hooks'
import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { ResultList, Video } from '@shared/models'
import { VideosSearchQuery } from '../../../../shared/models/search'
import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils'
diff --git a/server/controllers/api/server/contact.ts b/server/controllers/api/server/contact.ts
index caddc0909b..ae36dd599a 100644
--- a/server/controllers/api/server/contact.ts
+++ b/server/controllers/api/server/contact.ts
@@ -3,7 +3,7 @@ import { asyncMiddleware, contactAdministratorValidator } from '../../../middlew
import { Redis } from '../../../lib/redis'
import { Emailer } from '../../../lib/emailer'
import { ContactForm } from '../../../../shared/models/server'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
const contactRouter = express.Router()
@@ -15,7 +15,7 @@ contactRouter.post('/contact',
async function contactAdministrator (req: express.Request, res: express.Response) {
const data = req.body as ContactForm
- await Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body)
+ Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body)
await Redis.Instance.setContactFormIp(req.ip)
diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts
index 31888e963a..0601b89ceb 100644
--- a/server/controllers/api/server/debug.ts
+++ b/server/controllers/api/server/debug.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
import { InboxManager } from '@server/lib/activitypub/inbox-manager'
import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
import { Debug, SendDebugCommand } from '@shared/models'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { UserRight } from '../../../../shared/models/users'
import { authenticate, ensureUserHasRight } from '../../../middlewares'
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts
index 12357a2ca9..e6f4f6b92f 100644
--- a/server/controllers/api/server/follows.ts
+++ b/server/controllers/api/server/follows.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { getServerActor } from '@server/models/application/application'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { UserRight } from '../../../../shared/models/users'
import { logger } from '../../../helpers/logger'
import { getFormattedObjects } from '../../../helpers/utils'
diff --git a/server/controllers/api/server/redundancy.ts b/server/controllers/api/server/redundancy.ts
index bc593ad435..99d1c762b8 100644
--- a/server/controllers/api/server/redundancy.ts
+++ b/server/controllers/api/server/redundancy.ts
@@ -1,5 +1,10 @@
import * as express from 'express'
+import { JobQueue } from '@server/lib/job-queue'
+import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { UserRight } from '../../../../shared/models/users'
+import { logger } from '../../../helpers/logger'
+import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy'
import {
asyncMiddleware,
authenticate,
@@ -10,16 +15,11 @@ import {
videoRedundanciesSortValidator
} from '../../../middlewares'
import {
- listVideoRedundanciesValidator,
- updateServerRedundancyValidator,
addVideoRedundancyValidator,
- removeVideoRedundancyValidator
+ listVideoRedundanciesValidator,
+ removeVideoRedundancyValidator,
+ updateServerRedundancyValidator
} from '../../../middlewares/validators/redundancy'
-import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy'
-import { logger } from '../../../helpers/logger'
-import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
-import { JobQueue } from '@server/lib/job-queue'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const serverRedundancyRouter = express.Router()
diff --git a/server/controllers/api/server/server-blocklist.ts b/server/controllers/api/server/server-blocklist.ts
index a86bc7d191..b3ee50d855 100644
--- a/server/controllers/api/server/server-blocklist.ts
+++ b/server/controllers/api/server/server-blocklist.ts
@@ -1,8 +1,9 @@
import 'multer'
import * as express from 'express'
import { logger } from '@server/helpers/logger'
-import { UserNotificationModel } from '@server/models/user/user-notification'
import { getServerActor } from '@server/models/application/application'
+import { UserNotificationModel } from '@server/models/user/user-notification'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { UserRight } from '../../../../shared/models/users'
import { getFormattedObjects } from '../../../helpers/utils'
import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist'
@@ -25,7 +26,6 @@ import {
} from '../../../middlewares/validators'
import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
import { ServerBlocklistModel } from '../../../models/server/server-blocklist'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
const serverBlocklistRouter = express.Router()
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index b86fc94efd..be800e8b5d 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'
import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
import { MUser, MUserAccountDefault } from '@server/types/models'
import { UserCreate, UserCreateResult, UserRight, UserRole, UserUpdate } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
import { UserRegister } from '../../../../shared/models/users/user-register.model'
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts
index 1f2b2f9dde..c9610c59f2 100644
--- a/server/controllers/api/users/me.ts
+++ b/server/controllers/api/users/me.ts
@@ -3,7 +3,7 @@ import * as express from 'express'
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger'
import { Hooks } from '@server/lib/plugins/hooks'
import { ActorImageType, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model'
import { createReqFiles } from '../../../helpers/express-utils'
import { getFormattedObjects } from '../../../helpers/utils'
diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts
index a1561b751b..fe11b6e779 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
import { ServerBlocklistModel } from '../../../models/server/server-blocklist'
import { UserNotificationModel } from '@server/models/user/user-notification'
import { logger } from '@server/helpers/logger'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
const myBlocklistRouter = express.Router()
diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts
index cff1697ab7..85e04925ea 100644
--- a/server/controllers/api/users/my-history.ts
+++ b/server/controllers/api/users/my-history.ts
@@ -11,7 +11,7 @@ import {
import { getFormattedObjects } from '../../../helpers/utils'
import { UserVideoHistoryModel } from '../../../models/user/user-video-history'
import { sequelizeTypescript } from '../../../initializers/database'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
const myVideosHistoryRouter = express.Router()
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts
index 2909770dae..3beee07c02 100644
--- a/server/controllers/api/users/my-notifications.ts
+++ b/server/controllers/api/users/my-notifications.ts
@@ -1,7 +1,7 @@
import 'multer'
import * as express from 'express'
import { UserNotificationModel } from '@server/models/user/user-notification'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { UserNotificationSetting } from '../../../../shared/models/users'
import { getFormattedObjects } from '../../../helpers/utils'
import {
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts
index 46a73d49e7..84f5199264 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'
import { sendUndoFollow } from '@server/lib/activitypub/send'
import { VideoChannelModel } from '@server/models/video/video-channel'
import { VideosCommonQuery } from '@shared/models'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
import { getFormattedObjects } from '../../../helpers/utils'
import { WEBSERVER } from '../../../initializers/constants'
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts
index bc8d203b04..784f97b1e2 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'
import { getServerActor } from '@server/models/application/application'
import { MChannelBannerAccountDefault } from '@server/types/models'
import { ActorImageType, VideoChannelCreate, VideoChannelUpdate, VideosCommonQuery } from '../../../shared'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger'
import { resetSequelizeInstance } from '../../helpers/database-utils'
import { 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 78cbd9cff2..4971d0a772 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'
import { getServerActor } from '@server/models/application/application'
import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'
import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model'
import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model'
import { 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 530e179656..a7f5f53d85 100644
--- a/server/controllers/api/videos/blacklist.ts
+++ b/server/controllers/api/videos/blacklist.ts
@@ -19,7 +19,7 @@ import {
videosBlacklistUpdateValidator
} from '../../../middlewares'
import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
const blacklistRouter = express.Router()
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts
index ad7423a31f..4008de60fc 100644
--- a/server/controllers/api/videos/captions.ts
+++ b/server/controllers/api/videos/captions.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { MVideoCaption } from '@server/types/models'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils'
import { createReqFiles } from '../../../helpers/express-utils'
import { logger } from '../../../helpers/logger'
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts
index 6a25511e5c..90b633bb51 100644
--- a/server/controllers/api/videos/comment.ts
+++ b/server/controllers/api/videos/comment.ts
@@ -1,5 +1,5 @@
import * as express from 'express'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models'
import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model'
import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 74b100e592..5a2ff81dc1 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'
import { getServerActor } from '@server/models/application/application'
import { MVideoAccountLight } from '@server/types/models'
import { VideosCommonQuery } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs'
+import { HttpStatusCode } from '../../../../shared/models'
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils'
import { logger } from '../../../helpers/logger'
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts
index d8c51c2d41..ed4da8f479 100644
--- a/server/controllers/api/videos/live.ts
+++ b/server/controllers/api/videos/live.ts
@@ -11,7 +11,7 @@ import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator
import { VideoLiveModel } from '@server/models/video/video-live'
import { MVideoDetails, MVideoFullLight } from '@server/types/models'
import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { logger } from '../../../helpers/logger'
import { sequelizeTypescript } from '../../../initializers/database'
import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail'
diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts
index 1bb96e0460..e6c94a45ad 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'
import { sendUpdateVideo } from '../../../lib/activitypub/send'
import { VideoModel } from '../../../models/video/video'
import { MVideoFullLight } from '@server/types/models'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
const ownershipVideoRouter = express.Router()
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts
index 84f42633e7..134c9e5caa 100644
--- a/server/controllers/api/videos/rate.ts
+++ b/server/controllers/api/videos/rate.ts
@@ -7,7 +7,7 @@ import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUp
import { AccountModel } from '../../../models/account/account'
import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
import { sequelizeTypescript } from '../../../initializers/database'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
const rateVideoRouter = express.Router()
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts
index 8affe71c68..49639060bd 100644
--- a/server/controllers/api/videos/update.ts
+++ b/server/controllers/api/videos/update.ts
@@ -2,10 +2,11 @@ import * as express from 'express'
import { Transaction } from 'sequelize/types'
import { changeVideoChannelShare } from '@server/lib/activitypub/share'
import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video'
+import { openapiOperationDoc } from '@server/middlewares/doc'
import { FilteredModelAttributes } from '@server/types'
import { MVideoFullLight } from '@server/types/models'
import { VideoUpdate } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs'
+import { HttpStatusCode } from '../../../../shared/models'
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
import { resetSequelizeInstance } from '../../../helpers/database-utils'
import { createReqFiles } from '../../../helpers/express-utils'
@@ -20,7 +21,6 @@ import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares'
import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
import { VideoModel } from '../../../models/video/video'
-import { openapiOperationDoc } from '@server/middlewares/doc'
const lTags = loggerTagsFactory('api', 'video')
const auditLogger = auditLoggerFactory('videos')
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts
index bcd21ac998..1603ef127a 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'
import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
import { uploadx } from '@uploadx/core'
import { VideoCreate, VideoState } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs'
+import { HttpStatusCode } from '../../../../shared/models'
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
import { retryTransactionWrapper } from '../../../helpers/database-utils'
import { createReqFiles } from '../../../helpers/express-utils'
diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts
index 8b15525aa5..2899dbd9ca 100644
--- a/server/controllers/api/videos/watching.ts
+++ b/server/controllers/api/videos/watching.ts
@@ -8,7 +8,7 @@ import {
videoWatchingValidator
} from '../../../middlewares'
import { UserVideoHistoryModel } from '../../../models/user/user-video-history'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
const watchingRouter = express.Router()
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index eb1ee6cbd6..ba3c54440a 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -5,7 +5,7 @@ import { join } from 'path'
import { logger } from '@server/helpers/logger'
import { CONFIG } from '@server/initializers/config'
import { Hooks } from '@server/lib/plugins/hooks'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n'
import { root } from '../helpers/core-utils'
import { STATIC_MAX_AGE } from '../initializers/constants'
diff --git a/server/controllers/download.ts b/server/controllers/download.ts
index 4293a32e2b..13bc669002 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
import { Hooks } from '@server/lib/plugins/hooks'
import { getVideoFilePath } from '@server/lib/video-paths'
import { MStreamingPlaylist, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { VideoStreamingPlaylistType } from '@shared/models'
import { STATIC_DOWNLOAD_PATHS } from '../initializers/constants'
import { asyncMiddleware, videosDownloadValidator } from '../middlewares'
diff --git a/server/controllers/lazy-static.ts b/server/controllers/lazy-static.ts
index 9a7dacba04..632e4dcd8d 100644
--- a/server/controllers/lazy-static.ts
+++ b/server/controllers/lazy-static.ts
@@ -1,7 +1,7 @@
import * as cors from 'cors'
import * as express from 'express'
import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
-import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { logger } from '../helpers/logger'
import { LAZY_STATIC_PATHS, STATIC_MAX_AGE } from '../initializers/constants'
import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache'
diff --git a/server/controllers/live.ts b/server/controllers/live.ts
index f2686fb237..95d5c01357 100644
--- a/server/controllers/live.ts
+++ b/server/controllers/live.ts
@@ -2,7 +2,7 @@ import * as cors from 'cors'
import * as express from 'express'
import { mapToJSON } from '@server/helpers/core-utils'
import { LiveSegmentShaStore } from '@server/lib/live'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
const liveRouter = express.Router()
diff --git a/server/controllers/plugins.ts b/server/controllers/plugins.ts
index 7213e3f15f..11ab3f10ab 100644
--- a/server/controllers/plugins.ts
+++ b/server/controllers/plugins.ts
@@ -3,7 +3,7 @@ import { join } from 'path'
import { logger } from '@server/helpers/logger'
import { optionalAuthenticate } from '@server/middlewares/auth'
import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n'
-import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { PluginType } from '../../shared/models/plugins/plugin.type'
import { isTestInstance } from '../helpers/core-utils'
import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants'
diff --git a/server/controllers/static.ts b/server/controllers/static.ts
index 35e024dda2..5900eaff33 100644
--- a/server/controllers/static.ts
+++ b/server/controllers/static.ts
@@ -3,7 +3,7 @@ import * as express from 'express'
import { join } from 'path'
import { serveIndexHTML } from '@server/lib/client-html'
import { ServerConfigManager } from '@server/lib/server-config-manager'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model'
import { root } from '../helpers/core-utils'
import { CONFIG, isEmailEnabled } from '../initializers/config'
diff --git a/server/helpers/custom-validators/video-ownership.ts b/server/helpers/custom-validators/video-ownership.ts
index 0e1c63bad7..cf15b385a7 100644
--- a/server/helpers/custom-validators/video-ownership.ts
+++ b/server/helpers/custom-validators/video-ownership.ts
@@ -1,7 +1,7 @@
import { Response } from 'express'
import { MUserId } from '@server/types/models'
import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) {
if (videoChangeOwnership.NextOwner.userId === user.id) {
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts
index 0ff1132742..c299b70f13 100644
--- a/server/helpers/express-utils.ts
+++ b/server/helpers/express-utils.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import * as multer from 'multer'
-import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { CONFIG } from '../initializers/config'
import { REMOTE_SCHEME } from '../initializers/constants'
import { getLowercaseExtension } from './core-utils'
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts
index fdd3613900..3c80e7d41c 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'
import got from 'got'
import { join } from 'path'
import { CONFIG } from '@server/initializers/config'
-import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { VideoResolution } from '../../shared/models/videos'
import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES } from '../initializers/constants'
import { peertubeTruncate, pipelinePromise, root } from './core-utils'
diff --git a/server/lib/activitypub/actors/refresh.ts b/server/lib/activitypub/actors/refresh.ts
index b2fe3932ff..0acaa9f62c 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'
import { ActorLoadByUrlType } from '@server/lib/model-loaders'
import { ActorModel } from '@server/models/actor/actor'
import { MActorAccountChannelId, MActorFull } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { fetchRemoteActor } from './shared'
import { APActorUpdater } from './updater'
import { getUrlFromWebfinger } from './webfinger'
diff --git a/server/lib/activitypub/playlists/refresh.ts b/server/lib/activitypub/playlists/refresh.ts
index ef3cb3fe43..493e8c7ec7 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'
import { PeerTubeRequestError } from '@server/helpers/requests'
import { JobQueue } from '@server/lib/job-queue'
import { MVideoPlaylist, MVideoPlaylistOwner } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { createOrUpdateVideoPlaylist } from './create-update'
import { fetchRemoteVideoPlaylist } from './shared'
diff --git a/server/lib/activitypub/videos/refresh.ts b/server/lib/activitypub/videos/refresh.ts
index a7b82f2863..3af08acf4d 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'
import { VideoLoadByUrlType } from '@server/lib/model-loaders'
import { VideoModel } from '@server/models/video/video'
import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared'
import { APVideoUpdater } from './updater'
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index 72194416de..c5d39445b8 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -5,7 +5,7 @@ import validator from 'validator'
import { escapeHTML } from '@shared/core-utils/renderer'
import { HTMLServerConfig } from '@shared/models'
import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n'
-import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos'
import { isTestInstance, sha256 } from '../helpers/core-utils'
import { 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 1caca1dcc0..56e2b0cebc 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'
import { VideoModel } from '@server/models/video/video'
import { VideoCommentModel } from '@server/models/video/video-comment'
import { VideoShareModel } from '@server/models/video/video-share'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { logger } from '../../../helpers/logger'
import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts
index 6b43b7764b..6ef90b2757 100644
--- a/server/middlewares/activitypub.ts
+++ b/server/middlewares/activitypub.ts
@@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from 'express'
import { getAPId } from '@server/helpers/activitypub'
import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor'
import { ActivityDelete, ActivityPubSignature } from '../../shared'
-import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { logger } from '../helpers/logger'
import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto'
import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants'
diff --git a/server/middlewares/auth.ts b/server/middlewares/auth.ts
index 176461cc2c..9e6327b237 100644
--- a/server/middlewares/auth.ts
+++ b/server/middlewares/auth.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { Socket } from 'socket.io'
import { getAccessToken } from '@server/lib/auth/oauth-model'
-import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { logger } from '../helpers/logger'
import { handleOAuthAuthenticate } from '../lib/auth/oauth'
diff --git a/server/middlewares/cache.ts b/server/middlewares/cache.ts
index 0708ee8e8c..1ced060424 100644
--- a/server/middlewares/cache.ts
+++ b/server/middlewares/cache.ts
@@ -1,6 +1,6 @@
import { Redis } from '../lib/redis'
import * as apicache from 'apicache'
-import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
// Ensure Redis is initialized
Redis.Instance.init()
diff --git a/server/middlewares/error.ts b/server/middlewares/error.ts
index e3eb1c8f54..af5a9c29a0 100644
--- a/server/middlewares/error.ts
+++ b/server/middlewares/error.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
function apiFailMiddleware (req: express.Request, res: express.Response, next: express.NextFunction) {
res.fail = options => {
diff --git a/server/middlewares/servers.ts b/server/middlewares/servers.ts
index 9aa56bc933..49a2241b32 100644
--- a/server/middlewares/servers.ts
+++ b/server/middlewares/servers.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { getHostWithPort } from '../helpers/express-utils'
-import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) {
if (!req.body.hosts) return next()
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts
index d1888c2d38..87a1766cfa 100644
--- a/server/middlewares/user-right.ts
+++ b/server/middlewares/user-right.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { UserRight } from '../../shared'
import { logger } from '../helpers/logger'
-import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
function ensureUserHasRight (userRight: UserRight) {
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 c048bc6af3..f4d9c3af20 100644
--- a/server/middlewares/validators/abuse.ts
+++ b/server/middlewares/validators/abuse.ts
@@ -16,7 +16,7 @@ import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID, toIntOrNull } from
import { logger } from '@server/helpers/logger'
import { AbuseMessageModel } from '@server/models/abuse/abuse-message'
import { AbuseCreate, UserRight } from '@shared/models'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdExist, doesVideoExist } from './shared'
const abuseReportValidator = [
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts
index cc6acd4b1a..d65a8e4558 100644
--- a/server/middlewares/validators/activitypub/activity.ts
+++ b/server/middlewares/validators/activitypub/activity.ts
@@ -2,7 +2,7 @@ import * as express from 'express'
import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity'
import { logger } from '../../../helpers/logger'
import { getServerActor } from '@server/models/application/application'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) {
logger.debug('Checking activity pub parameters')
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts
index 826b16fc8f..f15b293e95 100644
--- a/server/middlewares/validators/blocklist.ts
+++ b/server/middlewares/validators/blocklist.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { body, param } from 'express-validator'
import { getServerActor } from '@server/models/application/application'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isHostValid } from '../../helpers/custom-validators/servers'
import { logger } from '../../helpers/logger'
import { WEBSERVER } from '../../initializers/constants'
diff --git a/server/middlewares/validators/bulk.ts b/server/middlewares/validators/bulk.ts
index 9bb95f5b70..4057b1e012 100644
--- a/server/middlewares/validators/bulk.ts
+++ b/server/middlewares/validators/bulk.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { body } from 'express-validator'
import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { UserRight } from '@shared/models'
import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts
index 51b8fdd19b..1a5a8ffa0a 100644
--- a/server/middlewares/validators/feeds.ts
+++ b/server/middlewares/validators/feeds.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { param, query } from 'express-validator'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isValidRSSFeed } from '../../helpers/custom-validators/feeds'
import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID } from '../../helpers/custom-validators/misc'
import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts
index 205baca48d..05cc66c38d 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'
import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors'
import { getServerActor } from '@server/models/application/application'
import { MActorFollowActorsDefault } from '@server/types/models'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isTestInstance } from '../../helpers/core-utils'
import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers'
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts
index 0a82e6932d..e5fc0c277d 100644
--- a/server/middlewares/validators/oembed.ts
+++ b/server/middlewares/validators/oembed.ts
@@ -4,7 +4,7 @@ import { join } from 'path'
import { loadVideo } from '@server/lib/model-loaders'
import { VideoPlaylistModel } from '@server/models/video/video-playlist'
import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isTestInstance } from '../../helpers/core-utils'
import { isIdOrUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc'
import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts
index 8c76d2e363..3fb2176b9d 100644
--- a/server/middlewares/validators/plugins.ts
+++ b/server/middlewares/validators/plugins.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { body, param, query, ValidationChain } from 'express-validator'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { PluginType } from '../../../shared/models/plugins/plugin.type'
import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model'
import { 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 116c8c6111..f1b2ff5cd9 100644
--- a/server/middlewares/validators/redundancy.ts
+++ b/server/middlewares/validators/redundancy.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { body, param, query } from 'express-validator'
import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import {
exists,
isBooleanValid,
diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts
index fc7239b252..29fdc13d28 100644
--- a/server/middlewares/validators/server.ts
+++ b/server/middlewares/validators/server.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { body } from 'express-validator'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers'
import { isUserDisplayNameValid } from '../../helpers/custom-validators/users'
import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/shared/abuses.ts b/server/middlewares/validators/shared/abuses.ts
index 4a20a55fae..2b8d86ba51 100644
--- a/server/middlewares/validators/shared/abuses.ts
+++ b/server/middlewares/validators/shared/abuses.ts
@@ -1,6 +1,6 @@
import { Response } from 'express'
import { AbuseModel } from '@server/models/abuse/abuse'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
async function doesAbuseExist (abuseId: number | string, res: Response) {
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 04da15441f..fe4f83aa00 100644
--- a/server/middlewares/validators/shared/accounts.ts
+++ b/server/middlewares/validators/shared/accounts.ts
@@ -2,7 +2,7 @@ import { Response } from 'express'
import { AccountModel } from '@server/models/account/account'
import { UserModel } from '@server/models/user/user'
import { MAccountDefault } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) {
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 01491c10f6..f85b39b232 100644
--- a/server/middlewares/validators/shared/video-blacklists.ts
+++ b/server/middlewares/validators/shared/video-blacklists.ts
@@ -1,6 +1,6 @@
import { Response } from 'express'
import { VideoBlacklistModel } from '@server/models/video/video-blacklist'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
async function doesVideoBlacklistExist (videoId: number, res: Response) {
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 80f6c5a524..831b366eae 100644
--- a/server/middlewares/validators/shared/video-captions.ts
+++ b/server/middlewares/validators/shared/video-captions.ts
@@ -1,7 +1,7 @@
import { Response } from 'express'
import { VideoCaptionModel } from '@server/models/video/video-caption'
import { MVideoId } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) {
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 fe2e663b75..3fc3d012a6 100644
--- a/server/middlewares/validators/shared/video-channels.ts
+++ b/server/middlewares/validators/shared/video-channels.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { VideoChannelModel } from '@server/models/video/video-channel'
import { MChannelBannerAccountDefault } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
async function doesLocalVideoChannelNameExist (name: string, res: express.Response) {
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 83ea15c988..60132fb6e0 100644
--- a/server/middlewares/validators/shared/video-comments.ts
+++ b/server/middlewares/validators/shared/video-comments.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { VideoCommentModel } from '@server/models/video/video-comment'
import { MVideoId } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) {
const id = parseInt(idArg + '', 10)
diff --git a/server/middlewares/validators/shared/video-imports.ts b/server/middlewares/validators/shared/video-imports.ts
index 0f984bc172..50b49ffcb6 100644
--- a/server/middlewares/validators/shared/video-imports.ts
+++ b/server/middlewares/validators/shared/video-imports.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { VideoImportModel } from '@server/models/video/video-import'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
async function doesVideoImportExist (id: number, res: express.Response) {
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 fc27006ce0..93a23ef40e 100644
--- a/server/middlewares/validators/shared/video-ownerships.ts
+++ b/server/middlewares/validators/shared/video-ownerships.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
async function doesChangeVideoOwnershipExist (idArg: number | string, res: express.Response) {
const id = parseInt(idArg + '', 10)
diff --git a/server/middlewares/validators/shared/video-playlists.ts b/server/middlewares/validators/shared/video-playlists.ts
index d762859a84..3f67681797 100644
--- a/server/middlewares/validators/shared/video-playlists.ts
+++ b/server/middlewares/validators/shared/video-playlists.ts
@@ -1,7 +1,7 @@
import * as express from 'express'
import { VideoPlaylistModel } from '@server/models/video/video-playlist'
import { MVideoPlaylist } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
export type VideoPlaylistFetchType = 'summary' | 'all'
async 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 2c66c1a3ad..7f42a4893b 100644
--- a/server/middlewares/validators/shared/videos.ts
+++ b/server/middlewares/validators/shared/videos.ts
@@ -12,7 +12,7 @@ import {
MVideoImmutable,
MVideoThumbnail
} from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { UserRight } from '@shared/models'
async 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 d4716257f9..2953b9505b 100644
--- a/server/middlewares/validators/themes.ts
+++ b/server/middlewares/validators/themes.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { param } from 'express-validator'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isSafePath } from '../../helpers/custom-validators/misc'
import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts
index ab7962923f..df57777714 100644
--- a/server/middlewares/validators/user-subscriptions.ts
+++ b/server/middlewares/validators/user-subscriptions.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { body, param, query } from 'express-validator'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
import { toArray } from '../../helpers/custom-validators/misc'
import { logger } from '../../helpers/logger'
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts
index 698d7d814b..748b89f8fd 100644
--- a/server/middlewares/validators/users.ts
+++ b/server/middlewares/validators/users.ts
@@ -3,7 +3,7 @@ import { body, param, query } from 'express-validator'
import { omit } from 'lodash'
import { Hooks } from '@server/lib/plugins/hooks'
import { MUserDefault } from '@server/types/models'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { UserRole } from '../../../shared/models/users'
import { UserRegister } from '../../../shared/models/users/user-register.model'
import { 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 21141d84d1..3a4937b7b6 100644
--- a/server/middlewares/validators/videos/video-blacklist.ts
+++ b/server/middlewares/validators/videos/video-blacklist.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { body, query } from 'express-validator'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist'
import { logger } from '../../../helpers/logger'
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts
index e7df185e4f..ea10fe4255 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'
import { VIDEO_CHANNELS } from '@server/initializers/constants'
import { MChannelAccountDefault, MUser } from '@server/types/models'
import { UserRight } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { isActorPreferredUsernameValid } from '../../../helpers/custom-validators/activitypub/actor'
import { isBooleanValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
import {
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts
index 885506ebe6..61c2ed92f8 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'
import { body, param, query } from 'express-validator'
import { MUserAccountUrl } from '@server/types/models'
import { UserRight } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { exists, isBooleanValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc'
import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments'
import { logger } from '../../../helpers/logger'
diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts
index 85dc647cef..52b839e569 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'
import { body } from 'express-validator'
import { isPreImportVideoAccepted } from '@server/lib/moderation'
import { Hooks } from '@server/lib/plugins/hooks'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { VideoImportCreate } from '@shared/models/videos/import/video-import-create.model'
import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc'
import { 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 7cfb935e30..5c8a4269d6 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'
import { Hooks } from '@server/lib/plugins/hooks'
import { VideoModel } from '@server/models/video/video'
import { VideoLiveModel } from '@server/models/video/video-live'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { ServerErrorCode, UserRight, VideoState } from '@shared/models'
import { isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc'
import { 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 54ac46c99c..06f86a4c8b 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'
import { isAbleToUploadVideo } from '@server/lib/user'
import { AccountModel } from '@server/models/account/account'
import { MVideoWithAllFiles } from '@server/types/models'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { ServerErrorCode, UserRight, VideoChangeOwnershipAccept, VideoChangeOwnershipStatus, VideoState } from '@shared/models'
import {
areValidationErrors,
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts
index 5ee7ee0ce5..ab84b4814a 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'
import { ExpressPromiseHandler } from '@server/types/express'
import { MUserAccountId } from '@server/types/models'
import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model'
import {
diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/middlewares/validators/videos/video-rates.ts
index 5d5dfb2227..5fe78b39e8 100644
--- a/server/middlewares/validators/videos/video-rates.ts
+++ b/server/middlewares/validators/videos/video-rates.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { body, param, query } from 'express-validator'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { VideoRateType } from '../../../../shared/models/videos'
import { isAccountNameValid } from '../../../helpers/custom-validators/accounts'
import { 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 7e54b6fc0f..3b8d617680 100644
--- a/server/middlewares/validators/videos/video-shares.ts
+++ b/server/middlewares/validators/videos/video-shares.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { param } from 'express-validator'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { isIdValid } from '../../../helpers/custom-validators/misc'
import { logger } from '../../../helpers/logger'
import { 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 43306f7cda..431515eb15 100644
--- a/server/middlewares/validators/videos/video-watch.ts
+++ b/server/middlewares/validators/videos/video-watch.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { body } from 'express-validator'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { toIntOrNull } from '../../../helpers/custom-validators/misc'
import { logger } from '../../../helpers/logger'
import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared'
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts
index 49e10e2b54..374a59c50d 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'
import { ExpressPromiseHandler } from '@server/types/express'
import { MUserAccountId, MVideoFullLight } from '@server/types/models'
import { ServerErrorCode, UserRight, VideoPrivacy } from '../../../../shared'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import {
exists,
isBooleanValid,
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts
index bcdd136c6a..1313608203 100644
--- a/server/middlewares/validators/webfinger.ts
+++ b/server/middlewares/validators/webfinger.ts
@@ -1,6 +1,6 @@
import * as express from 'express'
import { query } from 'express-validator'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger'
import { getHostWithPort } from '../../helpers/express-utils'
import { logger } from '../../helpers/logger'
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts
index 720231f025..53cc406638 100644
--- a/server/tests/api/activitypub/client.ts
+++ b/server/tests/api/activitypub/client.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
doubleFollow,
@@ -68,7 +68,7 @@ describe('Test activitypub', function () {
await setDefaultVideoChannel(servers)
{
- video = await await servers[0].videos.quickUpload({ name: 'video' })
+ video = await servers[0].videos.quickUpload({ name: 'video' })
}
{
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts
index bbec0d309b..a0b72c7e6d 100644
--- a/server/tests/api/activitypub/refresher.ts
+++ b/server/tests/api/activitypub/refresher.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
doubleFollow,
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index c173648b30..94d946563c 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -2,20 +2,13 @@
import 'mocha'
import * as chai from 'chai'
+import { activityPubContextify, buildSignedActivity } from '@server/helpers/activitypub'
import { buildDigest } from '@server/helpers/peertube-crypto'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
-import {
- buildAbsoluteFixturePath,
- cleanupTests,
- createMultipleServers,
- killallServers,
- PeerTubeServer,
- wait
-} from '../../../../shared/extra-utils'
-import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-utils/requests/activitypub'
-import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub'
-import { HTTP_SIGNATURE } from '../../../initializers/constants'
-import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils'
+import { HTTP_SIGNATURE } from '@server/initializers/constants'
+import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils'
+import { buildAbsoluteFixturePath, cleanupTests, createMultipleServers, killallServers, PeerTubeServer, wait } from '@shared/extra-utils'
+import { makeFollowRequest, makePOSTAPRequest } from '@shared/extra-utils/requests/activitypub'
+import { HttpStatusCode } from '@shared/models'
const expect = chai.expect
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts
index 62811f9324..87d93195cb 100644
--- a/server/tests/api/check-params/abuses.ts
+++ b/server/tests/api/check-params/abuses.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
AbusesCommand,
checkBadCountPagination,
@@ -66,7 +66,7 @@ describe('Test abuses API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -75,7 +75,7 @@ describe('Test abuses API validators', function () {
url: server.url,
path,
token: userToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -110,7 +110,7 @@ describe('Test abuses API validators', function () {
videoIs: 'deleted'
}
- await makeGetRequest({ url: server.url, path, token: server.accessToken, query, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, token: server.accessToken, query, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -133,7 +133,7 @@ describe('Test abuses API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -152,7 +152,7 @@ describe('Test abuses API validators', function () {
state: 2
}
- await makeGetRequest({ url: server.url, path, token: userToken, query, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, token: userToken, query, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -176,7 +176,7 @@ describe('Test abuses API validators', function () {
path,
token: userToken,
fields,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -192,7 +192,7 @@ describe('Test abuses API validators', function () {
path,
token: userToken,
fields,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -208,7 +208,7 @@ describe('Test abuses API validators', function () {
path,
token: userToken,
fields,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -219,14 +219,14 @@ describe('Test abuses API validators', function () {
path,
token: userToken,
fields,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
it('Should fail with a non authenticated user', async function () {
const fields = { video: { id: server.store.video.id }, reason: 'my super reason' }
- await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a reason too short', async function () {
@@ -249,7 +249,7 @@ describe('Test abuses API validators', function () {
path,
token: userToken,
fields,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
abuseId = res.body.abuse.id
})
@@ -283,7 +283,7 @@ describe('Test abuses API validators', function () {
predefinedReasons: [ 'serverRules' ]
}
- await makePostBodyRequest({ url: server.url, path, token: userToken, fields, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: HttpStatusCode.OK_200 })
})
})
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts
index e866593db8..0cae485d92 100644
--- a/server/tests/api/check-params/accounts.ts
+++ b/server/tests/api/check-params/accounts.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkBadCountPagination,
checkBadSortPagination,
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts
index b2a1cc4e22..7d5fae5cfb 100644
--- a/server/tests/api/check-params/blocklist.ts
+++ b/server/tests/api/check-params/blocklist.ts
@@ -1,23 +1,20 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-
import {
+ checkBadCountPagination,
+ checkBadSortPagination,
+ checkBadStartPagination,
cleanupTests,
- doubleFollow,
createMultipleServers,
+ doubleFollow,
makeDeleteRequest,
makeGetRequest,
makePostBodyRequest,
PeerTubeServer,
setAccessTokensToServers
-} from '../../../../shared/extra-utils'
-import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination
-} from '../../../../shared/extra-utils/requests/check-api-params'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+} from '@shared/extra-utils'
+import { HttpStatusCode } from '@shared/models'
describe('Test blocklist API validators', function () {
let servers: PeerTubeServer[]
@@ -52,7 +49,7 @@ describe('Test blocklist API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -75,7 +72,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path,
fields: { accountName: 'user1' },
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -85,7 +82,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { accountName: 'user2' },
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -95,7 +92,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { accountName: 'root' },
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -105,7 +102,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { accountName: 'user1' },
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -115,7 +112,7 @@ describe('Test blocklist API validators', function () {
await makeDeleteRequest({
url: server.url,
path: path + '/user1',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -124,7 +121,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path: path + '/user2',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -133,7 +130,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path: path + '/user1',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -147,7 +144,7 @@ describe('Test blocklist API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -170,7 +167,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path,
fields: { host: 'localhost:9002' },
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -180,7 +177,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { host: 'localhost:9003' },
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
@@ -190,7 +187,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { host: 'localhost:' + server.port },
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -200,7 +197,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { host: 'localhost:' + servers[1].port },
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -210,7 +207,7 @@ describe('Test blocklist API validators', function () {
await makeDeleteRequest({
url: server.url,
path: path + '/localhost:' + servers[1].port,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -219,7 +216,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path: path + '/localhost:9004',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -228,7 +225,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path: path + '/localhost:' + servers[1].port,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -245,7 +242,7 @@ describe('Test blocklist API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -254,7 +251,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
token: userAccessToken,
path,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -277,7 +274,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path,
fields: { accountName: 'user1' },
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -287,7 +284,7 @@ describe('Test blocklist API validators', function () {
token: userAccessToken,
path,
fields: { accountName: 'user1' },
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -297,7 +294,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { accountName: 'user2' },
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -307,7 +304,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { accountName: 'root' },
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -317,7 +314,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { accountName: 'user1' },
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -327,7 +324,7 @@ describe('Test blocklist API validators', function () {
await makeDeleteRequest({
url: server.url,
path: path + '/user1',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -336,7 +333,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path: path + '/user1',
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -345,7 +342,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path: path + '/user2',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -354,7 +351,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path: path + '/user1',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -368,7 +365,7 @@ describe('Test blocklist API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -377,7 +374,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
token: userAccessToken,
path,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -400,7 +397,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path,
fields: { host: 'localhost:' + servers[1].port },
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -410,7 +407,7 @@ describe('Test blocklist API validators', function () {
token: userAccessToken,
path,
fields: { host: 'localhost:' + servers[1].port },
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -420,7 +417,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { host: 'localhost:9003' },
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
@@ -430,7 +427,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { host: 'localhost:' + server.port },
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -440,7 +437,7 @@ describe('Test blocklist API validators', function () {
token: server.accessToken,
path,
fields: { host: 'localhost:' + servers[1].port },
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -450,7 +447,7 @@ describe('Test blocklist API validators', function () {
await makeDeleteRequest({
url: server.url,
path: path + '/localhost:' + servers[1].port,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -459,7 +456,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path: path + '/localhost:' + servers[1].port,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -468,7 +465,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path: path + '/localhost:9004',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -477,7 +474,7 @@ describe('Test blocklist API validators', function () {
url: server.url,
path: path + '/localhost:' + servers[1].port,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts
index a660c3d80f..bc9d7784d7 100644
--- a/server/tests/api/check-params/bulk.ts
+++ b/server/tests/api/check-params/bulk.ts
@@ -1,14 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import {
- cleanupTests,
- createSingleServer,
- PeerTubeServer,
- setAccessTokensToServers
-} from '../../../../shared/extra-utils'
-import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
+import { HttpStatusCode } from '@shared/models'
describe('Test bulk API validators', function () {
let server: PeerTubeServer
@@ -36,7 +30,7 @@ describe('Test bulk API validators', function () {
url: server.url,
path,
fields: { accountName: 'user1', scope: 'my-videos' },
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -46,7 +40,7 @@ describe('Test bulk API validators', function () {
token: server.accessToken,
path,
fields: { accountName: 'user2', scope: 'my-videos' },
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -56,7 +50,7 @@ describe('Test bulk API validators', function () {
token: server.accessToken,
path,
fields: { accountName: 'user1', scope: 'my-videoss' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -66,7 +60,7 @@ describe('Test bulk API validators', function () {
token: userAccessToken,
path,
fields: { accountName: 'user1', scope: 'instance' },
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -76,7 +70,7 @@ describe('Test bulk API validators', function () {
token: server.accessToken,
path,
fields: { accountName: 'user1', scope: 'instance' },
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts
index 1756d58eec..c3438917ec 100644
--- a/server/tests/api/check-params/config.ts
+++ b/server/tests/api/check-params/config.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { omit } from 'lodash'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
@@ -214,7 +214,7 @@ describe('Test config API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -223,7 +223,7 @@ describe('Test config API validators', function () {
url: server.url,
path,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
})
@@ -234,7 +234,7 @@ describe('Test config API validators', function () {
url: server.url,
path,
fields: updateParams,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -244,7 +244,7 @@ describe('Test config API validators', function () {
path,
fields: updateParams,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -256,7 +256,7 @@ describe('Test config API validators', function () {
path,
fields: newUpdateParams,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -274,7 +274,7 @@ describe('Test config API validators', function () {
path,
fields: newUpdateParams,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -295,7 +295,7 @@ describe('Test config API validators', function () {
path,
fields: newUpdateParams,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -318,7 +318,7 @@ describe('Test config API validators', function () {
path,
fields: newUpdateParams,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -328,7 +328,7 @@ describe('Test config API validators', function () {
path,
fields: updateParams,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -338,7 +338,7 @@ describe('Test config API validators', function () {
await makeDeleteRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -347,7 +347,7 @@ describe('Test config API validators', function () {
url: server.url,
path,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
})
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts
index 8c2b2a84b1..8e755c69bf 100644
--- a/server/tests/api/check-params/contact-form.ts
+++ b/server/tests/api/check-params/contact-form.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { cleanupTests, createSingleServer, killallServers, MockSmtpServer, PeerTubeServer } from '@shared/extra-utils'
import { ContactFormCommand } from '@shared/extra-utils/server'
diff --git a/server/tests/api/check-params/custom-pages.ts b/server/tests/api/check-params/custom-pages.ts
index 043505e328..9fbbea3150 100644
--- a/server/tests/api/check-params/custom-pages.ts
+++ b/server/tests/api/check-params/custom-pages.ts
@@ -1,14 +1,15 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import {
cleanupTests,
createSingleServer,
+ makeGetRequest,
+ makePutBodyRequest,
PeerTubeServer,
setAccessTokensToServers
-} from '../../../../shared/extra-utils'
-import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests'
+} from '@shared/extra-utils'
+import { HttpStatusCode } from '@shared/models'
describe('Test custom pages validators', function () {
const path = '/api/v1/custom-pages/homepage/instance'
@@ -37,7 +38,7 @@ describe('Test custom pages validators', function () {
url: server.url,
path,
fields: { content: 'super content' },
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -47,7 +48,7 @@ describe('Test custom pages validators', function () {
path,
token: userAccessToken,
fields: { content: 'super content' },
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -57,7 +58,7 @@ describe('Test custom pages validators', function () {
path,
token: server.accessToken,
fields: { content: 'super content' },
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -68,7 +69,7 @@ describe('Test custom pages validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts
index 9c13e9daf6..a55786359e 100644
--- a/server/tests/api/check-params/debug.ts
+++ b/server/tests/api/check-params/debug.ts
@@ -1,15 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-
-import {
- cleanupTests,
- createSingleServer,
- PeerTubeServer,
- setAccessTokensToServers
-} from '../../../../shared/extra-utils'
-import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
+import { HttpStatusCode } from '@shared/models'
describe('Test debug API validators', function () {
const path = '/api/v1/server/debug'
@@ -39,7 +32,7 @@ describe('Test debug API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -48,7 +41,7 @@ describe('Test debug API validators', function () {
url: server.url,
path,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -58,7 +51,7 @@ describe('Test debug API validators', function () {
path,
token: server.accessToken,
query: { startDate: new Date().toISOString() },
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts
index 0fd2b49250..dfe3f226d4 100644
--- a/server/tests/api/check-params/follows.ts
+++ b/server/tests/api/check-params/follows.ts
@@ -1,21 +1,19 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-
import {
+ checkBadCountPagination,
+ checkBadSortPagination,
+ checkBadStartPagination,
cleanupTests,
createSingleServer,
- makeDeleteRequest, makeGetRequest,
+ makeDeleteRequest,
+ makeGetRequest,
makePostBodyRequest,
PeerTubeServer,
setAccessTokensToServers
-} from '../../../../shared/extra-utils'
-import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination
-} from '../../../../shared/extra-utils/requests/check-api-params'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+} from '@shared/extra-utils'
+import { HttpStatusCode } from '@shared/models'
describe('Test server follows API validators', function () {
let server: PeerTubeServer
@@ -51,7 +49,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -61,7 +59,7 @@ describe('Test server follows API validators', function () {
path,
token: server.accessToken,
fields: { hosts: 'localhost:9002' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -71,7 +69,7 @@ describe('Test server follows API validators', function () {
path,
fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -81,7 +79,7 @@ describe('Test server follows API validators', function () {
path,
fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -91,7 +89,7 @@ describe('Test server follows API validators', function () {
path,
fields: { urls: [ 'localhost:9002', 'localhost:9002' ] },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -101,7 +99,7 @@ describe('Test server follows API validators', function () {
path,
fields: { hosts: [ 'localhost:9002' ] },
token: 'fake_token',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -111,7 +109,7 @@ describe('Test server follows API validators', function () {
path,
fields: { hosts: [ 'localhost:9002' ] },
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
})
@@ -155,7 +153,7 @@ describe('Test server follows API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.OK_200,
+ expectedStatus: HttpStatusCode.OK_200,
query: {
state: 'accepted',
actorType: 'Application'
@@ -204,7 +202,7 @@ describe('Test server follows API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.OK_200,
+ expectedStatus: HttpStatusCode.OK_200,
query: {
state: 'accepted'
}
@@ -220,7 +218,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto@localhost:9002',
token: 'fake_token',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -229,7 +227,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto@localhost:9002',
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -238,7 +236,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -247,7 +245,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto@localhost:9003',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
})
@@ -260,7 +258,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto@localhost:9002/accept',
token: 'fake_token',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -269,7 +267,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto@localhost:9002/accept',
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -278,7 +276,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto/accept',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -287,7 +285,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto@localhost:9003/accept',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
})
@@ -300,7 +298,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto@localhost:9002/reject',
token: 'fake_token',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -309,7 +307,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto@localhost:9002/reject',
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -318,7 +316,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto/reject',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -327,7 +325,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/toto@localhost:9003/reject',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
})
@@ -340,7 +338,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/localhost:9002',
token: 'fake_token',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -349,7 +347,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/localhost:9002',
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -358,7 +356,7 @@ describe('Test server follows API validators', function () {
url: server.url,
path: path + '/example.com',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
})
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts
index a370ec2d36..23d95d8e4c 100644
--- a/server/tests/api/check-params/jobs.ts
+++ b/server/tests/api/check-params/jobs.ts
@@ -1,20 +1,17 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-
import {
+ checkBadCountPagination,
+ checkBadSortPagination,
+ checkBadStartPagination,
cleanupTests,
createSingleServer,
+ makeGetRequest,
PeerTubeServer,
setAccessTokensToServers
-} from '../../../../shared/extra-utils'
-import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination
-} from '../../../../shared/extra-utils/requests/check-api-params'
-import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+} from '@shared/extra-utils'
+import { HttpStatusCode } from '@shared/models'
describe('Test jobs API validators', function () {
const path = '/api/v1/jobs/failed'
@@ -75,7 +72,7 @@ describe('Test jobs API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -84,7 +81,7 @@ describe('Test jobs API validators', function () {
url: server.url,
path,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts
index eb5cdd1d89..0ef86a5387 100644
--- a/server/tests/api/check-params/live.ts
+++ b/server/tests/api/check-params/live.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { omit } from 'lodash'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
buildAbsoluteFixturePath,
cleanupTests,
@@ -223,7 +223,7 @@ describe('Test video lives API validator', function () {
path,
token: server.accessToken,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
video = res.body.video
@@ -243,7 +243,7 @@ describe('Test video lives API validator', function () {
path,
token: server.accessToken,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -264,7 +264,7 @@ describe('Test video lives API validator', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -285,7 +285,7 @@ describe('Test video lives API validator', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
@@ -304,7 +304,7 @@ describe('Test video lives API validator', function () {
path,
token: server.accessToken,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -324,7 +324,7 @@ describe('Test video lives API validator', function () {
path,
token: server.accessToken,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
})
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts
index 2eb0740071..05372257a7 100644
--- a/server/tests/api/check-params/logs.ts
+++ b/server/tests/api/check-params/logs.ts
@@ -1,15 +1,8 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-
-import {
- cleanupTests,
- createSingleServer,
- PeerTubeServer,
- setAccessTokensToServers
-} from '../../../../shared/extra-utils'
-import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
+import { HttpStatusCode } from '@shared/models'
describe('Test logs API validators', function () {
const path = '/api/v1/server/logs'
@@ -39,7 +32,7 @@ describe('Test logs API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -48,7 +41,7 @@ describe('Test logs API validators', function () {
url: server.url,
path,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -57,7 +50,7 @@ describe('Test logs API validators', function () {
url: server.url,
path,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -67,7 +60,7 @@ describe('Test logs API validators', function () {
path,
token: server.accessToken,
query: { startDate: 'toto' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -77,7 +70,7 @@ describe('Test logs API validators', function () {
path,
token: server.accessToken,
query: { startDate: new Date().toISOString(), endDate: 'toto' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -87,7 +80,7 @@ describe('Test logs API validators', function () {
path,
token: server.accessToken,
query: { startDate: new Date().toISOString(), level: 'toto' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -97,7 +90,7 @@ describe('Test logs API validators', function () {
path,
token: server.accessToken,
query: { startDate: new Date().toISOString() },
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts
index 2b471ee7d5..d3dda7fce6 100644
--- a/server/tests/api/check-params/plugins.ts
+++ b/server/tests/api/check-params/plugins.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkBadCountPagination,
checkBadSortPagination,
@@ -70,7 +70,7 @@ describe('Test server plugins API validators', function () {
]
for (const p of paths) {
- await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
+ await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
}
})
@@ -78,7 +78,7 @@ describe('Test server plugins API validators', function () {
await makeGetRequest({
url: server.url,
path: '/themes/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -93,7 +93,7 @@ describe('Test server plugins API validators', function () {
]
for (const p of paths) {
- await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
})
@@ -107,14 +107,14 @@ describe('Test server plugins API validators', function () {
]
for (const p of paths) {
- await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
})
it('Should fail with an unknown auth name', async function () {
const path = '/plugins/' + pluginName + '/' + npmVersion + '/auth/bad-auth'
- await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
+ await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Should fail with an unknown static file', async function () {
@@ -126,7 +126,7 @@ describe('Test server plugins API validators', function () {
]
for (const p of paths) {
- await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
+ await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
}
})
@@ -134,7 +134,7 @@ describe('Test server plugins API validators', function () {
await makeGetRequest({
url: server.url,
path: '/themes/' + themeName + '/' + themeVersion + '/css/assets/fake.css',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -148,11 +148,11 @@ describe('Test server plugins API validators', function () {
]
for (const p of paths) {
- await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.OK_200 })
}
const authPath = '/plugins/' + pluginName + '/' + npmVersion + '/auth/fake-auth'
- await makeGetRequest({ url: server.url, path: authPath, statusCodeExpected: HttpStatusCode.FOUND_302 })
+ await makeGetRequest({ url: server.url, path: authPath, expectedStatus: HttpStatusCode.FOUND_302 })
})
})
@@ -170,7 +170,7 @@ describe('Test server plugins API validators', function () {
path,
token: 'fake_token',
query: baseQuery,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -180,7 +180,7 @@ describe('Test server plugins API validators', function () {
path,
token: userAccessToken,
query: baseQuery,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -224,7 +224,7 @@ describe('Test server plugins API validators', function () {
path,
token: server.accessToken,
query: baseQuery,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -241,7 +241,7 @@ describe('Test server plugins API validators', function () {
path,
token: 'fake_token',
query: baseQuery,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -251,7 +251,7 @@ describe('Test server plugins API validators', function () {
path,
token: userAccessToken,
query: baseQuery,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -284,7 +284,7 @@ describe('Test server plugins API validators', function () {
path,
token: server.accessToken,
query: baseQuery,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -298,7 +298,7 @@ describe('Test server plugins API validators', function () {
url: server.url,
path: path + suffix,
token: 'fake_token',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
}
})
@@ -309,7 +309,7 @@ describe('Test server plugins API validators', function () {
url: server.url,
path: path + suffix,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
}
})
@@ -320,7 +320,7 @@ describe('Test server plugins API validators', function () {
url: server.url,
path: path + suffix,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
}
@@ -329,7 +329,7 @@ describe('Test server plugins API validators', function () {
url: server.url,
path: path + suffix,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
}
})
@@ -340,7 +340,7 @@ describe('Test server plugins API validators', function () {
url: server.url,
path: path + suffix,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
}
})
@@ -351,7 +351,7 @@ describe('Test server plugins API validators', function () {
url: server.url,
path: path + suffix,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
}
})
@@ -367,7 +367,7 @@ describe('Test server plugins API validators', function () {
path: path + npmPlugin + '/settings',
fields: { settings },
token: 'fake_token',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -377,7 +377,7 @@ describe('Test server plugins API validators', function () {
path: path + npmPlugin + '/settings',
fields: { settings },
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -387,7 +387,7 @@ describe('Test server plugins API validators', function () {
path: path + 'toto/settings',
fields: { settings },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makePutBodyRequest({
@@ -395,7 +395,7 @@ describe('Test server plugins API validators', function () {
path: path + 'peertube-plugin-TOTO/settings',
fields: { settings },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -405,7 +405,7 @@ describe('Test server plugins API validators', function () {
path: path + 'peertube-plugin-toto/settings',
fields: { settings },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -415,7 +415,7 @@ describe('Test server plugins API validators', function () {
path: path + npmPlugin + '/settings',
fields: { settings },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -430,7 +430,7 @@ describe('Test server plugins API validators', function () {
path: path + suffix,
fields: { npmName: npmPlugin },
token: 'fake_token',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
}
})
@@ -442,7 +442,7 @@ describe('Test server plugins API validators', function () {
path: path + suffix,
fields: { npmName: npmPlugin },
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
}
})
@@ -454,7 +454,7 @@ describe('Test server plugins API validators', function () {
path: path + suffix,
fields: { npmName: 'toto' },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
}
@@ -464,7 +464,7 @@ describe('Test server plugins API validators', function () {
path: path + suffix,
fields: { npmName: 'peertube-plugin-TOTO' },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
}
})
@@ -484,7 +484,7 @@ describe('Test server plugins API validators', function () {
path: path + obj.suffix,
fields: { npmName: npmPlugin },
token: server.accessToken,
- statusCodeExpected: obj.status
+ expectedStatus: obj.status
})
}
})
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts
index 18b98a0f96..d9f9055496 100644
--- a/server/tests/api/check-params/redundancy.ts
+++ b/server/tests/api/check-params/redundancy.ts
@@ -1,15 +1,13 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { VideoCreateResult } from '@shared/models'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import {
checkBadCountPagination,
checkBadSortPagination,
checkBadStartPagination,
cleanupTests,
- doubleFollow,
createMultipleServers,
+ doubleFollow,
makeDeleteRequest,
makeGetRequest,
makePostBodyRequest,
@@ -17,7 +15,8 @@ import {
PeerTubeServer,
setAccessTokensToServers,
waitJobs
-} from '../../../../shared/extra-utils'
+} from '@shared/extra-utils'
+import { HttpStatusCode, VideoCreateResult } from '@shared/models'
describe('Test server redundancy API validators', function () {
let servers: PeerTubeServer[]
@@ -64,11 +63,11 @@ describe('Test server redundancy API validators', function () {
})
it('Should fail with an invalid token', async function () {
- await makeGetRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makeGetRequest({ url, path, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail if the user is not an administrator', async function () {
- await makeGetRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
+ await makeGetRequest({ url, path, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with a bad start pagination', async function () {
@@ -92,7 +91,7 @@ describe('Test server redundancy API validators', function () {
})
it('Should succeed with the correct params', async function () {
- await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -108,11 +107,11 @@ describe('Test server redundancy API validators', function () {
})
it('Should fail with an invalid token', async function () {
- await makePostBodyRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makePostBodyRequest({ url, path, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail if the user is not an administrator', async function () {
- await makePostBodyRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
+ await makePostBodyRequest({ url, path, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail without a video id', async function () {
@@ -124,7 +123,7 @@ describe('Test server redundancy API validators', function () {
})
it('Should fail with a not found video id', async function () {
- await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
+ await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Should fail with a local a video id', async function () {
@@ -137,7 +136,7 @@ describe('Test server redundancy API validators', function () {
path,
token,
fields: { videoId: videoRemote.shortUUID },
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
@@ -151,7 +150,7 @@ describe('Test server redundancy API validators', function () {
path,
token,
fields: { videoId: videoRemote.uuid },
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
})
@@ -168,11 +167,11 @@ describe('Test server redundancy API validators', function () {
})
it('Should fail with an invalid token', async function () {
- await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail if the user is not an administrator', async function () {
- await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
+ await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with an incorrect video id', async function () {
@@ -180,7 +179,7 @@ describe('Test server redundancy API validators', function () {
})
it('Should fail with a not found video redundancy', async function () {
- await makeDeleteRequest({ url, path: path + '454545', token, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
+ await makeDeleteRequest({ url, path: path + '454545', token, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
})
@@ -193,7 +192,7 @@ describe('Test server redundancy API validators', function () {
path: path + '/localhost:' + servers[1].port,
fields: { redundancyAllowed: true },
token: 'fake_token',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -203,7 +202,7 @@ describe('Test server redundancy API validators', function () {
path: path + '/localhost:' + servers[1].port,
fields: { redundancyAllowed: true },
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -213,7 +212,7 @@ describe('Test server redundancy API validators', function () {
path: path + '/example.com',
fields: { redundancyAllowed: true },
token: servers[0].accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -223,7 +222,7 @@ describe('Test server redundancy API validators', function () {
path: path + '/localhost:' + servers[1].port,
fields: { blabla: true },
token: servers[0].accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -233,7 +232,7 @@ describe('Test server redundancy API validators', function () {
path: path + '/localhost:' + servers[1].port,
fields: { redundancyAllowed: true },
token: servers[0].accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts
index 43cd81af9d..b49169e381 100644
--- a/server/tests/api/check-params/search.ts
+++ b/server/tests/api/check-params/search.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkBadCountPagination,
checkBadSortPagination,
@@ -58,83 +58,83 @@ describe('Test videos API validator', function () {
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
})
it('Should fail with an invalid category', async function () {
const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] }
- await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
const customQuery2 = { ...query, categoryOneOf: 'a' }
- await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should succeed with a valid category', async function () {
const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] }
- await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
const customQuery2 = { ...query, categoryOneOf: 1 }
- await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
})
it('Should fail with an invalid licence', async function () {
const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] }
- await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
const customQuery2 = { ...query, licenceOneOf: 'a' }
- await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should succeed with a valid licence', async function () {
const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] }
- await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
const customQuery2 = { ...query, licenceOneOf: 1 }
- await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
})
it('Should succeed with a valid language', async function () {
const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] }
- await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
const customQuery2 = { ...query, languageOneOf: 'fr' }
- await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
})
it('Should succeed with valid tags', async function () {
const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] }
- await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 })
const customQuery2 = { ...query, tagsOneOf: 'tag1' }
- await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 })
const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] }
- await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: HttpStatusCode.OK_200 })
const customQuery4 = { ...query, tagsAllOf: 'tag1' }
- await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.OK_200 })
})
it('Should fail with invalid durations', async function () {
const customQuery1 = { ...query, durationMin: 'hello' }
- await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
const customQuery2 = { ...query, durationMax: 'hello' }
- await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
it('Should fail with invalid dates', async function () {
const customQuery1 = { ...query, startDate: 'hello' }
- await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
const customQuery2 = { ...query, endDate: 'hello' }
- await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' }
- await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' }
- await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
})
})
@@ -158,7 +158,7 @@ describe('Test videos API validator', function () {
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -182,7 +182,7 @@ describe('Test videos API validator', function () {
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -201,41 +201,41 @@ describe('Test videos API validator', function () {
for (const path of paths) {
{
const customQuery = { ...query, searchTarget: 'hello' }
- await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
{
const customQuery = { ...query, searchTarget: undefined }
- await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
}
{
const customQuery = { ...query, searchTarget: 'local' }
- await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
}
{
const customQuery = { ...query, searchTarget: 'search-index' }
- await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
await updateSearchIndex(server, true, true)
{
const customQuery = { ...query, searchTarget: 'local' }
- await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 })
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
}
{
const customQuery = { ...query, searchTarget: 'search-index' }
- await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
}
await updateSearchIndex(server, true, false)
{
const customQuery = { ...query, searchTarget: 'local' }
- await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 })
}
await updateSearchIndex(server, false, false)
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index c623240b71..973b255982 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
@@ -120,13 +120,13 @@ describe('Test services API validators', function () {
})
})
-function checkParamEmbed (server: PeerTubeServer, embedUrl: string, statusCodeExpected = HttpStatusCode.BAD_REQUEST_400, query = {}) {
+function checkParamEmbed (server: PeerTubeServer, embedUrl: string, expectedStatus = HttpStatusCode.BAD_REQUEST_400, query = {}) {
const path = '/services/oembed'
return makeGetRequest({
url: server.url,
path,
query: Object.assign(query, { url: embedUrl }),
- statusCodeExpected
+ expectedStatus
})
}
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts
index bd8dce9753..322e93d0d5 100644
--- a/server/tests/api/check-params/upload-quota.ts
+++ b/server/tests/api/check-params/upload-quota.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode, randomInt } from '@shared/core-utils'
+import { randomInt } from '@shared/core-utils'
import {
cleanupTests,
createSingleServer,
@@ -13,7 +13,7 @@ import {
VideosCommand,
waitJobs
} from '@shared/extra-utils'
-import { VideoImportState, VideoPrivacy } from '@shared/models'
+import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models'
describe('Test upload quota', function () {
let server: PeerTubeServer
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts
index 038c444b3a..3b709ee5a2 100644
--- a/server/tests/api/check-params/user-notifications.ts
+++ b/server/tests/api/check-params/user-notifications.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { io } from 'socket.io-client'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkBadCountPagination,
checkBadSortPagination,
@@ -54,7 +54,7 @@ describe('Test user notifications API validators', function () {
unread: 'toto'
},
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
@@ -62,7 +62,7 @@ describe('Test user notifications API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -71,7 +71,7 @@ describe('Test user notifications API validators', function () {
url: server.url,
path,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -87,7 +87,7 @@ describe('Test user notifications API validators', function () {
ids: [ 'hello' ]
},
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makePostBodyRequest({
@@ -97,7 +97,7 @@ describe('Test user notifications API validators', function () {
ids: [ ]
},
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makePostBodyRequest({
@@ -107,7 +107,7 @@ describe('Test user notifications API validators', function () {
ids: 5
},
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -118,7 +118,7 @@ describe('Test user notifications API validators', function () {
fields: {
ids: [ 5 ]
},
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -130,7 +130,7 @@ describe('Test user notifications API validators', function () {
ids: [ 5 ]
},
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -142,7 +142,7 @@ describe('Test user notifications API validators', function () {
await makePostBodyRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -151,7 +151,7 @@ describe('Test user notifications API validators', function () {
url: server.url,
path,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -183,7 +183,7 @@ describe('Test user notifications API validators', function () {
path,
token: server.accessToken,
fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -196,7 +196,7 @@ describe('Test user notifications API validators', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
}
@@ -208,7 +208,7 @@ describe('Test user notifications API validators', function () {
path,
fields,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
}
})
@@ -218,7 +218,7 @@ describe('Test user notifications API validators', function () {
url: server.url,
path,
fields: correctFields,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -228,7 +228,7 @@ describe('Test user notifications API validators', function () {
path,
token: server.accessToken,
fields: correctFields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts
index 22cf130c28..624069c80b 100644
--- a/server/tests/api/check-params/user-subscriptions.ts
+++ b/server/tests/api/check-params/user-subscriptions.ts
@@ -1,24 +1,20 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-
import {
+ checkBadCountPagination,
+ checkBadSortPagination,
+ checkBadStartPagination,
cleanupTests,
createSingleServer,
makeDeleteRequest,
makeGetRequest,
makePostBodyRequest,
PeerTubeServer,
- setAccessTokensToServers
-} from '../../../../shared/extra-utils'
-
-import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination
-} from '../../../../shared/extra-utils/requests/check-api-params'
-import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+ setAccessTokensToServers,
+ waitJobs
+} from '@shared/extra-utils'
+import { HttpStatusCode } from '@shared/models'
describe('Test user subscriptions API validators', function () {
const path = '/api/v1/users/me/subscriptions'
@@ -59,7 +55,7 @@ describe('Test user subscriptions API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -68,7 +64,7 @@ describe('Test user subscriptions API validators', function () {
url: server.url,
path,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -92,7 +88,7 @@ describe('Test user subscriptions API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -101,7 +97,7 @@ describe('Test user subscriptions API validators', function () {
url: server.url,
path,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -112,7 +108,7 @@ describe('Test user subscriptions API validators', function () {
url: server.url,
path,
fields: { uri: 'user1_channel@localhost:' + server.port },
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -122,7 +118,7 @@ describe('Test user subscriptions API validators', function () {
path,
token: server.accessToken,
fields: { uri: 'root' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makePostBodyRequest({
@@ -130,7 +126,7 @@ describe('Test user subscriptions API validators', function () {
path,
token: server.accessToken,
fields: { uri: 'root@' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makePostBodyRequest({
@@ -138,7 +134,7 @@ describe('Test user subscriptions API validators', function () {
path,
token: server.accessToken,
fields: { uri: 'root@hello@' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -150,7 +146,7 @@ describe('Test user subscriptions API validators', function () {
path,
token: server.accessToken,
fields: { uri: 'user1_channel@localhost:' + server.port },
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
await waitJobs([ server ])
@@ -162,7 +158,7 @@ describe('Test user subscriptions API validators', function () {
await makeGetRequest({
url: server.url,
path: path + '/user1_channel@localhost:' + server.port,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -171,21 +167,21 @@ describe('Test user subscriptions API validators', function () {
url: server.url,
path: path + '/root',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makeGetRequest({
url: server.url,
path: path + '/root@',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makeGetRequest({
url: server.url,
path: path + '/root@hello@',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -194,7 +190,7 @@ describe('Test user subscriptions API validators', function () {
url: server.url,
path: path + '/root1@localhost:' + server.port,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -203,7 +199,7 @@ describe('Test user subscriptions API validators', function () {
url: server.url,
path: path + '/user1_channel@localhost:' + server.port,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -215,7 +211,7 @@ describe('Test user subscriptions API validators', function () {
await makeGetRequest({
url: server.url,
path: existPath,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -225,7 +221,7 @@ describe('Test user subscriptions API validators', function () {
path: existPath,
query: { uris: 'toto' },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makeGetRequest({
@@ -233,7 +229,7 @@ describe('Test user subscriptions API validators', function () {
path: existPath,
query: { 'uris[]': 1 },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -243,7 +239,7 @@ describe('Test user subscriptions API validators', function () {
path: existPath,
query: { 'uris[]': 'coucou@localhost:' + server.port },
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -253,7 +249,7 @@ describe('Test user subscriptions API validators', function () {
await makeDeleteRequest({
url: server.url,
path: path + '/user1_channel@localhost:' + server.port,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -262,21 +258,21 @@ describe('Test user subscriptions API validators', function () {
url: server.url,
path: path + '/root',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makeDeleteRequest({
url: server.url,
path: path + '/root@',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makeDeleteRequest({
url: server.url,
path: path + '/root@hello@',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -285,7 +281,7 @@ describe('Test user subscriptions API validators', function () {
url: server.url,
path: path + '/root1@localhost:' + server.port,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -294,7 +290,7 @@ describe('Test user subscriptions API validators', function () {
url: server.url,
path: path + '/user1_channel@localhost:' + server.port,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index c2c98f429e..34fe309f9e 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { omit } from 'lodash'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
buildAbsoluteFixturePath,
checkBadCountPagination,
@@ -103,7 +103,7 @@ describe('Test users API validators', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -112,7 +112,7 @@ describe('Test users API validators', function () {
url: server.url,
path,
token: userToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
})
@@ -210,7 +210,7 @@ describe('Test users API validators', function () {
path: path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
@@ -226,7 +226,7 @@ describe('Test users API validators', function () {
path,
token: 'super token',
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -238,7 +238,7 @@ describe('Test users API validators', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -250,7 +250,7 @@ describe('Test users API validators', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -298,7 +298,7 @@ describe('Test users API validators', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -311,7 +311,7 @@ describe('Test users API validators', function () {
path,
token: moderatorToken,
fields,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
}
})
@@ -324,7 +324,7 @@ describe('Test users API validators', function () {
path,
token: moderatorToken,
fields,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
@@ -334,7 +334,7 @@ describe('Test users API validators', function () {
path,
token: server.accessToken,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
@@ -348,7 +348,7 @@ describe('Test users API validators', function () {
password: 'my super password',
videoQuota: 42000000
}
- await makePostBodyRequest({ url: server.url, path, token: userToken, fields, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
+ await makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
})
@@ -400,7 +400,7 @@ describe('Test users API validators', function () {
path: path + 'me',
token: userToken,
fields,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -447,7 +447,7 @@ describe('Test users API validators', function () {
path: path + 'me',
token: 'super token',
fields,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -525,7 +525,7 @@ describe('Test users API validators', function () {
path: path + 'me',
token: userToken,
fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
@@ -540,7 +540,7 @@ describe('Test users API validators', function () {
path: path + 'me',
token: userToken,
fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -572,7 +572,7 @@ describe('Test users API validators', function () {
path: path + '/me/avatar/pick',
fields,
attaches,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -587,7 +587,7 @@ describe('Test users API validators', function () {
token: server.accessToken,
fields,
attaches,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -627,16 +627,16 @@ describe('Test users API validators', function () {
url: server.url,
path: path + userId,
token: 'super token',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
it('Should fail with a non admin user', async function () {
- await makeGetRequest({ url: server.url, path, token: userToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
+ await makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should succeed with the correct params', async function () {
- await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -702,7 +702,7 @@ describe('Test users API validators', function () {
path: path + userId,
token: 'super token',
fields,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -730,7 +730,7 @@ describe('Test users API validators', function () {
path: path + moderatorId,
token: moderatorToken,
fields,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -744,7 +744,7 @@ describe('Test users API validators', function () {
path: path + userId,
token: moderatorToken,
fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
@@ -761,7 +761,7 @@ describe('Test users API validators', function () {
path: path + userId,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -818,11 +818,11 @@ describe('Test users API validators', function () {
})
it('Should fail with a unauthenticated user', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a another user', async function () {
- await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
+ await makeGetRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
})
it('Should fail with a bad type', async function () {
@@ -831,12 +831,12 @@ describe('Test users API validators', function () {
path,
token: userToken,
query: { rating: 'toto ' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
it('Should succeed with the correct params', async function () {
- await makeGetRequest({ url: server.url, path, token: userToken, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -955,7 +955,7 @@ describe('Test users API validators', function () {
path: registrationPath,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -967,7 +967,7 @@ describe('Test users API validators', function () {
path: registrationPath,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -979,7 +979,7 @@ describe('Test users API validators', function () {
path: registrationPath,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -1019,7 +1019,7 @@ describe('Test users API validators', function () {
path: registrationPath,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -1031,7 +1031,7 @@ describe('Test users API validators', function () {
path: registrationPath,
token: server.accessToken,
fields: fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
@@ -1047,7 +1047,7 @@ describe('Test users API validators', function () {
path: registrationPath,
token: serverWithRegistrationDisabled.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
})
@@ -1081,7 +1081,7 @@ describe('Test users API validators', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -1109,7 +1109,7 @@ describe('Test users API validators', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts
index b5d0e0778f..2072df4b64 100644
--- a/server/tests/api/check-params/video-blacklist.ts
+++ b/server/tests/api/check-params/video-blacklist.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
BlacklistCommand,
checkBadCountPagination,
@@ -88,7 +88,7 @@ describe('Test video blacklist API validators', function () {
it('Should fail with a non authenticated user', async function () {
const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
- await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a non admin user', async function () {
@@ -99,7 +99,7 @@ describe('Test video blacklist API validators', function () {
path,
token: userAccessToken2,
fields,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -119,7 +119,7 @@ describe('Test video blacklist API validators', function () {
path,
token: servers[0].accessToken,
fields,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -132,7 +132,7 @@ describe('Test video blacklist API validators', function () {
path,
token: servers[0].accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -154,14 +154,14 @@ describe('Test video blacklist API validators', function () {
path,
token: servers[0].accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
it('Should fail with a non authenticated user', async function () {
const path = basePath + servers[0].store.video + '/blacklist'
const fields = {}
- await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a non admin user', async function () {
@@ -172,7 +172,7 @@ describe('Test video blacklist API validators', function () {
path,
token: userAccessToken2,
fields,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -192,7 +192,7 @@ describe('Test video blacklist API validators', function () {
path,
token: servers[0].accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts
index 26aab79e78..1b3d1aa951 100644
--- a/server/tests/api/check-params/video-captions.ts
+++ b/server/tests/api/check-params/video-captions.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
buildAbsoluteFixturePath,
cleanupTests,
@@ -67,7 +67,7 @@ describe('Test video captions API validator', function () {
token: server.accessToken,
fields,
attaches,
- statusCodeExpected: 404
+ expectedStatus: 404
})
})
@@ -103,7 +103,7 @@ describe('Test video captions API validator', function () {
path: captionPath,
fields,
attaches,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -116,7 +116,7 @@ describe('Test video captions API validator', function () {
token: 'blabla',
fields,
attaches,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -134,7 +134,7 @@ describe('Test video captions API validator', function () {
// token: server.accessToken,
// fields,
// attaches,
- // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ // expectedStatus: HttpStatusCode.BAD_REQUEST_400
// })
// })
@@ -147,7 +147,7 @@ describe('Test video captions API validator', function () {
// videoId: video.uuid,
// fixture: 'subtitle-bad.txt',
// mimeType: 'application/octet-stream',
- // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ // expectedStatus: HttpStatusCode.BAD_REQUEST_400
// })
// })
@@ -174,7 +174,7 @@ describe('Test video captions API validator', function () {
// token: server.accessToken,
// fields,
// attaches,
- // statusCodeExpected: HttpStatusCode.INTERNAL_SERVER_ERROR_500
+ // expectedStatus: HttpStatusCode.INTERNAL_SERVER_ERROR_500
// })
// })
@@ -187,7 +187,7 @@ describe('Test video captions API validator', function () {
token: server.accessToken,
fields,
attaches,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -201,12 +201,12 @@ describe('Test video captions API validator', function () {
await makeGetRequest({
url: server.url,
path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -224,7 +224,7 @@ describe('Test video captions API validator', function () {
url: server.url,
path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr',
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -248,12 +248,12 @@ describe('Test video captions API validator', function () {
it('Should fail without access token', async function () {
const captionPath = path + video.shortUUID + '/captions/fr'
- await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makeDeleteRequest({ url: server.url, path: captionPath, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a bad access token', async function () {
const captionPath = path + video.shortUUID + '/captions/fr'
- await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with another user', async function () {
@@ -262,7 +262,7 @@ describe('Test video captions API validator', function () {
url: server.url,
path: captionPath,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -272,7 +272,7 @@ describe('Test video captions API validator', function () {
url: server.url,
path: captionPath,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts
index 62b8fa4f6e..bbe42e43df 100644
--- a/server/tests/api/check-params/video-channels.ts
+++ b/server/tests/api/check-params/video-channels.ts
@@ -3,7 +3,7 @@
import 'mocha'
import * as chai from 'chai'
import { omit } from 'lodash'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
buildAbsoluteFixturePath,
ChannelsCommand,
@@ -88,7 +88,7 @@ describe('Test video channels API validator', function () {
await makeGetRequest({
url: server.url,
path: accountChannelPath,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -107,7 +107,7 @@ describe('Test video channels API validator', function () {
path: videoChannelPath,
token: 'none',
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -152,7 +152,7 @@ describe('Test video channels API validator', function () {
path: videoChannelPath,
token: server.accessToken,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
@@ -162,7 +162,7 @@ describe('Test video channels API validator', function () {
path: videoChannelPath,
token: server.accessToken,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
})
@@ -186,7 +186,7 @@ describe('Test video channels API validator', function () {
path,
token: 'hi',
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -196,7 +196,7 @@ describe('Test video channels API validator', function () {
path,
token: accessTokenUser,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -226,7 +226,7 @@ describe('Test video channels API validator', function () {
path,
token: server.accessToken,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -271,7 +271,7 @@ describe('Test video channels API validator', function () {
path: `${path}/${type}/pick`,
fields,
attaches,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
}
})
@@ -288,7 +288,7 @@ describe('Test video channels API validator', function () {
token: server.accessToken,
fields,
attaches,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
}
})
@@ -299,7 +299,7 @@ describe('Test video channels API validator', function () {
const res = await makeGetRequest({
url: server.url,
path: videoChannelPath,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.data).to.be.an('array')
@@ -309,7 +309,7 @@ describe('Test video channels API validator', function () {
await makeGetRequest({
url: server.url,
path: videoChannelPath + '/super_channel2',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -317,7 +317,7 @@ describe('Test video channels API validator', function () {
await makeGetRequest({
url: server.url,
path: videoChannelPath + '/super_channel',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts
index 92c29da0e7..bfd9e01723 100644
--- a/server/tests/api/check-params/video-comments.ts
+++ b/server/tests/api/check-params/video-comments.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkBadCountPagination,
checkBadSortPagination,
@@ -78,7 +78,7 @@ describe('Test video comments API validator', function () {
await makeGetRequest({
url: server.url,
path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
})
@@ -88,7 +88,7 @@ describe('Test video comments API validator', function () {
await makeGetRequest({
url: server.url,
path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads/' + commentId,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -96,7 +96,7 @@ describe('Test video comments API validator', function () {
await makeGetRequest({
url: server.url,
path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -104,7 +104,7 @@ describe('Test video comments API validator', function () {
await makeGetRequest({
url: server.url,
path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -120,7 +120,7 @@ describe('Test video comments API validator', function () {
path: pathThread,
token: 'none',
fields,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -153,7 +153,7 @@ describe('Test video comments API validator', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -166,7 +166,7 @@ describe('Test video comments API validator', function () {
path: pathThread,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
@@ -181,7 +181,7 @@ describe('Test video comments API validator', function () {
path: pathComment,
token: 'none',
fields,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -214,7 +214,7 @@ describe('Test video comments API validator', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -228,7 +228,7 @@ describe('Test video comments API validator', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -241,14 +241,14 @@ describe('Test video comments API validator', function () {
path: pathComment,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
describe('When removing video comments', function () {
it('Should fail with a non authenticated user', async function () {
- await makeDeleteRequest({ url: server.url, path: pathComment, token: 'none', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makeDeleteRequest({ url: server.url, path: pathComment, token: 'none', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with another user', async function () {
@@ -256,18 +256,18 @@ describe('Test video comments API validator', function () {
url: server.url,
path: pathComment,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
it('Should fail with an incorrect video', async function () {
const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comments/' + commentId
- await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
+ await makeDeleteRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Should fail with an incorrect comment', async function () {
const path = '/api/v1/videos/' + video.uuid + '/comments/124'
- await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 })
+ await makeDeleteRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 })
})
it('Should succeed with the same user', async function () {
@@ -280,8 +280,8 @@ describe('Test video comments API validator', function () {
const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete
- await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
- await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 })
+ await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await makeDeleteRequest({ url: server.url, path, token: userAccessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
})
it('Should succeed with the owner of the video', async function () {
@@ -300,8 +300,8 @@ describe('Test video comments API validator', function () {
const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete
- await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 })
- await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 })
+ await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 })
+ await makeDeleteRequest({ url: server.url, path, token: userAccessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 })
})
it('Should succeed with the correct parameters', async function () {
@@ -309,7 +309,7 @@ describe('Test video comments API validator', function () {
url: server.url,
path: pathComment,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -324,7 +324,7 @@ describe('Test video comments API validator', function () {
const res = await makeGetRequest({
url: server.url,
path: pathThread,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.total).to.equal(0)
expect(res.body.data).to.have.lengthOf(0)
@@ -341,7 +341,7 @@ describe('Test video comments API validator', function () {
path: pathThread,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -367,7 +367,7 @@ describe('Test video comments API validator', function () {
await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -376,7 +376,7 @@ describe('Test video comments API validator', function () {
url: server.url,
path,
token: userAccessToken,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -391,7 +391,7 @@ describe('Test video comments API validator', function () {
searchAccount: 'toto',
searchVideo: 'toto'
},
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts
index 0209275ac8..957556c9b6 100644
--- a/server/tests/api/check-params/video-imports.ts
+++ b/server/tests/api/check-params/video-imports.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { omit } from 'lodash'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
buildAbsoluteFixturePath,
checkBadCountPagination,
@@ -61,7 +61,7 @@ describe('Test video imports API validator', function () {
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path: myPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken })
+ await makeGetRequest({ url: server.url, path: myPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken })
})
})
@@ -99,7 +99,7 @@ describe('Test video imports API validator', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -251,7 +251,7 @@ describe('Test video imports API validator', function () {
path,
token: server.accessToken,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
@@ -276,7 +276,7 @@ describe('Test video imports API validator', function () {
path,
token: server.accessToken,
fields: baseCorrectParams,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
@@ -304,7 +304,7 @@ describe('Test video imports API validator', function () {
path,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
fields = omit(fields, 'magnetUri')
@@ -318,7 +318,7 @@ describe('Test video imports API validator', function () {
token: server.accessToken,
fields,
attaches,
- statusCodeExpected: HttpStatusCode.CONFLICT_409
+ expectedStatus: HttpStatusCode.CONFLICT_409
})
})
})
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts
index 9d054b1765..7dcb4935a3 100644
--- a/server/tests/api/check-params/video-playlists.ts
+++ b/server/tests/api/check-params/video-playlists.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkBadCountPagination,
checkBadSortPagination,
@@ -119,7 +119,7 @@ describe('Test video playlists API validator', function () {
await makeGetRequest({
url: server.url,
path: accountPath,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404,
+ expectedStatus: HttpStatusCode.NOT_FOUND_404,
token: server.accessToken
})
})
@@ -130,18 +130,18 @@ describe('Test video playlists API validator', function () {
await makeGetRequest({
url: server.url,
path: accountPath,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404,
+ expectedStatus: HttpStatusCode.NOT_FOUND_404,
token: server.accessToken
})
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path: globalPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken })
- await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken })
+ await makeGetRequest({ url: server.url, path: globalPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken })
+ await makeGetRequest({ url: server.url, path: accountPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken })
await makeGetRequest({
url: server.url,
path: videoChannelPath,
- statusCodeExpected: HttpStatusCode.OK_200,
+ expectedStatus: HttpStatusCode.OK_200,
token: server.accessToken
})
})
@@ -159,7 +159,7 @@ describe('Test video playlists API validator', function () {
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -580,7 +580,7 @@ describe('Test video playlists API validator', function () {
url: server.url,
path,
query: { videoIds: [ 1, 2 ] },
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
})
})
@@ -613,7 +613,7 @@ describe('Test video playlists API validator', function () {
token: server.accessToken,
path,
query: { videoIds: [ 1, 2 ] },
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
})
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts
index e4e799cc7b..c2c69904f6 100644
--- a/server/tests/api/check-params/videos-filter.ts
+++ b/server/tests/api/check-params/videos-filter.ts
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
@@ -8,11 +9,10 @@ import {
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel
-} from '../../../../shared/extra-utils'
-import { UserRole } from '../../../../shared/models/users'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+} from '@shared/extra-utils'
+import { UserRole } from '@shared/models'
-async function testEndpoints (server: PeerTubeServer, token: string, filter: string, statusCodeExpected: HttpStatusCode) {
+async function testEndpoints (server: PeerTubeServer, token: string, filter: string, expectedStatus: HttpStatusCode) {
const paths = [
'/api/v1/video-channels/root_channel/videos',
'/api/v1/accounts/root/videos',
@@ -28,7 +28,7 @@ async function testEndpoints (server: PeerTubeServer, token: string, filter: str
query: {
filter
},
- statusCodeExpected
+ expectedStatus
})
}
}
@@ -89,7 +89,7 @@ describe('Test video filters validators', function () {
await makeGetRequest({
url: server.url,
path: '/feeds/videos.json',
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401,
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401,
query: {
filter
}
@@ -101,7 +101,7 @@ describe('Test video filters validators', function () {
await makeGetRequest({
url: server.url,
path: '/feeds/videos.json',
- statusCodeExpected: HttpStatusCode.OK_200,
+ expectedStatus: HttpStatusCode.OK_200,
query: {
filter: 'local'
}
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts
index 3c1f479e4e..7283a4d285 100644
--- a/server/tests/api/check-params/videos-history.ts
+++ b/server/tests/api/check-params/videos-history.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkBadCountPagination,
checkBadStartPagination,
@@ -37,7 +37,7 @@ describe('Test videos history API validator', function () {
it('Should fail with an unauthenticated user', async function () {
const fields = { currentTime: 5 }
- await makePutBodyRequest({ url: server.url, path: watchingPath, fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makePutBodyRequest({ url: server.url, path: watchingPath, fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with an incorrect video id', async function () {
@@ -48,7 +48,7 @@ describe('Test videos history API validator', function () {
path,
fields,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -61,7 +61,7 @@ describe('Test videos history API validator', function () {
path,
fields,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -72,7 +72,7 @@ describe('Test videos history API validator', function () {
path: watchingPath,
fields,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -84,7 +84,7 @@ describe('Test videos history API validator', function () {
path: watchingPath,
fields,
token: server.accessToken,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -99,17 +99,17 @@ describe('Test videos history API validator', function () {
})
it('Should fail with an unauthenticated user', async function () {
- await makeGetRequest({ url: server.url, path: myHistoryPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makeGetRequest({ url: server.url, path: myHistoryPath, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should succeed with the correct params', async function () {
- await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, expectedStatus: HttpStatusCode.OK_200 })
})
})
describe('When removing user videos history', function () {
it('Should fail with an unauthenticated user', async function () {
- await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 })
+ await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
})
it('Should fail with a bad beforeDate parameter', async function () {
@@ -119,7 +119,7 @@ describe('Test videos history API validator', function () {
token: server.accessToken,
path: myHistoryRemove,
fields: body,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -130,7 +130,7 @@ describe('Test videos history API validator', function () {
token: server.accessToken,
path: myHistoryRemove,
fields: body,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
@@ -139,7 +139,7 @@ describe('Test videos history API validator', function () {
url: server.url,
token: server.accessToken,
path: myHistoryRemove,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts
index c60de2640e..e11ca0c828 100644
--- a/server/tests/api/check-params/videos.ts
+++ b/server/tests/api/check-params/videos.ts
@@ -4,7 +4,7 @@ import 'mocha'
import * as chai from 'chai'
import { omit } from 'lodash'
import { join } from 'path'
-import { HttpStatusCode, randomInt } from '@shared/core-utils'
+import { randomInt } from '@shared/core-utils'
import {
checkBadCountPagination,
checkBadSortPagination,
@@ -16,11 +16,11 @@ import {
makeGetRequest,
makePutBodyRequest,
makeUploadRequest,
- root,
PeerTubeServer,
+ root,
setAccessTokensToServers
} from '@shared/extra-utils'
-import { PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
+import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
const expect = chai.expect
@@ -69,11 +69,11 @@ describe('Test videos API validator', function () {
})
it('Should fail with a bad skipVideos query', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: 'toto' } })
+ await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: 'toto' } })
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: false } })
+ await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: false } })
})
})
@@ -83,7 +83,7 @@ describe('Test videos API validator', function () {
await makeGetRequest({
url: server.url,
path: join(path, 'search'),
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -100,7 +100,7 @@ describe('Test videos API validator', function () {
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -120,7 +120,7 @@ describe('Test videos API validator', function () {
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -144,7 +144,7 @@ describe('Test videos API validator', function () {
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -168,7 +168,7 @@ describe('Test videos API validator', function () {
})
it('Should success with the correct parameters', async function () {
- await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 })
})
})
@@ -506,7 +506,7 @@ describe('Test videos API validator', function () {
path: path + '4da6fde3-88f7-4d16-b119-108df5630b06',
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -660,7 +660,7 @@ describe('Test videos API validator', function () {
path: path + video.shortUUID,
token: userAccessToken,
fields,
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -692,7 +692,7 @@ describe('Test videos API validator', function () {
path: path + video.shortUUID,
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -702,7 +702,7 @@ describe('Test videos API validator', function () {
const res = await makeGetRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.data).to.be.an('array')
@@ -762,7 +762,7 @@ describe('Test videos API validator', function () {
path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate',
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -782,7 +782,7 @@ describe('Test videos API validator', function () {
path: path + videoId + '/rate',
token: server.accessToken,
fields,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
})
})
@@ -792,7 +792,7 @@ describe('Test videos API validator', function () {
await makeDeleteRequest({
url: server.url,
path,
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -812,7 +812,7 @@ describe('Test videos API validator', function () {
it('Shoud report the appropriate error', async function () {
const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
- const error = body as unknown as PeerTubeProblemDocument
+ const error = body as PeerTubeProblemDocument
expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo')
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts
index d403f27bfd..095c51b979 100644
--- a/server/tests/api/live/live-save-replay.ts
+++ b/server/tests/api/live/live-save-replay.ts
@@ -3,7 +3,7 @@
import 'mocha'
import * as chai from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkLiveCleanup,
cleanupTests,
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts
index 7cfac522cd..88995910c4 100644
--- a/server/tests/api/live/live.ts
+++ b/server/tests/api/live/live.ts
@@ -4,7 +4,7 @@ import 'mocha'
import * as chai from 'chai'
import { join } from 'path'
import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkLiveCleanup,
checkLiveSegmentHash,
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts
index 360b9de35d..8d6360eb3b 100644
--- a/server/tests/api/moderation/abuses.ts
+++ b/server/tests/api/moderation/abuses.ts
@@ -5,8 +5,8 @@ import * as chai from 'chai'
import {
AbusesCommand,
cleanupTests,
- doubleFollow,
createMultipleServers,
+ doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
waitJobs
@@ -65,7 +65,7 @@ describe('Test abuses', function () {
expect(data.length).to.equal(2)
servers[0].store.video = data.find(video => video.name === 'my super name for server 1')
- servers[1].store.video = data.find(video => video.name === 'my super name for server 2')
+ servers[1].store.video = data.find(video => video.name === 'my super name for server 2')
})
it('Should not have abuses', async function () {
@@ -402,8 +402,8 @@ describe('Test abuses', function () {
before(async function () {
this.timeout(50000)
- servers[0].store.video = await await servers[0].videos.quickUpload({ name: 'server 1' })
- servers[1].store.video = await await servers[1].videos.quickUpload({ name: 'server 2' })
+ servers[0].store.video = await servers[0].videos.quickUpload({ name: 'server 1' })
+ servers[1].store.video = await servers[1].videos.quickUpload({ name: 'server 2' })
await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' })
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 217691fb6a..71b93901eb 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 () {
}
}
}
- await await killallServers([ localServer ])
+ await killallServers([ localServer ])
await localServer.run(config)
await uploadWrapper('video 2 server 2')
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts
index 9d5d96efd3..921a488561 100644
--- a/server/tests/api/redundancy/redundancy.ts
+++ b/server/tests/api/redundancy/redundancy.ts
@@ -5,7 +5,7 @@ import * as chai from 'chai'
import { readdir } from 'fs-extra'
import * as magnetUtil from 'magnet-uri'
import { join } from 'path'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkSegmentHash,
checkVideoFilesWereRemoved,
@@ -129,13 +129,13 @@ async function check2Webseeds (videoUUID?: string) {
await makeGetRequest({
url: servers[0].url,
- statusCodeExpected: HttpStatusCode.OK_200,
+ expectedStatus: HttpStatusCode.OK_200,
path: '/static/redundancy/' + `${videoUUID}-${file.resolution.id}.mp4`,
contentType: null
})
await makeGetRequest({
url: servers[1].url,
- statusCodeExpected: HttpStatusCode.OK_200,
+ expectedStatus: HttpStatusCode.OK_200,
path: `/static/webseed/${videoUUID}-${file.resolution.id}.mp4`,
contentType: null
})
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts
index f5896ec255..b33f282663 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 () {
const { total, data } = await servers[0].videos.listByChannel({
token: null,
- videoChannelName: 'channel1_server2@localhost:' + servers[1].port
+ handle: 'channel1_server2@localhost:' + servers[1].port
})
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
@@ -157,7 +157,7 @@ describe('Test ActivityPub video channels search', function () {
it('Should list video channel videos of server 2 with token', async function () {
const { total, data } = await servers[0].videos.listByChannel({
- videoChannelName: 'channel1_server2@localhost:' + servers[1].port
+ handle: 'channel1_server2@localhost:' + servers[1].port
})
expect(total).to.equal(1)
@@ -206,8 +206,8 @@ describe('Test ActivityPub video channels search', function () {
await waitJobs(servers)
- const videoChannelName = 'channel1_server2@localhost:' + servers[1].port
- const { total, data } = await servers[0].videos.listByChannel({ videoChannelName, sort: '-createdAt' })
+ const handle = 'channel1_server2@localhost:' + servers[1].port
+ const { total, data } = await servers[0].videos.listByChannel({ handle, sort: '-createdAt' })
expect(total).to.equal(2)
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 a7191c5efa..a1c2f0f391 100644
--- a/server/tests/api/server/config.ts
+++ b/server/tests/api/server/config.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
@@ -498,7 +498,7 @@ describe('Test config', function () {
const res = await makeGetRequest({
url: server.url,
path: '/api/v1/config',
- statusCodeExpected: 200
+ expectedStatus: 200
})
expect(res.headers['x-frame-options']).to.exist
@@ -517,7 +517,7 @@ describe('Test config', function () {
const res = await makeGetRequest({
url: server.url,
path: '/api/v1/config',
- statusCodeExpected: 200
+ expectedStatus: 200
})
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 f0905bb3b1..fc5d0ad6a4 100644
--- a/server/tests/api/server/contact-form.ts
+++ b/server/tests/api/server/contact-form.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
ContactFormCommand,
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts
index b202cf8a7b..4c5b296ee5 100644
--- a/server/tests/api/server/email.ts
+++ b/server/tests/api/server/email.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
const expect = chai.expect
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts
index 4ed593b767..bd7b215dbd 100644
--- a/server/tests/api/server/follow-constraints.ts
+++ b/server/tests/api/server/follow-constraints.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models'
@@ -54,30 +54,30 @@ describe('Test follow constraints', function () {
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[0].port })
+ const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote account videos', async function () {
- const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[1].port })
+ const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[1].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list local channel videos', async function () {
- const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videos.listByChannel({ videoChannelName })
+ const handle = 'root_channel@localhost:' + servers[0].port
+ const { total, data } = await servers[0].videos.listByChannel({ handle })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote channel videos', async function () {
- const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videos.listByChannel({ videoChannelName })
+ const handle = 'root_channel@localhost:' + servers[1].port
+ const { total, data } = await servers[0].videos.listByChannel({ handle })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -94,30 +94,30 @@ describe('Test follow constraints', function () {
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote account videos', async function () {
- const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list local channel videos', async function () {
- const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
+ const handle = 'root_channel@localhost:' + servers[0].port
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote channel videos', async function () {
- const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
+ const handle = 'root_channel@localhost:' + servers[1].port
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
@@ -158,7 +158,7 @@ describe('Test follow constraints', function () {
it('Should list local account videos', async function () {
const { total, data } = await servers[0].videos.listByAccount({
token: undefined,
- accountName: 'root@localhost:' + servers[0].port
+ handle: 'root@localhost:' + servers[0].port
})
expect(total).to.equal(1)
@@ -168,7 +168,7 @@ describe('Test follow constraints', function () {
it('Should not list remote account videos', async function () {
const { total, data } = await servers[0].videos.listByAccount({
token: undefined,
- accountName: 'root@localhost:' + servers[1].port
+ handle: 'root@localhost:' + servers[1].port
})
expect(total).to.equal(0)
@@ -176,16 +176,16 @@ describe('Test follow constraints', function () {
})
it('Should list local channel videos', async function () {
- const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName })
+ const handle = 'root_channel@localhost:' + servers[0].port
+ const { total, data } = await servers[0].videos.listByChannel({ token: undefined, handle })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should not list remote channel videos', async function () {
- const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName })
+ const handle = 'root_channel@localhost:' + servers[1].port
+ const { total, data } = await servers[0].videos.listByChannel({ token: undefined, handle })
expect(total).to.equal(0)
expect(data).to.have.lengthOf(0)
@@ -202,30 +202,30 @@ describe('Test follow constraints', function () {
})
it('Should list local account videos', async function () {
- const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote account videos', async function () {
- const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port })
+ const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list local channel videos', async function () {
- const videoChannelName = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
+ const handle = 'root_channel@localhost:' + servers[0].port
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
})
it('Should list remote channel videos', async function () {
- const videoChannelName = 'root_channel@localhost:' + servers[1].port
- const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName })
+ const handle = 'root_channel@localhost:' + servers[1].port
+ const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle })
expect(total).to.equal(1)
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 5f20b00931..d22e843e02 100644
--- a/server/tests/api/server/handle-down.ts
+++ b/server/tests/api/server/handle-down.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
CommentsCommand,
diff --git a/server/tests/api/server/homepage.ts b/server/tests/api/server/homepage.ts
index c291037f22..7eae3df200 100644
--- a/server/tests/api/server/homepage.ts
+++ b/server/tests/api/server/homepage.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
CustomPagesCommand,
diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts
index f45222f2f4..efa890ad4f 100644
--- a/server/tests/api/server/no-client.ts
+++ b/server/tests/api/server/no-client.ts
@@ -1,8 +1,7 @@
import 'mocha'
import * as request from 'supertest'
-import { PeerTubeServer } from '../../../../shared/extra-utils'
-import { cleanupTests, createSingleServer } from '../../../../shared/extra-utils/server/servers'
-import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
+import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/extra-utils'
+import { HttpStatusCode } from '@shared/models'
describe('Start and stop server without web client routes', function () {
let server: PeerTubeServer
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts
index db03d026a7..334adfe9d5 100644
--- a/server/tests/api/server/plugins.ts
+++ b/server/tests/api/server/plugins.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts
index c20b7a5f0f..13b22bc0ec 100644
--- a/server/tests/api/server/reverse-proxy.ts
+++ b/server/tests/api/server/reverse-proxy.ts
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils'
describe('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 e629966bb1..e304e5d67f 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 () {
it('Should list account videos', async function () {
for (const server of servers) {
- const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port })
+ const { total, data } = await server.videos.listByAccount({ handle: 'user1@localhost:' + servers[0].port })
expect(total).to.equal(1)
expect(data).to.be.an('array')
@@ -148,7 +148,7 @@ describe('Test users with multiple servers', function () {
await waitJobs(servers)
for (const server of servers) {
- const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port, search: 'Kami' })
+ const { total, data } = await server.videos.listByAccount({ handle: 'user1@localhost:' + servers[0].port, search: 'Kami' })
expect(total).to.equal(1)
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 5dbe2af598..56fc25048e 100644
--- a/server/tests/api/users/users-verification.ts
+++ b/server/tests/api/users/users-verification.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
const expect = chai.expect
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 6ae5410b37..be80c26165 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
@@ -215,7 +215,7 @@ describe('Test users', function () {
path: path + videoId,
token: 'wrong token',
fields: data,
- statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
}
await makePutBodyRequest(options)
})
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 562079a154..edf2773cd4 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -3,7 +3,7 @@
import 'mocha'
import * as chai from 'chai'
import * as request from 'supertest'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
buildAbsoluteFixturePath,
checkTmpIsEmpty,
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts
index b4fc5ee09a..0e62972c26 100644
--- a/server/tests/api/videos/resumable-upload.ts
+++ b/server/tests/api/videos/resumable-upload.ts
@@ -4,7 +4,7 @@ import 'mocha'
import * as chai from 'chai'
import { pathExists, readdir, stat } from 'fs-extra'
import { join } from 'path'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
buildAbsoluteFixturePath,
cleanupTests,
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts
index cefddb68ee..792550101c 100644
--- a/server/tests/api/videos/video-change-ownership.ts
+++ b/server/tests/api/videos/video-change-ownership.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
ChangeOwnershipCommand,
cleanupTests,
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts
index 140fee7fed..eeaec5ad29 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 () {
for (const server of servers) {
const channelURI = 'second_video_channel@localhost:' + servers[0].port
- const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI })
+ const { total, data } = await server.videos.listByChannel({ handle: channelURI })
expect(total).to.equal(1)
expect(data).to.be.an('array')
@@ -347,13 +347,13 @@ describe('Test video channels', function () {
for (const server of servers) {
{
const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port
- const { total } = await server.videos.listByChannel({ videoChannelName: secondChannelURI })
+ const { total } = await server.videos.listByChannel({ handle: secondChannelURI })
expect(total).to.equal(0)
}
{
const channelURI = 'root_channel@localhost:' + servers[0].port
- const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI })
+ const { total, data } = await server.videos.listByChannel({ handle: channelURI })
expect(total).to.equal(1)
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 4c4b188871..df030110b9 100644
--- a/server/tests/api/videos/video-hls.ts
+++ b/server/tests/api/videos/video-hls.ts
@@ -3,7 +3,7 @@
import 'mocha'
import * as chai from 'chai'
import { join } from 'path'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkDirectoryIsEmpty,
checkResolutionsInMasterPlaylist,
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts
index b25dcda204..0a9e5ce3fa 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 () {
async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) {
const user = await server.users.getMyInfo()
- const videoChannelName = user.videoChannels[0].name
+
+ const channelName = user.videoChannels[0].name
const accountName = user.account.name + '@' + user.account.host
+
const hasQuery = Object.keys(query).length !== 0
let promises: Promise<ResultList<Video>>[]
@@ -28,8 +30,8 @@ describe('Test video NSFW policy', function () {
promises = [
server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }),
server.videos.listWithToken({ token, ...query }),
- server.videos.listByAccount({ token, accountName, ...query }),
- server.videos.listByChannel({ token, videoChannelName, ...query })
+ server.videos.listByAccount({ token, handle: channelName, ...query }),
+ server.videos.listByChannel({ token, handle: accountName, ...query })
]
// Overviews do not support video filters
@@ -45,8 +47,8 @@ describe('Test video NSFW policy', function () {
promises = [
server.search.searchVideos({ search: 'n', sort: '-publishedAt' }),
server.videos.list(),
- server.videos.listByAccount({ accountName }),
- server.videos.listByChannel({ videoChannelName })
+ server.videos.listByAccount({ handle: channelName }),
+ server.videos.listByChannel({ handle: accountName })
]
// 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 71ca3e63ab..9a28a421ad 100644
--- a/server/tests/api/videos/video-playlists.ts
+++ b/server/tests/api/videos/video-playlists.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkPlaylistFilesWereRemoved,
cleanupTests,
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts
index 5ec6261555..06011082d2 100644
--- a/server/tests/api/videos/video-privacy.ts
+++ b/server/tests/api/videos/video-privacy.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { cleanupTests, doubleFollow, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils'
import { VideoCreateResult, VideoPrivacy } from '@shared/models'
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts
index 2465d2d89a..7510472e3f 100644
--- a/server/tests/api/videos/video-transcoder.ts
+++ b/server/tests/api/videos/video-transcoder.ts
@@ -4,7 +4,7 @@ import 'mocha'
import * as chai from 'chai'
import { omit } from 'lodash'
import { join } from 'path'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
buildAbsoluteFixturePath,
cleanupTests,
@@ -384,8 +384,8 @@ describe('Test video transcoding', function () {
expect(videoDetails.files).to.have.lengthOf(1)
- await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 })
- await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: HttpStatusCode.OK_200 })
const magnetUri = videoDetails.files[0].magnetUri
expect(magnetUri).to.contain('.mp4')
@@ -408,8 +408,8 @@ describe('Test video transcoding', function () {
expect(videoDetails.files).to.have.lengthOf(1)
- await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 })
- await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 })
+ await makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: HttpStatusCode.OK_200 })
const magnetUri = videoDetails.files[0].magnetUri
expect(magnetUri).to.contain('.mp4')
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts
index db91506557..88dff3e7f7 100644
--- a/server/tests/api/videos/videos-filter.ts
+++ b/server/tests/api/videos/videos-filter.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
doubleFollow,
@@ -13,7 +13,7 @@ import {
} from '@shared/extra-utils'
import { UserRole, Video, VideoPrivacy } from '@shared/models'
-async function getVideosNames (server: PeerTubeServer, token: string, filter: string, statusCodeExpected = HttpStatusCode.OK_200) {
+async function getVideosNames (server: PeerTubeServer, token: string, filter: string, expectedStatus = HttpStatusCode.OK_200) {
const paths = [
'/api/v1/video-channels/root_channel/videos',
'/api/v1/accounts/root/videos',
@@ -32,7 +32,7 @@ async function getVideosNames (server: PeerTubeServer, token: string, filter: st
sort: 'createdAt',
filter
},
- statusCodeExpected
+ expectedStatus
})
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 55e53cb942..acb9d1a461 100644
--- a/server/tests/api/videos/videos-history.ts
+++ b/server/tests/api/videos/videos-history.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts
index 5bf86462b4..2bd4a466b8 100644
--- a/server/tests/cli/prune-storage.ts
+++ b/server/tests/cli/prune-storage.ts
@@ -5,7 +5,7 @@ import * as chai from 'chai'
import { createFile, readdir } from 'fs-extra'
import { join } from 'path'
import { buildUUID } from '@server/helpers/uuid'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
CLICommand,
@@ -91,7 +91,7 @@ describe('Test prune storage scripts', function () {
await makeGetRequest({
url: servers[0].url,
path: account.avatar.path,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
}
@@ -100,7 +100,7 @@ describe('Test prune storage scripts', function () {
await makeGetRequest({
url: servers[1].url,
path: account.avatar.path,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
}
diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts
index d532a5c2b5..595d842ef3 100644
--- a/server/tests/cli/regenerate-thumbnails.ts
+++ b/server/tests/cli/regenerate-thumbnails.ts
@@ -2,7 +2,7 @@ import 'mocha'
import { expect } from 'chai'
import { writeFile } from 'fs-extra'
import { basename, join } from 'path'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { Video } from '@shared/models'
import {
cleanupTests,
diff --git a/server/tests/client.ts b/server/tests/client.ts
index 959b346538..6255c69612 100644
--- a/server/tests/client.ts
+++ b/server/tests/client.ts
@@ -3,7 +3,7 @@
import 'mocha'
import * as chai from 'chai'
import { omit } from 'lodash'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { Account, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models'
import {
cleanupTests,
@@ -114,7 +114,7 @@ describe('Test a client controllers', function () {
url: servers[0].url,
path: basePath + id,
accept: 'text/html',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
const port = servers[0].port
@@ -135,7 +135,7 @@ describe('Test a client controllers', function () {
url: servers[0].url,
path: basePath + id,
accept: 'text/html',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
const port = servers[0].port
@@ -153,7 +153,7 @@ describe('Test a client controllers', function () {
describe('Open Graph', function () {
async function accountPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`)
@@ -163,7 +163,7 @@ describe('Test a client controllers', function () {
}
async function channelPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain(`<meta property="og:title" content="${servers[0].store.channel.displayName}" />`)
@@ -173,7 +173,7 @@ describe('Test a client controllers', function () {
}
async function watchVideoPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`)
@@ -183,7 +183,7 @@ describe('Test a client controllers', function () {
}
async function watchPlaylistPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain(`<meta property="og:title" content="${playlistName}" />`)
@@ -226,7 +226,7 @@ describe('Test a client controllers', function () {
describe('Not whitelisted', function () {
async function accountPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('<meta property="twitter:card" content="summary" />')
@@ -236,7 +236,7 @@ describe('Test a client controllers', function () {
}
async function channelPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('<meta property="twitter:card" content="summary" />')
@@ -246,7 +246,7 @@ describe('Test a client controllers', function () {
}
async function watchVideoPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('<meta property="twitter:card" content="summary_large_image" />')
@@ -256,7 +256,7 @@ describe('Test a client controllers', function () {
}
async function watchPlaylistPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('<meta property="twitter:card" content="summary" />')
@@ -307,7 +307,7 @@ describe('Test a client controllers', function () {
})
async function accountPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('<meta property="twitter:card" content="summary" />')
@@ -315,7 +315,7 @@ describe('Test a client controllers', function () {
}
async function channelPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('<meta property="twitter:card" content="summary" />')
@@ -323,7 +323,7 @@ describe('Test a client controllers', function () {
}
async function watchVideoPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
expect(text).to.contain('<meta property="twitter:card" content="player" />')
@@ -331,7 +331,7 @@ describe('Test a client controllers', function () {
}
async function watchPlaylistPageTest (path: string) {
- const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 })
+ const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 })
const text = res.text
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 aaaf232783..12b4a1b8d2 100644
--- a/server/tests/external-plugins/auth-ldap.ts
+++ b/server/tests/external-plugins/auth-ldap.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
describe('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 9cb86310b1..78b13eded7 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 () {
blocklistServer = new MockBlocklist()
port = await blocklistServer.initialize()
- await await servers[0].videos.quickUpload({ name: 'video server 1' })
- await await servers[1].videos.quickUpload({ name: 'video server 2' })
- await await servers[1].videos.quickUpload({ name: 'video 2 server 2' })
- await await servers[1].videos.quickUpload({ name: 'video 3 server 2' })
+ await servers[0].videos.quickUpload({ name: 'video server 1' })
+ await servers[1].videos.quickUpload({ name: 'video server 2' })
+ await servers[1].videos.quickUpload({ name: 'video 2 server 2' })
+ await servers[1].videos.quickUpload({ name: 'video 3 server 2' })
{
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 7712015056..b2046313b5 100644
--- a/server/tests/external-plugins/auto-mute.ts
+++ b/server/tests/external-plugins/auto-mute.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
doubleFollow,
@@ -34,8 +34,8 @@ describe('Official plugin auto-mute', function () {
blocklistServer = new MockBlocklist()
port = await blocklistServer.initialize()
- await await servers[0].videos.quickUpload({ name: 'video server 1' })
- await await servers[1].videos.quickUpload({ name: 'video server 2' })
+ await servers[0].videos.quickUpload({ name: 'video server 1' })
+ await servers[1].videos.quickUpload({ name: 'video server 2' })
await doubleFollow(servers[0], servers[1])
})
@@ -162,7 +162,7 @@ describe('Official plugin auto-mute', function () {
await makeGetRequest({
url: servers[0].url,
path: '/plugins/auto-mute/router/api/v1/mute-list',
- statusCodeExpected: HttpStatusCode.FORBIDDEN_403
+ expectedStatus: HttpStatusCode.FORBIDDEN_403
})
})
@@ -179,7 +179,7 @@ describe('Official plugin auto-mute', function () {
await makeGetRequest({
url: servers[0].url,
path: '/plugins/auto-mute/router/api/v1/mute-list',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
})
@@ -201,7 +201,7 @@ describe('Official plugin auto-mute', function () {
const res = await makeGetRequest({
url: servers[0].url,
path: '/plugins/auto-mute/router/api/v1/mute-list',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
const data = res.body.data
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts
index 7735299d32..543c431ddc 100644
--- a/server/tests/feeds/feeds.ts
+++ b/server/tests/feeds/feeds.ts
@@ -3,7 +3,7 @@
import 'mocha'
import * as chai from 'chai'
import * as xmlParser from 'fast-xml-parser'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
doubleFollow,
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts
index a4f344fcc4..4d9c07f1a8 100644
--- a/server/tests/misc-endpoints.ts
+++ b/server/tests/misc-endpoints.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
import { VideoPrivacy } from '@shared/models'
@@ -24,7 +24,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/.well-known/security.txt',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.text).to.contain('security issue')
@@ -34,7 +34,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/.well-known/nodeinfo',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.links).to.be.an('array')
@@ -46,7 +46,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/.well-known/dnt-policy.txt',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.text).to.contain('http://www.w3.org/TR/tracking-dnt')
@@ -56,7 +56,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/.well-known/dnt',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.tracking).to.equal('N')
@@ -66,7 +66,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/.well-known/change-password',
- statusCodeExpected: HttpStatusCode.FOUND_302
+ expectedStatus: HttpStatusCode.FOUND_302
})
expect(res.header.location).to.equal('/my-account/settings')
@@ -79,7 +79,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/.well-known/webfinger?resource=' + resource,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
const data = res.body
@@ -104,7 +104,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/robots.txt',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.text).to.contain('User-agent')
@@ -114,7 +114,7 @@ describe('Test misc endpoints', function () {
await makeGetRequest({
url: server.url,
path: '/security.txt',
- statusCodeExpected: HttpStatusCode.MOVED_PERMANENTLY_301
+ expectedStatus: HttpStatusCode.MOVED_PERMANENTLY_301
})
})
@@ -122,7 +122,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/nodeinfo/2.0.json',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.software.name).to.equal('peertube')
@@ -137,7 +137,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/sitemap.xml',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"')
@@ -148,7 +148,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/sitemap.xml',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"')
@@ -171,7 +171,7 @@ describe('Test misc endpoints', function () {
const res = await makeGetRequest({
url: server.url,
path: '/sitemap.xml?t=1', // avoid using cache
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
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 c0834a14c5..a2828603a6 100644
--- a/server/tests/plugins/external-auth.ts
+++ b/server/tests/plugins/external-auth.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
decodeQueryString,
@@ -20,15 +20,15 @@ async function loginExternal (options: {
authName: string
username: string
query?: any
- statusCodeExpected?: HttpStatusCode
- statusCodeExpectedStep2?: HttpStatusCode
+ expectedStatus?: HttpStatusCode
+ expectedStatusStep2?: HttpStatusCode
}) {
const res = await options.server.plugins.getExternalAuth({
npmName: options.npmName,
npmVersion: '0.0.1',
authName: options.authName,
query: options.query,
- expectedStatus: options.statusCodeExpected || HttpStatusCode.FOUND_302
+ expectedStatus: options.expectedStatus || HttpStatusCode.FOUND_302
})
if (res.status !== HttpStatusCode.FOUND_302) return
@@ -39,7 +39,7 @@ async function loginExternal (options: {
const resLogin = await options.server.login.loginUsingExternalToken({
username: options.username,
externalAuthToken: externalAuthToken as string,
- expectedStatus: options.statusCodeExpectedStep2
+ expectedStatus: options.expectedStatusStep2
})
return resLogin.body
@@ -268,7 +268,7 @@ describe('Test external auth plugins', function () {
username: 'kefka'
},
username: 'kefka',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -293,7 +293,7 @@ describe('Test external auth plugins', function () {
username: 'cyan'
},
username: 'cyan',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
@@ -307,7 +307,7 @@ describe('Test external auth plugins', function () {
npmName: 'test-external-auth-two',
authName: 'external-auth-4',
username: 'kefka2',
- statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400
+ expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
})
await loginExternal({
@@ -315,7 +315,7 @@ describe('Test external auth plugins', function () {
npmName: 'test-external-auth-two',
authName: 'external-auth-4',
username: 'kefka',
- statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400
+ expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
})
})
@@ -327,7 +327,7 @@ describe('Test external auth plugins', function () {
npmName: 'test-external-auth-two',
authName: 'external-auth-6',
username: 'existing_user',
- statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400
+ expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
})
})
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts
index df52bb3b57..ba84dd27a1 100644
--- a/server/tests/plugins/filter-hooks.ts
+++ b/server/tests/plugins/filter-hooks.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
@@ -71,28 +71,28 @@ describe('Test plugin filter hooks', function () {
})
it('Should run filter:api.accounts.videos.list.params', async function () {
- const { data } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 })
+ const { data } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 })
// 1 plugin do +1 to the count parameter
expect(data).to.have.lengthOf(3)
})
it('Should run filter:api.accounts.videos.list.result', async function () {
- const { total } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 })
+ const { total } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 })
// Plugin do +2 to the total result
expect(total).to.equal(12)
})
it('Should run filter:api.video-channels.videos.list.params', async function () {
- const { data } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
+ const { data } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 })
// 1 plugin do +3 to the count parameter
expect(data).to.have.lengthOf(5)
})
it('Should run filter:api.video-channels.videos.list.result', async function () {
- const { total } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 })
+ const { total } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 })
// Plugin do +3 to the total result
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 981bcad912..a73d76caac 100644
--- a/server/tests/plugins/id-and-pass-auth.ts
+++ b/server/tests/plugins/id-and-pass-auth.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils'
import { UserRole } from '@shared/models'
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index 1d87b84ae6..5cb664bda3 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
checkVideoFilesWereRemoved,
cleanupTests,
@@ -24,7 +24,7 @@ function postCommand (server: PeerTubeServer, command: string, bodyArg?: object)
url: server.url,
path: '/plugins/test-four/router/commander',
fields: body,
- statusCodeExpected: HttpStatusCode.NO_CONTENT_204
+ expectedStatus: HttpStatusCode.NO_CONTENT_204
})
}
@@ -67,7 +67,7 @@ describe('Test plugin helpers', function () {
const res = await makeGetRequest({
url: servers[0].url,
path: '/plugins/test-four/router/server-config',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.serverConfig).to.exist
@@ -88,7 +88,7 @@ describe('Test plugin helpers', function () {
const res = await makeGetRequest({
url: servers[0].url,
path: '/plugins/test-four/router/static-route',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.staticRoute).to.equal('/plugins/test-four/0.0.1/static/')
@@ -100,7 +100,7 @@ describe('Test plugin helpers', function () {
const res = await makeGetRequest({
url: servers[0].url,
path: baseRouter + 'router-route',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.routerRoute).to.equal(baseRouter)
@@ -113,7 +113,7 @@ describe('Test plugin helpers', function () {
await makeGetRequest({
url: servers[0].url,
path: '/plugins/test-four/router/user',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -122,7 +122,7 @@ describe('Test plugin helpers', function () {
url: servers[0].url,
token: servers[0].accessToken,
path: '/plugins/test-four/router/user',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.username).to.equal('root')
@@ -140,12 +140,12 @@ describe('Test plugin helpers', function () {
this.timeout(60000)
{
- const res = await await servers[0].videos.quickUpload({ name: 'video server 1' })
+ const res = await servers[0].videos.quickUpload({ name: 'video server 1' })
videoUUIDServer1 = res.uuid
}
{
- await await servers[1].videos.quickUpload({ name: 'video server 2' })
+ await servers[1].videos.quickUpload({ name: 'video server 2' })
}
await waitJobs(servers)
@@ -224,7 +224,7 @@ describe('Test plugin helpers', function () {
let videoUUID: string
before(async () => {
- const res = await await servers[0].videos.quickUpload({ name: 'video1' })
+ const res = await servers[0].videos.quickUpload({ name: 'video1' })
videoUUID = res.uuid
})
diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts
index dec8ca4bbf..becb7c47bf 100644
--- a/server/tests/plugins/plugin-router.ts
+++ b/server/tests/plugins/plugin-router.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
@@ -34,7 +34,7 @@ describe('Test plugin helpers', function () {
const res = await makeGetRequest({
url: server.url,
path: path + 'ping',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.message).to.equal('pong')
@@ -47,7 +47,7 @@ describe('Test plugin helpers', function () {
url: server.url,
path: path + 'is-authenticated',
token: server.accessToken,
- statusCodeExpected: 200
+ expectedStatus: 200
})
expect(res.body.isAuthenticated).to.equal(true)
@@ -55,7 +55,7 @@ describe('Test plugin helpers', function () {
const secRes = await makeGetRequest({
url: server.url,
path: path + 'is-authenticated',
- statusCodeExpected: 200
+ expectedStatus: 200
})
expect(secRes.body.isAuthenticated).to.equal(false)
@@ -74,7 +74,7 @@ describe('Test plugin helpers', function () {
url: server.url,
path: path + 'form/post/mirror',
fields: body,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body).to.deep.equal(body)
@@ -88,14 +88,14 @@ describe('Test plugin helpers', function () {
await makeGetRequest({
url: server.url,
path: path + 'ping',
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
await makePostBodyRequest({
url: server.url,
path: path + 'ping',
fields: {},
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
}
})
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts
index 5745914a53..90dafa3e1c 100644
--- a/server/tests/plugins/plugin-storage.ts
+++ b/server/tests/plugins/plugin-storage.ts
@@ -4,7 +4,7 @@ import 'mocha'
import { expect } from 'chai'
import { pathExists, readdir, readFile } from 'fs-extra'
import { join } from 'path'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
@@ -63,7 +63,7 @@ describe('Test plugin storage', function () {
url: server.url,
token: server.accessToken,
path: '/plugins/test-six/router/create-file',
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
const content = await getFileContent()
diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts
index 6c405b7f5e..faf9cc5994 100644
--- a/server/tests/plugins/plugin-unloading.ts
+++ b/server/tests/plugins/plugin-unloading.ts
@@ -2,7 +2,7 @@
import 'mocha'
import { expect } from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
@@ -30,7 +30,7 @@ describe('Test plugins module unloading', function () {
const res = await makeGetRequest({
url: server.url,
path: requestPath,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.message).to.match(/^\d+$/)
@@ -41,7 +41,7 @@ describe('Test plugins module unloading', function () {
const res = await makeGetRequest({
url: server.url,
path: requestPath,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.message).to.be.equal(value)
@@ -53,7 +53,7 @@ describe('Test plugins module unloading', function () {
await makeGetRequest({
url: server.url,
path: requestPath,
- statusCodeExpected: HttpStatusCode.NOT_FOUND_404
+ expectedStatus: HttpStatusCode.NOT_FOUND_404
})
})
@@ -63,7 +63,7 @@ describe('Test plugins module unloading', function () {
const res = await makeGetRequest({
url: server.url,
path: requestPath,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
expect(res.body.message).to.match(/^\d+$/)
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts
index 953916e8ec..dd3b40225e 100644
--- a/server/tests/plugins/video-constants.ts
+++ b/server/tests/plugins/video-constants.ts
@@ -2,7 +2,7 @@
import 'mocha'
import * as chai from 'chai'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils'
import { VideoPlaylistPrivacy } from '@shared/models'
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts
index 5fda68c8e6..bcaae63a3c 100644
--- a/server/tools/peertube-redundancy.ts
+++ b/server/tools/peertube-redundancy.ts
@@ -6,7 +6,7 @@ import { Command, program } from 'commander'
import { uniq } from 'lodash'
import { URL } from 'url'
import validator from 'validator'
-import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { VideoRedundanciesTarget } from '@shared/models'
import { assignToken, buildServer, getServerCredentials } from './cli'
diff --git a/server/typings/express/index.d.ts b/server/typings/express/index.d.ts
index 1a8dc34309..5469f3b831 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'
import { MVideoImportDefault } from '@server/types/models/video/video-import'
import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element'
import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate'
-import { HttpMethod } from '@shared/core-utils/miscs/http-methods'
-import { PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
+import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models'
import { File as UploadXFile, Metadata } from '@uploadx/core'
import { RegisteredPlugin } from '../../lib/plugins/plugin-manager'
import {
diff --git a/shared/core-utils/miscs/index.ts b/shared/core-utils/miscs/index.ts
index 251df1de2a..afd147f242 100644
--- a/shared/core-utils/miscs/index.ts
+++ b/shared/core-utils/miscs/index.ts
@@ -1,5 +1,3 @@
export * from './date'
export * from './miscs'
export * from './types'
-export * from './http-error-codes'
-export * from './http-methods'
diff --git a/shared/extra-utils/bulk/bulk-command.ts b/shared/extra-utils/bulk/bulk-command.ts
index 6dac6034f1..b5c5673ce6 100644
--- a/shared/extra-utils/bulk/bulk-command.ts
+++ b/shared/extra-utils/bulk/bulk-command.ts
@@ -1,6 +1,4 @@
-
-import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { BulkRemoveCommentsOfBody, HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class BulkCommand extends AbstractCommand {
diff --git a/shared/extra-utils/custom-pages/custom-pages-command.ts b/shared/extra-utils/custom-pages/custom-pages-command.ts
index 0dd77503ee..6042233d40 100644
--- a/shared/extra-utils/custom-pages/custom-pages-command.ts
+++ b/shared/extra-utils/custom-pages/custom-pages-command.ts
@@ -1,5 +1,5 @@
import { CustomPage } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class CustomPagesCommand extends AbstractCommand {
diff --git a/shared/extra-utils/feeds/feeds-command.ts b/shared/extra-utils/feeds/feeds-command.ts
index 2da4110a7c..3c95f95363 100644
--- a/shared/extra-utils/feeds/feeds-command.ts
+++ b/shared/extra-utils/feeds/feeds-command.ts
@@ -1,5 +1,5 @@
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
type FeedType = 'videos' | 'video-comments' | 'subscriptions'
diff --git a/shared/extra-utils/logs/logs-command.ts b/shared/extra-utils/logs/logs-command.ts
index f34c58c47e..5912e814f3 100644
--- a/shared/extra-utils/logs/logs-command.ts
+++ b/shared/extra-utils/logs/logs-command.ts
@@ -1,4 +1,4 @@
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { LogLevel } from '../../models/server/log-level.type'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/miscs/checks.ts b/shared/extra-utils/miscs/checks.ts
index c81460330d..7fc92f804e 100644
--- a/shared/extra-utils/miscs/checks.ts
+++ b/shared/extra-utils/miscs/checks.ts
@@ -4,7 +4,7 @@ import { expect } from 'chai'
import { pathExists, readFile } from 'fs-extra'
import { join } from 'path'
import { root } from '@server/helpers/core-utils'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { makeGetRequest } from '../requests'
import { PeerTubeServer } from '../server'
@@ -20,7 +20,7 @@ async function testImage (url: string, imageName: string, imagePath: string, ext
const res = await makeGetRequest({
url,
path: imagePath,
- statusCodeExpected: HttpStatusCode.OK_200
+ expectedStatus: HttpStatusCode.OK_200
})
const body = res.body
diff --git a/shared/extra-utils/moderation/abuses-command.ts b/shared/extra-utils/moderation/abuses-command.ts
index 03da0c85a5..72f2c9951a 100644
--- a/shared/extra-utils/moderation/abuses-command.ts
+++ b/shared/extra-utils/moderation/abuses-command.ts
@@ -10,7 +10,7 @@ import {
ResultList,
UserAbuse
} from '@shared/models'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
import { unwrapBody } from '../requests/requests'
diff --git a/shared/extra-utils/overviews/overviews-command.ts b/shared/extra-utils/overviews/overviews-command.ts
index e15644d942..d4a2ac2541 100644
--- a/shared/extra-utils/overviews/overviews-command.ts
+++ b/shared/extra-utils/overviews/overviews-command.ts
@@ -1,4 +1,4 @@
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { VideosOverview } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/requests/check-api-params.ts b/shared/extra-utils/requests/check-api-params.ts
index 7df63b0044..26ba1e9132 100644
--- a/shared/extra-utils/requests/check-api-params.ts
+++ b/shared/extra-utils/requests/check-api-params.ts
@@ -1,4 +1,4 @@
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { makeGetRequest } from './requests'
function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
@@ -7,7 +7,7 @@ function checkBadStartPagination (url: string, path: string, token?: string, que
path,
token,
query: { ...query, start: 'hello' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
}
@@ -17,7 +17,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin
path,
token,
query: { ...query, count: 'hello' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
await makeGetRequest({
@@ -25,7 +25,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin
path,
token,
query: { ...query, count: 2000 },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
}
@@ -35,7 +35,7 @@ function checkBadSortPagination (url: string, path: string, token?: string, quer
path,
token,
query: { ...query, sort: 'hello' },
- statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
})
}
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts
index 60c9b938bd..70f7902222 100644
--- a/shared/extra-utils/requests/requests.ts
+++ b/shared/extra-utils/requests/requests.ts
@@ -1,111 +1,82 @@
-/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
+/* eslint-disable @typescript-eslint/no-floating-promises */
-import { isAbsolute, join } from 'path'
import { decode } from 'querystring'
import * as request from 'supertest'
import { URL } from 'url'
-import { HttpStatusCode } from '@shared/core-utils'
-import { buildAbsoluteFixturePath, root } from '../miscs/tests'
+import { HttpStatusCode } from '@shared/models'
+import { buildAbsoluteFixturePath } from '../miscs/tests'
-function makeRawRequest (url: string, statusCodeExpected?: HttpStatusCode, range?: string) {
- const { host, protocol, pathname } = new URL(url)
-
- return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected, range })
-}
-
-function makeGetRequest (options: {
+export type CommonRequestParams = {
url: string
path?: string
- query?: any
- token?: string
- statusCodeExpected?: HttpStatusCode
contentType?: string
range?: string
redirects?: number
accept?: string
host?: string
-}) {
- if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400
- if (options.contentType === undefined) options.contentType = 'application/json'
-
- const req = request(options.url).get(options.path)
+ token?: string
+ headers?: { [ name: string ]: string }
+ type?: string
+ xForwardedFor?: string
+ expectedStatus?: HttpStatusCode
+}
- if (options.contentType) req.set('Accept', options.contentType)
- if (options.token) req.set('Authorization', 'Bearer ' + options.token)
- if (options.query) req.query(options.query)
- if (options.range) req.set('Range', options.range)
- if (options.accept) req.set('Accept', options.accept)
- if (options.host) req.set('Host', options.host)
- if (options.redirects) req.redirects(options.redirects)
+function makeRawRequest (url: string, expectedStatus?: HttpStatusCode, range?: string) {
+ const { host, protocol, pathname } = new URL(url)
- return req.expect(options.statusCodeExpected)
+ return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, expectedStatus, range })
}
-function makeDeleteRequest (options: {
- url: string
- path: string
- token?: string
- statusCodeExpected?: HttpStatusCode
+function makeGetRequest (options: CommonRequestParams & {
+ query?: any
}) {
- if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400
+ const req = request(options.url).get(options.path)
+ .query(options.query)
- const req = request(options.url)
- .delete(options.path)
- .set('Accept', 'application/json')
+ return buildRequest(req, { contentType: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options })
+}
- if (options.token) req.set('Authorization', 'Bearer ' + options.token)
+function makeHTMLRequest (url: string, path: string) {
+ return makeGetRequest({
+ url,
+ path,
+ accept: 'text/html',
+ expectedStatus: HttpStatusCode.OK_200
+ })
+}
- return req.expect(options.statusCodeExpected)
+function makeActivityPubGetRequest (url: string, path: string, expectedStatus = HttpStatusCode.OK_200) {
+ return makeGetRequest({
+ url,
+ path,
+ expectedStatus: expectedStatus,
+ accept: 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8'
+ })
}
-function makeUploadRequest (options: {
- url: string
+function makeDeleteRequest (options: CommonRequestParams) {
+ const req = request(options.url).delete(options.path)
+
+ return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options })
+}
+
+function makeUploadRequest (options: CommonRequestParams & {
method?: 'POST' | 'PUT'
- path: string
- token?: string
fields: { [ fieldName: string ]: any }
attaches?: { [ attachName: string ]: any | any[] }
-
- headers?: { [ name: string ]: string }
-
- statusCodeExpected?: HttpStatusCode
}) {
- if (options.statusCodeExpected === undefined) {
- options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400
- }
+ let req = options.method === 'PUT'
+ ? request(options.url).put(options.path)
+ : request(options.url).post(options.path)
- let req: request.Test
- if (options.method === 'PUT') {
- req = request(options.url).put(options.path)
- } else {
- req = request(options.url).post(options.path)
- }
+ req = buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options })
- req.set('Accept', 'application/json')
-
- if (options.token) req.set('Authorization', 'Bearer ' + options.token)
-
- Object.keys(options.headers || {}).forEach(name => {
- req.set(name, options.headers[name])
- })
-
- Object.keys(options.fields).forEach(field => {
- const value = options.fields[field]
-
- if (value === undefined) return
-
- if (Array.isArray(value)) {
- for (let i = 0; i < value.length; i++) {
- req.field(field + '[' + i + ']', value[i])
- }
- } else {
- req.field(field, value)
- }
- })
+ buildFields(req, options.fields)
Object.keys(options.attaches || {}).forEach(attach => {
const value = options.attaches[attach]
+
if (Array.isArray(value)) {
req.attach(attach, buildAbsoluteFixturePath(value[0]), value[1])
} else {
@@ -113,40 +84,16 @@ function makeUploadRequest (options: {
}
})
- if (options.statusCodeExpected) {
- req.expect(options.statusCodeExpected)
- }
-
return req
}
-function makePostBodyRequest (options: {
- url: string
- path: string
- token?: string
+function makePostBodyRequest (options: CommonRequestParams & {
fields?: { [ fieldName: string ]: any }
- headers?: { [ name: string ]: string }
- type?: string
- xForwardedFor?: string
- statusCodeExpected?: HttpStatusCode
}) {
- if (!options.fields) options.fields = {}
- if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400
-
- const req = request(options.url)
- .post(options.path)
- .set('Accept', 'application/json')
+ const req = request(options.url).post(options.path)
+ .send(options.fields)
- if (options.token) req.set('Authorization', 'Bearer ' + options.token)
- if (options.xForwardedFor) req.set('X-Forwarded-For', options.xForwardedFor)
- if (options.type) req.type(options.type)
-
- Object.keys(options.headers || {}).forEach(name => {
- req.set(name, options.headers[name])
- })
-
- return req.send(options.fields)
- .expect(options.statusCodeExpected)
+ return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options })
}
function makePutBodyRequest (options: {
@@ -154,58 +101,12 @@ function makePutBodyRequest (options: {
path: string
token?: string
fields: { [ fieldName: string ]: any }
- statusCodeExpected?: HttpStatusCode
-}) {
- if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400
-
- const req = request(options.url)
- .put(options.path)
- .set('Accept', 'application/json')
-
- if (options.token) req.set('Authorization', 'Bearer ' + options.token)
-
- return req.send(options.fields)
- .expect(options.statusCodeExpected)
-}
-
-function makeHTMLRequest (url: string, path: string) {
- return request(url)
- .get(path)
- .set('Accept', 'text/html')
- .expect(HttpStatusCode.OK_200)
-}
-
-function makeActivityPubGetRequest (url: string, path: string, expectedStatus = HttpStatusCode.OK_200) {
- return makeGetRequest({
- url,
- path,
- statusCodeExpected: expectedStatus,
- accept: 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8'
- })
-}
-
-function updateImageRequest (options: {
- url: string
- path: string
- accessToken: string
- fixture: string
- fieldname: string
+ expectedStatus?: HttpStatusCode
}) {
- let filePath = ''
- if (isAbsolute(options.fixture)) {
- filePath = options.fixture
- } else {
- filePath = join(root(), 'server', 'tests', 'fixtures', options.fixture)
- }
+ const req = request(options.url).put(options.path)
+ .send(options.fields)
- return makeUploadRequest({
- url: options.url,
- path: options.path,
- token: options.accessToken,
- fields: {},
- attaches: { [options.fieldname]: filePath },
- statusCodeExpected: HttpStatusCode.OK_200
- })
+ return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options })
}
function decodeQueryString (path: string) {
@@ -233,6 +134,49 @@ export {
makeRawRequest,
makeActivityPubGetRequest,
unwrapBody,
- unwrapText,
- updateImageRequest
+ unwrapText
+}
+
+// ---------------------------------------------------------------------------
+
+function buildRequest (req: request.Test, options: CommonRequestParams) {
+ if (options.contentType) req.set('Accept', options.contentType)
+ if (options.token) req.set('Authorization', 'Bearer ' + options.token)
+ if (options.range) req.set('Range', options.range)
+ if (options.accept) req.set('Accept', options.accept)
+ if (options.host) req.set('Host', options.host)
+ if (options.redirects) req.redirects(options.redirects)
+ if (options.expectedStatus) req.expect(options.expectedStatus)
+ if (options.xForwardedFor) req.set('X-Forwarded-For', options.xForwardedFor)
+ if (options.type) req.type(options.type)
+
+ Object.keys(options.headers || {}).forEach(name => {
+ req.set(name, options.headers[name])
+ })
+
+ return req
+}
+
+function buildFields (req: request.Test, fields: { [ fieldName: string ]: any }, namespace?: string) {
+ if (!fields) return
+
+ let formKey: string
+
+ for (const key of Object.keys(fields)) {
+ if (namespace) formKey = `${namespace}[${key}]`
+ else formKey = key
+
+ if (fields[key] === undefined) continue
+
+ if (Array.isArray(fields[key]) && fields[key].length === 0) {
+ req.field(key, null)
+ continue
+ }
+
+ if (fields[key] !== null && typeof fields[key] === 'object') {
+ buildFields(req, fields[key], formKey)
+ } else {
+ req.field(formKey, fields[key])
+ }
+ }
}
diff --git a/shared/extra-utils/search/search-command.ts b/shared/extra-utils/search/search-command.ts
index 7539a21eca..09f5d3f1d8 100644
--- a/shared/extra-utils/search/search-command.ts
+++ b/shared/extra-utils/search/search-command.ts
@@ -7,7 +7,7 @@ import {
VideoPlaylistsSearchQuery,
VideosSearchQuery
} from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class SearchCommand extends AbstractCommand {
diff --git a/shared/extra-utils/server/config-command.ts b/shared/extra-utils/server/config-command.ts
index f5d7fc5e34..6e875fdf60 100644
--- a/shared/extra-utils/server/config-command.ts
+++ b/shared/extra-utils/server/config-command.ts
@@ -1,6 +1,6 @@
import { merge } from 'lodash'
-import { DeepPartial, HttpStatusCode } from '@shared/core-utils'
-import { About, ServerConfig } from '@shared/models'
+import { DeepPartial } from '@shared/core-utils'
+import { About, ServerConfig, HttpStatusCode } from '@shared/models'
import { CustomConfig } from '../../models/server/custom-config.model'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/server/contact-form-command.ts b/shared/extra-utils/server/contact-form-command.ts
index 8d034552b3..0e8fd6d840 100644
--- a/shared/extra-utils/server/contact-form-command.ts
+++ b/shared/extra-utils/server/contact-form-command.ts
@@ -1,4 +1,4 @@
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { ContactForm } from '../../models/server'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/server/debug-command.ts b/shared/extra-utils/server/debug-command.ts
index 8b24b30672..36704836da 100644
--- a/shared/extra-utils/server/debug-command.ts
+++ b/shared/extra-utils/server/debug-command.ts
@@ -1,5 +1,5 @@
import { Debug, SendDebugCommand } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class DebugCommand extends AbstractCommand {
diff --git a/shared/extra-utils/server/follows-command.ts b/shared/extra-utils/server/follows-command.ts
index 4e9ed9494a..694f5ea244 100644
--- a/shared/extra-utils/server/follows-command.ts
+++ b/shared/extra-utils/server/follows-command.ts
@@ -1,6 +1,6 @@
import { pick } from 'lodash'
import { ActivityPubActorType, ActorFollow, FollowState, ResultList } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
import { PeerTubeServer } from './server'
diff --git a/shared/extra-utils/server/jobs-command.ts b/shared/extra-utils/server/jobs-command.ts
index 392b868c16..09a299e5bf 100644
--- a/shared/extra-utils/server/jobs-command.ts
+++ b/shared/extra-utils/server/jobs-command.ts
@@ -1,5 +1,5 @@
import { pick } from 'lodash'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { Job, JobState, JobType, ResultList } from '../../models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/server/plugins-command.ts b/shared/extra-utils/server/plugins-command.ts
index 98049ce193..59bc79b3d2 100644
--- a/shared/extra-utils/server/plugins-command.ts
+++ b/shared/extra-utils/server/plugins-command.ts
@@ -3,7 +3,7 @@
import { readJSON, writeJSON } from 'fs-extra'
import { join } from 'path'
import { root } from '@server/helpers/core-utils'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
PeerTubePlugin,
PeerTubePluginIndex,
diff --git a/shared/extra-utils/server/redundancy-command.ts b/shared/extra-utils/server/redundancy-command.ts
index 728332fdd1..137d7f01c5 100644
--- a/shared/extra-utils/server/redundancy-command.ts
+++ b/shared/extra-utils/server/redundancy-command.ts
@@ -1,5 +1,5 @@
import { ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class RedundancyCommand extends AbstractCommand {
diff --git a/shared/extra-utils/server/server.ts b/shared/extra-utils/server/server.ts
index cc6df2efe4..b33bb9d1e5 100644
--- a/shared/extra-utils/server/server.ts
+++ b/shared/extra-utils/server/server.ts
@@ -254,7 +254,7 @@ export class PeerTubeServer {
process.on('exit', () => {
try {
- process.kill(self.server.app.pid)
+ process.kill(self.app.pid)
} catch { /* empty */ }
})
diff --git a/shared/extra-utils/server/servers-command.ts b/shared/extra-utils/server/servers-command.ts
index 1a7b2aadef..107e2b4ad3 100644
--- a/shared/extra-utils/server/servers-command.ts
+++ b/shared/extra-utils/server/servers-command.ts
@@ -2,7 +2,7 @@ import { exec } from 'child_process'
import { copy, ensureDir, readFile, remove } from 'fs-extra'
import { join } from 'path'
import { root } from '@server/helpers/core-utils'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { getFileSize } from '@uploadx/core'
import { isGithubCI, wait } from '../miscs'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/server/stats-command.ts b/shared/extra-utils/server/stats-command.ts
index f0f02ca084..6db4735882 100644
--- a/shared/extra-utils/server/stats-command.ts
+++ b/shared/extra-utils/server/stats-command.ts
@@ -1,5 +1,5 @@
import { ServerStats } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class StatsCommand extends AbstractCommand {
diff --git a/shared/extra-utils/shared/abstract-command.ts b/shared/extra-utils/shared/abstract-command.ts
index 967f8f2ac6..021045e49a 100644
--- a/shared/extra-utils/shared/abstract-command.ts
+++ b/shared/extra-utils/shared/abstract-command.ts
@@ -24,15 +24,20 @@ interface InternalCommonCommandOptions extends OverrideCommandOptions {
// If we automatically send the server token if the token is not provided
implicitToken: boolean
defaultExpectedStatus: number
-}
-interface InternalGetCommandOptions extends InternalCommonCommandOptions {
- query?: { [ id: string ]: any }
+ // Common optional request parameters
contentType?: string
accept?: string
redirects?: number
range?: string
host?: string
+ headers?: { [ name: string ]: string }
+ requestType?: string
+ xForwardedFor?: string
+}
+
+interface InternalGetCommandOptions extends InternalCommonCommandOptions {
+ query?: { [ id: string ]: any }
}
abstract class AbstractCommand {
@@ -59,7 +64,7 @@ abstract class AbstractCommand {
...options,
token: this.buildCommonRequestToken(options),
- defaultExpectedStatus: this.buildStatusCodeExpected(options),
+ defaultExpectedStatus: this.buildExpectedStatus(options),
url: `${protocol}//${host}`,
path: pathname,
@@ -68,17 +73,12 @@ abstract class AbstractCommand {
}
protected getRequest (options: InternalGetCommandOptions) {
- const { redirects, query, contentType, accept, range, host } = options
+ const { query } = options
return makeGetRequest({
...this.buildCommonRequestOptions(options),
- redirects,
- query,
- contentType,
- range,
- host,
- accept
+ query
})
}
@@ -100,51 +100,41 @@ abstract class AbstractCommand {
protected postBodyRequest (options: InternalCommonCommandOptions & {
fields?: { [ fieldName: string ]: any }
- headers?: { [ name: string ]: string }
- type?: string
- xForwardedFor?: string
}) {
- const { type, fields, xForwardedFor, headers } = options
+ const { fields } = options
return makePostBodyRequest({
...this.buildCommonRequestOptions(options),
- fields,
- xForwardedFor,
- type,
- headers
+ fields
})
}
protected postUploadRequest (options: InternalCommonCommandOptions & {
fields?: { [ fieldName: string ]: any }
attaches?: { [ fieldName: string ]: any }
- headers?: { [ name: string ]: string }
}) {
- const { fields, attaches, headers } = options
+ const { fields, attaches } = options
return makeUploadRequest({
...this.buildCommonRequestOptions(options),
method: 'POST',
fields,
- attaches,
- headers
+ attaches
})
}
protected putUploadRequest (options: InternalCommonCommandOptions & {
fields?: { [ fieldName: string ]: any }
attaches?: { [ fieldName: string ]: any }
- headers?: { [ name: string ]: string }
}) {
- const { fields, attaches, headers } = options
+ const { fields, attaches } = options
return makeUploadRequest({
...this.buildCommonRequestOptions(options),
method: 'PUT',
- headers,
fields,
attaches
})
@@ -154,12 +144,9 @@ abstract class AbstractCommand {
fixture: string
fieldname: string
}) {
- let filePath = ''
- if (isAbsolute(options.fixture)) {
- filePath = options.fixture
- } else {
- filePath = join(root(), 'server', 'tests', 'fixtures', options.fixture)
- }
+ const filePath = isAbsolute(options.fixture)
+ ? options.fixture
+ : join(root(), 'server', 'tests', 'fixtures', options.fixture)
return this.postUploadRequest({
...options,
@@ -170,14 +157,23 @@ abstract class AbstractCommand {
}
protected buildCommonRequestOptions (options: InternalCommonCommandOptions) {
- const { url, path } = options
+ const { url, path, redirects, contentType, accept, range, host, headers, requestType, xForwardedFor } = options
return {
url: url ?? this.server.url,
path,
token: this.buildCommonRequestToken(options),
- statusCodeExpected: this.buildStatusCodeExpected(options)
+ expectedStatus: this.buildExpectedStatus(options),
+
+ redirects,
+ contentType,
+ range,
+ host,
+ accept,
+ headers,
+ type: requestType,
+ xForwardedFor
}
}
@@ -191,7 +187,7 @@ abstract class AbstractCommand {
return token !== undefined ? token : fallbackToken
}
- protected buildStatusCodeExpected (options: Pick<InternalCommonCommandOptions, 'expectedStatus' | 'defaultExpectedStatus'>) {
+ protected buildExpectedStatus (options: Pick<InternalCommonCommandOptions, 'expectedStatus' | 'defaultExpectedStatus'>) {
const { expectedStatus, defaultExpectedStatus } = options
return expectedStatus !== undefined ? expectedStatus : defaultExpectedStatus
diff --git a/shared/extra-utils/users/accounts-command.ts b/shared/extra-utils/users/accounts-command.ts
index 4cd1d2158a..08977e58b7 100644
--- a/shared/extra-utils/users/accounts-command.ts
+++ b/shared/extra-utils/users/accounts-command.ts
@@ -1,5 +1,5 @@
import { ResultList } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { Account } from '../../models/actors'
import { AccountVideoRate, VideoRateType } from '../../models/videos'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/users/blocklist-command.ts b/shared/extra-utils/users/blocklist-command.ts
index 089b5a5791..a9431acf3d 100644
--- a/shared/extra-utils/users/blocklist-command.ts
+++ b/shared/extra-utils/users/blocklist-command.ts
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { AccountBlock, ResultList, ServerBlock } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/users/index.ts b/shared/extra-utils/users/index.ts
index e6107afa53..fbb454e8f0 100644
--- a/shared/extra-utils/users/index.ts
+++ b/shared/extra-utils/users/index.ts
@@ -7,4 +7,3 @@ export * from './notifications'
export * from './notifications-command'
export * from './subscriptions-command'
export * from './users-command'
-export * from './users'
diff --git a/shared/extra-utils/users/login-command.ts b/shared/extra-utils/users/login-command.ts
index 10c3db8516..b39577260e 100644
--- a/shared/extra-utils/users/login-command.ts
+++ b/shared/extra-utils/users/login-command.ts
@@ -1,4 +1,4 @@
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { PeerTubeProblemDocument } from '@shared/models'
import { unwrapBody } from '../requests'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
@@ -26,7 +26,7 @@ export class LoginCommand extends AbstractCommand {
...options,
path,
- type: 'form',
+ requestType: 'form',
fields: body,
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
@@ -72,7 +72,7 @@ export class LoginCommand extends AbstractCommand {
...options,
path,
- type: 'form',
+ requestType: 'form',
fields: body,
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
@@ -88,7 +88,7 @@ export class LoginCommand extends AbstractCommand {
...options,
path,
- type: 'form',
+ requestType: 'form',
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
}))
@@ -111,7 +111,7 @@ export class LoginCommand extends AbstractCommand {
...options,
path,
- type: 'form',
+ requestType: 'form',
fields: body,
implicitToken: false,
defaultExpectedStatus: HttpStatusCode.OK_200
diff --git a/shared/extra-utils/users/notifications-command.ts b/shared/extra-utils/users/notifications-command.ts
index dfe574ca1f..a51fcc3af7 100644
--- a/shared/extra-utils/users/notifications-command.ts
+++ b/shared/extra-utils/users/notifications-command.ts
@@ -1,5 +1,5 @@
import { ResultList } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { UserNotification, UserNotificationSetting } from '../../models/users'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/users/subscriptions-command.ts b/shared/extra-utils/users/subscriptions-command.ts
index e998eb4264..a69d2a1948 100644
--- a/shared/extra-utils/users/subscriptions-command.ts
+++ b/shared/extra-utils/users/subscriptions-command.ts
@@ -1,5 +1,5 @@
import { ResultList, Video, VideoChannel } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class SubscriptionsCommand extends AbstractCommand {
diff --git a/shared/extra-utils/users/users-command.ts b/shared/extra-utils/users/users-command.ts
index 59dc6d018a..f3a251e65f 100644
--- a/shared/extra-utils/users/users-command.ts
+++ b/shared/extra-utils/users/users-command.ts
@@ -1,5 +1,5 @@
import { omit, pick } from 'lodash'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
MyUser,
ResultList,
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts
deleted file mode 100644
index 6cf61d60e0..0000000000
--- a/shared/extra-utils/users/users.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import * as request from 'supertest'
-import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
-
-// FIXME: delete once videos does not use it anymore
-function xxxgetMyUserInformation (url: string, accessToken: string, specialStatus = HttpStatusCode.OK_200) {
- const path = '/api/v1/users/me'
-
- return request(url)
- .get(path)
- .set('Accept', 'application/json')
- .set('Authorization', 'Bearer ' + accessToken)
- .expect(specialStatus)
- .expect('Content-Type', /json/)
-}
-
-// ---------------------------------------------------------------------------
-
-export {
- xxxgetMyUserInformation
-}
diff --git a/shared/extra-utils/videos/blacklist-command.ts b/shared/extra-utils/videos/blacklist-command.ts
index fdae6b4692..9404d4c08f 100644
--- a/shared/extra-utils/videos/blacklist-command.ts
+++ b/shared/extra-utils/videos/blacklist-command.ts
@@ -1,6 +1,6 @@
import { ResultList } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { VideoBlacklist, VideoBlacklistType } from '../../models/videos'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/captions-command.ts b/shared/extra-utils/videos/captions-command.ts
index ac3bde7a91..04dd32f844 100644
--- a/shared/extra-utils/videos/captions-command.ts
+++ b/shared/extra-utils/videos/captions-command.ts
@@ -1,4 +1,4 @@
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { ResultList, VideoCaption } from '@shared/models'
import { buildAbsoluteFixturePath } from '../miscs'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/captions.ts b/shared/extra-utils/videos/captions.ts
index 2246bd1335..ff8a43366f 100644
--- a/shared/extra-utils/videos/captions.ts
+++ b/shared/extra-utils/videos/captions.ts
@@ -1,6 +1,6 @@
import { expect } from 'chai'
import * as request from 'supertest'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
async function testCaptionFile (url: string, captionPath: string, containsString: string) {
const res = await request(url)
diff --git a/shared/extra-utils/videos/change-ownership-command.ts b/shared/extra-utils/videos/change-ownership-command.ts
index 03f77a95f4..ef6f075365 100644
--- a/shared/extra-utils/videos/change-ownership-command.ts
+++ b/shared/extra-utils/videos/change-ownership-command.ts
@@ -1,6 +1,6 @@
import { ResultList, VideoChangeOwnership } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class ChangeOwnershipCommand extends AbstractCommand {
diff --git a/shared/extra-utils/videos/channels-command.ts b/shared/extra-utils/videos/channels-command.ts
index a98c5cc93a..e5393ff564 100644
--- a/shared/extra-utils/videos/channels-command.ts
+++ b/shared/extra-utils/videos/channels-command.ts
@@ -1,6 +1,6 @@
import { pick } from 'lodash'
import { ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model'
import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model'
import { unwrapBody } from '../requests'
diff --git a/shared/extra-utils/videos/comments-command.ts b/shared/extra-utils/videos/comments-command.ts
index b31f3e2dd4..7368f3ea21 100644
--- a/shared/extra-utils/videos/comments-command.ts
+++ b/shared/extra-utils/videos/comments-command.ts
@@ -1,6 +1,6 @@
import { pick } from 'lodash'
+import { HttpStatusCode } from '@shared/models'
import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
import { unwrapBody } from '../requests'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/history-command.ts b/shared/extra-utils/videos/history-command.ts
index 8a144a3126..41afc6bc6a 100644
--- a/shared/extra-utils/videos/history-command.ts
+++ b/shared/extra-utils/videos/history-command.ts
@@ -1,5 +1,5 @@
+import { HttpStatusCode } from '@shared/models'
import { ResultList, Video } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class HistoryCommand extends AbstractCommand {
diff --git a/shared/extra-utils/videos/imports-command.ts b/shared/extra-utils/videos/imports-command.ts
index de8b658299..d30f9745b6 100644
--- a/shared/extra-utils/videos/imports-command.ts
+++ b/shared/extra-utils/videos/imports-command.ts
@@ -1,6 +1,6 @@
+import { HttpStatusCode } from '@shared/models'
import { ResultList } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
import { VideoImport, VideoImportCreate } from '../../models/videos'
import { unwrapBody } from '../requests'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts
index fd66c99243..9dfe3087ee 100644
--- a/shared/extra-utils/videos/live-command.ts
+++ b/shared/extra-utils/videos/live-command.ts
@@ -3,8 +3,8 @@
import { readdir } from 'fs-extra'
import { omit } from 'lodash'
import { join } from 'path'
+import { HttpStatusCode } from '@shared/models'
import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models'
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
import { wait } from '../miscs'
import { unwrapBody } from '../requests'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/playlists-command.ts b/shared/extra-utils/videos/playlists-command.ts
index cbfc7e10f3..40162c30d5 100644
--- a/shared/extra-utils/videos/playlists-command.ts
+++ b/shared/extra-utils/videos/playlists-command.ts
@@ -1,5 +1,5 @@
import { omit, pick } from 'lodash'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
BooleanBothQuery,
ResultList,
diff --git a/shared/extra-utils/videos/services-command.ts b/shared/extra-utils/videos/services-command.ts
index 313b7878c5..06760df424 100644
--- a/shared/extra-utils/videos/services-command.ts
+++ b/shared/extra-utils/videos/services-command.ts
@@ -1,4 +1,4 @@
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class ServicesCommand extends AbstractCommand {
diff --git a/shared/extra-utils/videos/streaming-playlists-command.ts b/shared/extra-utils/videos/streaming-playlists-command.ts
index fab3eb5562..9662685da1 100644
--- a/shared/extra-utils/videos/streaming-playlists-command.ts
+++ b/shared/extra-utils/videos/streaming-playlists-command.ts
@@ -1,5 +1,4 @@
-
-import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
+import { HttpStatusCode } from '@shared/models'
import { unwrapBody, unwrapText } from '../requests'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
diff --git a/shared/extra-utils/videos/streaming-playlists.ts b/shared/extra-utils/videos/streaming-playlists.ts
index 002ae08b24..007d3d98d0 100644
--- a/shared/extra-utils/videos/streaming-playlists.ts
+++ b/shared/extra-utils/videos/streaming-playlists.ts
@@ -1,6 +1,6 @@
import { expect } from 'chai'
import { sha256 } from '@server/helpers/core-utils'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { VideoStreamingPlaylist } from '@shared/models'
import { PeerTubeServer } from '../server'
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts
index feef5a7717..f46d386f4f 100644
--- a/shared/extra-utils/videos/videos-command.ts
+++ b/shared/extra-utils/videos/videos-command.ts
@@ -7,7 +7,7 @@ import { omit, pick } from 'lodash'
import validator from 'validator'
import { buildUUID } from '@server/helpers/uuid'
import { loadLanguages } from '@server/initializers/constants'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
ResultList,
UserVideoRateType,
@@ -234,10 +234,10 @@ export class VideosCommand extends AbstractCommand {
}
listByAccount (options: OverrideCommandOptions & VideosWithSearchCommonQuery & {
- accountName: string
+ handle: string
}) {
- const { accountName, search } = options
- const path = '/api/v1/accounts/' + accountName + '/videos'
+ const { handle, search } = options
+ const path = '/api/v1/accounts/' + handle + '/videos'
return this.getRequestBody<ResultList<Video>>({
...options,
@@ -250,10 +250,10 @@ export class VideosCommand extends AbstractCommand {
}
listByChannel (options: OverrideCommandOptions & VideosWithSearchCommonQuery & {
- videoChannelName: string
+ handle: string
}) {
- const { videoChannelName } = options
- const path = '/api/v1/video-channels/' + videoChannelName + '/videos'
+ const { handle } = options
+ const path = '/api/v1/video-channels/' + handle + '/videos'
return this.getRequestBody<ResultList<Video>>({
...options,
@@ -309,13 +309,13 @@ export class VideosCommand extends AbstractCommand {
}) {
const path = '/api/v1/videos/' + options.id
- return this.deleteRequest({
+ return unwrapBody(this.deleteRequest({
...options,
path,
implicitToken: true,
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
- })
+ }))
}
async removeAll () {
@@ -396,7 +396,7 @@ export class VideosCommand extends AbstractCommand {
async buildResumeUpload (options: OverrideCommandOptions & {
attributes: VideoEdit
- }) {
+ }): Promise<VideoCreateResult> {
const { attributes, expectedStatus } = options
let size = 0
@@ -414,7 +414,8 @@ export class VideosCommand extends AbstractCommand {
}
}
- const initializeSessionRes = await this.prepareResumableUpload({ ...options, attributes, size, mimetype })
+ // Do not check status automatically, we'll check it manually
+ const initializeSessionRes = await this.prepareResumableUpload({ ...options, expectedStatus: null, attributes, size, mimetype })
const initStatus = initializeSessionRes.status
if (videoFilePath && initStatus === HttpStatusCode.CREATED_201) {
@@ -425,7 +426,7 @@ export class VideosCommand extends AbstractCommand {
const result = await this.sendResumableChunks({ ...options, pathUploadId, videoFilePath, size })
- return result.body.video
+ return result.body?.video || result.body as any
}
const expectedInitStatus = expectedStatus === HttpStatusCode.OK_200
@@ -434,7 +435,7 @@ export class VideosCommand extends AbstractCommand {
expect(initStatus).to.equal(expectedInitStatus)
- return initializeSessionRes.body.video as VideoCreateResult
+ return initializeSessionRes.body.video || initializeSessionRes.body
}
async prepareResumableUpload (options: OverrideCommandOptions & {
@@ -455,7 +456,10 @@ export class VideosCommand extends AbstractCommand {
'X-Upload-Content-Length': size.toString()
},
fields: { filename: attributes.fixture, ...this.buildUploadFields(options.attributes) },
+ // Fixture will be sent later
+ attaches: this.buildUploadAttaches(omit(options.attributes, 'fixture')),
implicitToken: true,
+
defaultExpectedStatus: null
})
}
@@ -539,10 +543,10 @@ export class VideosCommand extends AbstractCommand {
const attributes = { name, additionalParams }
- if (wait) await waitJobs([ this.server ])
-
const result = await this.upload({ ...options, attributes })
+ if (wait) await waitJobs([ this.server ])
+
return { ...result, name }
}
@@ -566,7 +570,7 @@ export class VideosCommand extends AbstractCommand {
}
private buildUploadFields (attributes: VideoEdit) {
- return omit(attributes, [ 'thumbnailfile', 'previewfile' ])
+ return omit(attributes, [ 'fixture', 'thumbnailfile', 'previewfile' ])
}
private buildUploadAttaches (attributes: VideoEdit) {
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index b415338082..a96073c564 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -4,7 +4,7 @@ import { expect } from 'chai'
import { pathExists, readdir } from 'fs-extra'
import { join } from 'path'
import { getLowercaseExtension } from '@server/helpers/core-utils'
-import { HttpStatusCode } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
import { dateIsValid, testImage, webtorrentAdd } from '../miscs'
import { makeRawRequest } from '../requests/requests'
diff --git a/shared/core-utils/miscs/http-error-codes.ts b/shared/models/http/http-error-codes.ts
similarity index 100%
rename from shared/core-utils/miscs/http-error-codes.ts
rename to shared/models/http/http-error-codes.ts
diff --git a/shared/core-utils/miscs/http-methods.ts b/shared/models/http/http-methods.ts
similarity index 100%
rename from shared/core-utils/miscs/http-methods.ts
rename to shared/models/http/http-methods.ts
diff --git a/shared/models/http/index.ts b/shared/models/http/index.ts
new file mode 100644
index 0000000000..ec991afe08
--- /dev/null
+++ b/shared/models/http/index.ts
@@ -0,0 +1,2 @@
+export * from './http-error-codes'
+export * from './http-methods'
diff --git a/shared/models/index.ts b/shared/models/index.ts
index 5c2bc480ee..78723d8304 100644
--- a/shared/models/index.ts
+++ b/shared/models/index.ts
@@ -4,6 +4,7 @@ export * from './bulk'
export * from './common'
export * from './custom-markup'
export * from './feeds'
+export * from './http'
export * from './joinpeertube'
export * from './moderation'
export * from './overviews'
diff --git a/shared/models/server/peertube-problem-document.model.ts b/shared/models/server/peertube-problem-document.model.ts
index e391d5aadb..8dd96f7a37 100644
--- a/shared/models/server/peertube-problem-document.model.ts
+++ b/shared/models/server/peertube-problem-document.model.ts
@@ -1,4 +1,4 @@
-import { HttpStatusCode } from '../../core-utils'
+import { HttpStatusCode } from '../../models'
import { OAuth2ErrorCode, ServerErrorCode } from './server-error-code.enum'
export interface PeerTubeProblemDocumentData {