diff options
230 files changed, 940 insertions, 1056 deletions
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 a528faa20..37e9feacb 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' | |||
11 | import { InstanceService } from '@app/shared/shared-instance' | 11 | import { InstanceService } from '@app/shared/shared-instance' |
12 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 12 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
13 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | 13 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' |
14 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 14 | import { HTMLServerConfig, HttpStatusCode } from '@shared/models' |
15 | import { HTMLServerConfig } from '@shared/models' | ||
16 | 15 | ||
17 | type Prefill = { | 16 | type Prefill = { |
18 | subject?: string | 17 | subject?: string |
diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts index c69b04a01..5b59f3cd0 100644 --- a/client/src/app/+accounts/accounts.component.ts +++ b/client/src/app/+accounts/accounts.component.ts | |||
@@ -13,8 +13,7 @@ import { | |||
13 | VideoService | 13 | VideoService |
14 | } from '@app/shared/shared-main' | 14 | } from '@app/shared/shared-main' |
15 | import { AccountReportComponent } from '@app/shared/shared-moderation' | 15 | import { AccountReportComponent } from '@app/shared/shared-moderation' |
16 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 16 | import { HttpStatusCode, User, UserRight } from '@shared/models' |
17 | import { User, UserRight } from '@shared/models' | ||
18 | import { AccountSearchComponent } from './account-search/account-search.component' | 17 | import { AccountSearchComponent } from './account-search/account-search.component' |
19 | 18 | ||
20 | @Component({ | 19 | @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 b3265210f..433475f66 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 @@ | |||
1 | import { of } from 'rxjs' | ||
2 | import { switchMap } from 'rxjs/operators' | ||
1 | import { Component, OnInit } from '@angular/core' | 3 | import { Component, OnInit } from '@angular/core' |
2 | import { Router } from '@angular/router' | 4 | import { Router } from '@angular/router' |
3 | import { AuthService, Notifier } from '@app/core' | 5 | import { AuthService, Notifier } from '@app/core' |
@@ -9,11 +11,8 @@ import { | |||
9 | } from '@app/shared/form-validators/video-channel-validators' | 11 | } from '@app/shared/form-validators/video-channel-validators' |
10 | import { FormValidatorService } from '@app/shared/shared-forms' | 12 | import { FormValidatorService } from '@app/shared/shared-forms' |
11 | import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' | 13 | import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' |
12 | import { VideoChannelCreate } from '@shared/models' | 14 | import { HttpStatusCode, VideoChannelCreate } from '@shared/models' |
13 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
14 | import { MyVideoChannelEdit } from './my-video-channel-edit' | 15 | import { MyVideoChannelEdit } from './my-video-channel-edit' |
15 | import { switchMap } from 'rxjs/operators' | ||
16 | import { of } from 'rxjs' | ||
17 | 16 | ||
18 | @Component({ | 17 | @Component({ |
19 | templateUrl: './my-video-channel-edit.component.html', | 18 | 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 639e5db78..10645a634 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 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { Title } from '@angular/platform-browser' | 2 | import { Title } from '@angular/platform-browser' |
3 | import { Router } from '@angular/router' | 3 | import { Router } from '@angular/router' |
4 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | |||
5 | @Component({ | 6 | @Component({ |
6 | selector: 'my-page-not-found', | 7 | selector: 'my-page-not-found', |
7 | templateUrl: './page-not-found.component.html', | 8 | 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 3833d9c54..6479644f1 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 } | |||
7 | import { ListOverflowItem, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' | 7 | import { ListOverflowItem, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' |
8 | import { SupportModalComponent } from '@app/shared/shared-support-modal' | 8 | import { SupportModalComponent } from '@app/shared/shared-support-modal' |
9 | import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' | 9 | import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' |
10 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 10 | import { HttpStatusCode } from '@shared/models' |
11 | 11 | ||
12 | @Component({ | 12 | @Component({ |
13 | templateUrl: './video-channels.component.html', | 13 | 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 627de33c0..e9420fe62 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' | |||
7 | import { FormValidatorService } from '@app/shared/shared-forms' | 7 | import { FormValidatorService } from '@app/shared/shared-forms' |
8 | import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' | 8 | import { BytesPipe, Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' |
9 | import { LoadingBarService } from '@ngx-loading-bar/core' | 9 | import { LoadingBarService } from '@ngx-loading-bar/core' |
10 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 10 | import { HttpStatusCode, VideoPrivacy } from '@shared/models' |
11 | import { VideoPrivacy } from '@shared/models' | ||
12 | import { UploaderXFormData } from './uploaderx-form-data' | 11 | import { UploaderXFormData } from './uploaderx-form-data' |
13 | import { VideoSend } from './video-send' | 12 | import { VideoSend } from './video-send' |
14 | 13 | ||
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 d078844c3..7460ae3fc 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' | |||
21 | import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main' | 21 | import { Video, VideoCaptionService, VideoDetails, VideoService } from '@app/shared/shared-main' |
22 | import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' | 22 | import { SubscribeButtonComponent } from '@app/shared/shared-user-subscription' |
23 | import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' | 23 | import { VideoPlaylist, VideoPlaylistService } from '@app/shared/shared-video-playlist' |
24 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 24 | import { |
25 | import { HTMLServerConfig, PeerTubeProblemDocument, ServerErrorCode, VideoCaption, VideoPrivacy, VideoState } from '@shared/models' | 25 | HTMLServerConfig, |
26 | HttpStatusCode, | ||
27 | PeerTubeProblemDocument, | ||
28 | ServerErrorCode, | ||
29 | VideoCaption, | ||
30 | VideoPrivacy, | ||
31 | VideoState | ||
32 | } from '@shared/models' | ||
26 | import { cleanupVideoWatch, getStoredTheater, getStoredVideoWatchHistory } from '../../../assets/player/peertube-player-local-storage' | 33 | import { cleanupVideoWatch, getStoredTheater, getStoredVideoWatchHistory } from '../../../assets/player/peertube-player-local-storage' |
27 | import { | 34 | import { |
28 | CustomizationOptions, | 35 | CustomizationOptions, |
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index cdf13186b..60bd72c60 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' | |||
6 | import { Router } from '@angular/router' | 6 | import { Router } from '@angular/router' |
7 | import { Notifier } from '@app/core/notification/notifier.service' | 7 | import { Notifier } from '@app/core/notification/notifier.service' |
8 | import { objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index' | 8 | import { objectToUrlEncoded, peertubeLocalStorage } from '@root-helpers/index' |
9 | import { MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' | 9 | import { HttpStatusCode, MyUser as UserServerModel, OAuthClientLocal, User, UserLogin, UserRefreshToken } from '@shared/models' |
10 | import { environment } from '../../../environments/environment' | 10 | import { environment } from '../../../environments/environment' |
11 | import { RestExtractor } from '../rest/rest-extractor.service' | 11 | import { RestExtractor } from '../rest/rest-extractor.service' |
12 | import { AuthStatus } from './auth-status.model' | 12 | import { AuthStatus } from './auth-status.model' |
13 | import { AuthUser } from './auth-user.model' | 13 | import { AuthUser } from './auth-user.model' |
14 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
15 | 14 | ||
16 | interface UserLoginWithUsername extends UserLogin { | 15 | interface UserLoginWithUsername extends UserLogin { |
17 | access_token: string | 16 | 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 08ab49512..2a926e68f 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' | |||
2 | import { Injectable } from '@angular/core' | 2 | import { Injectable } from '@angular/core' |
3 | import { Router } from '@angular/router' | 3 | import { Router } from '@angular/router' |
4 | import { dateToHuman } from '@app/helpers' | 4 | import { dateToHuman } from '@app/helpers' |
5 | import { ResultList } from '@shared/models' | 5 | import { HttpStatusCode, ResultList } from '@shared/models' |
6 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | ||
7 | 6 | ||
8 | @Injectable() | 7 | @Injectable() |
9 | export class RestExtractor { | 8 | export class RestExtractor { |
diff --git a/client/src/app/helpers/utils.ts b/client/src/app/helpers/utils.ts index 94f6def26..edcaf50e0 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' | |||
3 | import { DatePipe } from '@angular/common' | 3 | import { DatePipe } from '@angular/common' |
4 | import { HttpErrorResponse } from '@angular/common/http' | 4 | import { HttpErrorResponse } from '@angular/common/http' |
5 | import { Notifier } from '@app/core' | 5 | import { Notifier } from '@app/core' |
6 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { environment } from '../../environments/environment' | 7 | import { environment } from '../../environments/environment' |
8 | import { AuthService } from '../core/auth' | 8 | import { AuthService } from '../core/auth' |
9 | 9 | ||
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 5bcad36d0..a75c8a25c 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 @@ | |||
1 | import { Observable, of, throwError as observableThrowError } from 'rxjs' | 1 | import { Observable, of, throwError as observableThrowError } from 'rxjs' |
2 | import { catchError, switchMap } from 'rxjs/operators' | 2 | import { catchError, switchMap } from 'rxjs/operators' |
3 | import { HTTP_INTERCEPTORS, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpErrorResponse } from '@angular/common/http' | 3 | import { HTTP_INTERCEPTORS, HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http' |
4 | import { Injectable, Injector } from '@angular/core' | 4 | import { Injectable, Injector } from '@angular/core' |
5 | import { AuthService } from '@app/core/auth/auth.service' | ||
6 | import { Router } from '@angular/router' | 5 | import { Router } from '@angular/router' |
7 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 6 | import { AuthService } from '@app/core/auth/auth.service' |
8 | import { OAuth2ErrorCode, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models/server' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { OAuth2ErrorCode, PeerTubeProblemDocument } from '@shared/models/server' | ||
9 | 9 | ||
10 | @Injectable() | 10 | @Injectable() |
11 | export class AuthInterceptor implements HttpInterceptor { | 11 | export class AuthInterceptor implements HttpInterceptor { |
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index e59d8b940..97437ce45 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | import './embed.scss' | 1 | import './embed.scss' |
2 | import videojs from 'video.js' | 2 | import videojs from 'video.js' |
3 | import { peertubeTranslate } from '../../../../shared/core-utils/i18n' | 3 | import { peertubeTranslate } from '../../../../shared/core-utils/i18n' |
4 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
5 | import { | 4 | import { |
6 | HTMLServerConfig, | 5 | HTMLServerConfig, |
6 | HttpStatusCode, | ||
7 | OAuth2ErrorCode, | 7 | OAuth2ErrorCode, |
8 | ResultList, | 8 | ResultList, |
9 | UserRefreshToken, | 9 | UserRefreshToken, |
@@ -125,7 +125,7 @@ import { PeerTubeVersionCheckScheduler } from './server/lib/schedulers/peertube- | |||
125 | import { Hooks } from './server/lib/plugins/hooks' | 125 | import { Hooks } from './server/lib/plugins/hooks' |
126 | import { PluginManager } from './server/lib/plugins/plugin-manager' | 126 | import { PluginManager } from './server/lib/plugins/plugin-manager' |
127 | import { LiveManager } from './server/lib/live' | 127 | import { LiveManager } from './server/lib/live' |
128 | import { HttpStatusCode } from './shared/core-utils/miscs/http-error-codes' | 128 | import { HttpStatusCode } from './shared/models/http/http-error-codes' |
129 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' | 129 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' |
130 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 130 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
131 | 131 | ||
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts index 14f301ab7..30662990a 100644 --- a/server/controllers/activitypub/inbox.ts +++ b/server/controllers/activitypub/inbox.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { InboxManager } from '@server/lib/activitypub/inbox-manager' | 2 | import { InboxManager } from '@server/lib/activitypub/inbox-manager' |
3 | import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' | 3 | import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' |
4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
5 | import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' | 5 | import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
7 | import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares' | 7 | import { asyncMiddleware, checkSignature, localAccountValidator, localVideoChannelValidator, signatureValidator } from '../../middlewares' |
diff --git a/server/controllers/api/abuse.ts b/server/controllers/api/abuse.ts index ba5b94840..e851365e9 100644 --- a/server/controllers/api/abuse.ts +++ b/server/controllers/api/abuse.ts | |||
@@ -6,7 +6,7 @@ import { AbuseModel } from '@server/models/abuse/abuse' | |||
6 | import { AbuseMessageModel } from '@server/models/abuse/abuse-message' | 6 | import { AbuseMessageModel } from '@server/models/abuse/abuse-message' |
7 | import { getServerActor } from '@server/models/application/application' | 7 | import { getServerActor } from '@server/models/application/application' |
8 | import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' | 8 | import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' |
9 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 9 | import { HttpStatusCode } from '@shared/models' |
10 | import { AbuseCreate, AbuseState, UserRight } from '../../../shared' | 10 | import { AbuseCreate, AbuseState, UserRight } from '../../../shared' |
11 | import { getFormattedObjects } from '../../helpers/utils' | 11 | import { getFormattedObjects } from '../../helpers/utils' |
12 | import { sequelizeTypescript } from '../../initializers/database' | 12 | import { sequelizeTypescript } from '../../initializers/database' |
diff --git a/server/controllers/api/bulk.ts b/server/controllers/api/bulk.ts index 192daccde..10d83571d 100644 --- a/server/controllers/api/bulk.ts +++ b/server/controllers/api/bulk.ts | |||
@@ -4,7 +4,7 @@ import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bu | |||
4 | import { VideoCommentModel } from '@server/models/video/video-comment' | 4 | import { VideoCommentModel } from '@server/models/video/video-comment' |
5 | import { removeComment } from '@server/lib/video-comment' | 5 | import { removeComment } from '@server/lib/video-comment' |
6 | import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' | 6 | import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' |
7 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | 8 | ||
9 | const bulkRouter = express.Router() | 9 | const bulkRouter = express.Router() |
10 | 10 | ||
diff --git a/server/controllers/api/custom-page.ts b/server/controllers/api/custom-page.ts index c19f03c56..cc1aa8427 100644 --- a/server/controllers/api/custom-page.ts +++ b/server/controllers/api/custom-page.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 2 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
3 | import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' | 3 | import { ActorCustomPageModel } from '@server/models/account/actor-custom-page' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { UserRight } from '@shared/models' | 5 | import { UserRight } from '@shared/models' |
6 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' | 6 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' |
7 | 7 | ||
diff --git a/server/controllers/api/index.ts b/server/controllers/api/index.ts index 28378654a..93b14dadb 100644 --- a/server/controllers/api/index.ts +++ b/server/controllers/api/index.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as cors from 'cors' | 1 | import * as cors from 'cors' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import * as RateLimit from 'express-rate-limit' | 3 | import * as RateLimit from 'express-rate-limit' |
4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '../../../shared/models' |
5 | import { badRequest } from '../../helpers/express-utils' | 5 | import { badRequest } from '../../helpers/express-utils' |
6 | import { CONFIG } from '../../initializers/config' | 6 | import { CONFIG } from '../../initializers/config' |
7 | import { abuseRouter } from './abuse' | 7 | import { abuseRouter } from './abuse' |
diff --git a/server/controllers/api/oauth-clients.ts b/server/controllers/api/oauth-clients.ts index 15bbf5c4d..f95f06864 100644 --- a/server/controllers/api/oauth-clients.ts +++ b/server/controllers/api/oauth-clients.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { OAuthClientLocal } from '../../../shared' | 2 | import { OAuthClientLocal } from '../../../shared' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { logger } from '../../helpers/logger' | 4 | import { logger } from '../../helpers/logger' |
5 | import { CONFIG } from '../../initializers/config' | 5 | import { CONFIG } from '../../initializers/config' |
6 | import { asyncMiddleware, openapiOperationDoc } from '../../middlewares' | 6 | import { asyncMiddleware, openapiOperationDoc } from '../../middlewares' |
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts index 1e6a02c49..4b213c246 100644 --- a/server/controllers/api/plugins.ts +++ b/server/controllers/api/plugins.ts | |||
@@ -23,7 +23,7 @@ import { | |||
23 | updatePluginSettingsValidator | 23 | updatePluginSettingsValidator |
24 | } from '@server/middlewares/validators/plugins' | 24 | } from '@server/middlewares/validators/plugins' |
25 | import { PluginModel } from '@server/models/server/plugin' | 25 | import { PluginModel } from '@server/models/server/plugin' |
26 | import { HttpStatusCode } from '@shared/core-utils' | 26 | import { HttpStatusCode } from '@shared/models' |
27 | import { | 27 | import { |
28 | InstallOrUpdatePlugin, | 28 | InstallOrUpdatePlugin, |
29 | ManagePlugin, | 29 | ManagePlugin, |
diff --git a/server/controllers/api/search/search-video-channels.ts b/server/controllers/api/search/search-video-channels.ts index 16beeed60..fe9178e69 100644 --- a/server/controllers/api/search/search-video-channels.ts +++ b/server/controllers/api/search/search-video-channels.ts | |||
@@ -6,7 +6,7 @@ import { WEBSERVER } from '@server/initializers/constants' | |||
6 | import { Hooks } from '@server/lib/plugins/hooks' | 6 | import { Hooks } from '@server/lib/plugins/hooks' |
7 | import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' | 7 | import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' |
8 | import { getServerActor } from '@server/models/application/application' | 8 | import { getServerActor } from '@server/models/application/application' |
9 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 9 | import { HttpStatusCode } from '@shared/models' |
10 | import { ResultList, VideoChannel } from '@shared/models' | 10 | import { ResultList, VideoChannel } from '@shared/models' |
11 | import { VideoChannelsSearchQuery } from '../../../../shared/models/search' | 11 | import { VideoChannelsSearchQuery } from '../../../../shared/models/search' |
12 | import { isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' | 12 | 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 b231ff1e2..a0e2c1747 100644 --- a/server/controllers/api/search/search-video-playlists.ts +++ b/server/controllers/api/search/search-video-playlists.ts | |||
@@ -11,7 +11,7 @@ import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@ser | |||
11 | import { getServerActor } from '@server/models/application/application' | 11 | import { getServerActor } from '@server/models/application/application' |
12 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' | 12 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' |
13 | import { MVideoPlaylistFullSummary } from '@server/types/models' | 13 | import { MVideoPlaylistFullSummary } from '@server/types/models' |
14 | import { HttpStatusCode } from '@shared/core-utils' | 14 | import { HttpStatusCode } from '@shared/models' |
15 | import { ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models' | 15 | import { ResultList, VideoPlaylist, VideoPlaylistsSearchQuery } from '@shared/models' |
16 | import { | 16 | import { |
17 | asyncMiddleware, | 17 | asyncMiddleware, |
diff --git a/server/controllers/api/search/search-videos.ts b/server/controllers/api/search/search-videos.ts index b626baa28..0e6fd9c72 100644 --- a/server/controllers/api/search/search-videos.ts +++ b/server/controllers/api/search/search-videos.ts | |||
@@ -6,7 +6,7 @@ import { WEBSERVER } from '@server/initializers/constants' | |||
6 | import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' | 6 | import { getOrCreateAPVideo } from '@server/lib/activitypub/videos' |
7 | import { Hooks } from '@server/lib/plugins/hooks' | 7 | import { Hooks } from '@server/lib/plugins/hooks' |
8 | import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' | 8 | import { buildMutedForSearchIndex, isSearchIndexSearch, isURISearch } from '@server/lib/search' |
9 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 9 | import { HttpStatusCode } from '@shared/models' |
10 | import { ResultList, Video } from '@shared/models' | 10 | import { ResultList, Video } from '@shared/models' |
11 | import { VideosSearchQuery } from '../../../../shared/models/search' | 11 | import { VideosSearchQuery } from '../../../../shared/models/search' |
12 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' | 12 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../../helpers/express-utils' |
diff --git a/server/controllers/api/server/contact.ts b/server/controllers/api/server/contact.ts index caddc0909..ae36dd599 100644 --- a/server/controllers/api/server/contact.ts +++ b/server/controllers/api/server/contact.ts | |||
@@ -3,7 +3,7 @@ import { asyncMiddleware, contactAdministratorValidator } from '../../../middlew | |||
3 | import { Redis } from '../../../lib/redis' | 3 | import { Redis } from '../../../lib/redis' |
4 | import { Emailer } from '../../../lib/emailer' | 4 | import { Emailer } from '../../../lib/emailer' |
5 | import { ContactForm } from '../../../../shared/models/server' | 5 | import { ContactForm } from '../../../../shared/models/server' |
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
7 | 7 | ||
8 | const contactRouter = express.Router() | 8 | const contactRouter = express.Router() |
9 | 9 | ||
@@ -15,7 +15,7 @@ contactRouter.post('/contact', | |||
15 | async function contactAdministrator (req: express.Request, res: express.Response) { | 15 | async function contactAdministrator (req: express.Request, res: express.Response) { |
16 | const data = req.body as ContactForm | 16 | const data = req.body as ContactForm |
17 | 17 | ||
18 | await Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body) | 18 | Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body) |
19 | 19 | ||
20 | await Redis.Instance.setContactFormIp(req.ip) | 20 | await Redis.Instance.setContactFormIp(req.ip) |
21 | 21 | ||
diff --git a/server/controllers/api/server/debug.ts b/server/controllers/api/server/debug.ts index 31888e963..0601b89ce 100644 --- a/server/controllers/api/server/debug.ts +++ b/server/controllers/api/server/debug.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import { InboxManager } from '@server/lib/activitypub/inbox-manager' | 2 | import { InboxManager } from '@server/lib/activitypub/inbox-manager' |
3 | import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' | 3 | import { RemoveDanglingResumableUploadsScheduler } from '@server/lib/schedulers/remove-dangling-resumable-uploads-scheduler' |
4 | import { Debug, SendDebugCommand } from '@shared/models' | 4 | import { Debug, SendDebugCommand } from '@shared/models' |
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 5 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
6 | import { UserRight } from '../../../../shared/models/users' | 6 | import { UserRight } from '../../../../shared/models/users' |
7 | import { authenticate, ensureUserHasRight } from '../../../middlewares' | 7 | import { authenticate, ensureUserHasRight } from '../../../middlewares' |
8 | 8 | ||
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 12357a2ca..e6f4f6b92 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { getServerActor } from '@server/models/application/application' | 2 | import { getServerActor } from '@server/models/application/application' |
3 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { UserRight } from '../../../../shared/models/users' | 4 | import { UserRight } from '../../../../shared/models/users' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
6 | import { getFormattedObjects } from '../../../helpers/utils' | 6 | import { getFormattedObjects } from '../../../helpers/utils' |
diff --git a/server/controllers/api/server/redundancy.ts b/server/controllers/api/server/redundancy.ts index bc593ad43..99d1c762b 100644 --- a/server/controllers/api/server/redundancy.ts +++ b/server/controllers/api/server/redundancy.ts | |||
@@ -1,5 +1,10 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { JobQueue } from '@server/lib/job-queue' | ||
3 | import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' | ||
4 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | ||
2 | import { UserRight } from '../../../../shared/models/users' | 5 | import { UserRight } from '../../../../shared/models/users' |
6 | import { logger } from '../../../helpers/logger' | ||
7 | import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy' | ||
3 | import { | 8 | import { |
4 | asyncMiddleware, | 9 | asyncMiddleware, |
5 | authenticate, | 10 | authenticate, |
@@ -10,16 +15,11 @@ import { | |||
10 | videoRedundanciesSortValidator | 15 | videoRedundanciesSortValidator |
11 | } from '../../../middlewares' | 16 | } from '../../../middlewares' |
12 | import { | 17 | import { |
13 | listVideoRedundanciesValidator, | ||
14 | updateServerRedundancyValidator, | ||
15 | addVideoRedundancyValidator, | 18 | addVideoRedundancyValidator, |
16 | removeVideoRedundancyValidator | 19 | listVideoRedundanciesValidator, |
20 | removeVideoRedundancyValidator, | ||
21 | updateServerRedundancyValidator | ||
17 | } from '../../../middlewares/validators/redundancy' | 22 | } from '../../../middlewares/validators/redundancy' |
18 | import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy' | ||
19 | import { logger } from '../../../helpers/logger' | ||
20 | import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy' | ||
21 | import { JobQueue } from '@server/lib/job-queue' | ||
22 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
23 | 23 | ||
24 | const serverRedundancyRouter = express.Router() | 24 | const serverRedundancyRouter = express.Router() |
25 | 25 | ||
diff --git a/server/controllers/api/server/server-blocklist.ts b/server/controllers/api/server/server-blocklist.ts index a86bc7d19..b3ee50d85 100644 --- a/server/controllers/api/server/server-blocklist.ts +++ b/server/controllers/api/server/server-blocklist.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { UserNotificationModel } from '@server/models/user/user-notification' | ||
5 | import { getServerActor } from '@server/models/application/application' | 4 | import { getServerActor } from '@server/models/application/application' |
5 | import { UserNotificationModel } from '@server/models/user/user-notification' | ||
6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | ||
6 | import { UserRight } from '../../../../shared/models/users' | 7 | import { UserRight } from '../../../../shared/models/users' |
7 | import { getFormattedObjects } from '../../../helpers/utils' | 8 | import { getFormattedObjects } from '../../../helpers/utils' |
8 | import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' | 9 | import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist, removeServerFromBlocklist } from '../../../lib/blocklist' |
@@ -25,7 +26,6 @@ import { | |||
25 | } from '../../../middlewares/validators' | 26 | } from '../../../middlewares/validators' |
26 | import { AccountBlocklistModel } from '../../../models/account/account-blocklist' | 27 | import { AccountBlocklistModel } from '../../../models/account/account-blocklist' |
27 | import { ServerBlocklistModel } from '../../../models/server/server-blocklist' | 28 | import { ServerBlocklistModel } from '../../../models/server/server-blocklist' |
28 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
29 | 29 | ||
30 | const serverBlocklistRouter = express.Router() | 30 | const serverBlocklistRouter = express.Router() |
31 | 31 | ||
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts index b86fc94ef..be800e8b5 100644 --- a/server/controllers/api/users/index.ts +++ b/server/controllers/api/users/index.ts | |||
@@ -5,7 +5,7 @@ import { Hooks } from '@server/lib/plugins/hooks' | |||
5 | import { OAuthTokenModel } from '@server/models/oauth/oauth-token' | 5 | import { OAuthTokenModel } from '@server/models/oauth/oauth-token' |
6 | import { MUser, MUserAccountDefault } from '@server/types/models' | 6 | import { MUser, MUserAccountDefault } from '@server/types/models' |
7 | import { UserCreate, UserCreateResult, UserRight, UserRole, UserUpdate } from '../../../../shared' | 7 | import { UserCreate, UserCreateResult, UserRight, UserRole, UserUpdate } from '../../../../shared' |
8 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 8 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
9 | import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' | 9 | import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model' |
10 | import { UserRegister } from '../../../../shared/models/users/user-register.model' | 10 | import { UserRegister } from '../../../../shared/models/users/user-register.model' |
11 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger' | 11 | 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 1f2b2f9dd..c9610c59f 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -3,7 +3,7 @@ import * as express from 'express' | |||
3 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' | 3 | import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '@server/helpers/audit-logger' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
5 | import { ActorImageType, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' | 5 | import { ActorImageType, UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared' |
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
7 | import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' | 7 | import { UserVideoQuota } from '../../../../shared/models/users/user-video-quota.model' |
8 | import { createReqFiles } from '../../../helpers/express-utils' | 8 | import { createReqFiles } from '../../../helpers/express-utils' |
9 | import { getFormattedObjects } from '../../../helpers/utils' | 9 | import { getFormattedObjects } from '../../../helpers/utils' |
diff --git a/server/controllers/api/users/my-blocklist.ts b/server/controllers/api/users/my-blocklist.ts index a1561b751..fe11b6e77 100644 --- a/server/controllers/api/users/my-blocklist.ts +++ b/server/controllers/api/users/my-blocklist.ts | |||
@@ -22,7 +22,7 @@ import { addAccountInBlocklist, addServerInBlocklist, removeAccountFromBlocklist | |||
22 | import { ServerBlocklistModel } from '../../../models/server/server-blocklist' | 22 | import { ServerBlocklistModel } from '../../../models/server/server-blocklist' |
23 | import { UserNotificationModel } from '@server/models/user/user-notification' | 23 | import { UserNotificationModel } from '@server/models/user/user-notification' |
24 | import { logger } from '@server/helpers/logger' | 24 | import { logger } from '@server/helpers/logger' |
25 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 25 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
26 | 26 | ||
27 | const myBlocklistRouter = express.Router() | 27 | const myBlocklistRouter = express.Router() |
28 | 28 | ||
diff --git a/server/controllers/api/users/my-history.ts b/server/controllers/api/users/my-history.ts index cff1697ab..85e04925e 100644 --- a/server/controllers/api/users/my-history.ts +++ b/server/controllers/api/users/my-history.ts | |||
@@ -11,7 +11,7 @@ import { | |||
11 | import { getFormattedObjects } from '../../../helpers/utils' | 11 | import { getFormattedObjects } from '../../../helpers/utils' |
12 | import { UserVideoHistoryModel } from '../../../models/user/user-video-history' | 12 | import { UserVideoHistoryModel } from '../../../models/user/user-video-history' |
13 | import { sequelizeTypescript } from '../../../initializers/database' | 13 | import { sequelizeTypescript } from '../../../initializers/database' |
14 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 14 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
15 | 15 | ||
16 | const myVideosHistoryRouter = express.Router() | 16 | const myVideosHistoryRouter = express.Router() |
17 | 17 | ||
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts index 2909770da..3beee07c0 100644 --- a/server/controllers/api/users/my-notifications.ts +++ b/server/controllers/api/users/my-notifications.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import 'multer' | 1 | import 'multer' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { UserNotificationModel } from '@server/models/user/user-notification' | 3 | import { UserNotificationModel } from '@server/models/user/user-notification' |
4 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
5 | import { UserNotificationSetting } from '../../../../shared/models/users' | 5 | import { UserNotificationSetting } from '../../../../shared/models/users' |
6 | import { getFormattedObjects } from '../../../helpers/utils' | 6 | import { getFormattedObjects } from '../../../helpers/utils' |
7 | import { | 7 | import { |
diff --git a/server/controllers/api/users/my-subscriptions.ts b/server/controllers/api/users/my-subscriptions.ts index 46a73d49e..84f519926 100644 --- a/server/controllers/api/users/my-subscriptions.ts +++ b/server/controllers/api/users/my-subscriptions.ts | |||
@@ -3,7 +3,7 @@ import * as express from 'express' | |||
3 | import { sendUndoFollow } from '@server/lib/activitypub/send' | 3 | import { sendUndoFollow } from '@server/lib/activitypub/send' |
4 | import { VideoChannelModel } from '@server/models/video/video-channel' | 4 | import { VideoChannelModel } from '@server/models/video/video-channel' |
5 | import { VideosCommonQuery } from '@shared/models' | 5 | import { VideosCommonQuery } from '@shared/models' |
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
7 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' | 7 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' |
8 | import { getFormattedObjects } from '../../../helpers/utils' | 8 | import { getFormattedObjects } from '../../../helpers/utils' |
9 | import { WEBSERVER } from '../../../initializers/constants' | 9 | import { WEBSERVER } from '../../../initializers/constants' |
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index bc8d203b0..784f97b1e 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -3,7 +3,7 @@ import { Hooks } from '@server/lib/plugins/hooks' | |||
3 | import { getServerActor } from '@server/models/application/application' | 3 | import { getServerActor } from '@server/models/application/application' |
4 | import { MChannelBannerAccountDefault } from '@server/types/models' | 4 | import { MChannelBannerAccountDefault } from '@server/types/models' |
5 | import { ActorImageType, VideoChannelCreate, VideoChannelUpdate, VideosCommonQuery } from '../../../shared' | 5 | import { ActorImageType, VideoChannelCreate, VideoChannelUpdate, VideosCommonQuery } from '../../../shared' |
6 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
7 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' | 7 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' |
8 | import { resetSequelizeInstance } from '../../helpers/database-utils' | 8 | import { resetSequelizeInstance } from '../../helpers/database-utils' |
9 | import { buildNSFWFilter, createReqFiles, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 9 | 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 78cbd9cff..4971d0a77 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts | |||
@@ -6,7 +6,7 @@ import { Hooks } from '@server/lib/plugins/hooks' | |||
6 | import { getServerActor } from '@server/models/application/application' | 6 | import { getServerActor } from '@server/models/application/application' |
7 | import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' | 7 | import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models' |
8 | import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models' | 8 | import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models' |
9 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 9 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
10 | import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' | 10 | import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model' |
11 | import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' | 11 | import { VideoPlaylistElementCreate } from '../../../shared/models/videos/playlist/video-playlist-element-create.model' |
12 | import { VideoPlaylistElementUpdate } from '../../../shared/models/videos/playlist/video-playlist-element-update.model' | 12 | 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 530e17965..a7f5f53d8 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts | |||
@@ -19,7 +19,7 @@ import { | |||
19 | videosBlacklistUpdateValidator | 19 | videosBlacklistUpdateValidator |
20 | } from '../../../middlewares' | 20 | } from '../../../middlewares' |
21 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | 21 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' |
22 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 22 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
23 | 23 | ||
24 | const blacklistRouter = express.Router() | 24 | const blacklistRouter = express.Router() |
25 | 25 | ||
diff --git a/server/controllers/api/videos/captions.ts b/server/controllers/api/videos/captions.ts index ad7423a31..4008de60f 100644 --- a/server/controllers/api/videos/captions.ts +++ b/server/controllers/api/videos/captions.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { MVideoCaption } from '@server/types/models' | 2 | import { MVideoCaption } from '@server/types/models' |
3 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' | 4 | import { moveAndProcessCaptionFile } from '../../../helpers/captions-utils' |
5 | import { createReqFiles } from '../../../helpers/express-utils' | 5 | import { createReqFiles } from '../../../helpers/express-utils' |
6 | import { logger } from '../../../helpers/logger' | 6 | import { logger } from '../../../helpers/logger' |
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index 6a25511e5..90b633bb5 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
3 | import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' | 3 | import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' |
4 | import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' | 4 | import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' |
5 | import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' | 5 | 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 74b100e59..5a2ff81dc 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -6,7 +6,7 @@ import { openapiOperationDoc } from '@server/middlewares/doc' | |||
6 | import { getServerActor } from '@server/models/application/application' | 6 | import { getServerActor } from '@server/models/application/application' |
7 | import { MVideoAccountLight } from '@server/types/models' | 7 | import { MVideoAccountLight } from '@server/types/models' |
8 | import { VideosCommonQuery } from '../../../../shared' | 8 | import { VideosCommonQuery } from '../../../../shared' |
9 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs' | 9 | import { HttpStatusCode } from '../../../../shared/models' |
10 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 10 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
11 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' | 11 | import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils' |
12 | import { logger } from '../../../helpers/logger' | 12 | import { logger } from '../../../helpers/logger' |
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts index d8c51c2d4..ed4da8f47 100644 --- a/server/controllers/api/videos/live.ts +++ b/server/controllers/api/videos/live.ts | |||
@@ -11,7 +11,7 @@ import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator | |||
11 | import { VideoLiveModel } from '@server/models/video/video-live' | 11 | import { VideoLiveModel } from '@server/models/video/video-live' |
12 | import { MVideoDetails, MVideoFullLight } from '@server/types/models' | 12 | import { MVideoDetails, MVideoFullLight } from '@server/types/models' |
13 | import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared' | 13 | import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared' |
14 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 14 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
15 | import { logger } from '../../../helpers/logger' | 15 | import { logger } from '../../../helpers/logger' |
16 | import { sequelizeTypescript } from '../../../initializers/database' | 16 | import { sequelizeTypescript } from '../../../initializers/database' |
17 | import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail' | 17 | import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail' |
diff --git a/server/controllers/api/videos/ownership.ts b/server/controllers/api/videos/ownership.ts index 1bb96e046..e6c94a45a 100644 --- a/server/controllers/api/videos/ownership.ts +++ b/server/controllers/api/videos/ownership.ts | |||
@@ -19,7 +19,7 @@ import { changeVideoChannelShare } from '../../../lib/activitypub/share' | |||
19 | import { sendUpdateVideo } from '../../../lib/activitypub/send' | 19 | import { sendUpdateVideo } from '../../../lib/activitypub/send' |
20 | import { VideoModel } from '../../../models/video/video' | 20 | import { VideoModel } from '../../../models/video/video' |
21 | import { MVideoFullLight } from '@server/types/models' | 21 | import { MVideoFullLight } from '@server/types/models' |
22 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 22 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
23 | 23 | ||
24 | const ownershipVideoRouter = express.Router() | 24 | const ownershipVideoRouter = express.Router() |
25 | 25 | ||
diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index 84f42633e..134c9e5ca 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts | |||
@@ -7,7 +7,7 @@ import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoUp | |||
7 | import { AccountModel } from '../../../models/account/account' | 7 | import { AccountModel } from '../../../models/account/account' |
8 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 8 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
9 | import { sequelizeTypescript } from '../../../initializers/database' | 9 | import { sequelizeTypescript } from '../../../initializers/database' |
10 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 10 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
11 | 11 | ||
12 | const rateVideoRouter = express.Router() | 12 | const rateVideoRouter = express.Router() |
13 | 13 | ||
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts index 8affe71c6..49639060b 100644 --- a/server/controllers/api/videos/update.ts +++ b/server/controllers/api/videos/update.ts | |||
@@ -2,10 +2,11 @@ import * as express from 'express' | |||
2 | import { Transaction } from 'sequelize/types' | 2 | import { Transaction } from 'sequelize/types' |
3 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' | 3 | import { changeVideoChannelShare } from '@server/lib/activitypub/share' |
4 | import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' | 4 | import { buildVideoThumbnailsFromReq, setVideoTags } from '@server/lib/video' |
5 | import { openapiOperationDoc } from '@server/middlewares/doc' | ||
5 | import { FilteredModelAttributes } from '@server/types' | 6 | import { FilteredModelAttributes } from '@server/types' |
6 | import { MVideoFullLight } from '@server/types/models' | 7 | import { MVideoFullLight } from '@server/types/models' |
7 | import { VideoUpdate } from '../../../../shared' | 8 | import { VideoUpdate } from '../../../../shared' |
8 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs' | 9 | import { HttpStatusCode } from '../../../../shared/models' |
9 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 10 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
10 | import { resetSequelizeInstance } from '../../../helpers/database-utils' | 11 | import { resetSequelizeInstance } from '../../../helpers/database-utils' |
11 | import { createReqFiles } from '../../../helpers/express-utils' | 12 | import { createReqFiles } from '../../../helpers/express-utils' |
@@ -20,7 +21,6 @@ import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' | |||
20 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares' | 21 | import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videosUpdateValidator } from '../../../middlewares' |
21 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' | 22 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' |
22 | import { VideoModel } from '../../../models/video/video' | 23 | import { VideoModel } from '../../../models/video/video' |
23 | import { openapiOperationDoc } from '@server/middlewares/doc' | ||
24 | 24 | ||
25 | const lTags = loggerTagsFactory('api', 'video') | 25 | const lTags = loggerTagsFactory('api', 'video') |
26 | const auditLogger = auditLoggerFactory('videos') | 26 | const auditLogger = auditLoggerFactory('videos') |
diff --git a/server/controllers/api/videos/upload.ts b/server/controllers/api/videos/upload.ts index bcd21ac99..1603ef127 100644 --- a/server/controllers/api/videos/upload.ts +++ b/server/controllers/api/videos/upload.ts | |||
@@ -11,7 +11,7 @@ import { openapiOperationDoc } from '@server/middlewares/doc' | |||
11 | import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' | 11 | import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' |
12 | import { uploadx } from '@uploadx/core' | 12 | import { uploadx } from '@uploadx/core' |
13 | import { VideoCreate, VideoState } from '../../../../shared' | 13 | import { VideoCreate, VideoState } from '../../../../shared' |
14 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs' | 14 | import { HttpStatusCode } from '../../../../shared/models' |
15 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' | 15 | import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' |
16 | import { retryTransactionWrapper } from '../../../helpers/database-utils' | 16 | import { retryTransactionWrapper } from '../../../helpers/database-utils' |
17 | import { createReqFiles } from '../../../helpers/express-utils' | 17 | import { createReqFiles } from '../../../helpers/express-utils' |
diff --git a/server/controllers/api/videos/watching.ts b/server/controllers/api/videos/watching.ts index 8b15525aa..2899dbd9c 100644 --- a/server/controllers/api/videos/watching.ts +++ b/server/controllers/api/videos/watching.ts | |||
@@ -8,7 +8,7 @@ import { | |||
8 | videoWatchingValidator | 8 | videoWatchingValidator |
9 | } from '../../../middlewares' | 9 | } from '../../../middlewares' |
10 | import { UserVideoHistoryModel } from '../../../models/user/user-video-history' | 10 | import { UserVideoHistoryModel } from '../../../models/user/user-video-history' |
11 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 11 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
12 | 12 | ||
13 | const watchingRouter = express.Router() | 13 | const watchingRouter = express.Router() |
14 | 14 | ||
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index eb1ee6cbd..ba3c54440 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -5,7 +5,7 @@ import { join } from 'path' | |||
5 | import { logger } from '@server/helpers/logger' | 5 | import { logger } from '@server/helpers/logger' |
6 | import { CONFIG } from '@server/initializers/config' | 6 | import { CONFIG } from '@server/initializers/config' |
7 | import { Hooks } from '@server/lib/plugins/hooks' | 7 | import { Hooks } from '@server/lib/plugins/hooks' |
8 | import { HttpStatusCode } from '@shared/core-utils' | 8 | import { HttpStatusCode } from '@shared/models' |
9 | import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n' | 9 | import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '@shared/core-utils/i18n' |
10 | import { root } from '../helpers/core-utils' | 10 | import { root } from '../helpers/core-utils' |
11 | import { STATIC_MAX_AGE } from '../initializers/constants' | 11 | import { STATIC_MAX_AGE } from '../initializers/constants' |
diff --git a/server/controllers/download.ts b/server/controllers/download.ts index 4293a32e2..13bc66900 100644 --- a/server/controllers/download.ts +++ b/server/controllers/download.ts | |||
@@ -5,7 +5,7 @@ import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache | |||
5 | import { Hooks } from '@server/lib/plugins/hooks' | 5 | import { Hooks } from '@server/lib/plugins/hooks' |
6 | import { getVideoFilePath } from '@server/lib/video-paths' | 6 | import { getVideoFilePath } from '@server/lib/video-paths' |
7 | import { MStreamingPlaylist, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' | 7 | import { MStreamingPlaylist, MVideo, MVideoFile, MVideoFullLight } from '@server/types/models' |
8 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 8 | import { HttpStatusCode } from '@shared/models' |
9 | import { VideoStreamingPlaylistType } from '@shared/models' | 9 | import { VideoStreamingPlaylistType } from '@shared/models' |
10 | import { STATIC_DOWNLOAD_PATHS } from '../initializers/constants' | 10 | import { STATIC_DOWNLOAD_PATHS } from '../initializers/constants' |
11 | import { asyncMiddleware, videosDownloadValidator } from '../middlewares' | 11 | import { asyncMiddleware, videosDownloadValidator } from '../middlewares' |
diff --git a/server/controllers/lazy-static.ts b/server/controllers/lazy-static.ts index 9a7dacba0..632e4dcd8 100644 --- a/server/controllers/lazy-static.ts +++ b/server/controllers/lazy-static.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as cors from 'cors' | 1 | import * as cors from 'cors' |
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' | 3 | import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache' |
4 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
5 | import { logger } from '../helpers/logger' | 5 | import { logger } from '../helpers/logger' |
6 | import { LAZY_STATIC_PATHS, STATIC_MAX_AGE } from '../initializers/constants' | 6 | import { LAZY_STATIC_PATHS, STATIC_MAX_AGE } from '../initializers/constants' |
7 | import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache' | 7 | import { VideosCaptionCache, VideosPreviewCache } from '../lib/files-cache' |
diff --git a/server/controllers/live.ts b/server/controllers/live.ts index f2686fb23..95d5c0135 100644 --- a/server/controllers/live.ts +++ b/server/controllers/live.ts | |||
@@ -2,7 +2,7 @@ import * as cors from 'cors' | |||
2 | import * as express from 'express' | 2 | import * as express from 'express' |
3 | import { mapToJSON } from '@server/helpers/core-utils' | 3 | import { mapToJSON } from '@server/helpers/core-utils' |
4 | import { LiveSegmentShaStore } from '@server/lib/live' | 4 | import { LiveSegmentShaStore } from '@server/lib/live' |
5 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | 6 | ||
7 | const liveRouter = express.Router() | 7 | const liveRouter = express.Router() |
8 | 8 | ||
diff --git a/server/controllers/plugins.ts b/server/controllers/plugins.ts index 7213e3f15..11ab3f10a 100644 --- a/server/controllers/plugins.ts +++ b/server/controllers/plugins.ts | |||
@@ -3,7 +3,7 @@ import { join } from 'path' | |||
3 | import { logger } from '@server/helpers/logger' | 3 | import { logger } from '@server/helpers/logger' |
4 | import { optionalAuthenticate } from '@server/middlewares/auth' | 4 | import { optionalAuthenticate } from '@server/middlewares/auth' |
5 | import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n' | 5 | import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n' |
6 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
7 | import { PluginType } from '../../shared/models/plugins/plugin.type' | 7 | import { PluginType } from '../../shared/models/plugins/plugin.type' |
8 | import { isTestInstance } from '../helpers/core-utils' | 8 | import { isTestInstance } from '../helpers/core-utils' |
9 | import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants' | 9 | import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants' |
diff --git a/server/controllers/static.ts b/server/controllers/static.ts index 35e024dda..5900eaff3 100644 --- a/server/controllers/static.ts +++ b/server/controllers/static.ts | |||
@@ -3,7 +3,7 @@ import * as express from 'express' | |||
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { serveIndexHTML } from '@server/lib/client-html' | 4 | import { serveIndexHTML } from '@server/lib/client-html' |
5 | import { ServerConfigManager } from '@server/lib/server-config-manager' | 5 | import { ServerConfigManager } from '@server/lib/server-config-manager' |
6 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model' | 7 | import { HttpNodeinfoDiasporaSoftwareNsSchema20 } from '../../shared/models/nodeinfo/nodeinfo.model' |
8 | import { root } from '../helpers/core-utils' | 8 | import { root } from '../helpers/core-utils' |
9 | import { CONFIG, isEmailEnabled } from '../initializers/config' | 9 | 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 0e1c63bad..cf15b385a 100644 --- a/server/helpers/custom-validators/video-ownership.ts +++ b/server/helpers/custom-validators/video-ownership.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Response } from 'express' | 1 | import { Response } from 'express' |
2 | import { MUserId } from '@server/types/models' | 2 | import { MUserId } from '@server/types/models' |
3 | import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership' | 3 | import { MVideoChangeOwnershipFull } from '@server/types/models/video/video-change-ownership' |
4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
5 | 5 | ||
6 | function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) { | 6 | function checkUserCanTerminateOwnershipChange (user: MUserId, videoChangeOwnership: MVideoChangeOwnershipFull, res: Response) { |
7 | if (videoChangeOwnership.NextOwner.userId === user.id) { | 7 | if (videoChangeOwnership.NextOwner.userId === user.id) { |
diff --git a/server/helpers/express-utils.ts b/server/helpers/express-utils.ts index 0ff113274..c299b70f1 100644 --- a/server/helpers/express-utils.ts +++ b/server/helpers/express-utils.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import * as multer from 'multer' | 2 | import * as multer from 'multer' |
3 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
4 | import { CONFIG } from '../initializers/config' | 4 | import { CONFIG } from '../initializers/config' |
5 | import { REMOTE_SCHEME } from '../initializers/constants' | 5 | import { REMOTE_SCHEME } from '../initializers/constants' |
6 | import { getLowercaseExtension } from './core-utils' | 6 | import { getLowercaseExtension } from './core-utils' |
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index fdd361390..3c80e7d41 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts | |||
@@ -3,7 +3,7 @@ import { ensureDir, move, pathExists, remove, writeFile } from 'fs-extra' | |||
3 | import got from 'got' | 3 | import got from 'got' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { CONFIG } from '@server/initializers/config' | 5 | import { CONFIG } from '@server/initializers/config' |
6 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
7 | import { VideoResolution } from '../../shared/models/videos' | 7 | import { VideoResolution } from '../../shared/models/videos' |
8 | import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES } from '../initializers/constants' | 8 | import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES } from '../initializers/constants' |
9 | import { peertubeTruncate, pipelinePromise, root } from './core-utils' | 9 | import { peertubeTruncate, pipelinePromise, root } from './core-utils' |
diff --git a/server/lib/activitypub/actors/refresh.ts b/server/lib/activitypub/actors/refresh.ts index b2fe3932f..0acaa9f62 100644 --- a/server/lib/activitypub/actors/refresh.ts +++ b/server/lib/activitypub/actors/refresh.ts | |||
@@ -4,7 +4,7 @@ import { PeerTubeRequestError } from '@server/helpers/requests' | |||
4 | import { ActorLoadByUrlType } from '@server/lib/model-loaders' | 4 | import { ActorLoadByUrlType } from '@server/lib/model-loaders' |
5 | import { ActorModel } from '@server/models/actor/actor' | 5 | import { ActorModel } from '@server/models/actor/actor' |
6 | import { MActorAccountChannelId, MActorFull } from '@server/types/models' | 6 | import { MActorAccountChannelId, MActorFull } from '@server/types/models' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { fetchRemoteActor } from './shared' | 8 | import { fetchRemoteActor } from './shared' |
9 | import { APActorUpdater } from './updater' | 9 | import { APActorUpdater } from './updater' |
10 | import { getUrlFromWebfinger } from './webfinger' | 10 | import { getUrlFromWebfinger } from './webfinger' |
diff --git a/server/lib/activitypub/playlists/refresh.ts b/server/lib/activitypub/playlists/refresh.ts index ef3cb3fe4..493e8c7ec 100644 --- a/server/lib/activitypub/playlists/refresh.ts +++ b/server/lib/activitypub/playlists/refresh.ts | |||
@@ -2,7 +2,7 @@ import { logger, loggerTagsFactory } from '@server/helpers/logger' | |||
2 | import { PeerTubeRequestError } from '@server/helpers/requests' | 2 | import { PeerTubeRequestError } from '@server/helpers/requests' |
3 | import { JobQueue } from '@server/lib/job-queue' | 3 | import { JobQueue } from '@server/lib/job-queue' |
4 | import { MVideoPlaylist, MVideoPlaylistOwner } from '@server/types/models' | 4 | import { MVideoPlaylist, MVideoPlaylistOwner } from '@server/types/models' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { createOrUpdateVideoPlaylist } from './create-update' | 6 | import { createOrUpdateVideoPlaylist } from './create-update' |
7 | import { fetchRemoteVideoPlaylist } from './shared' | 7 | import { fetchRemoteVideoPlaylist } from './shared' |
8 | 8 | ||
diff --git a/server/lib/activitypub/videos/refresh.ts b/server/lib/activitypub/videos/refresh.ts index a7b82f286..3af08acf4 100644 --- a/server/lib/activitypub/videos/refresh.ts +++ b/server/lib/activitypub/videos/refresh.ts | |||
@@ -4,7 +4,7 @@ import { ActorFollowScoreCache } from '@server/lib/files-cache' | |||
4 | import { VideoLoadByUrlType } from '@server/lib/model-loaders' | 4 | import { VideoLoadByUrlType } from '@server/lib/model-loaders' |
5 | import { VideoModel } from '@server/models/video/video' | 5 | import { VideoModel } from '@server/models/video/video' |
6 | import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models' | 6 | import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared' | 8 | import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared' |
9 | import { APVideoUpdater } from './updater' | 9 | import { APVideoUpdater } from './updater' |
10 | 10 | ||
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index 72194416d..c5d39445b 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -5,7 +5,7 @@ import validator from 'validator' | |||
5 | import { escapeHTML } from '@shared/core-utils/renderer' | 5 | import { escapeHTML } from '@shared/core-utils/renderer' |
6 | import { HTMLServerConfig } from '@shared/models' | 6 | import { HTMLServerConfig } from '@shared/models' |
7 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n' | 7 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n' |
8 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 8 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
9 | import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' | 9 | import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' |
10 | import { isTestInstance, sha256 } from '../helpers/core-utils' | 10 | import { isTestInstance, sha256 } from '../helpers/core-utils' |
11 | import { logger } from '../helpers/logger' | 11 | 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 1caca1dcc..56e2b0ceb 100644 --- a/server/lib/job-queue/handlers/activitypub-cleaner.ts +++ b/server/lib/job-queue/handlers/activitypub-cleaner.ts | |||
@@ -12,7 +12,7 @@ import { AP_CLEANER_CONCURRENCY } from '@server/initializers/constants' | |||
12 | import { VideoModel } from '@server/models/video/video' | 12 | import { VideoModel } from '@server/models/video/video' |
13 | import { VideoCommentModel } from '@server/models/video/video-comment' | 13 | import { VideoCommentModel } from '@server/models/video/video-comment' |
14 | import { VideoShareModel } from '@server/models/video/video-share' | 14 | import { VideoShareModel } from '@server/models/video/video-share' |
15 | import { HttpStatusCode } from '@shared/core-utils' | 15 | import { HttpStatusCode } from '@shared/models' |
16 | import { logger } from '../../../helpers/logger' | 16 | import { logger } from '../../../helpers/logger' |
17 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 17 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
18 | 18 | ||
diff --git a/server/middlewares/activitypub.ts b/server/middlewares/activitypub.ts index 6b43b7764..6ef90b275 100644 --- a/server/middlewares/activitypub.ts +++ b/server/middlewares/activitypub.ts | |||
@@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from 'express' | |||
2 | import { getAPId } from '@server/helpers/activitypub' | 2 | import { getAPId } from '@server/helpers/activitypub' |
3 | import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' | 3 | import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor' |
4 | import { ActivityDelete, ActivityPubSignature } from '../../shared' | 4 | import { ActivityDelete, ActivityPubSignature } from '../../shared' |
5 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 5 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
6 | import { logger } from '../helpers/logger' | 6 | import { logger } from '../helpers/logger' |
7 | import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' | 7 | import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto' |
8 | import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' | 8 | import { ACCEPT_HEADERS, ACTIVITY_PUB, HTTP_SIGNATURE } from '../initializers/constants' |
diff --git a/server/middlewares/auth.ts b/server/middlewares/auth.ts index 176461cc2..9e6327b23 100644 --- a/server/middlewares/auth.ts +++ b/server/middlewares/auth.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { Socket } from 'socket.io' | 2 | import { Socket } from 'socket.io' |
3 | import { getAccessToken } from '@server/lib/auth/oauth-model' | 3 | import { getAccessToken } from '@server/lib/auth/oauth-model' |
4 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
5 | import { logger } from '../helpers/logger' | 5 | import { logger } from '../helpers/logger' |
6 | import { handleOAuthAuthenticate } from '../lib/auth/oauth' | 6 | import { handleOAuthAuthenticate } from '../lib/auth/oauth' |
7 | 7 | ||
diff --git a/server/middlewares/cache.ts b/server/middlewares/cache.ts index 0708ee8e8..1ced06042 100644 --- a/server/middlewares/cache.ts +++ b/server/middlewares/cache.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Redis } from '../lib/redis' | 1 | import { Redis } from '../lib/redis' |
2 | import * as apicache from 'apicache' | 2 | import * as apicache from 'apicache' |
3 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
4 | 4 | ||
5 | // Ensure Redis is initialized | 5 | // Ensure Redis is initialized |
6 | Redis.Instance.init() | 6 | Redis.Instance.init() |
diff --git a/server/middlewares/error.ts b/server/middlewares/error.ts index e3eb1c8f5..af5a9c29a 100644 --- a/server/middlewares/error.ts +++ b/server/middlewares/error.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details' | 2 | import { ProblemDocument, ProblemDocumentExtension } from 'http-problem-details' |
3 | import { HttpStatusCode } from '@shared/core-utils' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | 4 | ||
5 | function apiFailMiddleware (req: express.Request, res: express.Response, next: express.NextFunction) { | 5 | function apiFailMiddleware (req: express.Request, res: express.Response, next: express.NextFunction) { |
6 | res.fail = options => { | 6 | res.fail = options => { |
diff --git a/server/middlewares/servers.ts b/server/middlewares/servers.ts index 9aa56bc93..49a2241b3 100644 --- a/server/middlewares/servers.ts +++ b/server/middlewares/servers.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { getHostWithPort } from '../helpers/express-utils' | 2 | import { getHostWithPort } from '../helpers/express-utils' |
3 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
4 | 4 | ||
5 | function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) { | 5 | function setBodyHostsPort (req: express.Request, res: express.Response, next: express.NextFunction) { |
6 | if (!req.body.hosts) return next() | 6 | if (!req.body.hosts) return next() |
diff --git a/server/middlewares/user-right.ts b/server/middlewares/user-right.ts index d1888c2d3..87a1766cf 100644 --- a/server/middlewares/user-right.ts +++ b/server/middlewares/user-right.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { UserRight } from '../../shared' | 2 | import { UserRight } from '../../shared' |
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '../../shared/models/http/http-error-codes' |
5 | 5 | ||
6 | function ensureUserHasRight (userRight: UserRight) { | 6 | function ensureUserHasRight (userRight: UserRight) { |
7 | return function (req: express.Request, res: express.Response, next: express.NextFunction) { | 7 | return function (req: express.Request, res: express.Response, next: express.NextFunction) { |
diff --git a/server/middlewares/validators/abuse.ts b/server/middlewares/validators/abuse.ts index c048bc6af..f4d9c3af2 100644 --- a/server/middlewares/validators/abuse.ts +++ b/server/middlewares/validators/abuse.ts | |||
@@ -16,7 +16,7 @@ import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID, toIntOrNull } from | |||
16 | import { logger } from '@server/helpers/logger' | 16 | import { logger } from '@server/helpers/logger' |
17 | import { AbuseMessageModel } from '@server/models/abuse/abuse-message' | 17 | import { AbuseMessageModel } from '@server/models/abuse/abuse-message' |
18 | import { AbuseCreate, UserRight } from '@shared/models' | 18 | import { AbuseCreate, UserRight } from '@shared/models' |
19 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 19 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
20 | import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdExist, doesVideoExist } from './shared' | 20 | import { areValidationErrors, doesAbuseExist, doesAccountIdExist, doesCommentIdExist, doesVideoExist } from './shared' |
21 | 21 | ||
22 | const abuseReportValidator = [ | 22 | const abuseReportValidator = [ |
diff --git a/server/middlewares/validators/activitypub/activity.ts b/server/middlewares/validators/activitypub/activity.ts index cc6acd4b1..d65a8e455 100644 --- a/server/middlewares/validators/activitypub/activity.ts +++ b/server/middlewares/validators/activitypub/activity.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' | 2 | import { isRootActivityValid } from '../../../helpers/custom-validators/activitypub/activity' |
3 | import { logger } from '../../../helpers/logger' | 3 | import { logger } from '../../../helpers/logger' |
4 | import { getServerActor } from '@server/models/application/application' | 4 | import { getServerActor } from '@server/models/application/application' |
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 5 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
6 | 6 | ||
7 | async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) { | 7 | async function activityPubValidator (req: express.Request, res: express.Response, next: express.NextFunction) { |
8 | logger.debug('Checking activity pub parameters') | 8 | logger.debug('Checking activity pub parameters') |
diff --git a/server/middlewares/validators/blocklist.ts b/server/middlewares/validators/blocklist.ts index 826b16fc8..f15b293e9 100644 --- a/server/middlewares/validators/blocklist.ts +++ b/server/middlewares/validators/blocklist.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param } from 'express-validator' | 2 | import { body, param } from 'express-validator' |
3 | import { getServerActor } from '@server/models/application/application' | 3 | import { getServerActor } from '@server/models/application/application' |
4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
5 | import { isHostValid } from '../../helpers/custom-validators/servers' | 5 | import { isHostValid } from '../../helpers/custom-validators/servers' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
7 | import { WEBSERVER } from '../../initializers/constants' | 7 | import { WEBSERVER } from '../../initializers/constants' |
diff --git a/server/middlewares/validators/bulk.ts b/server/middlewares/validators/bulk.ts index 9bb95f5b7..4057b1e01 100644 --- a/server/middlewares/validators/bulk.ts +++ b/server/middlewares/validators/bulk.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk' | 3 | import { isBulkRemoveCommentsOfScopeValid } from '@server/helpers/custom-validators/bulk' |
4 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { UserRight } from '@shared/models' | 5 | import { UserRight } from '@shared/models' |
6 | import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' | 6 | import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' |
7 | import { logger } from '../../helpers/logger' | 7 | import { logger } from '../../helpers/logger' |
diff --git a/server/middlewares/validators/feeds.ts b/server/middlewares/validators/feeds.ts index 51b8fdd19..1a5a8ffa0 100644 --- a/server/middlewares/validators/feeds.ts +++ b/server/middlewares/validators/feeds.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { param, query } from 'express-validator' | 2 | import { param, query } from 'express-validator' |
3 | 3 | ||
4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
5 | import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' | 5 | import { isValidRSSFeed } from '../../helpers/custom-validators/feeds' |
6 | import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID } from '../../helpers/custom-validators/misc' | 6 | import { exists, isIdOrUUIDValid, isIdValid, toCompleteUUID } from '../../helpers/custom-validators/misc' |
7 | import { logger } from '../../helpers/logger' | 7 | import { logger } from '../../helpers/logger' |
diff --git a/server/middlewares/validators/follows.ts b/server/middlewares/validators/follows.ts index 205baca48..05cc66c38 100644 --- a/server/middlewares/validators/follows.ts +++ b/server/middlewares/validators/follows.ts | |||
@@ -4,7 +4,7 @@ import { isFollowStateValid } from '@server/helpers/custom-validators/follows' | |||
4 | import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors' | 4 | import { loadActorUrlOrGetFromWebfinger } from '@server/lib/activitypub/actors' |
5 | import { getServerActor } from '@server/models/application/application' | 5 | import { getServerActor } from '@server/models/application/application' |
6 | import { MActorFollowActorsDefault } from '@server/types/models' | 6 | import { MActorFollowActorsDefault } from '@server/types/models' |
7 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 7 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
8 | import { isTestInstance } from '../../helpers/core-utils' | 8 | import { isTestInstance } from '../../helpers/core-utils' |
9 | import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' | 9 | import { isActorTypeValid, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' |
10 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' | 10 | import { isEachUniqueHostValid, isHostValid } from '../../helpers/custom-validators/servers' |
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts index 0a82e6932..e5fc0c277 100644 --- a/server/middlewares/validators/oembed.ts +++ b/server/middlewares/validators/oembed.ts | |||
@@ -4,7 +4,7 @@ import { join } from 'path' | |||
4 | import { loadVideo } from '@server/lib/model-loaders' | 4 | import { loadVideo } from '@server/lib/model-loaders' |
5 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' | 5 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' |
6 | import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' | 6 | import { VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models' |
7 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 7 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
8 | import { isTestInstance } from '../../helpers/core-utils' | 8 | import { isTestInstance } from '../../helpers/core-utils' |
9 | import { isIdOrUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc' | 9 | import { isIdOrUUIDValid, toCompleteUUID } from '../../helpers/custom-validators/misc' |
10 | import { logger } from '../../helpers/logger' | 10 | import { logger } from '../../helpers/logger' |
diff --git a/server/middlewares/validators/plugins.ts b/server/middlewares/validators/plugins.ts index 8c76d2e36..3fb2176b9 100644 --- a/server/middlewares/validators/plugins.ts +++ b/server/middlewares/validators/plugins.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param, query, ValidationChain } from 'express-validator' | 2 | import { body, param, query, ValidationChain } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { PluginType } from '../../../shared/models/plugins/plugin.type' | 4 | import { PluginType } from '../../../shared/models/plugins/plugin.type' |
5 | import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model' | 5 | import { InstallOrUpdatePlugin } from '../../../shared/models/plugins/server/api/install-plugin.model' |
6 | import { exists, isBooleanValid, isSafePath, toBooleanOrNull, toIntOrNull } from '../../helpers/custom-validators/misc' | 6 | 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 116c8c611..f1b2ff5cd 100644 --- a/server/middlewares/validators/redundancy.ts +++ b/server/middlewares/validators/redundancy.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies' | 3 | import { isVideoRedundancyTarget } from '@server/helpers/custom-validators/video-redundancies' |
4 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 4 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
5 | import { | 5 | import { |
6 | exists, | 6 | exists, |
7 | isBooleanValid, | 7 | isBooleanValid, |
diff --git a/server/middlewares/validators/server.ts b/server/middlewares/validators/server.ts index fc7239b25..29fdc13d2 100644 --- a/server/middlewares/validators/server.ts +++ b/server/middlewares/validators/server.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers' | 4 | import { isHostValid, isValidContactBody } from '../../helpers/custom-validators/servers' |
5 | import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' | 5 | import { isUserDisplayNameValid } from '../../helpers/custom-validators/users' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
diff --git a/server/middlewares/validators/shared/abuses.ts b/server/middlewares/validators/shared/abuses.ts index 4a20a55fa..2b8d86ba5 100644 --- a/server/middlewares/validators/shared/abuses.ts +++ b/server/middlewares/validators/shared/abuses.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Response } from 'express' | 1 | import { Response } from 'express' |
2 | import { AbuseModel } from '@server/models/abuse/abuse' | 2 | import { AbuseModel } from '@server/models/abuse/abuse' |
3 | import { HttpStatusCode } from '@shared/core-utils' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | 4 | ||
5 | async function doesAbuseExist (abuseId: number | string, res: Response) { | 5 | async function doesAbuseExist (abuseId: number | string, res: Response) { |
6 | const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10)) | 6 | const abuse = await AbuseModel.loadByIdWithReporter(parseInt(abuseId + '', 10)) |
diff --git a/server/middlewares/validators/shared/accounts.ts b/server/middlewares/validators/shared/accounts.ts index 04da15441..fe4f83aa0 100644 --- a/server/middlewares/validators/shared/accounts.ts +++ b/server/middlewares/validators/shared/accounts.ts | |||
@@ -2,7 +2,7 @@ import { Response } from 'express' | |||
2 | import { AccountModel } from '@server/models/account/account' | 2 | import { AccountModel } from '@server/models/account/account' |
3 | import { UserModel } from '@server/models/user/user' | 3 | import { UserModel } from '@server/models/user/user' |
4 | import { MAccountDefault } from '@server/types/models' | 4 | import { MAccountDefault } from '@server/types/models' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | 6 | ||
7 | function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { | 7 | function doesAccountIdExist (id: number | string, res: Response, sendNotFound = true) { |
8 | const promise = AccountModel.load(parseInt(id + '', 10)) | 8 | const promise = AccountModel.load(parseInt(id + '', 10)) |
diff --git a/server/middlewares/validators/shared/video-blacklists.ts b/server/middlewares/validators/shared/video-blacklists.ts index 01491c10f..f85b39b23 100644 --- a/server/middlewares/validators/shared/video-blacklists.ts +++ b/server/middlewares/validators/shared/video-blacklists.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Response } from 'express' | 1 | import { Response } from 'express' |
2 | import { VideoBlacklistModel } from '@server/models/video/video-blacklist' | 2 | import { VideoBlacklistModel } from '@server/models/video/video-blacklist' |
3 | import { HttpStatusCode } from '@shared/core-utils' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | 4 | ||
5 | async function doesVideoBlacklistExist (videoId: number, res: Response) { | 5 | async function doesVideoBlacklistExist (videoId: number, res: Response) { |
6 | const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId) | 6 | const videoBlacklist = await VideoBlacklistModel.loadByVideoId(videoId) |
diff --git a/server/middlewares/validators/shared/video-captions.ts b/server/middlewares/validators/shared/video-captions.ts index 80f6c5a52..831b366ea 100644 --- a/server/middlewares/validators/shared/video-captions.ts +++ b/server/middlewares/validators/shared/video-captions.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Response } from 'express' | 1 | import { Response } from 'express' |
2 | import { VideoCaptionModel } from '@server/models/video/video-caption' | 2 | import { VideoCaptionModel } from '@server/models/video/video-caption' |
3 | import { MVideoId } from '@server/types/models' | 3 | import { MVideoId } from '@server/types/models' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | 5 | ||
6 | async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) { | 6 | async function doesVideoCaptionExist (video: MVideoId, language: string, res: Response) { |
7 | const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language) | 7 | const videoCaption = await VideoCaptionModel.loadByVideoIdAndLanguage(video.id, language) |
diff --git a/server/middlewares/validators/shared/video-channels.ts b/server/middlewares/validators/shared/video-channels.ts index fe2e663b7..3fc3d012a 100644 --- a/server/middlewares/validators/shared/video-channels.ts +++ b/server/middlewares/validators/shared/video-channels.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { VideoChannelModel } from '@server/models/video/video-channel' | 2 | import { VideoChannelModel } from '@server/models/video/video-channel' |
3 | import { MChannelBannerAccountDefault } from '@server/types/models' | 3 | import { MChannelBannerAccountDefault } from '@server/types/models' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | 5 | ||
6 | async function doesLocalVideoChannelNameExist (name: string, res: express.Response) { | 6 | async function doesLocalVideoChannelNameExist (name: string, res: express.Response) { |
7 | const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) | 7 | const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) |
diff --git a/server/middlewares/validators/shared/video-comments.ts b/server/middlewares/validators/shared/video-comments.ts index 83ea15c98..60132fb6e 100644 --- a/server/middlewares/validators/shared/video-comments.ts +++ b/server/middlewares/validators/shared/video-comments.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { VideoCommentModel } from '@server/models/video/video-comment' | 2 | import { VideoCommentModel } from '@server/models/video/video-comment' |
3 | import { MVideoId } from '@server/types/models' | 3 | import { MVideoId } from '@server/types/models' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | 5 | ||
6 | async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) { | 6 | async function doesVideoCommentThreadExist (idArg: number | string, video: MVideoId, res: express.Response) { |
7 | const id = parseInt(idArg + '', 10) | 7 | const id = parseInt(idArg + '', 10) |
diff --git a/server/middlewares/validators/shared/video-imports.ts b/server/middlewares/validators/shared/video-imports.ts index 0f984bc17..50b49ffcb 100644 --- a/server/middlewares/validators/shared/video-imports.ts +++ b/server/middlewares/validators/shared/video-imports.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { VideoImportModel } from '@server/models/video/video-import' | 2 | import { VideoImportModel } from '@server/models/video/video-import' |
3 | import { HttpStatusCode } from '@shared/core-utils' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | 4 | ||
5 | async function doesVideoImportExist (id: number, res: express.Response) { | 5 | async function doesVideoImportExist (id: number, res: express.Response) { |
6 | const videoImport = await VideoImportModel.loadAndPopulateVideo(id) | 6 | const videoImport = await VideoImportModel.loadAndPopulateVideo(id) |
diff --git a/server/middlewares/validators/shared/video-ownerships.ts b/server/middlewares/validators/shared/video-ownerships.ts index fc27006ce..93a23ef40 100644 --- a/server/middlewares/validators/shared/video-ownerships.ts +++ b/server/middlewares/validators/shared/video-ownerships.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' | 2 | import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' |
3 | import { HttpStatusCode } from '@shared/core-utils' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | 4 | ||
5 | async function doesChangeVideoOwnershipExist (idArg: number | string, res: express.Response) { | 5 | async function doesChangeVideoOwnershipExist (idArg: number | string, res: express.Response) { |
6 | const id = parseInt(idArg + '', 10) | 6 | const id = parseInt(idArg + '', 10) |
diff --git a/server/middlewares/validators/shared/video-playlists.ts b/server/middlewares/validators/shared/video-playlists.ts index d762859a8..3f6768179 100644 --- a/server/middlewares/validators/shared/video-playlists.ts +++ b/server/middlewares/validators/shared/video-playlists.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' | 2 | import { VideoPlaylistModel } from '@server/models/video/video-playlist' |
3 | import { MVideoPlaylist } from '@server/types/models' | 3 | import { MVideoPlaylist } from '@server/types/models' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | 5 | ||
6 | export type VideoPlaylistFetchType = 'summary' | 'all' | 6 | export type VideoPlaylistFetchType = 'summary' | 'all' |
7 | async function doesVideoPlaylistExist (id: number | string, res: express.Response, fetchType: VideoPlaylistFetchType = 'summary') { | 7 | 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 2c66c1a3a..7f42a4893 100644 --- a/server/middlewares/validators/shared/videos.ts +++ b/server/middlewares/validators/shared/videos.ts | |||
@@ -12,7 +12,7 @@ import { | |||
12 | MVideoImmutable, | 12 | MVideoImmutable, |
13 | MVideoThumbnail | 13 | MVideoThumbnail |
14 | } from '@server/types/models' | 14 | } from '@server/types/models' |
15 | import { HttpStatusCode } from '@shared/core-utils' | 15 | import { HttpStatusCode } from '@shared/models' |
16 | import { UserRight } from '@shared/models' | 16 | import { UserRight } from '@shared/models' |
17 | 17 | ||
18 | async function doesVideoExist (id: number | string, res: Response, fetchType: VideoLoadType = 'all') { | 18 | 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 d4716257f..2953b9505 100644 --- a/server/middlewares/validators/themes.ts +++ b/server/middlewares/validators/themes.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { param } from 'express-validator' | 2 | import { param } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { isSafePath } from '../../helpers/custom-validators/misc' | 4 | import { isSafePath } from '../../helpers/custom-validators/misc' |
5 | import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' | 5 | import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
diff --git a/server/middlewares/validators/user-subscriptions.ts b/server/middlewares/validators/user-subscriptions.ts index ab7962923..df5777771 100644 --- a/server/middlewares/validators/user-subscriptions.ts +++ b/server/middlewares/validators/user-subscriptions.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' | 4 | import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor' |
5 | import { toArray } from '../../helpers/custom-validators/misc' | 5 | import { toArray } from '../../helpers/custom-validators/misc' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
diff --git a/server/middlewares/validators/users.ts b/server/middlewares/validators/users.ts index 698d7d814..748b89f8f 100644 --- a/server/middlewares/validators/users.ts +++ b/server/middlewares/validators/users.ts | |||
@@ -3,7 +3,7 @@ import { body, param, query } from 'express-validator' | |||
3 | import { omit } from 'lodash' | 3 | import { omit } from 'lodash' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
5 | import { MUserDefault } from '@server/types/models' | 5 | import { MUserDefault } from '@server/types/models' |
6 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
7 | import { UserRole } from '../../../shared/models/users' | 7 | import { UserRole } from '../../../shared/models/users' |
8 | import { UserRegister } from '../../../shared/models/users/user-register.model' | 8 | import { UserRegister } from '../../../shared/models/users/user-register.model' |
9 | import { isActorPreferredUsernameValid } from '../../helpers/custom-validators/activitypub/actor' | 9 | 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 21141d84d..3a4937b7b 100644 --- a/server/middlewares/validators/videos/video-blacklist.ts +++ b/server/middlewares/validators/videos/video-blacklist.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, query } from 'express-validator' | 2 | import { body, query } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' | 4 | import { isBooleanValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' |
5 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' | 5 | import { isVideoBlacklistReasonValid, isVideoBlacklistTypeValid } from '../../../helpers/custom-validators/video-blacklist' |
6 | import { logger } from '../../../helpers/logger' | 6 | import { logger } from '../../../helpers/logger' |
diff --git a/server/middlewares/validators/videos/video-channels.ts b/server/middlewares/validators/videos/video-channels.ts index e7df185e4..ea10fe425 100644 --- a/server/middlewares/validators/videos/video-channels.ts +++ b/server/middlewares/validators/videos/video-channels.ts | |||
@@ -3,7 +3,7 @@ import { body, param, query } from 'express-validator' | |||
3 | import { VIDEO_CHANNELS } from '@server/initializers/constants' | 3 | import { VIDEO_CHANNELS } from '@server/initializers/constants' |
4 | import { MChannelAccountDefault, MUser } from '@server/types/models' | 4 | import { MChannelAccountDefault, MUser } from '@server/types/models' |
5 | import { UserRight } from '../../../../shared' | 5 | import { UserRight } from '../../../../shared' |
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
7 | import { isActorPreferredUsernameValid } from '../../../helpers/custom-validators/activitypub/actor' | 7 | import { isActorPreferredUsernameValid } from '../../../helpers/custom-validators/activitypub/actor' |
8 | import { isBooleanValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' | 8 | import { isBooleanValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' |
9 | import { | 9 | import { |
diff --git a/server/middlewares/validators/videos/video-comments.ts b/server/middlewares/validators/videos/video-comments.ts index 885506ebe..61c2ed92f 100644 --- a/server/middlewares/validators/videos/video-comments.ts +++ b/server/middlewares/validators/videos/video-comments.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { MUserAccountUrl } from '@server/types/models' | 3 | import { MUserAccountUrl } from '@server/types/models' |
4 | import { UserRight } from '../../../../shared' | 4 | import { UserRight } from '../../../../shared' |
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 5 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
6 | import { exists, isBooleanValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' | 6 | import { exists, isBooleanValid, isIdValid, toBooleanOrNull } from '../../../helpers/custom-validators/misc' |
7 | import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments' | 7 | import { isValidVideoCommentText } from '../../../helpers/custom-validators/video-comments' |
8 | import { logger } from '../../../helpers/logger' | 8 | import { logger } from '../../../helpers/logger' |
diff --git a/server/middlewares/validators/videos/video-imports.ts b/server/middlewares/validators/videos/video-imports.ts index 85dc647ce..52b839e56 100644 --- a/server/middlewares/validators/videos/video-imports.ts +++ b/server/middlewares/validators/videos/video-imports.ts | |||
@@ -2,7 +2,7 @@ import * as express from 'express' | |||
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { isPreImportVideoAccepted } from '@server/lib/moderation' | 3 | import { isPreImportVideoAccepted } from '@server/lib/moderation' |
4 | import { Hooks } from '@server/lib/plugins/hooks' | 4 | import { Hooks } from '@server/lib/plugins/hooks' |
5 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { VideoImportCreate } from '@shared/models/videos/import/video-import-create.model' | 6 | import { VideoImportCreate } from '@shared/models/videos/import/video-import-create.model' |
7 | import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc' | 7 | import { isIdValid, toIntOrNull } from '../../../helpers/custom-validators/misc' |
8 | import { isVideoImportTargetUrlValid, isVideoImportTorrentFile } from '../../../helpers/custom-validators/video-imports' | 8 | 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 7cfb935e3..5c8a4269d 100644 --- a/server/middlewares/validators/videos/video-live.ts +++ b/server/middlewares/validators/videos/video-live.ts | |||
@@ -5,7 +5,7 @@ import { isLocalLiveVideoAccepted } from '@server/lib/moderation' | |||
5 | import { Hooks } from '@server/lib/plugins/hooks' | 5 | import { Hooks } from '@server/lib/plugins/hooks' |
6 | import { VideoModel } from '@server/models/video/video' | 6 | import { VideoModel } from '@server/models/video/video' |
7 | import { VideoLiveModel } from '@server/models/video/video-live' | 7 | import { VideoLiveModel } from '@server/models/video/video-live' |
8 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 8 | import { HttpStatusCode } from '@shared/models' |
9 | import { ServerErrorCode, UserRight, VideoState } from '@shared/models' | 9 | import { ServerErrorCode, UserRight, VideoState } from '@shared/models' |
10 | import { isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' | 10 | import { isBooleanValid, isIdValid, toBooleanOrNull, toIntOrNull } from '../../../helpers/custom-validators/misc' |
11 | import { isVideoNameValid } from '../../../helpers/custom-validators/videos' | 11 | 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 54ac46c99..06f86a4c8 100644 --- a/server/middlewares/validators/videos/video-ownership-changes.ts +++ b/server/middlewares/validators/videos/video-ownership-changes.ts | |||
@@ -6,7 +6,7 @@ import { logger } from '@server/helpers/logger' | |||
6 | import { isAbleToUploadVideo } from '@server/lib/user' | 6 | import { isAbleToUploadVideo } from '@server/lib/user' |
7 | import { AccountModel } from '@server/models/account/account' | 7 | import { AccountModel } from '@server/models/account/account' |
8 | import { MVideoWithAllFiles } from '@server/types/models' | 8 | import { MVideoWithAllFiles } from '@server/types/models' |
9 | import { HttpStatusCode } from '@shared/core-utils' | 9 | import { HttpStatusCode } from '@shared/models' |
10 | import { ServerErrorCode, UserRight, VideoChangeOwnershipAccept, VideoChangeOwnershipStatus, VideoState } from '@shared/models' | 10 | import { ServerErrorCode, UserRight, VideoChangeOwnershipAccept, VideoChangeOwnershipStatus, VideoState } from '@shared/models' |
11 | import { | 11 | import { |
12 | areValidationErrors, | 12 | areValidationErrors, |
diff --git a/server/middlewares/validators/videos/video-playlists.ts b/server/middlewares/validators/videos/video-playlists.ts index 5ee7ee0ce..ab84b4814 100644 --- a/server/middlewares/validators/videos/video-playlists.ts +++ b/server/middlewares/validators/videos/video-playlists.ts | |||
@@ -3,7 +3,7 @@ import { body, param, query, ValidationChain } from 'express-validator' | |||
3 | import { ExpressPromiseHandler } from '@server/types/express' | 3 | import { ExpressPromiseHandler } from '@server/types/express' |
4 | import { MUserAccountId } from '@server/types/models' | 4 | import { MUserAccountId } from '@server/types/models' |
5 | import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared' | 5 | import { UserRight, VideoPlaylistCreate, VideoPlaylistUpdate } from '../../../../shared' |
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
7 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' | 7 | import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' |
8 | import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' | 8 | import { VideoPlaylistType } from '../../../../shared/models/videos/playlist/video-playlist-type.model' |
9 | import { | 9 | import { |
diff --git a/server/middlewares/validators/videos/video-rates.ts b/server/middlewares/validators/videos/video-rates.ts index 5d5dfb222..5fe78b39e 100644 --- a/server/middlewares/validators/videos/video-rates.ts +++ b/server/middlewares/validators/videos/video-rates.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body, param, query } from 'express-validator' | 2 | import { body, param, query } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { VideoRateType } from '../../../../shared/models/videos' | 4 | import { VideoRateType } from '../../../../shared/models/videos' |
5 | import { isAccountNameValid } from '../../../helpers/custom-validators/accounts' | 5 | import { isAccountNameValid } from '../../../helpers/custom-validators/accounts' |
6 | import { isIdValid } from '../../../helpers/custom-validators/misc' | 6 | 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 7e54b6fc0..3b8d61768 100644 --- a/server/middlewares/validators/videos/video-shares.ts +++ b/server/middlewares/validators/videos/video-shares.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { param } from 'express-validator' | 2 | import { param } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { isIdValid } from '../../../helpers/custom-validators/misc' | 4 | import { isIdValid } from '../../../helpers/custom-validators/misc' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
6 | import { VideoShareModel } from '../../../models/video/video-share' | 6 | 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 43306f7cd..431515eb1 100644 --- a/server/middlewares/validators/videos/video-watch.ts +++ b/server/middlewares/validators/videos/video-watch.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { body } from 'express-validator' | 2 | import { body } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
4 | import { toIntOrNull } from '../../../helpers/custom-validators/misc' | 4 | import { toIntOrNull } from '../../../helpers/custom-validators/misc' |
5 | import { logger } from '../../../helpers/logger' | 5 | import { logger } from '../../../helpers/logger' |
6 | import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' | 6 | import { areValidationErrors, doesVideoExist, isValidVideoIdParam } from '../shared' |
diff --git a/server/middlewares/validators/videos/videos.ts b/server/middlewares/validators/videos/videos.ts index 49e10e2b5..374a59c50 100644 --- a/server/middlewares/validators/videos/videos.ts +++ b/server/middlewares/validators/videos/videos.ts | |||
@@ -6,7 +6,7 @@ import { getServerActor } from '@server/models/application/application' | |||
6 | import { ExpressPromiseHandler } from '@server/types/express' | 6 | import { ExpressPromiseHandler } from '@server/types/express' |
7 | import { MUserAccountId, MVideoFullLight } from '@server/types/models' | 7 | import { MUserAccountId, MVideoFullLight } from '@server/types/models' |
8 | import { ServerErrorCode, UserRight, VideoPrivacy } from '../../../../shared' | 8 | import { ServerErrorCode, UserRight, VideoPrivacy } from '../../../../shared' |
9 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 9 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
10 | import { | 10 | import { |
11 | exists, | 11 | exists, |
12 | isBooleanValid, | 12 | isBooleanValid, |
diff --git a/server/middlewares/validators/webfinger.ts b/server/middlewares/validators/webfinger.ts index bcdd136c6..131360820 100644 --- a/server/middlewares/validators/webfinger.ts +++ b/server/middlewares/validators/webfinger.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { query } from 'express-validator' | 2 | import { query } from 'express-validator' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '../../../shared/models/http/http-error-codes' |
4 | import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger' | 4 | import { isWebfingerLocalResourceValid } from '../../helpers/custom-validators/webfinger' |
5 | import { getHostWithPort } from '../../helpers/express-utils' | 5 | import { getHostWithPort } from '../../helpers/express-utils' |
6 | import { logger } from '../../helpers/logger' | 6 | import { logger } from '../../helpers/logger' |
diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts index 720231f02..53cc40663 100644 --- a/server/tests/api/activitypub/client.ts +++ b/server/tests/api/activitypub/client.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | doubleFollow, | 8 | doubleFollow, |
@@ -68,7 +68,7 @@ describe('Test activitypub', function () { | |||
68 | await setDefaultVideoChannel(servers) | 68 | await setDefaultVideoChannel(servers) |
69 | 69 | ||
70 | { | 70 | { |
71 | video = await await servers[0].videos.quickUpload({ name: 'video' }) | 71 | video = await servers[0].videos.quickUpload({ name: 'video' }) |
72 | } | 72 | } |
73 | 73 | ||
74 | { | 74 | { |
diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts index bbec0d309..a0b72c7e6 100644 --- a/server/tests/api/activitypub/refresher.ts +++ b/server/tests/api/activitypub/refresher.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 5 | import { |
6 | cleanupTests, | 6 | cleanupTests, |
7 | doubleFollow, | 7 | doubleFollow, |
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts index c173648b3..94d946563 100644 --- a/server/tests/api/activitypub/security.ts +++ b/server/tests/api/activitypub/security.ts | |||
@@ -2,20 +2,13 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { activityPubContextify, buildSignedActivity } from '@server/helpers/activitypub' | ||
5 | import { buildDigest } from '@server/helpers/peertube-crypto' | 6 | import { buildDigest } from '@server/helpers/peertube-crypto' |
6 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 7 | import { HTTP_SIGNATURE } from '@server/initializers/constants' |
7 | import { | 8 | import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils' |
8 | buildAbsoluteFixturePath, | 9 | import { buildAbsoluteFixturePath, cleanupTests, createMultipleServers, killallServers, PeerTubeServer, wait } from '@shared/extra-utils' |
9 | cleanupTests, | 10 | import { makeFollowRequest, makePOSTAPRequest } from '@shared/extra-utils/requests/activitypub' |
10 | createMultipleServers, | 11 | import { HttpStatusCode } from '@shared/models' |
11 | killallServers, | ||
12 | PeerTubeServer, | ||
13 | wait | ||
14 | } from '../../../../shared/extra-utils' | ||
15 | import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-utils/requests/activitypub' | ||
16 | import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub' | ||
17 | import { HTTP_SIGNATURE } from '../../../initializers/constants' | ||
18 | import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils' | ||
19 | 12 | ||
20 | const expect = chai.expect | 13 | const expect = chai.expect |
21 | 14 | ||
diff --git a/server/tests/api/check-params/abuses.ts b/server/tests/api/check-params/abuses.ts index 62811f932..87d93195c 100644 --- a/server/tests/api/check-params/abuses.ts +++ b/server/tests/api/check-params/abuses.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 5 | import { |
6 | AbusesCommand, | 6 | AbusesCommand, |
7 | checkBadCountPagination, | 7 | checkBadCountPagination, |
@@ -66,7 +66,7 @@ describe('Test abuses API validators', function () { | |||
66 | await makeGetRequest({ | 66 | await makeGetRequest({ |
67 | url: server.url, | 67 | url: server.url, |
68 | path, | 68 | path, |
69 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 69 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
70 | }) | 70 | }) |
71 | }) | 71 | }) |
72 | 72 | ||
@@ -75,7 +75,7 @@ describe('Test abuses API validators', function () { | |||
75 | url: server.url, | 75 | url: server.url, |
76 | path, | 76 | path, |
77 | token: userToken, | 77 | token: userToken, |
78 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 78 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
79 | }) | 79 | }) |
80 | }) | 80 | }) |
81 | 81 | ||
@@ -110,7 +110,7 @@ describe('Test abuses API validators', function () { | |||
110 | videoIs: 'deleted' | 110 | videoIs: 'deleted' |
111 | } | 111 | } |
112 | 112 | ||
113 | await makeGetRequest({ url: server.url, path, token: server.accessToken, query, statusCodeExpected: HttpStatusCode.OK_200 }) | 113 | await makeGetRequest({ url: server.url, path, token: server.accessToken, query, expectedStatus: HttpStatusCode.OK_200 }) |
114 | }) | 114 | }) |
115 | }) | 115 | }) |
116 | 116 | ||
@@ -133,7 +133,7 @@ describe('Test abuses API validators', function () { | |||
133 | await makeGetRequest({ | 133 | await makeGetRequest({ |
134 | url: server.url, | 134 | url: server.url, |
135 | path, | 135 | path, |
136 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 136 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
137 | }) | 137 | }) |
138 | }) | 138 | }) |
139 | 139 | ||
@@ -152,7 +152,7 @@ describe('Test abuses API validators', function () { | |||
152 | state: 2 | 152 | state: 2 |
153 | } | 153 | } |
154 | 154 | ||
155 | await makeGetRequest({ url: server.url, path, token: userToken, query, statusCodeExpected: HttpStatusCode.OK_200 }) | 155 | await makeGetRequest({ url: server.url, path, token: userToken, query, expectedStatus: HttpStatusCode.OK_200 }) |
156 | }) | 156 | }) |
157 | }) | 157 | }) |
158 | 158 | ||
@@ -176,7 +176,7 @@ describe('Test abuses API validators', function () { | |||
176 | path, | 176 | path, |
177 | token: userToken, | 177 | token: userToken, |
178 | fields, | 178 | fields, |
179 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 179 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
180 | }) | 180 | }) |
181 | }) | 181 | }) |
182 | 182 | ||
@@ -192,7 +192,7 @@ describe('Test abuses API validators', function () { | |||
192 | path, | 192 | path, |
193 | token: userToken, | 193 | token: userToken, |
194 | fields, | 194 | fields, |
195 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 195 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
196 | }) | 196 | }) |
197 | }) | 197 | }) |
198 | 198 | ||
@@ -208,7 +208,7 @@ describe('Test abuses API validators', function () { | |||
208 | path, | 208 | path, |
209 | token: userToken, | 209 | token: userToken, |
210 | fields, | 210 | fields, |
211 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 211 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
212 | }) | 212 | }) |
213 | }) | 213 | }) |
214 | 214 | ||
@@ -219,14 +219,14 @@ describe('Test abuses API validators', function () { | |||
219 | path, | 219 | path, |
220 | token: userToken, | 220 | token: userToken, |
221 | fields, | 221 | fields, |
222 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 222 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
223 | }) | 223 | }) |
224 | }) | 224 | }) |
225 | 225 | ||
226 | it('Should fail with a non authenticated user', async function () { | 226 | it('Should fail with a non authenticated user', async function () { |
227 | const fields = { video: { id: server.store.video.id }, reason: 'my super reason' } | 227 | const fields = { video: { id: server.store.video.id }, reason: 'my super reason' } |
228 | 228 | ||
229 | await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 229 | await makePostBodyRequest({ url: server.url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
230 | }) | 230 | }) |
231 | 231 | ||
232 | it('Should fail with a reason too short', async function () { | 232 | it('Should fail with a reason too short', async function () { |
@@ -249,7 +249,7 @@ describe('Test abuses API validators', function () { | |||
249 | path, | 249 | path, |
250 | token: userToken, | 250 | token: userToken, |
251 | fields, | 251 | fields, |
252 | statusCodeExpected: HttpStatusCode.OK_200 | 252 | expectedStatus: HttpStatusCode.OK_200 |
253 | }) | 253 | }) |
254 | abuseId = res.body.abuse.id | 254 | abuseId = res.body.abuse.id |
255 | }) | 255 | }) |
@@ -283,7 +283,7 @@ describe('Test abuses API validators', function () { | |||
283 | predefinedReasons: [ 'serverRules' ] | 283 | predefinedReasons: [ 'serverRules' ] |
284 | } | 284 | } |
285 | 285 | ||
286 | await makePostBodyRequest({ url: server.url, path, token: userToken, fields, statusCodeExpected: HttpStatusCode.OK_200 }) | 286 | await makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: HttpStatusCode.OK_200 }) |
287 | }) | 287 | }) |
288 | }) | 288 | }) |
289 | 289 | ||
diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts index e866593db..0cae485d9 100644 --- a/server/tests/api/check-params/accounts.ts +++ b/server/tests/api/check-params/accounts.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 5 | import { |
6 | checkBadCountPagination, | 6 | checkBadCountPagination, |
7 | checkBadSortPagination, | 7 | checkBadSortPagination, |
diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts index b2a1cc4e2..7d5fae5cf 100644 --- a/server/tests/api/check-params/blocklist.ts +++ b/server/tests/api/check-params/blocklist.ts | |||
@@ -1,23 +1,20 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | |||
5 | import { | 4 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
6 | cleanupTests, | 8 | cleanupTests, |
7 | doubleFollow, | ||
8 | createMultipleServers, | 9 | createMultipleServers, |
10 | doubleFollow, | ||
9 | makeDeleteRequest, | 11 | makeDeleteRequest, |
10 | makeGetRequest, | 12 | makeGetRequest, |
11 | makePostBodyRequest, | 13 | makePostBodyRequest, |
12 | PeerTubeServer, | 14 | PeerTubeServer, |
13 | setAccessTokensToServers | 15 | setAccessTokensToServers |
14 | } from '../../../../shared/extra-utils' | 16 | } from '@shared/extra-utils' |
15 | import { | 17 | import { HttpStatusCode } from '@shared/models' |
16 | checkBadCountPagination, | ||
17 | checkBadSortPagination, | ||
18 | checkBadStartPagination | ||
19 | } from '../../../../shared/extra-utils/requests/check-api-params' | ||
20 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
21 | 18 | ||
22 | describe('Test blocklist API validators', function () { | 19 | describe('Test blocklist API validators', function () { |
23 | let servers: PeerTubeServer[] | 20 | let servers: PeerTubeServer[] |
@@ -52,7 +49,7 @@ describe('Test blocklist API validators', function () { | |||
52 | await makeGetRequest({ | 49 | await makeGetRequest({ |
53 | url: server.url, | 50 | url: server.url, |
54 | path, | 51 | path, |
55 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 52 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
56 | }) | 53 | }) |
57 | }) | 54 | }) |
58 | 55 | ||
@@ -75,7 +72,7 @@ describe('Test blocklist API validators', function () { | |||
75 | url: server.url, | 72 | url: server.url, |
76 | path, | 73 | path, |
77 | fields: { accountName: 'user1' }, | 74 | fields: { accountName: 'user1' }, |
78 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 75 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
79 | }) | 76 | }) |
80 | }) | 77 | }) |
81 | 78 | ||
@@ -85,7 +82,7 @@ describe('Test blocklist API validators', function () { | |||
85 | token: server.accessToken, | 82 | token: server.accessToken, |
86 | path, | 83 | path, |
87 | fields: { accountName: 'user2' }, | 84 | fields: { accountName: 'user2' }, |
88 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 85 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
89 | }) | 86 | }) |
90 | }) | 87 | }) |
91 | 88 | ||
@@ -95,7 +92,7 @@ describe('Test blocklist API validators', function () { | |||
95 | token: server.accessToken, | 92 | token: server.accessToken, |
96 | path, | 93 | path, |
97 | fields: { accountName: 'root' }, | 94 | fields: { accountName: 'root' }, |
98 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 95 | expectedStatus: HttpStatusCode.CONFLICT_409 |
99 | }) | 96 | }) |
100 | }) | 97 | }) |
101 | 98 | ||
@@ -105,7 +102,7 @@ describe('Test blocklist API validators', function () { | |||
105 | token: server.accessToken, | 102 | token: server.accessToken, |
106 | path, | 103 | path, |
107 | fields: { accountName: 'user1' }, | 104 | fields: { accountName: 'user1' }, |
108 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 105 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
109 | }) | 106 | }) |
110 | }) | 107 | }) |
111 | }) | 108 | }) |
@@ -115,7 +112,7 @@ describe('Test blocklist API validators', function () { | |||
115 | await makeDeleteRequest({ | 112 | await makeDeleteRequest({ |
116 | url: server.url, | 113 | url: server.url, |
117 | path: path + '/user1', | 114 | path: path + '/user1', |
118 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 115 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
119 | }) | 116 | }) |
120 | }) | 117 | }) |
121 | 118 | ||
@@ -124,7 +121,7 @@ describe('Test blocklist API validators', function () { | |||
124 | url: server.url, | 121 | url: server.url, |
125 | path: path + '/user2', | 122 | path: path + '/user2', |
126 | token: server.accessToken, | 123 | token: server.accessToken, |
127 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 124 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
128 | }) | 125 | }) |
129 | }) | 126 | }) |
130 | 127 | ||
@@ -133,7 +130,7 @@ describe('Test blocklist API validators', function () { | |||
133 | url: server.url, | 130 | url: server.url, |
134 | path: path + '/user1', | 131 | path: path + '/user1', |
135 | token: server.accessToken, | 132 | token: server.accessToken, |
136 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 133 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
137 | }) | 134 | }) |
138 | }) | 135 | }) |
139 | }) | 136 | }) |
@@ -147,7 +144,7 @@ describe('Test blocklist API validators', function () { | |||
147 | await makeGetRequest({ | 144 | await makeGetRequest({ |
148 | url: server.url, | 145 | url: server.url, |
149 | path, | 146 | path, |
150 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 147 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
151 | }) | 148 | }) |
152 | }) | 149 | }) |
153 | 150 | ||
@@ -170,7 +167,7 @@ describe('Test blocklist API validators', function () { | |||
170 | url: server.url, | 167 | url: server.url, |
171 | path, | 168 | path, |
172 | fields: { host: 'localhost:9002' }, | 169 | fields: { host: 'localhost:9002' }, |
173 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 170 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
174 | }) | 171 | }) |
175 | }) | 172 | }) |
176 | 173 | ||
@@ -180,7 +177,7 @@ describe('Test blocklist API validators', function () { | |||
180 | token: server.accessToken, | 177 | token: server.accessToken, |
181 | path, | 178 | path, |
182 | fields: { host: 'localhost:9003' }, | 179 | fields: { host: 'localhost:9003' }, |
183 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 180 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
184 | }) | 181 | }) |
185 | }) | 182 | }) |
186 | 183 | ||
@@ -190,7 +187,7 @@ describe('Test blocklist API validators', function () { | |||
190 | token: server.accessToken, | 187 | token: server.accessToken, |
191 | path, | 188 | path, |
192 | fields: { host: 'localhost:' + server.port }, | 189 | fields: { host: 'localhost:' + server.port }, |
193 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 190 | expectedStatus: HttpStatusCode.CONFLICT_409 |
194 | }) | 191 | }) |
195 | }) | 192 | }) |
196 | 193 | ||
@@ -200,7 +197,7 @@ describe('Test blocklist API validators', function () { | |||
200 | token: server.accessToken, | 197 | token: server.accessToken, |
201 | path, | 198 | path, |
202 | fields: { host: 'localhost:' + servers[1].port }, | 199 | fields: { host: 'localhost:' + servers[1].port }, |
203 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 200 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
204 | }) | 201 | }) |
205 | }) | 202 | }) |
206 | }) | 203 | }) |
@@ -210,7 +207,7 @@ describe('Test blocklist API validators', function () { | |||
210 | await makeDeleteRequest({ | 207 | await makeDeleteRequest({ |
211 | url: server.url, | 208 | url: server.url, |
212 | path: path + '/localhost:' + servers[1].port, | 209 | path: path + '/localhost:' + servers[1].port, |
213 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 210 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
214 | }) | 211 | }) |
215 | }) | 212 | }) |
216 | 213 | ||
@@ -219,7 +216,7 @@ describe('Test blocklist API validators', function () { | |||
219 | url: server.url, | 216 | url: server.url, |
220 | path: path + '/localhost:9004', | 217 | path: path + '/localhost:9004', |
221 | token: server.accessToken, | 218 | token: server.accessToken, |
222 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 219 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
223 | }) | 220 | }) |
224 | }) | 221 | }) |
225 | 222 | ||
@@ -228,7 +225,7 @@ describe('Test blocklist API validators', function () { | |||
228 | url: server.url, | 225 | url: server.url, |
229 | path: path + '/localhost:' + servers[1].port, | 226 | path: path + '/localhost:' + servers[1].port, |
230 | token: server.accessToken, | 227 | token: server.accessToken, |
231 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 228 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
232 | }) | 229 | }) |
233 | }) | 230 | }) |
234 | }) | 231 | }) |
@@ -245,7 +242,7 @@ describe('Test blocklist API validators', function () { | |||
245 | await makeGetRequest({ | 242 | await makeGetRequest({ |
246 | url: server.url, | 243 | url: server.url, |
247 | path, | 244 | path, |
248 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 245 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
249 | }) | 246 | }) |
250 | }) | 247 | }) |
251 | 248 | ||
@@ -254,7 +251,7 @@ describe('Test blocklist API validators', function () { | |||
254 | url: server.url, | 251 | url: server.url, |
255 | token: userAccessToken, | 252 | token: userAccessToken, |
256 | path, | 253 | path, |
257 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 254 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
258 | }) | 255 | }) |
259 | }) | 256 | }) |
260 | 257 | ||
@@ -277,7 +274,7 @@ describe('Test blocklist API validators', function () { | |||
277 | url: server.url, | 274 | url: server.url, |
278 | path, | 275 | path, |
279 | fields: { accountName: 'user1' }, | 276 | fields: { accountName: 'user1' }, |
280 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 277 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
281 | }) | 278 | }) |
282 | }) | 279 | }) |
283 | 280 | ||
@@ -287,7 +284,7 @@ describe('Test blocklist API validators', function () { | |||
287 | token: userAccessToken, | 284 | token: userAccessToken, |
288 | path, | 285 | path, |
289 | fields: { accountName: 'user1' }, | 286 | fields: { accountName: 'user1' }, |
290 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 287 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
291 | }) | 288 | }) |
292 | }) | 289 | }) |
293 | 290 | ||
@@ -297,7 +294,7 @@ describe('Test blocklist API validators', function () { | |||
297 | token: server.accessToken, | 294 | token: server.accessToken, |
298 | path, | 295 | path, |
299 | fields: { accountName: 'user2' }, | 296 | fields: { accountName: 'user2' }, |
300 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 297 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
301 | }) | 298 | }) |
302 | }) | 299 | }) |
303 | 300 | ||
@@ -307,7 +304,7 @@ describe('Test blocklist API validators', function () { | |||
307 | token: server.accessToken, | 304 | token: server.accessToken, |
308 | path, | 305 | path, |
309 | fields: { accountName: 'root' }, | 306 | fields: { accountName: 'root' }, |
310 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 307 | expectedStatus: HttpStatusCode.CONFLICT_409 |
311 | }) | 308 | }) |
312 | }) | 309 | }) |
313 | 310 | ||
@@ -317,7 +314,7 @@ describe('Test blocklist API validators', function () { | |||
317 | token: server.accessToken, | 314 | token: server.accessToken, |
318 | path, | 315 | path, |
319 | fields: { accountName: 'user1' }, | 316 | fields: { accountName: 'user1' }, |
320 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 317 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
321 | }) | 318 | }) |
322 | }) | 319 | }) |
323 | }) | 320 | }) |
@@ -327,7 +324,7 @@ describe('Test blocklist API validators', function () { | |||
327 | await makeDeleteRequest({ | 324 | await makeDeleteRequest({ |
328 | url: server.url, | 325 | url: server.url, |
329 | path: path + '/user1', | 326 | path: path + '/user1', |
330 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 327 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
331 | }) | 328 | }) |
332 | }) | 329 | }) |
333 | 330 | ||
@@ -336,7 +333,7 @@ describe('Test blocklist API validators', function () { | |||
336 | url: server.url, | 333 | url: server.url, |
337 | path: path + '/user1', | 334 | path: path + '/user1', |
338 | token: userAccessToken, | 335 | token: userAccessToken, |
339 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 336 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
340 | }) | 337 | }) |
341 | }) | 338 | }) |
342 | 339 | ||
@@ -345,7 +342,7 @@ describe('Test blocklist API validators', function () { | |||
345 | url: server.url, | 342 | url: server.url, |
346 | path: path + '/user2', | 343 | path: path + '/user2', |
347 | token: server.accessToken, | 344 | token: server.accessToken, |
348 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 345 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
349 | }) | 346 | }) |
350 | }) | 347 | }) |
351 | 348 | ||
@@ -354,7 +351,7 @@ describe('Test blocklist API validators', function () { | |||
354 | url: server.url, | 351 | url: server.url, |
355 | path: path + '/user1', | 352 | path: path + '/user1', |
356 | token: server.accessToken, | 353 | token: server.accessToken, |
357 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 354 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
358 | }) | 355 | }) |
359 | }) | 356 | }) |
360 | }) | 357 | }) |
@@ -368,7 +365,7 @@ describe('Test blocklist API validators', function () { | |||
368 | await makeGetRequest({ | 365 | await makeGetRequest({ |
369 | url: server.url, | 366 | url: server.url, |
370 | path, | 367 | path, |
371 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 368 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
372 | }) | 369 | }) |
373 | }) | 370 | }) |
374 | 371 | ||
@@ -377,7 +374,7 @@ describe('Test blocklist API validators', function () { | |||
377 | url: server.url, | 374 | url: server.url, |
378 | token: userAccessToken, | 375 | token: userAccessToken, |
379 | path, | 376 | path, |
380 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 377 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
381 | }) | 378 | }) |
382 | }) | 379 | }) |
383 | 380 | ||
@@ -400,7 +397,7 @@ describe('Test blocklist API validators', function () { | |||
400 | url: server.url, | 397 | url: server.url, |
401 | path, | 398 | path, |
402 | fields: { host: 'localhost:' + servers[1].port }, | 399 | fields: { host: 'localhost:' + servers[1].port }, |
403 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 400 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
404 | }) | 401 | }) |
405 | }) | 402 | }) |
406 | 403 | ||
@@ -410,7 +407,7 @@ describe('Test blocklist API validators', function () { | |||
410 | token: userAccessToken, | 407 | token: userAccessToken, |
411 | path, | 408 | path, |
412 | fields: { host: 'localhost:' + servers[1].port }, | 409 | fields: { host: 'localhost:' + servers[1].port }, |
413 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 410 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
414 | }) | 411 | }) |
415 | }) | 412 | }) |
416 | 413 | ||
@@ -420,7 +417,7 @@ describe('Test blocklist API validators', function () { | |||
420 | token: server.accessToken, | 417 | token: server.accessToken, |
421 | path, | 418 | path, |
422 | fields: { host: 'localhost:9003' }, | 419 | fields: { host: 'localhost:9003' }, |
423 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 420 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
424 | }) | 421 | }) |
425 | }) | 422 | }) |
426 | 423 | ||
@@ -430,7 +427,7 @@ describe('Test blocklist API validators', function () { | |||
430 | token: server.accessToken, | 427 | token: server.accessToken, |
431 | path, | 428 | path, |
432 | fields: { host: 'localhost:' + server.port }, | 429 | fields: { host: 'localhost:' + server.port }, |
433 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 430 | expectedStatus: HttpStatusCode.CONFLICT_409 |
434 | }) | 431 | }) |
435 | }) | 432 | }) |
436 | 433 | ||
@@ -440,7 +437,7 @@ describe('Test blocklist API validators', function () { | |||
440 | token: server.accessToken, | 437 | token: server.accessToken, |
441 | path, | 438 | path, |
442 | fields: { host: 'localhost:' + servers[1].port }, | 439 | fields: { host: 'localhost:' + servers[1].port }, |
443 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 440 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
444 | }) | 441 | }) |
445 | }) | 442 | }) |
446 | }) | 443 | }) |
@@ -450,7 +447,7 @@ describe('Test blocklist API validators', function () { | |||
450 | await makeDeleteRequest({ | 447 | await makeDeleteRequest({ |
451 | url: server.url, | 448 | url: server.url, |
452 | path: path + '/localhost:' + servers[1].port, | 449 | path: path + '/localhost:' + servers[1].port, |
453 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 450 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
454 | }) | 451 | }) |
455 | }) | 452 | }) |
456 | 453 | ||
@@ -459,7 +456,7 @@ describe('Test blocklist API validators', function () { | |||
459 | url: server.url, | 456 | url: server.url, |
460 | path: path + '/localhost:' + servers[1].port, | 457 | path: path + '/localhost:' + servers[1].port, |
461 | token: userAccessToken, | 458 | token: userAccessToken, |
462 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 459 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
463 | }) | 460 | }) |
464 | }) | 461 | }) |
465 | 462 | ||
@@ -468,7 +465,7 @@ describe('Test blocklist API validators', function () { | |||
468 | url: server.url, | 465 | url: server.url, |
469 | path: path + '/localhost:9004', | 466 | path: path + '/localhost:9004', |
470 | token: server.accessToken, | 467 | token: server.accessToken, |
471 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 468 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
472 | }) | 469 | }) |
473 | }) | 470 | }) |
474 | 471 | ||
@@ -477,7 +474,7 @@ describe('Test blocklist API validators', function () { | |||
477 | url: server.url, | 474 | url: server.url, |
478 | path: path + '/localhost:' + servers[1].port, | 475 | path: path + '/localhost:' + servers[1].port, |
479 | token: server.accessToken, | 476 | token: server.accessToken, |
480 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 477 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
481 | }) | 478 | }) |
482 | }) | 479 | }) |
483 | }) | 480 | }) |
diff --git a/server/tests/api/check-params/bulk.ts b/server/tests/api/check-params/bulk.ts index a660c3d80..bc9d7784d 100644 --- a/server/tests/api/check-params/bulk.ts +++ b/server/tests/api/check-params/bulk.ts | |||
@@ -1,14 +1,8 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { | 4 | import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' |
5 | cleanupTests, | 5 | import { HttpStatusCode } from '@shared/models' |
6 | createSingleServer, | ||
7 | PeerTubeServer, | ||
8 | setAccessTokensToServers | ||
9 | } from '../../../../shared/extra-utils' | ||
10 | import { makePostBodyRequest } from '../../../../shared/extra-utils/requests/requests' | ||
11 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
12 | 6 | ||
13 | describe('Test bulk API validators', function () { | 7 | describe('Test bulk API validators', function () { |
14 | let server: PeerTubeServer | 8 | let server: PeerTubeServer |
@@ -36,7 +30,7 @@ describe('Test bulk API validators', function () { | |||
36 | url: server.url, | 30 | url: server.url, |
37 | path, | 31 | path, |
38 | fields: { accountName: 'user1', scope: 'my-videos' }, | 32 | fields: { accountName: 'user1', scope: 'my-videos' }, |
39 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 33 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
40 | }) | 34 | }) |
41 | }) | 35 | }) |
42 | 36 | ||
@@ -46,7 +40,7 @@ describe('Test bulk API validators', function () { | |||
46 | token: server.accessToken, | 40 | token: server.accessToken, |
47 | path, | 41 | path, |
48 | fields: { accountName: 'user2', scope: 'my-videos' }, | 42 | fields: { accountName: 'user2', scope: 'my-videos' }, |
49 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 43 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
50 | }) | 44 | }) |
51 | }) | 45 | }) |
52 | 46 | ||
@@ -56,7 +50,7 @@ describe('Test bulk API validators', function () { | |||
56 | token: server.accessToken, | 50 | token: server.accessToken, |
57 | path, | 51 | path, |
58 | fields: { accountName: 'user1', scope: 'my-videoss' }, | 52 | fields: { accountName: 'user1', scope: 'my-videoss' }, |
59 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 53 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
60 | }) | 54 | }) |
61 | }) | 55 | }) |
62 | 56 | ||
@@ -66,7 +60,7 @@ describe('Test bulk API validators', function () { | |||
66 | token: userAccessToken, | 60 | token: userAccessToken, |
67 | path, | 61 | path, |
68 | fields: { accountName: 'user1', scope: 'instance' }, | 62 | fields: { accountName: 'user1', scope: 'instance' }, |
69 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 63 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
70 | }) | 64 | }) |
71 | }) | 65 | }) |
72 | 66 | ||
@@ -76,7 +70,7 @@ describe('Test bulk API validators', function () { | |||
76 | token: server.accessToken, | 70 | token: server.accessToken, |
77 | path, | 71 | path, |
78 | fields: { accountName: 'user1', scope: 'instance' }, | 72 | fields: { accountName: 'user1', scope: 'instance' }, |
79 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 73 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
80 | }) | 74 | }) |
81 | }) | 75 | }) |
82 | }) | 76 | }) |
diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index 1756d58ee..c3438917e 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
@@ -214,7 +214,7 @@ describe('Test config API validators', function () { | |||
214 | await makeGetRequest({ | 214 | await makeGetRequest({ |
215 | url: server.url, | 215 | url: server.url, |
216 | path, | 216 | path, |
217 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 217 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
218 | }) | 218 | }) |
219 | }) | 219 | }) |
220 | 220 | ||
@@ -223,7 +223,7 @@ describe('Test config API validators', function () { | |||
223 | url: server.url, | 223 | url: server.url, |
224 | path, | 224 | path, |
225 | token: userAccessToken, | 225 | token: userAccessToken, |
226 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 226 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
227 | }) | 227 | }) |
228 | }) | 228 | }) |
229 | }) | 229 | }) |
@@ -234,7 +234,7 @@ describe('Test config API validators', function () { | |||
234 | url: server.url, | 234 | url: server.url, |
235 | path, | 235 | path, |
236 | fields: updateParams, | 236 | fields: updateParams, |
237 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 237 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
238 | }) | 238 | }) |
239 | }) | 239 | }) |
240 | 240 | ||
@@ -244,7 +244,7 @@ describe('Test config API validators', function () { | |||
244 | path, | 244 | path, |
245 | fields: updateParams, | 245 | fields: updateParams, |
246 | token: userAccessToken, | 246 | token: userAccessToken, |
247 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 247 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
248 | }) | 248 | }) |
249 | }) | 249 | }) |
250 | 250 | ||
@@ -256,7 +256,7 @@ describe('Test config API validators', function () { | |||
256 | path, | 256 | path, |
257 | fields: newUpdateParams, | 257 | fields: newUpdateParams, |
258 | token: server.accessToken, | 258 | token: server.accessToken, |
259 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 259 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
260 | }) | 260 | }) |
261 | }) | 261 | }) |
262 | 262 | ||
@@ -274,7 +274,7 @@ describe('Test config API validators', function () { | |||
274 | path, | 274 | path, |
275 | fields: newUpdateParams, | 275 | fields: newUpdateParams, |
276 | token: server.accessToken, | 276 | token: server.accessToken, |
277 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 277 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
278 | }) | 278 | }) |
279 | }) | 279 | }) |
280 | 280 | ||
@@ -295,7 +295,7 @@ describe('Test config API validators', function () { | |||
295 | path, | 295 | path, |
296 | fields: newUpdateParams, | 296 | fields: newUpdateParams, |
297 | token: server.accessToken, | 297 | token: server.accessToken, |
298 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 298 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
299 | }) | 299 | }) |
300 | }) | 300 | }) |
301 | 301 | ||
@@ -318,7 +318,7 @@ describe('Test config API validators', function () { | |||
318 | path, | 318 | path, |
319 | fields: newUpdateParams, | 319 | fields: newUpdateParams, |
320 | token: server.accessToken, | 320 | token: server.accessToken, |
321 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 321 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
322 | }) | 322 | }) |
323 | }) | 323 | }) |
324 | 324 | ||
@@ -328,7 +328,7 @@ describe('Test config API validators', function () { | |||
328 | path, | 328 | path, |
329 | fields: updateParams, | 329 | fields: updateParams, |
330 | token: server.accessToken, | 330 | token: server.accessToken, |
331 | statusCodeExpected: HttpStatusCode.OK_200 | 331 | expectedStatus: HttpStatusCode.OK_200 |
332 | }) | 332 | }) |
333 | }) | 333 | }) |
334 | }) | 334 | }) |
@@ -338,7 +338,7 @@ describe('Test config API validators', function () { | |||
338 | await makeDeleteRequest({ | 338 | await makeDeleteRequest({ |
339 | url: server.url, | 339 | url: server.url, |
340 | path, | 340 | path, |
341 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 341 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
342 | }) | 342 | }) |
343 | }) | 343 | }) |
344 | 344 | ||
@@ -347,7 +347,7 @@ describe('Test config API validators', function () { | |||
347 | url: server.url, | 347 | url: server.url, |
348 | path, | 348 | path, |
349 | token: userAccessToken, | 349 | token: userAccessToken, |
350 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 350 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
351 | }) | 351 | }) |
352 | }) | 352 | }) |
353 | }) | 353 | }) |
diff --git a/server/tests/api/check-params/contact-form.ts b/server/tests/api/check-params/contact-form.ts index 8c2b2a84b..8e755c69b 100644 --- a/server/tests/api/check-params/contact-form.ts +++ b/server/tests/api/check-params/contact-form.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { cleanupTests, createSingleServer, killallServers, MockSmtpServer, PeerTubeServer } from '@shared/extra-utils' | 5 | import { cleanupTests, createSingleServer, killallServers, MockSmtpServer, PeerTubeServer } from '@shared/extra-utils' |
6 | import { ContactFormCommand } from '@shared/extra-utils/server' | 6 | import { ContactFormCommand } from '@shared/extra-utils/server' |
7 | 7 | ||
diff --git a/server/tests/api/check-params/custom-pages.ts b/server/tests/api/check-params/custom-pages.ts index 043505e32..9fbbea315 100644 --- a/server/tests/api/check-params/custom-pages.ts +++ b/server/tests/api/check-params/custom-pages.ts | |||
@@ -1,14 +1,15 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
5 | import { | 4 | import { |
6 | cleanupTests, | 5 | cleanupTests, |
7 | createSingleServer, | 6 | createSingleServer, |
7 | makeGetRequest, | ||
8 | makePutBodyRequest, | ||
8 | PeerTubeServer, | 9 | PeerTubeServer, |
9 | setAccessTokensToServers | 10 | setAccessTokensToServers |
10 | } from '../../../../shared/extra-utils' | 11 | } from '@shared/extra-utils' |
11 | import { makeGetRequest, makePutBodyRequest } from '../../../../shared/extra-utils/requests/requests' | 12 | import { HttpStatusCode } from '@shared/models' |
12 | 13 | ||
13 | describe('Test custom pages validators', function () { | 14 | describe('Test custom pages validators', function () { |
14 | const path = '/api/v1/custom-pages/homepage/instance' | 15 | const path = '/api/v1/custom-pages/homepage/instance' |
@@ -37,7 +38,7 @@ describe('Test custom pages validators', function () { | |||
37 | url: server.url, | 38 | url: server.url, |
38 | path, | 39 | path, |
39 | fields: { content: 'super content' }, | 40 | fields: { content: 'super content' }, |
40 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 41 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
41 | }) | 42 | }) |
42 | }) | 43 | }) |
43 | 44 | ||
@@ -47,7 +48,7 @@ describe('Test custom pages validators', function () { | |||
47 | path, | 48 | path, |
48 | token: userAccessToken, | 49 | token: userAccessToken, |
49 | fields: { content: 'super content' }, | 50 | fields: { content: 'super content' }, |
50 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 51 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
51 | }) | 52 | }) |
52 | }) | 53 | }) |
53 | 54 | ||
@@ -57,7 +58,7 @@ describe('Test custom pages validators', function () { | |||
57 | path, | 58 | path, |
58 | token: server.accessToken, | 59 | token: server.accessToken, |
59 | fields: { content: 'super content' }, | 60 | fields: { content: 'super content' }, |
60 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 61 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
61 | }) | 62 | }) |
62 | }) | 63 | }) |
63 | }) | 64 | }) |
@@ -68,7 +69,7 @@ describe('Test custom pages validators', function () { | |||
68 | await makeGetRequest({ | 69 | await makeGetRequest({ |
69 | url: server.url, | 70 | url: server.url, |
70 | path, | 71 | path, |
71 | statusCodeExpected: HttpStatusCode.OK_200 | 72 | expectedStatus: HttpStatusCode.OK_200 |
72 | }) | 73 | }) |
73 | }) | 74 | }) |
74 | }) | 75 | }) |
diff --git a/server/tests/api/check-params/debug.ts b/server/tests/api/check-params/debug.ts index 9c13e9daf..a55786359 100644 --- a/server/tests/api/check-params/debug.ts +++ b/server/tests/api/check-params/debug.ts | |||
@@ -1,15 +1,8 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | 4 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | |
5 | import { | 5 | import { HttpStatusCode } from '@shared/models' |
6 | cleanupTests, | ||
7 | createSingleServer, | ||
8 | PeerTubeServer, | ||
9 | setAccessTokensToServers | ||
10 | } from '../../../../shared/extra-utils' | ||
11 | import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' | ||
12 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
13 | 6 | ||
14 | describe('Test debug API validators', function () { | 7 | describe('Test debug API validators', function () { |
15 | const path = '/api/v1/server/debug' | 8 | const path = '/api/v1/server/debug' |
@@ -39,7 +32,7 @@ describe('Test debug API validators', function () { | |||
39 | await makeGetRequest({ | 32 | await makeGetRequest({ |
40 | url: server.url, | 33 | url: server.url, |
41 | path, | 34 | path, |
42 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 35 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
43 | }) | 36 | }) |
44 | }) | 37 | }) |
45 | 38 | ||
@@ -48,7 +41,7 @@ describe('Test debug API validators', function () { | |||
48 | url: server.url, | 41 | url: server.url, |
49 | path, | 42 | path, |
50 | token: userAccessToken, | 43 | token: userAccessToken, |
51 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 44 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
52 | }) | 45 | }) |
53 | }) | 46 | }) |
54 | 47 | ||
@@ -58,7 +51,7 @@ describe('Test debug API validators', function () { | |||
58 | path, | 51 | path, |
59 | token: server.accessToken, | 52 | token: server.accessToken, |
60 | query: { startDate: new Date().toISOString() }, | 53 | query: { startDate: new Date().toISOString() }, |
61 | statusCodeExpected: HttpStatusCode.OK_200 | 54 | expectedStatus: HttpStatusCode.OK_200 |
62 | }) | 55 | }) |
63 | }) | 56 | }) |
64 | }) | 57 | }) |
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index 0fd2b4925..dfe3f226d 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts | |||
@@ -1,21 +1,19 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | |||
5 | import { | 4 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
8 | makeDeleteRequest, makeGetRequest, | 10 | makeDeleteRequest, |
11 | makeGetRequest, | ||
9 | makePostBodyRequest, | 12 | makePostBodyRequest, |
10 | PeerTubeServer, | 13 | PeerTubeServer, |
11 | setAccessTokensToServers | 14 | setAccessTokensToServers |
12 | } from '../../../../shared/extra-utils' | 15 | } from '@shared/extra-utils' |
13 | import { | 16 | import { HttpStatusCode } from '@shared/models' |
14 | checkBadCountPagination, | ||
15 | checkBadSortPagination, | ||
16 | checkBadStartPagination | ||
17 | } from '../../../../shared/extra-utils/requests/check-api-params' | ||
18 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
19 | 17 | ||
20 | describe('Test server follows API validators', function () { | 18 | describe('Test server follows API validators', function () { |
21 | let server: PeerTubeServer | 19 | let server: PeerTubeServer |
@@ -51,7 +49,7 @@ describe('Test server follows API validators', function () { | |||
51 | url: server.url, | 49 | url: server.url, |
52 | path, | 50 | path, |
53 | token: server.accessToken, | 51 | token: server.accessToken, |
54 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 52 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
55 | }) | 53 | }) |
56 | }) | 54 | }) |
57 | 55 | ||
@@ -61,7 +59,7 @@ describe('Test server follows API validators', function () { | |||
61 | path, | 59 | path, |
62 | token: server.accessToken, | 60 | token: server.accessToken, |
63 | fields: { hosts: 'localhost:9002' }, | 61 | fields: { hosts: 'localhost:9002' }, |
64 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 62 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
65 | }) | 63 | }) |
66 | }) | 64 | }) |
67 | 65 | ||
@@ -71,7 +69,7 @@ describe('Test server follows API validators', function () { | |||
71 | path, | 69 | path, |
72 | fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, | 70 | fields: { hosts: [ 'localhost:9002', 'localhost:coucou' ] }, |
73 | token: server.accessToken, | 71 | token: server.accessToken, |
74 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 72 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
75 | }) | 73 | }) |
76 | }) | 74 | }) |
77 | 75 | ||
@@ -81,7 +79,7 @@ describe('Test server follows API validators', function () { | |||
81 | path, | 79 | path, |
82 | fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, | 80 | fields: { hosts: [ 'localhost:9002', 'http://localhost:9003' ] }, |
83 | token: server.accessToken, | 81 | token: server.accessToken, |
84 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 82 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
85 | }) | 83 | }) |
86 | }) | 84 | }) |
87 | 85 | ||
@@ -91,7 +89,7 @@ describe('Test server follows API validators', function () { | |||
91 | path, | 89 | path, |
92 | fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, | 90 | fields: { urls: [ 'localhost:9002', 'localhost:9002' ] }, |
93 | token: server.accessToken, | 91 | token: server.accessToken, |
94 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 92 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
95 | }) | 93 | }) |
96 | }) | 94 | }) |
97 | 95 | ||
@@ -101,7 +99,7 @@ describe('Test server follows API validators', function () { | |||
101 | path, | 99 | path, |
102 | fields: { hosts: [ 'localhost:9002' ] }, | 100 | fields: { hosts: [ 'localhost:9002' ] }, |
103 | token: 'fake_token', | 101 | token: 'fake_token', |
104 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 102 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
105 | }) | 103 | }) |
106 | }) | 104 | }) |
107 | 105 | ||
@@ -111,7 +109,7 @@ describe('Test server follows API validators', function () { | |||
111 | path, | 109 | path, |
112 | fields: { hosts: [ 'localhost:9002' ] }, | 110 | fields: { hosts: [ 'localhost:9002' ] }, |
113 | token: userAccessToken, | 111 | token: userAccessToken, |
114 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 112 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
115 | }) | 113 | }) |
116 | }) | 114 | }) |
117 | }) | 115 | }) |
@@ -155,7 +153,7 @@ describe('Test server follows API validators', function () { | |||
155 | await makeGetRequest({ | 153 | await makeGetRequest({ |
156 | url: server.url, | 154 | url: server.url, |
157 | path, | 155 | path, |
158 | statusCodeExpected: HttpStatusCode.OK_200, | 156 | expectedStatus: HttpStatusCode.OK_200, |
159 | query: { | 157 | query: { |
160 | state: 'accepted', | 158 | state: 'accepted', |
161 | actorType: 'Application' | 159 | actorType: 'Application' |
@@ -204,7 +202,7 @@ describe('Test server follows API validators', function () { | |||
204 | await makeGetRequest({ | 202 | await makeGetRequest({ |
205 | url: server.url, | 203 | url: server.url, |
206 | path, | 204 | path, |
207 | statusCodeExpected: HttpStatusCode.OK_200, | 205 | expectedStatus: HttpStatusCode.OK_200, |
208 | query: { | 206 | query: { |
209 | state: 'accepted' | 207 | state: 'accepted' |
210 | } | 208 | } |
@@ -220,7 +218,7 @@ describe('Test server follows API validators', function () { | |||
220 | url: server.url, | 218 | url: server.url, |
221 | path: path + '/toto@localhost:9002', | 219 | path: path + '/toto@localhost:9002', |
222 | token: 'fake_token', | 220 | token: 'fake_token', |
223 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 221 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
224 | }) | 222 | }) |
225 | }) | 223 | }) |
226 | 224 | ||
@@ -229,7 +227,7 @@ describe('Test server follows API validators', function () { | |||
229 | url: server.url, | 227 | url: server.url, |
230 | path: path + '/toto@localhost:9002', | 228 | path: path + '/toto@localhost:9002', |
231 | token: userAccessToken, | 229 | token: userAccessToken, |
232 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 230 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
233 | }) | 231 | }) |
234 | }) | 232 | }) |
235 | 233 | ||
@@ -238,7 +236,7 @@ describe('Test server follows API validators', function () { | |||
238 | url: server.url, | 236 | url: server.url, |
239 | path: path + '/toto', | 237 | path: path + '/toto', |
240 | token: server.accessToken, | 238 | token: server.accessToken, |
241 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 239 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
242 | }) | 240 | }) |
243 | }) | 241 | }) |
244 | 242 | ||
@@ -247,7 +245,7 @@ describe('Test server follows API validators', function () { | |||
247 | url: server.url, | 245 | url: server.url, |
248 | path: path + '/toto@localhost:9003', | 246 | path: path + '/toto@localhost:9003', |
249 | token: server.accessToken, | 247 | token: server.accessToken, |
250 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 248 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
251 | }) | 249 | }) |
252 | }) | 250 | }) |
253 | }) | 251 | }) |
@@ -260,7 +258,7 @@ describe('Test server follows API validators', function () { | |||
260 | url: server.url, | 258 | url: server.url, |
261 | path: path + '/toto@localhost:9002/accept', | 259 | path: path + '/toto@localhost:9002/accept', |
262 | token: 'fake_token', | 260 | token: 'fake_token', |
263 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 261 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
264 | }) | 262 | }) |
265 | }) | 263 | }) |
266 | 264 | ||
@@ -269,7 +267,7 @@ describe('Test server follows API validators', function () { | |||
269 | url: server.url, | 267 | url: server.url, |
270 | path: path + '/toto@localhost:9002/accept', | 268 | path: path + '/toto@localhost:9002/accept', |
271 | token: userAccessToken, | 269 | token: userAccessToken, |
272 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 270 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
273 | }) | 271 | }) |
274 | }) | 272 | }) |
275 | 273 | ||
@@ -278,7 +276,7 @@ describe('Test server follows API validators', function () { | |||
278 | url: server.url, | 276 | url: server.url, |
279 | path: path + '/toto/accept', | 277 | path: path + '/toto/accept', |
280 | token: server.accessToken, | 278 | token: server.accessToken, |
281 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 279 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
282 | }) | 280 | }) |
283 | }) | 281 | }) |
284 | 282 | ||
@@ -287,7 +285,7 @@ describe('Test server follows API validators', function () { | |||
287 | url: server.url, | 285 | url: server.url, |
288 | path: path + '/toto@localhost:9003/accept', | 286 | path: path + '/toto@localhost:9003/accept', |
289 | token: server.accessToken, | 287 | token: server.accessToken, |
290 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 288 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
291 | }) | 289 | }) |
292 | }) | 290 | }) |
293 | }) | 291 | }) |
@@ -300,7 +298,7 @@ describe('Test server follows API validators', function () { | |||
300 | url: server.url, | 298 | url: server.url, |
301 | path: path + '/toto@localhost:9002/reject', | 299 | path: path + '/toto@localhost:9002/reject', |
302 | token: 'fake_token', | 300 | token: 'fake_token', |
303 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 301 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
304 | }) | 302 | }) |
305 | }) | 303 | }) |
306 | 304 | ||
@@ -309,7 +307,7 @@ describe('Test server follows API validators', function () { | |||
309 | url: server.url, | 307 | url: server.url, |
310 | path: path + '/toto@localhost:9002/reject', | 308 | path: path + '/toto@localhost:9002/reject', |
311 | token: userAccessToken, | 309 | token: userAccessToken, |
312 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 310 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
313 | }) | 311 | }) |
314 | }) | 312 | }) |
315 | 313 | ||
@@ -318,7 +316,7 @@ describe('Test server follows API validators', function () { | |||
318 | url: server.url, | 316 | url: server.url, |
319 | path: path + '/toto/reject', | 317 | path: path + '/toto/reject', |
320 | token: server.accessToken, | 318 | token: server.accessToken, |
321 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 319 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
322 | }) | 320 | }) |
323 | }) | 321 | }) |
324 | 322 | ||
@@ -327,7 +325,7 @@ describe('Test server follows API validators', function () { | |||
327 | url: server.url, | 325 | url: server.url, |
328 | path: path + '/toto@localhost:9003/reject', | 326 | path: path + '/toto@localhost:9003/reject', |
329 | token: server.accessToken, | 327 | token: server.accessToken, |
330 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 328 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
331 | }) | 329 | }) |
332 | }) | 330 | }) |
333 | }) | 331 | }) |
@@ -340,7 +338,7 @@ describe('Test server follows API validators', function () { | |||
340 | url: server.url, | 338 | url: server.url, |
341 | path: path + '/localhost:9002', | 339 | path: path + '/localhost:9002', |
342 | token: 'fake_token', | 340 | token: 'fake_token', |
343 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 341 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
344 | }) | 342 | }) |
345 | }) | 343 | }) |
346 | 344 | ||
@@ -349,7 +347,7 @@ describe('Test server follows API validators', function () { | |||
349 | url: server.url, | 347 | url: server.url, |
350 | path: path + '/localhost:9002', | 348 | path: path + '/localhost:9002', |
351 | token: userAccessToken, | 349 | token: userAccessToken, |
352 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 350 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
353 | }) | 351 | }) |
354 | }) | 352 | }) |
355 | 353 | ||
@@ -358,7 +356,7 @@ describe('Test server follows API validators', function () { | |||
358 | url: server.url, | 356 | url: server.url, |
359 | path: path + '/example.com', | 357 | path: path + '/example.com', |
360 | token: server.accessToken, | 358 | token: server.accessToken, |
361 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 359 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
362 | }) | 360 | }) |
363 | }) | 361 | }) |
364 | }) | 362 | }) |
diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts index a370ec2d3..23d95d8e4 100644 --- a/server/tests/api/check-params/jobs.ts +++ b/server/tests/api/check-params/jobs.ts | |||
@@ -1,20 +1,17 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | |||
5 | import { | 4 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
10 | makeGetRequest, | ||
8 | PeerTubeServer, | 11 | PeerTubeServer, |
9 | setAccessTokensToServers | 12 | setAccessTokensToServers |
10 | } from '../../../../shared/extra-utils' | 13 | } from '@shared/extra-utils' |
11 | import { | 14 | import { HttpStatusCode } from '@shared/models' |
12 | checkBadCountPagination, | ||
13 | checkBadSortPagination, | ||
14 | checkBadStartPagination | ||
15 | } from '../../../../shared/extra-utils/requests/check-api-params' | ||
16 | import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' | ||
17 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
18 | 15 | ||
19 | describe('Test jobs API validators', function () { | 16 | describe('Test jobs API validators', function () { |
20 | const path = '/api/v1/jobs/failed' | 17 | const path = '/api/v1/jobs/failed' |
@@ -75,7 +72,7 @@ describe('Test jobs API validators', function () { | |||
75 | await makeGetRequest({ | 72 | await makeGetRequest({ |
76 | url: server.url, | 73 | url: server.url, |
77 | path, | 74 | path, |
78 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 75 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
79 | }) | 76 | }) |
80 | }) | 77 | }) |
81 | 78 | ||
@@ -84,7 +81,7 @@ describe('Test jobs API validators', function () { | |||
84 | url: server.url, | 81 | url: server.url, |
85 | path, | 82 | path, |
86 | token: userAccessToken, | 83 | token: userAccessToken, |
87 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 84 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
88 | }) | 85 | }) |
89 | }) | 86 | }) |
90 | 87 | ||
diff --git a/server/tests/api/check-params/live.ts b/server/tests/api/check-params/live.ts index eb5cdd1d8..0ef86a538 100644 --- a/server/tests/api/check-params/live.ts +++ b/server/tests/api/check-params/live.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | buildAbsoluteFixturePath, | 7 | buildAbsoluteFixturePath, |
8 | cleanupTests, | 8 | cleanupTests, |
@@ -223,7 +223,7 @@ describe('Test video lives API validator', function () { | |||
223 | path, | 223 | path, |
224 | token: server.accessToken, | 224 | token: server.accessToken, |
225 | fields: baseCorrectParams, | 225 | fields: baseCorrectParams, |
226 | statusCodeExpected: HttpStatusCode.OK_200 | 226 | expectedStatus: HttpStatusCode.OK_200 |
227 | }) | 227 | }) |
228 | 228 | ||
229 | video = res.body.video | 229 | video = res.body.video |
@@ -243,7 +243,7 @@ describe('Test video lives API validator', function () { | |||
243 | path, | 243 | path, |
244 | token: server.accessToken, | 244 | token: server.accessToken, |
245 | fields: baseCorrectParams, | 245 | fields: baseCorrectParams, |
246 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 246 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
247 | }) | 247 | }) |
248 | }) | 248 | }) |
249 | 249 | ||
@@ -264,7 +264,7 @@ describe('Test video lives API validator', function () { | |||
264 | path, | 264 | path, |
265 | token: server.accessToken, | 265 | token: server.accessToken, |
266 | fields, | 266 | fields, |
267 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 267 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
268 | }) | 268 | }) |
269 | }) | 269 | }) |
270 | 270 | ||
@@ -285,7 +285,7 @@ describe('Test video lives API validator', function () { | |||
285 | path, | 285 | path, |
286 | token: server.accessToken, | 286 | token: server.accessToken, |
287 | fields, | 287 | fields, |
288 | statusCodeExpected: HttpStatusCode.OK_200 | 288 | expectedStatus: HttpStatusCode.OK_200 |
289 | }) | 289 | }) |
290 | }) | 290 | }) |
291 | 291 | ||
@@ -304,7 +304,7 @@ describe('Test video lives API validator', function () { | |||
304 | path, | 304 | path, |
305 | token: server.accessToken, | 305 | token: server.accessToken, |
306 | fields: baseCorrectParams, | 306 | fields: baseCorrectParams, |
307 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 307 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
308 | }) | 308 | }) |
309 | }) | 309 | }) |
310 | 310 | ||
@@ -324,7 +324,7 @@ describe('Test video lives API validator', function () { | |||
324 | path, | 324 | path, |
325 | token: server.accessToken, | 325 | token: server.accessToken, |
326 | fields: baseCorrectParams, | 326 | fields: baseCorrectParams, |
327 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 327 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
328 | }) | 328 | }) |
329 | }) | 329 | }) |
330 | }) | 330 | }) |
diff --git a/server/tests/api/check-params/logs.ts b/server/tests/api/check-params/logs.ts index 2eb074007..05372257a 100644 --- a/server/tests/api/check-params/logs.ts +++ b/server/tests/api/check-params/logs.ts | |||
@@ -1,15 +1,8 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | 4 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | |
5 | import { | 5 | import { HttpStatusCode } from '@shared/models' |
6 | cleanupTests, | ||
7 | createSingleServer, | ||
8 | PeerTubeServer, | ||
9 | setAccessTokensToServers | ||
10 | } from '../../../../shared/extra-utils' | ||
11 | import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests' | ||
12 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
13 | 6 | ||
14 | describe('Test logs API validators', function () { | 7 | describe('Test logs API validators', function () { |
15 | const path = '/api/v1/server/logs' | 8 | const path = '/api/v1/server/logs' |
@@ -39,7 +32,7 @@ describe('Test logs API validators', function () { | |||
39 | await makeGetRequest({ | 32 | await makeGetRequest({ |
40 | url: server.url, | 33 | url: server.url, |
41 | path, | 34 | path, |
42 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 35 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
43 | }) | 36 | }) |
44 | }) | 37 | }) |
45 | 38 | ||
@@ -48,7 +41,7 @@ describe('Test logs API validators', function () { | |||
48 | url: server.url, | 41 | url: server.url, |
49 | path, | 42 | path, |
50 | token: userAccessToken, | 43 | token: userAccessToken, |
51 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 44 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
52 | }) | 45 | }) |
53 | }) | 46 | }) |
54 | 47 | ||
@@ -57,7 +50,7 @@ describe('Test logs API validators', function () { | |||
57 | url: server.url, | 50 | url: server.url, |
58 | path, | 51 | path, |
59 | token: server.accessToken, | 52 | token: server.accessToken, |
60 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 53 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
61 | }) | 54 | }) |
62 | }) | 55 | }) |
63 | 56 | ||
@@ -67,7 +60,7 @@ describe('Test logs API validators', function () { | |||
67 | path, | 60 | path, |
68 | token: server.accessToken, | 61 | token: server.accessToken, |
69 | query: { startDate: 'toto' }, | 62 | query: { startDate: 'toto' }, |
70 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 63 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
71 | }) | 64 | }) |
72 | }) | 65 | }) |
73 | 66 | ||
@@ -77,7 +70,7 @@ describe('Test logs API validators', function () { | |||
77 | path, | 70 | path, |
78 | token: server.accessToken, | 71 | token: server.accessToken, |
79 | query: { startDate: new Date().toISOString(), endDate: 'toto' }, | 72 | query: { startDate: new Date().toISOString(), endDate: 'toto' }, |
80 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 73 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
81 | }) | 74 | }) |
82 | }) | 75 | }) |
83 | 76 | ||
@@ -87,7 +80,7 @@ describe('Test logs API validators', function () { | |||
87 | path, | 80 | path, |
88 | token: server.accessToken, | 81 | token: server.accessToken, |
89 | query: { startDate: new Date().toISOString(), level: 'toto' }, | 82 | query: { startDate: new Date().toISOString(), level: 'toto' }, |
90 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 83 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
91 | }) | 84 | }) |
92 | }) | 85 | }) |
93 | 86 | ||
@@ -97,7 +90,7 @@ describe('Test logs API validators', function () { | |||
97 | path, | 90 | path, |
98 | token: server.accessToken, | 91 | token: server.accessToken, |
99 | query: { startDate: new Date().toISOString() }, | 92 | query: { startDate: new Date().toISOString() }, |
100 | statusCodeExpected: HttpStatusCode.OK_200 | 93 | expectedStatus: HttpStatusCode.OK_200 |
101 | }) | 94 | }) |
102 | }) | 95 | }) |
103 | }) | 96 | }) |
diff --git a/server/tests/api/check-params/plugins.ts b/server/tests/api/check-params/plugins.ts index 2b471ee7d..d3dda7fce 100644 --- a/server/tests/api/check-params/plugins.ts +++ b/server/tests/api/check-params/plugins.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 5 | import { |
6 | checkBadCountPagination, | 6 | checkBadCountPagination, |
7 | checkBadSortPagination, | 7 | checkBadSortPagination, |
@@ -70,7 +70,7 @@ describe('Test server plugins API validators', function () { | |||
70 | ] | 70 | ] |
71 | 71 | ||
72 | for (const p of paths) { | 72 | for (const p of paths) { |
73 | await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) | 73 | await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
74 | } | 74 | } |
75 | }) | 75 | }) |
76 | 76 | ||
@@ -78,7 +78,7 @@ describe('Test server plugins API validators', function () { | |||
78 | await makeGetRequest({ | 78 | await makeGetRequest({ |
79 | url: server.url, | 79 | url: server.url, |
80 | path: '/themes/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png', | 80 | path: '/themes/' + pluginName + '/' + npmVersion + '/static/images/chocobo.png', |
81 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 81 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
82 | }) | 82 | }) |
83 | }) | 83 | }) |
84 | 84 | ||
@@ -93,7 +93,7 @@ describe('Test server plugins API validators', function () { | |||
93 | ] | 93 | ] |
94 | 94 | ||
95 | for (const p of paths) { | 95 | for (const p of paths) { |
96 | await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 96 | await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
97 | } | 97 | } |
98 | }) | 98 | }) |
99 | 99 | ||
@@ -107,14 +107,14 @@ describe('Test server plugins API validators', function () { | |||
107 | ] | 107 | ] |
108 | 108 | ||
109 | for (const p of paths) { | 109 | for (const p of paths) { |
110 | await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 110 | await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
111 | } | 111 | } |
112 | }) | 112 | }) |
113 | 113 | ||
114 | it('Should fail with an unknown auth name', async function () { | 114 | it('Should fail with an unknown auth name', async function () { |
115 | const path = '/plugins/' + pluginName + '/' + npmVersion + '/auth/bad-auth' | 115 | const path = '/plugins/' + pluginName + '/' + npmVersion + '/auth/bad-auth' |
116 | 116 | ||
117 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) | 117 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
118 | }) | 118 | }) |
119 | 119 | ||
120 | it('Should fail with an unknown static file', async function () { | 120 | it('Should fail with an unknown static file', async function () { |
@@ -126,7 +126,7 @@ describe('Test server plugins API validators', function () { | |||
126 | ] | 126 | ] |
127 | 127 | ||
128 | for (const p of paths) { | 128 | for (const p of paths) { |
129 | await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) | 129 | await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
130 | } | 130 | } |
131 | }) | 131 | }) |
132 | 132 | ||
@@ -134,7 +134,7 @@ describe('Test server plugins API validators', function () { | |||
134 | await makeGetRequest({ | 134 | await makeGetRequest({ |
135 | url: server.url, | 135 | url: server.url, |
136 | path: '/themes/' + themeName + '/' + themeVersion + '/css/assets/fake.css', | 136 | path: '/themes/' + themeName + '/' + themeVersion + '/css/assets/fake.css', |
137 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 137 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
138 | }) | 138 | }) |
139 | }) | 139 | }) |
140 | 140 | ||
@@ -148,11 +148,11 @@ describe('Test server plugins API validators', function () { | |||
148 | ] | 148 | ] |
149 | 149 | ||
150 | for (const p of paths) { | 150 | for (const p of paths) { |
151 | await makeGetRequest({ url: server.url, path: p, statusCodeExpected: HttpStatusCode.OK_200 }) | 151 | await makeGetRequest({ url: server.url, path: p, expectedStatus: HttpStatusCode.OK_200 }) |
152 | } | 152 | } |
153 | 153 | ||
154 | const authPath = '/plugins/' + pluginName + '/' + npmVersion + '/auth/fake-auth' | 154 | const authPath = '/plugins/' + pluginName + '/' + npmVersion + '/auth/fake-auth' |
155 | await makeGetRequest({ url: server.url, path: authPath, statusCodeExpected: HttpStatusCode.FOUND_302 }) | 155 | await makeGetRequest({ url: server.url, path: authPath, expectedStatus: HttpStatusCode.FOUND_302 }) |
156 | }) | 156 | }) |
157 | }) | 157 | }) |
158 | 158 | ||
@@ -170,7 +170,7 @@ describe('Test server plugins API validators', function () { | |||
170 | path, | 170 | path, |
171 | token: 'fake_token', | 171 | token: 'fake_token', |
172 | query: baseQuery, | 172 | query: baseQuery, |
173 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 173 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
174 | }) | 174 | }) |
175 | }) | 175 | }) |
176 | 176 | ||
@@ -180,7 +180,7 @@ describe('Test server plugins API validators', function () { | |||
180 | path, | 180 | path, |
181 | token: userAccessToken, | 181 | token: userAccessToken, |
182 | query: baseQuery, | 182 | query: baseQuery, |
183 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 183 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
184 | }) | 184 | }) |
185 | }) | 185 | }) |
186 | 186 | ||
@@ -224,7 +224,7 @@ describe('Test server plugins API validators', function () { | |||
224 | path, | 224 | path, |
225 | token: server.accessToken, | 225 | token: server.accessToken, |
226 | query: baseQuery, | 226 | query: baseQuery, |
227 | statusCodeExpected: HttpStatusCode.OK_200 | 227 | expectedStatus: HttpStatusCode.OK_200 |
228 | }) | 228 | }) |
229 | }) | 229 | }) |
230 | }) | 230 | }) |
@@ -241,7 +241,7 @@ describe('Test server plugins API validators', function () { | |||
241 | path, | 241 | path, |
242 | token: 'fake_token', | 242 | token: 'fake_token', |
243 | query: baseQuery, | 243 | query: baseQuery, |
244 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 244 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
245 | }) | 245 | }) |
246 | }) | 246 | }) |
247 | 247 | ||
@@ -251,7 +251,7 @@ describe('Test server plugins API validators', function () { | |||
251 | path, | 251 | path, |
252 | token: userAccessToken, | 252 | token: userAccessToken, |
253 | query: baseQuery, | 253 | query: baseQuery, |
254 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 254 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
255 | }) | 255 | }) |
256 | }) | 256 | }) |
257 | 257 | ||
@@ -284,7 +284,7 @@ describe('Test server plugins API validators', function () { | |||
284 | path, | 284 | path, |
285 | token: server.accessToken, | 285 | token: server.accessToken, |
286 | query: baseQuery, | 286 | query: baseQuery, |
287 | statusCodeExpected: HttpStatusCode.OK_200 | 287 | expectedStatus: HttpStatusCode.OK_200 |
288 | }) | 288 | }) |
289 | }) | 289 | }) |
290 | }) | 290 | }) |
@@ -298,7 +298,7 @@ describe('Test server plugins API validators', function () { | |||
298 | url: server.url, | 298 | url: server.url, |
299 | path: path + suffix, | 299 | path: path + suffix, |
300 | token: 'fake_token', | 300 | token: 'fake_token', |
301 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 301 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
302 | }) | 302 | }) |
303 | } | 303 | } |
304 | }) | 304 | }) |
@@ -309,7 +309,7 @@ describe('Test server plugins API validators', function () { | |||
309 | url: server.url, | 309 | url: server.url, |
310 | path: path + suffix, | 310 | path: path + suffix, |
311 | token: userAccessToken, | 311 | token: userAccessToken, |
312 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 312 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
313 | }) | 313 | }) |
314 | } | 314 | } |
315 | }) | 315 | }) |
@@ -320,7 +320,7 @@ describe('Test server plugins API validators', function () { | |||
320 | url: server.url, | 320 | url: server.url, |
321 | path: path + suffix, | 321 | path: path + suffix, |
322 | token: server.accessToken, | 322 | token: server.accessToken, |
323 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 323 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
324 | }) | 324 | }) |
325 | } | 325 | } |
326 | 326 | ||
@@ -329,7 +329,7 @@ describe('Test server plugins API validators', function () { | |||
329 | url: server.url, | 329 | url: server.url, |
330 | path: path + suffix, | 330 | path: path + suffix, |
331 | token: server.accessToken, | 331 | token: server.accessToken, |
332 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 332 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
333 | }) | 333 | }) |
334 | } | 334 | } |
335 | }) | 335 | }) |
@@ -340,7 +340,7 @@ describe('Test server plugins API validators', function () { | |||
340 | url: server.url, | 340 | url: server.url, |
341 | path: path + suffix, | 341 | path: path + suffix, |
342 | token: server.accessToken, | 342 | token: server.accessToken, |
343 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 343 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
344 | }) | 344 | }) |
345 | } | 345 | } |
346 | }) | 346 | }) |
@@ -351,7 +351,7 @@ describe('Test server plugins API validators', function () { | |||
351 | url: server.url, | 351 | url: server.url, |
352 | path: path + suffix, | 352 | path: path + suffix, |
353 | token: server.accessToken, | 353 | token: server.accessToken, |
354 | statusCodeExpected: HttpStatusCode.OK_200 | 354 | expectedStatus: HttpStatusCode.OK_200 |
355 | }) | 355 | }) |
356 | } | 356 | } |
357 | }) | 357 | }) |
@@ -367,7 +367,7 @@ describe('Test server plugins API validators', function () { | |||
367 | path: path + npmPlugin + '/settings', | 367 | path: path + npmPlugin + '/settings', |
368 | fields: { settings }, | 368 | fields: { settings }, |
369 | token: 'fake_token', | 369 | token: 'fake_token', |
370 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 370 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
371 | }) | 371 | }) |
372 | }) | 372 | }) |
373 | 373 | ||
@@ -377,7 +377,7 @@ describe('Test server plugins API validators', function () { | |||
377 | path: path + npmPlugin + '/settings', | 377 | path: path + npmPlugin + '/settings', |
378 | fields: { settings }, | 378 | fields: { settings }, |
379 | token: userAccessToken, | 379 | token: userAccessToken, |
380 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 380 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
381 | }) | 381 | }) |
382 | }) | 382 | }) |
383 | 383 | ||
@@ -387,7 +387,7 @@ describe('Test server plugins API validators', function () { | |||
387 | path: path + 'toto/settings', | 387 | path: path + 'toto/settings', |
388 | fields: { settings }, | 388 | fields: { settings }, |
389 | token: server.accessToken, | 389 | token: server.accessToken, |
390 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 390 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
391 | }) | 391 | }) |
392 | 392 | ||
393 | await makePutBodyRequest({ | 393 | await makePutBodyRequest({ |
@@ -395,7 +395,7 @@ describe('Test server plugins API validators', function () { | |||
395 | path: path + 'peertube-plugin-TOTO/settings', | 395 | path: path + 'peertube-plugin-TOTO/settings', |
396 | fields: { settings }, | 396 | fields: { settings }, |
397 | token: server.accessToken, | 397 | token: server.accessToken, |
398 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 398 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
399 | }) | 399 | }) |
400 | }) | 400 | }) |
401 | 401 | ||
@@ -405,7 +405,7 @@ describe('Test server plugins API validators', function () { | |||
405 | path: path + 'peertube-plugin-toto/settings', | 405 | path: path + 'peertube-plugin-toto/settings', |
406 | fields: { settings }, | 406 | fields: { settings }, |
407 | token: server.accessToken, | 407 | token: server.accessToken, |
408 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 408 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
409 | }) | 409 | }) |
410 | }) | 410 | }) |
411 | 411 | ||
@@ -415,7 +415,7 @@ describe('Test server plugins API validators', function () { | |||
415 | path: path + npmPlugin + '/settings', | 415 | path: path + npmPlugin + '/settings', |
416 | fields: { settings }, | 416 | fields: { settings }, |
417 | token: server.accessToken, | 417 | token: server.accessToken, |
418 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 418 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
419 | }) | 419 | }) |
420 | }) | 420 | }) |
421 | }) | 421 | }) |
@@ -430,7 +430,7 @@ describe('Test server plugins API validators', function () { | |||
430 | path: path + suffix, | 430 | path: path + suffix, |
431 | fields: { npmName: npmPlugin }, | 431 | fields: { npmName: npmPlugin }, |
432 | token: 'fake_token', | 432 | token: 'fake_token', |
433 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 433 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
434 | }) | 434 | }) |
435 | } | 435 | } |
436 | }) | 436 | }) |
@@ -442,7 +442,7 @@ describe('Test server plugins API validators', function () { | |||
442 | path: path + suffix, | 442 | path: path + suffix, |
443 | fields: { npmName: npmPlugin }, | 443 | fields: { npmName: npmPlugin }, |
444 | token: userAccessToken, | 444 | token: userAccessToken, |
445 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 445 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
446 | }) | 446 | }) |
447 | } | 447 | } |
448 | }) | 448 | }) |
@@ -454,7 +454,7 @@ describe('Test server plugins API validators', function () { | |||
454 | path: path + suffix, | 454 | path: path + suffix, |
455 | fields: { npmName: 'toto' }, | 455 | fields: { npmName: 'toto' }, |
456 | token: server.accessToken, | 456 | token: server.accessToken, |
457 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 457 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
458 | }) | 458 | }) |
459 | } | 459 | } |
460 | 460 | ||
@@ -464,7 +464,7 @@ describe('Test server plugins API validators', function () { | |||
464 | path: path + suffix, | 464 | path: path + suffix, |
465 | fields: { npmName: 'peertube-plugin-TOTO' }, | 465 | fields: { npmName: 'peertube-plugin-TOTO' }, |
466 | token: server.accessToken, | 466 | token: server.accessToken, |
467 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 467 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
468 | }) | 468 | }) |
469 | } | 469 | } |
470 | }) | 470 | }) |
@@ -484,7 +484,7 @@ describe('Test server plugins API validators', function () { | |||
484 | path: path + obj.suffix, | 484 | path: path + obj.suffix, |
485 | fields: { npmName: npmPlugin }, | 485 | fields: { npmName: npmPlugin }, |
486 | token: server.accessToken, | 486 | token: server.accessToken, |
487 | statusCodeExpected: obj.status | 487 | expectedStatus: obj.status |
488 | }) | 488 | }) |
489 | } | 489 | } |
490 | }) | 490 | }) |
diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts index 18b98a0f9..d9f905549 100644 --- a/server/tests/api/check-params/redundancy.ts +++ b/server/tests/api/check-params/redundancy.ts | |||
@@ -1,15 +1,13 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { VideoCreateResult } from '@shared/models' | ||
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
6 | import { | 4 | import { |
7 | checkBadCountPagination, | 5 | checkBadCountPagination, |
8 | checkBadSortPagination, | 6 | checkBadSortPagination, |
9 | checkBadStartPagination, | 7 | checkBadStartPagination, |
10 | cleanupTests, | 8 | cleanupTests, |
11 | doubleFollow, | ||
12 | createMultipleServers, | 9 | createMultipleServers, |
10 | doubleFollow, | ||
13 | makeDeleteRequest, | 11 | makeDeleteRequest, |
14 | makeGetRequest, | 12 | makeGetRequest, |
15 | makePostBodyRequest, | 13 | makePostBodyRequest, |
@@ -17,7 +15,8 @@ import { | |||
17 | PeerTubeServer, | 15 | PeerTubeServer, |
18 | setAccessTokensToServers, | 16 | setAccessTokensToServers, |
19 | waitJobs | 17 | waitJobs |
20 | } from '../../../../shared/extra-utils' | 18 | } from '@shared/extra-utils' |
19 | import { HttpStatusCode, VideoCreateResult } from '@shared/models' | ||
21 | 20 | ||
22 | describe('Test server redundancy API validators', function () { | 21 | describe('Test server redundancy API validators', function () { |
23 | let servers: PeerTubeServer[] | 22 | let servers: PeerTubeServer[] |
@@ -64,11 +63,11 @@ describe('Test server redundancy API validators', function () { | |||
64 | }) | 63 | }) |
65 | 64 | ||
66 | it('Should fail with an invalid token', async function () { | 65 | it('Should fail with an invalid token', async function () { |
67 | await makeGetRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 66 | await makeGetRequest({ url, path, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
68 | }) | 67 | }) |
69 | 68 | ||
70 | it('Should fail if the user is not an administrator', async function () { | 69 | it('Should fail if the user is not an administrator', async function () { |
71 | await makeGetRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 70 | await makeGetRequest({ url, path, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
72 | }) | 71 | }) |
73 | 72 | ||
74 | it('Should fail with a bad start pagination', async function () { | 73 | it('Should fail with a bad start pagination', async function () { |
@@ -92,7 +91,7 @@ describe('Test server redundancy API validators', function () { | |||
92 | }) | 91 | }) |
93 | 92 | ||
94 | it('Should succeed with the correct params', async function () { | 93 | it('Should succeed with the correct params', async function () { |
95 | await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, statusCodeExpected: HttpStatusCode.OK_200 }) | 94 | await makeGetRequest({ url, path, token, query: { target: 'my-videos' }, expectedStatus: HttpStatusCode.OK_200 }) |
96 | }) | 95 | }) |
97 | }) | 96 | }) |
98 | 97 | ||
@@ -108,11 +107,11 @@ describe('Test server redundancy API validators', function () { | |||
108 | }) | 107 | }) |
109 | 108 | ||
110 | it('Should fail with an invalid token', async function () { | 109 | it('Should fail with an invalid token', async function () { |
111 | await makePostBodyRequest({ url, path, token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 110 | await makePostBodyRequest({ url, path, token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
112 | }) | 111 | }) |
113 | 112 | ||
114 | it('Should fail if the user is not an administrator', async function () { | 113 | it('Should fail if the user is not an administrator', async function () { |
115 | await makePostBodyRequest({ url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 114 | await makePostBodyRequest({ url, path, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
116 | }) | 115 | }) |
117 | 116 | ||
118 | it('Should fail without a video id', async function () { | 117 | it('Should fail without a video id', async function () { |
@@ -124,7 +123,7 @@ describe('Test server redundancy API validators', function () { | |||
124 | }) | 123 | }) |
125 | 124 | ||
126 | it('Should fail with a not found video id', async function () { | 125 | it('Should fail with a not found video id', async function () { |
127 | await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) | 126 | await makePostBodyRequest({ url, path, token, fields: { videoId: 6565 }, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
128 | }) | 127 | }) |
129 | 128 | ||
130 | it('Should fail with a local a video id', async function () { | 129 | it('Should fail with a local a video id', async function () { |
@@ -137,7 +136,7 @@ describe('Test server redundancy API validators', function () { | |||
137 | path, | 136 | path, |
138 | token, | 137 | token, |
139 | fields: { videoId: videoRemote.shortUUID }, | 138 | fields: { videoId: videoRemote.shortUUID }, |
140 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 139 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
141 | }) | 140 | }) |
142 | }) | 141 | }) |
143 | 142 | ||
@@ -151,7 +150,7 @@ describe('Test server redundancy API validators', function () { | |||
151 | path, | 150 | path, |
152 | token, | 151 | token, |
153 | fields: { videoId: videoRemote.uuid }, | 152 | fields: { videoId: videoRemote.uuid }, |
154 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 153 | expectedStatus: HttpStatusCode.CONFLICT_409 |
155 | }) | 154 | }) |
156 | }) | 155 | }) |
157 | }) | 156 | }) |
@@ -168,11 +167,11 @@ describe('Test server redundancy API validators', function () { | |||
168 | }) | 167 | }) |
169 | 168 | ||
170 | it('Should fail with an invalid token', async function () { | 169 | it('Should fail with an invalid token', async function () { |
171 | await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 170 | await makeDeleteRequest({ url, path: path + '1', token: 'fake_token', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
172 | }) | 171 | }) |
173 | 172 | ||
174 | it('Should fail if the user is not an administrator', async function () { | 173 | it('Should fail if the user is not an administrator', async function () { |
175 | await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 174 | await makeDeleteRequest({ url, path: path + '1', token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
176 | }) | 175 | }) |
177 | 176 | ||
178 | it('Should fail with an incorrect video id', async function () { | 177 | it('Should fail with an incorrect video id', async function () { |
@@ -180,7 +179,7 @@ describe('Test server redundancy API validators', function () { | |||
180 | }) | 179 | }) |
181 | 180 | ||
182 | it('Should fail with a not found video redundancy', async function () { | 181 | it('Should fail with a not found video redundancy', async function () { |
183 | await makeDeleteRequest({ url, path: path + '454545', token, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) | 182 | await makeDeleteRequest({ url, path: path + '454545', token, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
184 | }) | 183 | }) |
185 | }) | 184 | }) |
186 | 185 | ||
@@ -193,7 +192,7 @@ describe('Test server redundancy API validators', function () { | |||
193 | path: path + '/localhost:' + servers[1].port, | 192 | path: path + '/localhost:' + servers[1].port, |
194 | fields: { redundancyAllowed: true }, | 193 | fields: { redundancyAllowed: true }, |
195 | token: 'fake_token', | 194 | token: 'fake_token', |
196 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 195 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
197 | }) | 196 | }) |
198 | }) | 197 | }) |
199 | 198 | ||
@@ -203,7 +202,7 @@ describe('Test server redundancy API validators', function () { | |||
203 | path: path + '/localhost:' + servers[1].port, | 202 | path: path + '/localhost:' + servers[1].port, |
204 | fields: { redundancyAllowed: true }, | 203 | fields: { redundancyAllowed: true }, |
205 | token: userAccessToken, | 204 | token: userAccessToken, |
206 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 205 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
207 | }) | 206 | }) |
208 | }) | 207 | }) |
209 | 208 | ||
@@ -213,7 +212,7 @@ describe('Test server redundancy API validators', function () { | |||
213 | path: path + '/example.com', | 212 | path: path + '/example.com', |
214 | fields: { redundancyAllowed: true }, | 213 | fields: { redundancyAllowed: true }, |
215 | token: servers[0].accessToken, | 214 | token: servers[0].accessToken, |
216 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 215 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
217 | }) | 216 | }) |
218 | }) | 217 | }) |
219 | 218 | ||
@@ -223,7 +222,7 @@ describe('Test server redundancy API validators', function () { | |||
223 | path: path + '/localhost:' + servers[1].port, | 222 | path: path + '/localhost:' + servers[1].port, |
224 | fields: { blabla: true }, | 223 | fields: { blabla: true }, |
225 | token: servers[0].accessToken, | 224 | token: servers[0].accessToken, |
226 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 225 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
227 | }) | 226 | }) |
228 | }) | 227 | }) |
229 | 228 | ||
@@ -233,7 +232,7 @@ describe('Test server redundancy API validators', function () { | |||
233 | path: path + '/localhost:' + servers[1].port, | 232 | path: path + '/localhost:' + servers[1].port, |
234 | fields: { redundancyAllowed: true }, | 233 | fields: { redundancyAllowed: true }, |
235 | token: servers[0].accessToken, | 234 | token: servers[0].accessToken, |
236 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 235 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
237 | }) | 236 | }) |
238 | }) | 237 | }) |
239 | }) | 238 | }) |
diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts index 43cd81af9..b49169e38 100644 --- a/server/tests/api/check-params/search.ts +++ b/server/tests/api/check-params/search.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 5 | import { |
6 | checkBadCountPagination, | 6 | checkBadCountPagination, |
7 | checkBadSortPagination, | 7 | checkBadSortPagination, |
@@ -58,83 +58,83 @@ describe('Test videos API validator', function () { | |||
58 | }) | 58 | }) |
59 | 59 | ||
60 | it('Should success with the correct parameters', async function () { | 60 | it('Should success with the correct parameters', async function () { |
61 | await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) | 61 | await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 }) |
62 | }) | 62 | }) |
63 | 63 | ||
64 | it('Should fail with an invalid category', async function () { | 64 | it('Should fail with an invalid category', async function () { |
65 | const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] } | 65 | const customQuery1 = { ...query, categoryOneOf: [ 'aa', 'b' ] } |
66 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 66 | await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
67 | 67 | ||
68 | const customQuery2 = { ...query, categoryOneOf: 'a' } | 68 | const customQuery2 = { ...query, categoryOneOf: 'a' } |
69 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 69 | await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
70 | }) | 70 | }) |
71 | 71 | ||
72 | it('Should succeed with a valid category', async function () { | 72 | it('Should succeed with a valid category', async function () { |
73 | const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] } | 73 | const customQuery1 = { ...query, categoryOneOf: [ 1, 7 ] } |
74 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) | 74 | await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 }) |
75 | 75 | ||
76 | const customQuery2 = { ...query, categoryOneOf: 1 } | 76 | const customQuery2 = { ...query, categoryOneOf: 1 } |
77 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) | 77 | await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 }) |
78 | }) | 78 | }) |
79 | 79 | ||
80 | it('Should fail with an invalid licence', async function () { | 80 | it('Should fail with an invalid licence', async function () { |
81 | const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] } | 81 | const customQuery1 = { ...query, licenceOneOf: [ 'aa', 'b' ] } |
82 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 82 | await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
83 | 83 | ||
84 | const customQuery2 = { ...query, licenceOneOf: 'a' } | 84 | const customQuery2 = { ...query, licenceOneOf: 'a' } |
85 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 85 | await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
86 | }) | 86 | }) |
87 | 87 | ||
88 | it('Should succeed with a valid licence', async function () { | 88 | it('Should succeed with a valid licence', async function () { |
89 | const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] } | 89 | const customQuery1 = { ...query, licenceOneOf: [ 1, 2 ] } |
90 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) | 90 | await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 }) |
91 | 91 | ||
92 | const customQuery2 = { ...query, licenceOneOf: 1 } | 92 | const customQuery2 = { ...query, licenceOneOf: 1 } |
93 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) | 93 | await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 }) |
94 | }) | 94 | }) |
95 | 95 | ||
96 | it('Should succeed with a valid language', async function () { | 96 | it('Should succeed with a valid language', async function () { |
97 | const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] } | 97 | const customQuery1 = { ...query, languageOneOf: [ 'fr', 'en' ] } |
98 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) | 98 | await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 }) |
99 | 99 | ||
100 | const customQuery2 = { ...query, languageOneOf: 'fr' } | 100 | const customQuery2 = { ...query, languageOneOf: 'fr' } |
101 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) | 101 | await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 }) |
102 | }) | 102 | }) |
103 | 103 | ||
104 | it('Should succeed with valid tags', async function () { | 104 | it('Should succeed with valid tags', async function () { |
105 | const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] } | 105 | const customQuery1 = { ...query, tagsOneOf: [ 'tag1', 'tag2' ] } |
106 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.OK_200 }) | 106 | await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.OK_200 }) |
107 | 107 | ||
108 | const customQuery2 = { ...query, tagsOneOf: 'tag1' } | 108 | const customQuery2 = { ...query, tagsOneOf: 'tag1' } |
109 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.OK_200 }) | 109 | await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.OK_200 }) |
110 | 110 | ||
111 | const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] } | 111 | const customQuery3 = { ...query, tagsAllOf: [ 'tag1', 'tag2' ] } |
112 | await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.OK_200 }) | 112 | await makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: HttpStatusCode.OK_200 }) |
113 | 113 | ||
114 | const customQuery4 = { ...query, tagsAllOf: 'tag1' } | 114 | const customQuery4 = { ...query, tagsAllOf: 'tag1' } |
115 | await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.OK_200 }) | 115 | await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.OK_200 }) |
116 | }) | 116 | }) |
117 | 117 | ||
118 | it('Should fail with invalid durations', async function () { | 118 | it('Should fail with invalid durations', async function () { |
119 | const customQuery1 = { ...query, durationMin: 'hello' } | 119 | const customQuery1 = { ...query, durationMin: 'hello' } |
120 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 120 | await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
121 | 121 | ||
122 | const customQuery2 = { ...query, durationMax: 'hello' } | 122 | const customQuery2 = { ...query, durationMax: 'hello' } |
123 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 123 | await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
124 | }) | 124 | }) |
125 | 125 | ||
126 | it('Should fail with invalid dates', async function () { | 126 | it('Should fail with invalid dates', async function () { |
127 | const customQuery1 = { ...query, startDate: 'hello' } | 127 | const customQuery1 = { ...query, startDate: 'hello' } |
128 | await makeGetRequest({ url: server.url, path, query: customQuery1, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 128 | await makeGetRequest({ url: server.url, path, query: customQuery1, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
129 | 129 | ||
130 | const customQuery2 = { ...query, endDate: 'hello' } | 130 | const customQuery2 = { ...query, endDate: 'hello' } |
131 | await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 131 | await makeGetRequest({ url: server.url, path, query: customQuery2, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
132 | 132 | ||
133 | const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' } | 133 | const customQuery3 = { ...query, originallyPublishedStartDate: 'hello' } |
134 | await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 134 | await makeGetRequest({ url: server.url, path, query: customQuery3, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
135 | 135 | ||
136 | const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' } | 136 | const customQuery4 = { ...query, originallyPublishedEndDate: 'hello' } |
137 | await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 137 | await makeGetRequest({ url: server.url, path, query: customQuery4, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
138 | }) | 138 | }) |
139 | }) | 139 | }) |
140 | 140 | ||
@@ -158,7 +158,7 @@ describe('Test videos API validator', function () { | |||
158 | }) | 158 | }) |
159 | 159 | ||
160 | it('Should success with the correct parameters', async function () { | 160 | it('Should success with the correct parameters', async function () { |
161 | await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) | 161 | await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 }) |
162 | }) | 162 | }) |
163 | }) | 163 | }) |
164 | 164 | ||
@@ -182,7 +182,7 @@ describe('Test videos API validator', function () { | |||
182 | }) | 182 | }) |
183 | 183 | ||
184 | it('Should success with the correct parameters', async function () { | 184 | it('Should success with the correct parameters', async function () { |
185 | await makeGetRequest({ url: server.url, path, query, statusCodeExpected: HttpStatusCode.OK_200 }) | 185 | await makeGetRequest({ url: server.url, path, query, expectedStatus: HttpStatusCode.OK_200 }) |
186 | }) | 186 | }) |
187 | }) | 187 | }) |
188 | 188 | ||
@@ -201,41 +201,41 @@ describe('Test videos API validator', function () { | |||
201 | for (const path of paths) { | 201 | for (const path of paths) { |
202 | { | 202 | { |
203 | const customQuery = { ...query, searchTarget: 'hello' } | 203 | const customQuery = { ...query, searchTarget: 'hello' } |
204 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 204 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
205 | } | 205 | } |
206 | 206 | ||
207 | { | 207 | { |
208 | const customQuery = { ...query, searchTarget: undefined } | 208 | const customQuery = { ...query, searchTarget: undefined } |
209 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) | 209 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 }) |
210 | } | 210 | } |
211 | 211 | ||
212 | { | 212 | { |
213 | const customQuery = { ...query, searchTarget: 'local' } | 213 | const customQuery = { ...query, searchTarget: 'local' } |
214 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) | 214 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 }) |
215 | } | 215 | } |
216 | 216 | ||
217 | { | 217 | { |
218 | const customQuery = { ...query, searchTarget: 'search-index' } | 218 | const customQuery = { ...query, searchTarget: 'search-index' } |
219 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 219 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
220 | } | 220 | } |
221 | 221 | ||
222 | await updateSearchIndex(server, true, true) | 222 | await updateSearchIndex(server, true, true) |
223 | 223 | ||
224 | { | 224 | { |
225 | const customQuery = { ...query, searchTarget: 'local' } | 225 | const customQuery = { ...query, searchTarget: 'local' } |
226 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 }) | 226 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
227 | } | 227 | } |
228 | 228 | ||
229 | { | 229 | { |
230 | const customQuery = { ...query, searchTarget: 'search-index' } | 230 | const customQuery = { ...query, searchTarget: 'search-index' } |
231 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) | 231 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 }) |
232 | } | 232 | } |
233 | 233 | ||
234 | await updateSearchIndex(server, true, false) | 234 | await updateSearchIndex(server, true, false) |
235 | 235 | ||
236 | { | 236 | { |
237 | const customQuery = { ...query, searchTarget: 'local' } | 237 | const customQuery = { ...query, searchTarget: 'local' } |
238 | await makeGetRequest({ url: server.url, path, query: customQuery, statusCodeExpected: HttpStatusCode.OK_200 }) | 238 | await makeGetRequest({ url: server.url, path, query: customQuery, expectedStatus: HttpStatusCode.OK_200 }) |
239 | } | 239 | } |
240 | 240 | ||
241 | await updateSearchIndex(server, false, false) | 241 | await updateSearchIndex(server, false, false) |
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts index c623240b7..973b25598 100644 --- a/server/tests/api/check-params/services.ts +++ b/server/tests/api/check-params/services.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 5 | import { |
6 | cleanupTests, | 6 | cleanupTests, |
7 | createSingleServer, | 7 | createSingleServer, |
@@ -120,13 +120,13 @@ describe('Test services API validators', function () { | |||
120 | }) | 120 | }) |
121 | }) | 121 | }) |
122 | 122 | ||
123 | function checkParamEmbed (server: PeerTubeServer, embedUrl: string, statusCodeExpected = HttpStatusCode.BAD_REQUEST_400, query = {}) { | 123 | function checkParamEmbed (server: PeerTubeServer, embedUrl: string, expectedStatus = HttpStatusCode.BAD_REQUEST_400, query = {}) { |
124 | const path = '/services/oembed' | 124 | const path = '/services/oembed' |
125 | 125 | ||
126 | return makeGetRequest({ | 126 | return makeGetRequest({ |
127 | url: server.url, | 127 | url: server.url, |
128 | path, | 128 | path, |
129 | query: Object.assign(query, { url: embedUrl }), | 129 | query: Object.assign(query, { url: embedUrl }), |
130 | statusCodeExpected | 130 | expectedStatus |
131 | }) | 131 | }) |
132 | } | 132 | } |
diff --git a/server/tests/api/check-params/upload-quota.ts b/server/tests/api/check-params/upload-quota.ts index bd8dce975..322e93d0d 100644 --- a/server/tests/api/check-params/upload-quota.ts +++ b/server/tests/api/check-params/upload-quota.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode, randomInt } from '@shared/core-utils' | 5 | import { randomInt } from '@shared/core-utils' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
@@ -13,7 +13,7 @@ import { | |||
13 | VideosCommand, | 13 | VideosCommand, |
14 | waitJobs | 14 | waitJobs |
15 | } from '@shared/extra-utils' | 15 | } from '@shared/extra-utils' |
16 | import { VideoImportState, VideoPrivacy } from '@shared/models' | 16 | import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models' |
17 | 17 | ||
18 | describe('Test upload quota', function () { | 18 | describe('Test upload quota', function () { |
19 | let server: PeerTubeServer | 19 | let server: PeerTubeServer |
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts index 038c444b3..3b709ee5a 100644 --- a/server/tests/api/check-params/user-notifications.ts +++ b/server/tests/api/check-params/user-notifications.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { io } from 'socket.io-client' | 4 | import { io } from 'socket.io-client' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | checkBadCountPagination, | 7 | checkBadCountPagination, |
8 | checkBadSortPagination, | 8 | checkBadSortPagination, |
@@ -54,7 +54,7 @@ describe('Test user notifications API validators', function () { | |||
54 | unread: 'toto' | 54 | unread: 'toto' |
55 | }, | 55 | }, |
56 | token: server.accessToken, | 56 | token: server.accessToken, |
57 | statusCodeExpected: HttpStatusCode.OK_200 | 57 | expectedStatus: HttpStatusCode.OK_200 |
58 | }) | 58 | }) |
59 | }) | 59 | }) |
60 | 60 | ||
@@ -62,7 +62,7 @@ describe('Test user notifications API validators', function () { | |||
62 | await makeGetRequest({ | 62 | await makeGetRequest({ |
63 | url: server.url, | 63 | url: server.url, |
64 | path, | 64 | path, |
65 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 65 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
66 | }) | 66 | }) |
67 | }) | 67 | }) |
68 | 68 | ||
@@ -71,7 +71,7 @@ describe('Test user notifications API validators', function () { | |||
71 | url: server.url, | 71 | url: server.url, |
72 | path, | 72 | path, |
73 | token: server.accessToken, | 73 | token: server.accessToken, |
74 | statusCodeExpected: HttpStatusCode.OK_200 | 74 | expectedStatus: HttpStatusCode.OK_200 |
75 | }) | 75 | }) |
76 | }) | 76 | }) |
77 | }) | 77 | }) |
@@ -87,7 +87,7 @@ describe('Test user notifications API validators', function () { | |||
87 | ids: [ 'hello' ] | 87 | ids: [ 'hello' ] |
88 | }, | 88 | }, |
89 | token: server.accessToken, | 89 | token: server.accessToken, |
90 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 90 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
91 | }) | 91 | }) |
92 | 92 | ||
93 | await makePostBodyRequest({ | 93 | await makePostBodyRequest({ |
@@ -97,7 +97,7 @@ describe('Test user notifications API validators', function () { | |||
97 | ids: [ ] | 97 | ids: [ ] |
98 | }, | 98 | }, |
99 | token: server.accessToken, | 99 | token: server.accessToken, |
100 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 100 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
101 | }) | 101 | }) |
102 | 102 | ||
103 | await makePostBodyRequest({ | 103 | await makePostBodyRequest({ |
@@ -107,7 +107,7 @@ describe('Test user notifications API validators', function () { | |||
107 | ids: 5 | 107 | ids: 5 |
108 | }, | 108 | }, |
109 | token: server.accessToken, | 109 | token: server.accessToken, |
110 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 110 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
111 | }) | 111 | }) |
112 | }) | 112 | }) |
113 | 113 | ||
@@ -118,7 +118,7 @@ describe('Test user notifications API validators', function () { | |||
118 | fields: { | 118 | fields: { |
119 | ids: [ 5 ] | 119 | ids: [ 5 ] |
120 | }, | 120 | }, |
121 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 121 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
122 | }) | 122 | }) |
123 | }) | 123 | }) |
124 | 124 | ||
@@ -130,7 +130,7 @@ describe('Test user notifications API validators', function () { | |||
130 | ids: [ 5 ] | 130 | ids: [ 5 ] |
131 | }, | 131 | }, |
132 | token: server.accessToken, | 132 | token: server.accessToken, |
133 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 133 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
134 | }) | 134 | }) |
135 | }) | 135 | }) |
136 | }) | 136 | }) |
@@ -142,7 +142,7 @@ describe('Test user notifications API validators', function () { | |||
142 | await makePostBodyRequest({ | 142 | await makePostBodyRequest({ |
143 | url: server.url, | 143 | url: server.url, |
144 | path, | 144 | path, |
145 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 145 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
146 | }) | 146 | }) |
147 | }) | 147 | }) |
148 | 148 | ||
@@ -151,7 +151,7 @@ describe('Test user notifications API validators', function () { | |||
151 | url: server.url, | 151 | url: server.url, |
152 | path, | 152 | path, |
153 | token: server.accessToken, | 153 | token: server.accessToken, |
154 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 154 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
155 | }) | 155 | }) |
156 | }) | 156 | }) |
157 | }) | 157 | }) |
@@ -183,7 +183,7 @@ describe('Test user notifications API validators', function () { | |||
183 | path, | 183 | path, |
184 | token: server.accessToken, | 184 | token: server.accessToken, |
185 | fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB }, | 185 | fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB }, |
186 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 186 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
187 | }) | 187 | }) |
188 | }) | 188 | }) |
189 | 189 | ||
@@ -196,7 +196,7 @@ describe('Test user notifications API validators', function () { | |||
196 | path, | 196 | path, |
197 | token: server.accessToken, | 197 | token: server.accessToken, |
198 | fields, | 198 | fields, |
199 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 199 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
200 | }) | 200 | }) |
201 | } | 201 | } |
202 | 202 | ||
@@ -208,7 +208,7 @@ describe('Test user notifications API validators', function () { | |||
208 | path, | 208 | path, |
209 | fields, | 209 | fields, |
210 | token: server.accessToken, | 210 | token: server.accessToken, |
211 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 211 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
212 | }) | 212 | }) |
213 | } | 213 | } |
214 | }) | 214 | }) |
@@ -218,7 +218,7 @@ describe('Test user notifications API validators', function () { | |||
218 | url: server.url, | 218 | url: server.url, |
219 | path, | 219 | path, |
220 | fields: correctFields, | 220 | fields: correctFields, |
221 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 221 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
222 | }) | 222 | }) |
223 | }) | 223 | }) |
224 | 224 | ||
@@ -228,7 +228,7 @@ describe('Test user notifications API validators', function () { | |||
228 | path, | 228 | path, |
229 | token: server.accessToken, | 229 | token: server.accessToken, |
230 | fields: correctFields, | 230 | fields: correctFields, |
231 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 231 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
232 | }) | 232 | }) |
233 | }) | 233 | }) |
234 | }) | 234 | }) |
diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts index 22cf130c2..624069c80 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/server/tests/api/check-params/user-subscriptions.ts | |||
@@ -1,24 +1,20 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | |||
5 | import { | 4 | import { |
5 | checkBadCountPagination, | ||
6 | checkBadSortPagination, | ||
7 | checkBadStartPagination, | ||
6 | cleanupTests, | 8 | cleanupTests, |
7 | createSingleServer, | 9 | createSingleServer, |
8 | makeDeleteRequest, | 10 | makeDeleteRequest, |
9 | makeGetRequest, | 11 | makeGetRequest, |
10 | makePostBodyRequest, | 12 | makePostBodyRequest, |
11 | PeerTubeServer, | 13 | PeerTubeServer, |
12 | setAccessTokensToServers | 14 | setAccessTokensToServers, |
13 | } from '../../../../shared/extra-utils' | 15 | waitJobs |
14 | 16 | } from '@shared/extra-utils' | |
15 | import { | 17 | import { HttpStatusCode } from '@shared/models' |
16 | checkBadCountPagination, | ||
17 | checkBadSortPagination, | ||
18 | checkBadStartPagination | ||
19 | } from '../../../../shared/extra-utils/requests/check-api-params' | ||
20 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | ||
21 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
22 | 18 | ||
23 | describe('Test user subscriptions API validators', function () { | 19 | describe('Test user subscriptions API validators', function () { |
24 | const path = '/api/v1/users/me/subscriptions' | 20 | const path = '/api/v1/users/me/subscriptions' |
@@ -59,7 +55,7 @@ describe('Test user subscriptions API validators', function () { | |||
59 | await makeGetRequest({ | 55 | await makeGetRequest({ |
60 | url: server.url, | 56 | url: server.url, |
61 | path, | 57 | path, |
62 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 58 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
63 | }) | 59 | }) |
64 | }) | 60 | }) |
65 | 61 | ||
@@ -68,7 +64,7 @@ describe('Test user subscriptions API validators', function () { | |||
68 | url: server.url, | 64 | url: server.url, |
69 | path, | 65 | path, |
70 | token: userAccessToken, | 66 | token: userAccessToken, |
71 | statusCodeExpected: HttpStatusCode.OK_200 | 67 | expectedStatus: HttpStatusCode.OK_200 |
72 | }) | 68 | }) |
73 | }) | 69 | }) |
74 | }) | 70 | }) |
@@ -92,7 +88,7 @@ describe('Test user subscriptions API validators', function () { | |||
92 | await makeGetRequest({ | 88 | await makeGetRequest({ |
93 | url: server.url, | 89 | url: server.url, |
94 | path, | 90 | path, |
95 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 91 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
96 | }) | 92 | }) |
97 | }) | 93 | }) |
98 | 94 | ||
@@ -101,7 +97,7 @@ describe('Test user subscriptions API validators', function () { | |||
101 | url: server.url, | 97 | url: server.url, |
102 | path, | 98 | path, |
103 | token: userAccessToken, | 99 | token: userAccessToken, |
104 | statusCodeExpected: HttpStatusCode.OK_200 | 100 | expectedStatus: HttpStatusCode.OK_200 |
105 | }) | 101 | }) |
106 | }) | 102 | }) |
107 | }) | 103 | }) |
@@ -112,7 +108,7 @@ describe('Test user subscriptions API validators', function () { | |||
112 | url: server.url, | 108 | url: server.url, |
113 | path, | 109 | path, |
114 | fields: { uri: 'user1_channel@localhost:' + server.port }, | 110 | fields: { uri: 'user1_channel@localhost:' + server.port }, |
115 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 111 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
116 | }) | 112 | }) |
117 | }) | 113 | }) |
118 | 114 | ||
@@ -122,7 +118,7 @@ describe('Test user subscriptions API validators', function () { | |||
122 | path, | 118 | path, |
123 | token: server.accessToken, | 119 | token: server.accessToken, |
124 | fields: { uri: 'root' }, | 120 | fields: { uri: 'root' }, |
125 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 121 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
126 | }) | 122 | }) |
127 | 123 | ||
128 | await makePostBodyRequest({ | 124 | await makePostBodyRequest({ |
@@ -130,7 +126,7 @@ describe('Test user subscriptions API validators', function () { | |||
130 | path, | 126 | path, |
131 | token: server.accessToken, | 127 | token: server.accessToken, |
132 | fields: { uri: 'root@' }, | 128 | fields: { uri: 'root@' }, |
133 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 129 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
134 | }) | 130 | }) |
135 | 131 | ||
136 | await makePostBodyRequest({ | 132 | await makePostBodyRequest({ |
@@ -138,7 +134,7 @@ describe('Test user subscriptions API validators', function () { | |||
138 | path, | 134 | path, |
139 | token: server.accessToken, | 135 | token: server.accessToken, |
140 | fields: { uri: 'root@hello@' }, | 136 | fields: { uri: 'root@hello@' }, |
141 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 137 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
142 | }) | 138 | }) |
143 | }) | 139 | }) |
144 | 140 | ||
@@ -150,7 +146,7 @@ describe('Test user subscriptions API validators', function () { | |||
150 | path, | 146 | path, |
151 | token: server.accessToken, | 147 | token: server.accessToken, |
152 | fields: { uri: 'user1_channel@localhost:' + server.port }, | 148 | fields: { uri: 'user1_channel@localhost:' + server.port }, |
153 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 149 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
154 | }) | 150 | }) |
155 | 151 | ||
156 | await waitJobs([ server ]) | 152 | await waitJobs([ server ]) |
@@ -162,7 +158,7 @@ describe('Test user subscriptions API validators', function () { | |||
162 | await makeGetRequest({ | 158 | await makeGetRequest({ |
163 | url: server.url, | 159 | url: server.url, |
164 | path: path + '/user1_channel@localhost:' + server.port, | 160 | path: path + '/user1_channel@localhost:' + server.port, |
165 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 161 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
166 | }) | 162 | }) |
167 | }) | 163 | }) |
168 | 164 | ||
@@ -171,21 +167,21 @@ describe('Test user subscriptions API validators', function () { | |||
171 | url: server.url, | 167 | url: server.url, |
172 | path: path + '/root', | 168 | path: path + '/root', |
173 | token: server.accessToken, | 169 | token: server.accessToken, |
174 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 170 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
175 | }) | 171 | }) |
176 | 172 | ||
177 | await makeGetRequest({ | 173 | await makeGetRequest({ |
178 | url: server.url, | 174 | url: server.url, |
179 | path: path + '/root@', | 175 | path: path + '/root@', |
180 | token: server.accessToken, | 176 | token: server.accessToken, |
181 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 177 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
182 | }) | 178 | }) |
183 | 179 | ||
184 | await makeGetRequest({ | 180 | await makeGetRequest({ |
185 | url: server.url, | 181 | url: server.url, |
186 | path: path + '/root@hello@', | 182 | path: path + '/root@hello@', |
187 | token: server.accessToken, | 183 | token: server.accessToken, |
188 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 184 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
189 | }) | 185 | }) |
190 | }) | 186 | }) |
191 | 187 | ||
@@ -194,7 +190,7 @@ describe('Test user subscriptions API validators', function () { | |||
194 | url: server.url, | 190 | url: server.url, |
195 | path: path + '/root1@localhost:' + server.port, | 191 | path: path + '/root1@localhost:' + server.port, |
196 | token: server.accessToken, | 192 | token: server.accessToken, |
197 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 193 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
198 | }) | 194 | }) |
199 | }) | 195 | }) |
200 | 196 | ||
@@ -203,7 +199,7 @@ describe('Test user subscriptions API validators', function () { | |||
203 | url: server.url, | 199 | url: server.url, |
204 | path: path + '/user1_channel@localhost:' + server.port, | 200 | path: path + '/user1_channel@localhost:' + server.port, |
205 | token: server.accessToken, | 201 | token: server.accessToken, |
206 | statusCodeExpected: HttpStatusCode.OK_200 | 202 | expectedStatus: HttpStatusCode.OK_200 |
207 | }) | 203 | }) |
208 | }) | 204 | }) |
209 | }) | 205 | }) |
@@ -215,7 +211,7 @@ describe('Test user subscriptions API validators', function () { | |||
215 | await makeGetRequest({ | 211 | await makeGetRequest({ |
216 | url: server.url, | 212 | url: server.url, |
217 | path: existPath, | 213 | path: existPath, |
218 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 214 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
219 | }) | 215 | }) |
220 | }) | 216 | }) |
221 | 217 | ||
@@ -225,7 +221,7 @@ describe('Test user subscriptions API validators', function () { | |||
225 | path: existPath, | 221 | path: existPath, |
226 | query: { uris: 'toto' }, | 222 | query: { uris: 'toto' }, |
227 | token: server.accessToken, | 223 | token: server.accessToken, |
228 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 224 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
229 | }) | 225 | }) |
230 | 226 | ||
231 | await makeGetRequest({ | 227 | await makeGetRequest({ |
@@ -233,7 +229,7 @@ describe('Test user subscriptions API validators', function () { | |||
233 | path: existPath, | 229 | path: existPath, |
234 | query: { 'uris[]': 1 }, | 230 | query: { 'uris[]': 1 }, |
235 | token: server.accessToken, | 231 | token: server.accessToken, |
236 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 232 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
237 | }) | 233 | }) |
238 | }) | 234 | }) |
239 | 235 | ||
@@ -243,7 +239,7 @@ describe('Test user subscriptions API validators', function () { | |||
243 | path: existPath, | 239 | path: existPath, |
244 | query: { 'uris[]': 'coucou@localhost:' + server.port }, | 240 | query: { 'uris[]': 'coucou@localhost:' + server.port }, |
245 | token: server.accessToken, | 241 | token: server.accessToken, |
246 | statusCodeExpected: HttpStatusCode.OK_200 | 242 | expectedStatus: HttpStatusCode.OK_200 |
247 | }) | 243 | }) |
248 | }) | 244 | }) |
249 | }) | 245 | }) |
@@ -253,7 +249,7 @@ describe('Test user subscriptions API validators', function () { | |||
253 | await makeDeleteRequest({ | 249 | await makeDeleteRequest({ |
254 | url: server.url, | 250 | url: server.url, |
255 | path: path + '/user1_channel@localhost:' + server.port, | 251 | path: path + '/user1_channel@localhost:' + server.port, |
256 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 252 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
257 | }) | 253 | }) |
258 | }) | 254 | }) |
259 | 255 | ||
@@ -262,21 +258,21 @@ describe('Test user subscriptions API validators', function () { | |||
262 | url: server.url, | 258 | url: server.url, |
263 | path: path + '/root', | 259 | path: path + '/root', |
264 | token: server.accessToken, | 260 | token: server.accessToken, |
265 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 261 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
266 | }) | 262 | }) |
267 | 263 | ||
268 | await makeDeleteRequest({ | 264 | await makeDeleteRequest({ |
269 | url: server.url, | 265 | url: server.url, |
270 | path: path + '/root@', | 266 | path: path + '/root@', |
271 | token: server.accessToken, | 267 | token: server.accessToken, |
272 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 268 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
273 | }) | 269 | }) |
274 | 270 | ||
275 | await makeDeleteRequest({ | 271 | await makeDeleteRequest({ |
276 | url: server.url, | 272 | url: server.url, |
277 | path: path + '/root@hello@', | 273 | path: path + '/root@hello@', |
278 | token: server.accessToken, | 274 | token: server.accessToken, |
279 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 275 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
280 | }) | 276 | }) |
281 | }) | 277 | }) |
282 | 278 | ||
@@ -285,7 +281,7 @@ describe('Test user subscriptions API validators', function () { | |||
285 | url: server.url, | 281 | url: server.url, |
286 | path: path + '/root1@localhost:' + server.port, | 282 | path: path + '/root1@localhost:' + server.port, |
287 | token: server.accessToken, | 283 | token: server.accessToken, |
288 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 284 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
289 | }) | 285 | }) |
290 | }) | 286 | }) |
291 | 287 | ||
@@ -294,7 +290,7 @@ describe('Test user subscriptions API validators', function () { | |||
294 | url: server.url, | 290 | url: server.url, |
295 | path: path + '/user1_channel@localhost:' + server.port, | 291 | path: path + '/user1_channel@localhost:' + server.port, |
296 | token: server.accessToken, | 292 | token: server.accessToken, |
297 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 293 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
298 | }) | 294 | }) |
299 | }) | 295 | }) |
300 | }) | 296 | }) |
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index c2c98f429..34fe309f9 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | buildAbsoluteFixturePath, | 7 | buildAbsoluteFixturePath, |
8 | checkBadCountPagination, | 8 | checkBadCountPagination, |
@@ -103,7 +103,7 @@ describe('Test users API validators', function () { | |||
103 | await makeGetRequest({ | 103 | await makeGetRequest({ |
104 | url: server.url, | 104 | url: server.url, |
105 | path, | 105 | path, |
106 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 106 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
107 | }) | 107 | }) |
108 | }) | 108 | }) |
109 | 109 | ||
@@ -112,7 +112,7 @@ describe('Test users API validators', function () { | |||
112 | url: server.url, | 112 | url: server.url, |
113 | path, | 113 | path, |
114 | token: userToken, | 114 | token: userToken, |
115 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 115 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
116 | }) | 116 | }) |
117 | }) | 117 | }) |
118 | }) | 118 | }) |
@@ -210,7 +210,7 @@ describe('Test users API validators', function () { | |||
210 | path: path, | 210 | path: path, |
211 | token: server.accessToken, | 211 | token: server.accessToken, |
212 | fields, | 212 | fields, |
213 | statusCodeExpected: HttpStatusCode.OK_200 | 213 | expectedStatus: HttpStatusCode.OK_200 |
214 | }) | 214 | }) |
215 | }) | 215 | }) |
216 | 216 | ||
@@ -226,7 +226,7 @@ describe('Test users API validators', function () { | |||
226 | path, | 226 | path, |
227 | token: 'super token', | 227 | token: 'super token', |
228 | fields: baseCorrectParams, | 228 | fields: baseCorrectParams, |
229 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 229 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
230 | }) | 230 | }) |
231 | }) | 231 | }) |
232 | 232 | ||
@@ -238,7 +238,7 @@ describe('Test users API validators', function () { | |||
238 | path, | 238 | path, |
239 | token: server.accessToken, | 239 | token: server.accessToken, |
240 | fields, | 240 | fields, |
241 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 241 | expectedStatus: HttpStatusCode.CONFLICT_409 |
242 | }) | 242 | }) |
243 | }) | 243 | }) |
244 | 244 | ||
@@ -250,7 +250,7 @@ describe('Test users API validators', function () { | |||
250 | path, | 250 | path, |
251 | token: server.accessToken, | 251 | token: server.accessToken, |
252 | fields, | 252 | fields, |
253 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 253 | expectedStatus: HttpStatusCode.CONFLICT_409 |
254 | }) | 254 | }) |
255 | }) | 255 | }) |
256 | 256 | ||
@@ -298,7 +298,7 @@ describe('Test users API validators', function () { | |||
298 | path, | 298 | path, |
299 | token: server.accessToken, | 299 | token: server.accessToken, |
300 | fields, | 300 | fields, |
301 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 301 | expectedStatus: HttpStatusCode.CONFLICT_409 |
302 | }) | 302 | }) |
303 | }) | 303 | }) |
304 | 304 | ||
@@ -311,7 +311,7 @@ describe('Test users API validators', function () { | |||
311 | path, | 311 | path, |
312 | token: moderatorToken, | 312 | token: moderatorToken, |
313 | fields, | 313 | fields, |
314 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 314 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
315 | }) | 315 | }) |
316 | } | 316 | } |
317 | }) | 317 | }) |
@@ -324,7 +324,7 @@ describe('Test users API validators', function () { | |||
324 | path, | 324 | path, |
325 | token: moderatorToken, | 325 | token: moderatorToken, |
326 | fields, | 326 | fields, |
327 | statusCodeExpected: HttpStatusCode.OK_200 | 327 | expectedStatus: HttpStatusCode.OK_200 |
328 | }) | 328 | }) |
329 | }) | 329 | }) |
330 | 330 | ||
@@ -334,7 +334,7 @@ describe('Test users API validators', function () { | |||
334 | path, | 334 | path, |
335 | token: server.accessToken, | 335 | token: server.accessToken, |
336 | fields: baseCorrectParams, | 336 | fields: baseCorrectParams, |
337 | statusCodeExpected: HttpStatusCode.OK_200 | 337 | expectedStatus: HttpStatusCode.OK_200 |
338 | }) | 338 | }) |
339 | }) | 339 | }) |
340 | 340 | ||
@@ -348,7 +348,7 @@ describe('Test users API validators', function () { | |||
348 | password: 'my super password', | 348 | password: 'my super password', |
349 | videoQuota: 42000000 | 349 | videoQuota: 42000000 |
350 | } | 350 | } |
351 | await makePostBodyRequest({ url: server.url, path, token: userToken, fields, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 351 | await makePostBodyRequest({ url: server.url, path, token: userToken, fields, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
352 | }) | 352 | }) |
353 | }) | 353 | }) |
354 | 354 | ||
@@ -400,7 +400,7 @@ describe('Test users API validators', function () { | |||
400 | path: path + 'me', | 400 | path: path + 'me', |
401 | token: userToken, | 401 | token: userToken, |
402 | fields, | 402 | fields, |
403 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 403 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
404 | }) | 404 | }) |
405 | }) | 405 | }) |
406 | 406 | ||
@@ -447,7 +447,7 @@ describe('Test users API validators', function () { | |||
447 | path: path + 'me', | 447 | path: path + 'me', |
448 | token: 'super token', | 448 | token: 'super token', |
449 | fields, | 449 | fields, |
450 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 450 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
451 | }) | 451 | }) |
452 | }) | 452 | }) |
453 | 453 | ||
@@ -525,7 +525,7 @@ describe('Test users API validators', function () { | |||
525 | path: path + 'me', | 525 | path: path + 'me', |
526 | token: userToken, | 526 | token: userToken, |
527 | fields, | 527 | fields, |
528 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 528 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
529 | }) | 529 | }) |
530 | }) | 530 | }) |
531 | 531 | ||
@@ -540,7 +540,7 @@ describe('Test users API validators', function () { | |||
540 | path: path + 'me', | 540 | path: path + 'me', |
541 | token: userToken, | 541 | token: userToken, |
542 | fields, | 542 | fields, |
543 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 543 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
544 | }) | 544 | }) |
545 | }) | 545 | }) |
546 | }) | 546 | }) |
@@ -572,7 +572,7 @@ describe('Test users API validators', function () { | |||
572 | path: path + '/me/avatar/pick', | 572 | path: path + '/me/avatar/pick', |
573 | fields, | 573 | fields, |
574 | attaches, | 574 | attaches, |
575 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 575 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
576 | }) | 576 | }) |
577 | }) | 577 | }) |
578 | 578 | ||
@@ -587,7 +587,7 @@ describe('Test users API validators', function () { | |||
587 | token: server.accessToken, | 587 | token: server.accessToken, |
588 | fields, | 588 | fields, |
589 | attaches, | 589 | attaches, |
590 | statusCodeExpected: HttpStatusCode.OK_200 | 590 | expectedStatus: HttpStatusCode.OK_200 |
591 | }) | 591 | }) |
592 | }) | 592 | }) |
593 | }) | 593 | }) |
@@ -627,16 +627,16 @@ describe('Test users API validators', function () { | |||
627 | url: server.url, | 627 | url: server.url, |
628 | path: path + userId, | 628 | path: path + userId, |
629 | token: 'super token', | 629 | token: 'super token', |
630 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 630 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
631 | }) | 631 | }) |
632 | }) | 632 | }) |
633 | 633 | ||
634 | it('Should fail with a non admin user', async function () { | 634 | it('Should fail with a non admin user', async function () { |
635 | await makeGetRequest({ url: server.url, path, token: userToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 635 | await makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
636 | }) | 636 | }) |
637 | 637 | ||
638 | it('Should succeed with the correct params', async function () { | 638 | it('Should succeed with the correct params', async function () { |
639 | await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: HttpStatusCode.OK_200 }) | 639 | await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, expectedStatus: HttpStatusCode.OK_200 }) |
640 | }) | 640 | }) |
641 | }) | 641 | }) |
642 | 642 | ||
@@ -702,7 +702,7 @@ describe('Test users API validators', function () { | |||
702 | path: path + userId, | 702 | path: path + userId, |
703 | token: 'super token', | 703 | token: 'super token', |
704 | fields, | 704 | fields, |
705 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 705 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
706 | }) | 706 | }) |
707 | }) | 707 | }) |
708 | 708 | ||
@@ -730,7 +730,7 @@ describe('Test users API validators', function () { | |||
730 | path: path + moderatorId, | 730 | path: path + moderatorId, |
731 | token: moderatorToken, | 731 | token: moderatorToken, |
732 | fields, | 732 | fields, |
733 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 733 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
734 | }) | 734 | }) |
735 | }) | 735 | }) |
736 | 736 | ||
@@ -744,7 +744,7 @@ describe('Test users API validators', function () { | |||
744 | path: path + userId, | 744 | path: path + userId, |
745 | token: moderatorToken, | 745 | token: moderatorToken, |
746 | fields, | 746 | fields, |
747 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 747 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
748 | }) | 748 | }) |
749 | }) | 749 | }) |
750 | 750 | ||
@@ -761,7 +761,7 @@ describe('Test users API validators', function () { | |||
761 | path: path + userId, | 761 | path: path + userId, |
762 | token: server.accessToken, | 762 | token: server.accessToken, |
763 | fields, | 763 | fields, |
764 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 764 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
765 | }) | 765 | }) |
766 | }) | 766 | }) |
767 | }) | 767 | }) |
@@ -818,11 +818,11 @@ describe('Test users API validators', function () { | |||
818 | }) | 818 | }) |
819 | 819 | ||
820 | it('Should fail with a unauthenticated user', async function () { | 820 | it('Should fail with a unauthenticated user', async function () { |
821 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 821 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
822 | }) | 822 | }) |
823 | 823 | ||
824 | it('Should fail with a another user', async function () { | 824 | it('Should fail with a another user', async function () { |
825 | await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 825 | await makeGetRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
826 | }) | 826 | }) |
827 | 827 | ||
828 | it('Should fail with a bad type', async function () { | 828 | it('Should fail with a bad type', async function () { |
@@ -831,12 +831,12 @@ describe('Test users API validators', function () { | |||
831 | path, | 831 | path, |
832 | token: userToken, | 832 | token: userToken, |
833 | query: { rating: 'toto ' }, | 833 | query: { rating: 'toto ' }, |
834 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 834 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
835 | }) | 835 | }) |
836 | }) | 836 | }) |
837 | 837 | ||
838 | it('Should succeed with the correct params', async function () { | 838 | it('Should succeed with the correct params', async function () { |
839 | await makeGetRequest({ url: server.url, path, token: userToken, statusCodeExpected: HttpStatusCode.OK_200 }) | 839 | await makeGetRequest({ url: server.url, path, token: userToken, expectedStatus: HttpStatusCode.OK_200 }) |
840 | }) | 840 | }) |
841 | }) | 841 | }) |
842 | 842 | ||
@@ -955,7 +955,7 @@ describe('Test users API validators', function () { | |||
955 | path: registrationPath, | 955 | path: registrationPath, |
956 | token: server.accessToken, | 956 | token: server.accessToken, |
957 | fields, | 957 | fields, |
958 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 958 | expectedStatus: HttpStatusCode.CONFLICT_409 |
959 | }) | 959 | }) |
960 | }) | 960 | }) |
961 | 961 | ||
@@ -967,7 +967,7 @@ describe('Test users API validators', function () { | |||
967 | path: registrationPath, | 967 | path: registrationPath, |
968 | token: server.accessToken, | 968 | token: server.accessToken, |
969 | fields, | 969 | fields, |
970 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 970 | expectedStatus: HttpStatusCode.CONFLICT_409 |
971 | }) | 971 | }) |
972 | }) | 972 | }) |
973 | 973 | ||
@@ -979,7 +979,7 @@ describe('Test users API validators', function () { | |||
979 | path: registrationPath, | 979 | path: registrationPath, |
980 | token: server.accessToken, | 980 | token: server.accessToken, |
981 | fields, | 981 | fields, |
982 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 982 | expectedStatus: HttpStatusCode.CONFLICT_409 |
983 | }) | 983 | }) |
984 | }) | 984 | }) |
985 | 985 | ||
@@ -1019,7 +1019,7 @@ describe('Test users API validators', function () { | |||
1019 | path: registrationPath, | 1019 | path: registrationPath, |
1020 | token: server.accessToken, | 1020 | token: server.accessToken, |
1021 | fields, | 1021 | fields, |
1022 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 1022 | expectedStatus: HttpStatusCode.CONFLICT_409 |
1023 | }) | 1023 | }) |
1024 | }) | 1024 | }) |
1025 | 1025 | ||
@@ -1031,7 +1031,7 @@ describe('Test users API validators', function () { | |||
1031 | path: registrationPath, | 1031 | path: registrationPath, |
1032 | token: server.accessToken, | 1032 | token: server.accessToken, |
1033 | fields: fields, | 1033 | fields: fields, |
1034 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 1034 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
1035 | }) | 1035 | }) |
1036 | }) | 1036 | }) |
1037 | 1037 | ||
@@ -1047,7 +1047,7 @@ describe('Test users API validators', function () { | |||
1047 | path: registrationPath, | 1047 | path: registrationPath, |
1048 | token: serverWithRegistrationDisabled.accessToken, | 1048 | token: serverWithRegistrationDisabled.accessToken, |
1049 | fields, | 1049 | fields, |
1050 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 1050 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
1051 | }) | 1051 | }) |
1052 | }) | 1052 | }) |
1053 | }) | 1053 | }) |
@@ -1081,7 +1081,7 @@ describe('Test users API validators', function () { | |||
1081 | path, | 1081 | path, |
1082 | token: server.accessToken, | 1082 | token: server.accessToken, |
1083 | fields, | 1083 | fields, |
1084 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 1084 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
1085 | }) | 1085 | }) |
1086 | }) | 1086 | }) |
1087 | }) | 1087 | }) |
@@ -1109,7 +1109,7 @@ describe('Test users API validators', function () { | |||
1109 | path, | 1109 | path, |
1110 | token: server.accessToken, | 1110 | token: server.accessToken, |
1111 | fields, | 1111 | fields, |
1112 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 1112 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
1113 | }) | 1113 | }) |
1114 | }) | 1114 | }) |
1115 | }) | 1115 | }) |
diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index b5d0e0778..2072df4b6 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | BlacklistCommand, | 7 | BlacklistCommand, |
8 | checkBadCountPagination, | 8 | checkBadCountPagination, |
@@ -88,7 +88,7 @@ describe('Test video blacklist API validators', function () { | |||
88 | it('Should fail with a non authenticated user', async function () { | 88 | it('Should fail with a non authenticated user', async function () { |
89 | const path = basePath + servers[0].store.video + '/blacklist' | 89 | const path = basePath + servers[0].store.video + '/blacklist' |
90 | const fields = {} | 90 | const fields = {} |
91 | await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 91 | await makePostBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
92 | }) | 92 | }) |
93 | 93 | ||
94 | it('Should fail with a non admin user', async function () { | 94 | it('Should fail with a non admin user', async function () { |
@@ -99,7 +99,7 @@ describe('Test video blacklist API validators', function () { | |||
99 | path, | 99 | path, |
100 | token: userAccessToken2, | 100 | token: userAccessToken2, |
101 | fields, | 101 | fields, |
102 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 102 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
103 | }) | 103 | }) |
104 | }) | 104 | }) |
105 | 105 | ||
@@ -119,7 +119,7 @@ describe('Test video blacklist API validators', function () { | |||
119 | path, | 119 | path, |
120 | token: servers[0].accessToken, | 120 | token: servers[0].accessToken, |
121 | fields, | 121 | fields, |
122 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 122 | expectedStatus: HttpStatusCode.CONFLICT_409 |
123 | }) | 123 | }) |
124 | }) | 124 | }) |
125 | 125 | ||
@@ -132,7 +132,7 @@ describe('Test video blacklist API validators', function () { | |||
132 | path, | 132 | path, |
133 | token: servers[0].accessToken, | 133 | token: servers[0].accessToken, |
134 | fields, | 134 | fields, |
135 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 135 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
136 | }) | 136 | }) |
137 | }) | 137 | }) |
138 | }) | 138 | }) |
@@ -154,14 +154,14 @@ describe('Test video blacklist API validators', function () { | |||
154 | path, | 154 | path, |
155 | token: servers[0].accessToken, | 155 | token: servers[0].accessToken, |
156 | fields, | 156 | fields, |
157 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 157 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
158 | }) | 158 | }) |
159 | }) | 159 | }) |
160 | 160 | ||
161 | it('Should fail with a non authenticated user', async function () { | 161 | it('Should fail with a non authenticated user', async function () { |
162 | const path = basePath + servers[0].store.video + '/blacklist' | 162 | const path = basePath + servers[0].store.video + '/blacklist' |
163 | const fields = {} | 163 | const fields = {} |
164 | await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 164 | await makePutBodyRequest({ url: servers[0].url, path, token: 'hello', fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
165 | }) | 165 | }) |
166 | 166 | ||
167 | it('Should fail with a non admin user', async function () { | 167 | it('Should fail with a non admin user', async function () { |
@@ -172,7 +172,7 @@ describe('Test video blacklist API validators', function () { | |||
172 | path, | 172 | path, |
173 | token: userAccessToken2, | 173 | token: userAccessToken2, |
174 | fields, | 174 | fields, |
175 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 175 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
176 | }) | 176 | }) |
177 | }) | 177 | }) |
178 | 178 | ||
@@ -192,7 +192,7 @@ describe('Test video blacklist API validators', function () { | |||
192 | path, | 192 | path, |
193 | token: servers[0].accessToken, | 193 | token: servers[0].accessToken, |
194 | fields, | 194 | fields, |
195 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 195 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
196 | }) | 196 | }) |
197 | }) | 197 | }) |
198 | }) | 198 | }) |
diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 26aab79e7..1b3d1aa95 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 5 | import { |
6 | buildAbsoluteFixturePath, | 6 | buildAbsoluteFixturePath, |
7 | cleanupTests, | 7 | cleanupTests, |
@@ -67,7 +67,7 @@ describe('Test video captions API validator', function () { | |||
67 | token: server.accessToken, | 67 | token: server.accessToken, |
68 | fields, | 68 | fields, |
69 | attaches, | 69 | attaches, |
70 | statusCodeExpected: 404 | 70 | expectedStatus: 404 |
71 | }) | 71 | }) |
72 | }) | 72 | }) |
73 | 73 | ||
@@ -103,7 +103,7 @@ describe('Test video captions API validator', function () { | |||
103 | path: captionPath, | 103 | path: captionPath, |
104 | fields, | 104 | fields, |
105 | attaches, | 105 | attaches, |
106 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 106 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
107 | }) | 107 | }) |
108 | }) | 108 | }) |
109 | 109 | ||
@@ -116,7 +116,7 @@ describe('Test video captions API validator', function () { | |||
116 | token: 'blabla', | 116 | token: 'blabla', |
117 | fields, | 117 | fields, |
118 | attaches, | 118 | attaches, |
119 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 119 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
120 | }) | 120 | }) |
121 | }) | 121 | }) |
122 | 122 | ||
@@ -134,7 +134,7 @@ describe('Test video captions API validator', function () { | |||
134 | // token: server.accessToken, | 134 | // token: server.accessToken, |
135 | // fields, | 135 | // fields, |
136 | // attaches, | 136 | // attaches, |
137 | // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 137 | // expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
138 | // }) | 138 | // }) |
139 | // }) | 139 | // }) |
140 | 140 | ||
@@ -147,7 +147,7 @@ describe('Test video captions API validator', function () { | |||
147 | // videoId: video.uuid, | 147 | // videoId: video.uuid, |
148 | // fixture: 'subtitle-bad.txt', | 148 | // fixture: 'subtitle-bad.txt', |
149 | // mimeType: 'application/octet-stream', | 149 | // mimeType: 'application/octet-stream', |
150 | // statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 150 | // expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
151 | // }) | 151 | // }) |
152 | // }) | 152 | // }) |
153 | 153 | ||
@@ -174,7 +174,7 @@ describe('Test video captions API validator', function () { | |||
174 | // token: server.accessToken, | 174 | // token: server.accessToken, |
175 | // fields, | 175 | // fields, |
176 | // attaches, | 176 | // attaches, |
177 | // statusCodeExpected: HttpStatusCode.INTERNAL_SERVER_ERROR_500 | 177 | // expectedStatus: HttpStatusCode.INTERNAL_SERVER_ERROR_500 |
178 | // }) | 178 | // }) |
179 | // }) | 179 | // }) |
180 | 180 | ||
@@ -187,7 +187,7 @@ describe('Test video captions API validator', function () { | |||
187 | token: server.accessToken, | 187 | token: server.accessToken, |
188 | fields, | 188 | fields, |
189 | attaches, | 189 | attaches, |
190 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 190 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
191 | }) | 191 | }) |
192 | }) | 192 | }) |
193 | }) | 193 | }) |
@@ -201,12 +201,12 @@ describe('Test video captions API validator', function () { | |||
201 | await makeGetRequest({ | 201 | await makeGetRequest({ |
202 | url: server.url, | 202 | url: server.url, |
203 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions', | 203 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions', |
204 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 204 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
205 | }) | 205 | }) |
206 | }) | 206 | }) |
207 | 207 | ||
208 | it('Should success with the correct parameters', async function () { | 208 | it('Should success with the correct parameters', async function () { |
209 | await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', statusCodeExpected: HttpStatusCode.OK_200 }) | 209 | await makeGetRequest({ url: server.url, path: path + video.shortUUID + '/captions', expectedStatus: HttpStatusCode.OK_200 }) |
210 | }) | 210 | }) |
211 | }) | 211 | }) |
212 | 212 | ||
@@ -224,7 +224,7 @@ describe('Test video captions API validator', function () { | |||
224 | url: server.url, | 224 | url: server.url, |
225 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr', | 225 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/captions/fr', |
226 | token: server.accessToken, | 226 | token: server.accessToken, |
227 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 227 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
228 | }) | 228 | }) |
229 | }) | 229 | }) |
230 | 230 | ||
@@ -248,12 +248,12 @@ describe('Test video captions API validator', function () { | |||
248 | 248 | ||
249 | it('Should fail without access token', async function () { | 249 | it('Should fail without access token', async function () { |
250 | const captionPath = path + video.shortUUID + '/captions/fr' | 250 | const captionPath = path + video.shortUUID + '/captions/fr' |
251 | await makeDeleteRequest({ url: server.url, path: captionPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 251 | await makeDeleteRequest({ url: server.url, path: captionPath, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
252 | }) | 252 | }) |
253 | 253 | ||
254 | it('Should fail with a bad access token', async function () { | 254 | it('Should fail with a bad access token', async function () { |
255 | const captionPath = path + video.shortUUID + '/captions/fr' | 255 | const captionPath = path + video.shortUUID + '/captions/fr' |
256 | await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 256 | await makeDeleteRequest({ url: server.url, path: captionPath, token: 'coucou', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
257 | }) | 257 | }) |
258 | 258 | ||
259 | it('Should fail with another user', async function () { | 259 | it('Should fail with another user', async function () { |
@@ -262,7 +262,7 @@ describe('Test video captions API validator', function () { | |||
262 | url: server.url, | 262 | url: server.url, |
263 | path: captionPath, | 263 | path: captionPath, |
264 | token: userAccessToken, | 264 | token: userAccessToken, |
265 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 265 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
266 | }) | 266 | }) |
267 | }) | 267 | }) |
268 | 268 | ||
@@ -272,7 +272,7 @@ describe('Test video captions API validator', function () { | |||
272 | url: server.url, | 272 | url: server.url, |
273 | path: captionPath, | 273 | path: captionPath, |
274 | token: server.accessToken, | 274 | token: server.accessToken, |
275 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 275 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
276 | }) | 276 | }) |
277 | }) | 277 | }) |
278 | }) | 278 | }) |
diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index 62b8fa4f6..bbe42e43d 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { | 7 | import { |
8 | buildAbsoluteFixturePath, | 8 | buildAbsoluteFixturePath, |
9 | ChannelsCommand, | 9 | ChannelsCommand, |
@@ -88,7 +88,7 @@ describe('Test video channels API validator', function () { | |||
88 | await makeGetRequest({ | 88 | await makeGetRequest({ |
89 | url: server.url, | 89 | url: server.url, |
90 | path: accountChannelPath, | 90 | path: accountChannelPath, |
91 | statusCodeExpected: HttpStatusCode.OK_200 | 91 | expectedStatus: HttpStatusCode.OK_200 |
92 | }) | 92 | }) |
93 | }) | 93 | }) |
94 | }) | 94 | }) |
@@ -107,7 +107,7 @@ describe('Test video channels API validator', function () { | |||
107 | path: videoChannelPath, | 107 | path: videoChannelPath, |
108 | token: 'none', | 108 | token: 'none', |
109 | fields: baseCorrectParams, | 109 | fields: baseCorrectParams, |
110 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 110 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
111 | }) | 111 | }) |
112 | }) | 112 | }) |
113 | 113 | ||
@@ -152,7 +152,7 @@ describe('Test video channels API validator', function () { | |||
152 | path: videoChannelPath, | 152 | path: videoChannelPath, |
153 | token: server.accessToken, | 153 | token: server.accessToken, |
154 | fields: baseCorrectParams, | 154 | fields: baseCorrectParams, |
155 | statusCodeExpected: HttpStatusCode.OK_200 | 155 | expectedStatus: HttpStatusCode.OK_200 |
156 | }) | 156 | }) |
157 | }) | 157 | }) |
158 | 158 | ||
@@ -162,7 +162,7 @@ describe('Test video channels API validator', function () { | |||
162 | path: videoChannelPath, | 162 | path: videoChannelPath, |
163 | token: server.accessToken, | 163 | token: server.accessToken, |
164 | fields: baseCorrectParams, | 164 | fields: baseCorrectParams, |
165 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 165 | expectedStatus: HttpStatusCode.CONFLICT_409 |
166 | }) | 166 | }) |
167 | }) | 167 | }) |
168 | }) | 168 | }) |
@@ -186,7 +186,7 @@ describe('Test video channels API validator', function () { | |||
186 | path, | 186 | path, |
187 | token: 'hi', | 187 | token: 'hi', |
188 | fields: baseCorrectParams, | 188 | fields: baseCorrectParams, |
189 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 189 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
190 | }) | 190 | }) |
191 | }) | 191 | }) |
192 | 192 | ||
@@ -196,7 +196,7 @@ describe('Test video channels API validator', function () { | |||
196 | path, | 196 | path, |
197 | token: accessTokenUser, | 197 | token: accessTokenUser, |
198 | fields: baseCorrectParams, | 198 | fields: baseCorrectParams, |
199 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 199 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
200 | }) | 200 | }) |
201 | }) | 201 | }) |
202 | 202 | ||
@@ -226,7 +226,7 @@ describe('Test video channels API validator', function () { | |||
226 | path, | 226 | path, |
227 | token: server.accessToken, | 227 | token: server.accessToken, |
228 | fields: baseCorrectParams, | 228 | fields: baseCorrectParams, |
229 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 229 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
230 | }) | 230 | }) |
231 | }) | 231 | }) |
232 | }) | 232 | }) |
@@ -271,7 +271,7 @@ describe('Test video channels API validator', function () { | |||
271 | path: `${path}/${type}/pick`, | 271 | path: `${path}/${type}/pick`, |
272 | fields, | 272 | fields, |
273 | attaches, | 273 | attaches, |
274 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 274 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
275 | }) | 275 | }) |
276 | } | 276 | } |
277 | }) | 277 | }) |
@@ -288,7 +288,7 @@ describe('Test video channels API validator', function () { | |||
288 | token: server.accessToken, | 288 | token: server.accessToken, |
289 | fields, | 289 | fields, |
290 | attaches, | 290 | attaches, |
291 | statusCodeExpected: HttpStatusCode.OK_200 | 291 | expectedStatus: HttpStatusCode.OK_200 |
292 | }) | 292 | }) |
293 | } | 293 | } |
294 | }) | 294 | }) |
@@ -299,7 +299,7 @@ describe('Test video channels API validator', function () { | |||
299 | const res = await makeGetRequest({ | 299 | const res = await makeGetRequest({ |
300 | url: server.url, | 300 | url: server.url, |
301 | path: videoChannelPath, | 301 | path: videoChannelPath, |
302 | statusCodeExpected: HttpStatusCode.OK_200 | 302 | expectedStatus: HttpStatusCode.OK_200 |
303 | }) | 303 | }) |
304 | 304 | ||
305 | expect(res.body.data).to.be.an('array') | 305 | expect(res.body.data).to.be.an('array') |
@@ -309,7 +309,7 @@ describe('Test video channels API validator', function () { | |||
309 | await makeGetRequest({ | 309 | await makeGetRequest({ |
310 | url: server.url, | 310 | url: server.url, |
311 | path: videoChannelPath + '/super_channel2', | 311 | path: videoChannelPath + '/super_channel2', |
312 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 312 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
313 | }) | 313 | }) |
314 | }) | 314 | }) |
315 | 315 | ||
@@ -317,7 +317,7 @@ describe('Test video channels API validator', function () { | |||
317 | await makeGetRequest({ | 317 | await makeGetRequest({ |
318 | url: server.url, | 318 | url: server.url, |
319 | path: videoChannelPath + '/super_channel', | 319 | path: videoChannelPath + '/super_channel', |
320 | statusCodeExpected: HttpStatusCode.OK_200 | 320 | expectedStatus: HttpStatusCode.OK_200 |
321 | }) | 321 | }) |
322 | }) | 322 | }) |
323 | }) | 323 | }) |
diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index 92c29da0e..bfd9e0172 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | checkBadCountPagination, | 7 | checkBadCountPagination, |
8 | checkBadSortPagination, | 8 | checkBadSortPagination, |
@@ -78,7 +78,7 @@ describe('Test video comments API validator', function () { | |||
78 | await makeGetRequest({ | 78 | await makeGetRequest({ |
79 | url: server.url, | 79 | url: server.url, |
80 | path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads', | 80 | path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads', |
81 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 81 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
82 | }) | 82 | }) |
83 | }) | 83 | }) |
84 | }) | 84 | }) |
@@ -88,7 +88,7 @@ describe('Test video comments API validator', function () { | |||
88 | await makeGetRequest({ | 88 | await makeGetRequest({ |
89 | url: server.url, | 89 | url: server.url, |
90 | path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads/' + commentId, | 90 | path: '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comment-threads/' + commentId, |
91 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 91 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
92 | }) | 92 | }) |
93 | }) | 93 | }) |
94 | 94 | ||
@@ -96,7 +96,7 @@ describe('Test video comments API validator', function () { | |||
96 | await makeGetRequest({ | 96 | await makeGetRequest({ |
97 | url: server.url, | 97 | url: server.url, |
98 | path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156', | 98 | path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/156', |
99 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 99 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
100 | }) | 100 | }) |
101 | }) | 101 | }) |
102 | 102 | ||
@@ -104,7 +104,7 @@ describe('Test video comments API validator', function () { | |||
104 | await makeGetRequest({ | 104 | await makeGetRequest({ |
105 | url: server.url, | 105 | url: server.url, |
106 | path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId, | 106 | path: '/api/v1/videos/' + video.shortUUID + '/comment-threads/' + commentId, |
107 | statusCodeExpected: HttpStatusCode.OK_200 | 107 | expectedStatus: HttpStatusCode.OK_200 |
108 | }) | 108 | }) |
109 | }) | 109 | }) |
110 | }) | 110 | }) |
@@ -120,7 +120,7 @@ describe('Test video comments API validator', function () { | |||
120 | path: pathThread, | 120 | path: pathThread, |
121 | token: 'none', | 121 | token: 'none', |
122 | fields, | 122 | fields, |
123 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 123 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
124 | }) | 124 | }) |
125 | }) | 125 | }) |
126 | 126 | ||
@@ -153,7 +153,7 @@ describe('Test video comments API validator', function () { | |||
153 | path, | 153 | path, |
154 | token: server.accessToken, | 154 | token: server.accessToken, |
155 | fields, | 155 | fields, |
156 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 156 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
157 | }) | 157 | }) |
158 | }) | 158 | }) |
159 | 159 | ||
@@ -166,7 +166,7 @@ describe('Test video comments API validator', function () { | |||
166 | path: pathThread, | 166 | path: pathThread, |
167 | token: server.accessToken, | 167 | token: server.accessToken, |
168 | fields, | 168 | fields, |
169 | statusCodeExpected: HttpStatusCode.OK_200 | 169 | expectedStatus: HttpStatusCode.OK_200 |
170 | }) | 170 | }) |
171 | }) | 171 | }) |
172 | }) | 172 | }) |
@@ -181,7 +181,7 @@ describe('Test video comments API validator', function () { | |||
181 | path: pathComment, | 181 | path: pathComment, |
182 | token: 'none', | 182 | token: 'none', |
183 | fields, | 183 | fields, |
184 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 184 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
185 | }) | 185 | }) |
186 | }) | 186 | }) |
187 | 187 | ||
@@ -214,7 +214,7 @@ describe('Test video comments API validator', function () { | |||
214 | path, | 214 | path, |
215 | token: server.accessToken, | 215 | token: server.accessToken, |
216 | fields, | 216 | fields, |
217 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 217 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
218 | }) | 218 | }) |
219 | }) | 219 | }) |
220 | 220 | ||
@@ -228,7 +228,7 @@ describe('Test video comments API validator', function () { | |||
228 | path, | 228 | path, |
229 | token: server.accessToken, | 229 | token: server.accessToken, |
230 | fields, | 230 | fields, |
231 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 231 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
232 | }) | 232 | }) |
233 | }) | 233 | }) |
234 | 234 | ||
@@ -241,14 +241,14 @@ describe('Test video comments API validator', function () { | |||
241 | path: pathComment, | 241 | path: pathComment, |
242 | token: server.accessToken, | 242 | token: server.accessToken, |
243 | fields, | 243 | fields, |
244 | statusCodeExpected: HttpStatusCode.OK_200 | 244 | expectedStatus: HttpStatusCode.OK_200 |
245 | }) | 245 | }) |
246 | }) | 246 | }) |
247 | }) | 247 | }) |
248 | 248 | ||
249 | describe('When removing video comments', function () { | 249 | describe('When removing video comments', function () { |
250 | it('Should fail with a non authenticated user', async function () { | 250 | it('Should fail with a non authenticated user', async function () { |
251 | await makeDeleteRequest({ url: server.url, path: pathComment, token: 'none', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 251 | await makeDeleteRequest({ url: server.url, path: pathComment, token: 'none', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
252 | }) | 252 | }) |
253 | 253 | ||
254 | it('Should fail with another user', async function () { | 254 | it('Should fail with another user', async function () { |
@@ -256,18 +256,18 @@ describe('Test video comments API validator', function () { | |||
256 | url: server.url, | 256 | url: server.url, |
257 | path: pathComment, | 257 | path: pathComment, |
258 | token: userAccessToken, | 258 | token: userAccessToken, |
259 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 259 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
260 | }) | 260 | }) |
261 | }) | 261 | }) |
262 | 262 | ||
263 | it('Should fail with an incorrect video', async function () { | 263 | it('Should fail with an incorrect video', async function () { |
264 | const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comments/' + commentId | 264 | const path = '/api/v1/videos/ba708d62-e3d7-45d9-9d73-41b9097cc02d/comments/' + commentId |
265 | await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) | 265 | await makeDeleteRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
266 | }) | 266 | }) |
267 | 267 | ||
268 | it('Should fail with an incorrect comment', async function () { | 268 | it('Should fail with an incorrect comment', async function () { |
269 | const path = '/api/v1/videos/' + video.uuid + '/comments/124' | 269 | const path = '/api/v1/videos/' + video.uuid + '/comments/124' |
270 | await makeDeleteRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) | 270 | await makeDeleteRequest({ url: server.url, path, token: server.accessToken, expectedStatus: HttpStatusCode.NOT_FOUND_404 }) |
271 | }) | 271 | }) |
272 | 272 | ||
273 | it('Should succeed with the same user', async function () { | 273 | it('Should succeed with the same user', async function () { |
@@ -280,8 +280,8 @@ describe('Test video comments API validator', function () { | |||
280 | 280 | ||
281 | const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete | 281 | const path = '/api/v1/videos/' + video.uuid + '/comments/' + commentToDelete |
282 | 282 | ||
283 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 283 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
284 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) | 284 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) |
285 | }) | 285 | }) |
286 | 286 | ||
287 | it('Should succeed with the owner of the video', async function () { | 287 | it('Should succeed with the owner of the video', async function () { |
@@ -300,8 +300,8 @@ describe('Test video comments API validator', function () { | |||
300 | 300 | ||
301 | const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete | 301 | const path = '/api/v1/videos/' + anotherVideoUUID + '/comments/' + commentToDelete |
302 | 302 | ||
303 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, statusCodeExpected: HttpStatusCode.FORBIDDEN_403 }) | 303 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken2, expectedStatus: HttpStatusCode.FORBIDDEN_403 }) |
304 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: HttpStatusCode.NO_CONTENT_204 }) | 304 | await makeDeleteRequest({ url: server.url, path, token: userAccessToken, expectedStatus: HttpStatusCode.NO_CONTENT_204 }) |
305 | }) | 305 | }) |
306 | 306 | ||
307 | it('Should succeed with the correct parameters', async function () { | 307 | it('Should succeed with the correct parameters', async function () { |
@@ -309,7 +309,7 @@ describe('Test video comments API validator', function () { | |||
309 | url: server.url, | 309 | url: server.url, |
310 | path: pathComment, | 310 | path: pathComment, |
311 | token: server.accessToken, | 311 | token: server.accessToken, |
312 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 312 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
313 | }) | 313 | }) |
314 | }) | 314 | }) |
315 | }) | 315 | }) |
@@ -324,7 +324,7 @@ describe('Test video comments API validator', function () { | |||
324 | const res = await makeGetRequest({ | 324 | const res = await makeGetRequest({ |
325 | url: server.url, | 325 | url: server.url, |
326 | path: pathThread, | 326 | path: pathThread, |
327 | statusCodeExpected: HttpStatusCode.OK_200 | 327 | expectedStatus: HttpStatusCode.OK_200 |
328 | }) | 328 | }) |
329 | expect(res.body.total).to.equal(0) | 329 | expect(res.body.total).to.equal(0) |
330 | expect(res.body.data).to.have.lengthOf(0) | 330 | expect(res.body.data).to.have.lengthOf(0) |
@@ -341,7 +341,7 @@ describe('Test video comments API validator', function () { | |||
341 | path: pathThread, | 341 | path: pathThread, |
342 | token: server.accessToken, | 342 | token: server.accessToken, |
343 | fields, | 343 | fields, |
344 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 344 | expectedStatus: HttpStatusCode.CONFLICT_409 |
345 | }) | 345 | }) |
346 | }) | 346 | }) |
347 | 347 | ||
@@ -367,7 +367,7 @@ describe('Test video comments API validator', function () { | |||
367 | await makeGetRequest({ | 367 | await makeGetRequest({ |
368 | url: server.url, | 368 | url: server.url, |
369 | path, | 369 | path, |
370 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 370 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
371 | }) | 371 | }) |
372 | }) | 372 | }) |
373 | 373 | ||
@@ -376,7 +376,7 @@ describe('Test video comments API validator', function () { | |||
376 | url: server.url, | 376 | url: server.url, |
377 | path, | 377 | path, |
378 | token: userAccessToken, | 378 | token: userAccessToken, |
379 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 379 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
380 | }) | 380 | }) |
381 | }) | 381 | }) |
382 | 382 | ||
@@ -391,7 +391,7 @@ describe('Test video comments API validator', function () { | |||
391 | searchAccount: 'toto', | 391 | searchAccount: 'toto', |
392 | searchVideo: 'toto' | 392 | searchVideo: 'toto' |
393 | }, | 393 | }, |
394 | statusCodeExpected: HttpStatusCode.OK_200 | 394 | expectedStatus: HttpStatusCode.OK_200 |
395 | }) | 395 | }) |
396 | }) | 396 | }) |
397 | }) | 397 | }) |
diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index 0209275ac..957556c9b 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | buildAbsoluteFixturePath, | 7 | buildAbsoluteFixturePath, |
8 | checkBadCountPagination, | 8 | checkBadCountPagination, |
@@ -61,7 +61,7 @@ describe('Test video imports API validator', function () { | |||
61 | }) | 61 | }) |
62 | 62 | ||
63 | it('Should success with the correct parameters', async function () { | 63 | it('Should success with the correct parameters', async function () { |
64 | await makeGetRequest({ url: server.url, path: myPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) | 64 | await makeGetRequest({ url: server.url, path: myPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken }) |
65 | }) | 65 | }) |
66 | }) | 66 | }) |
67 | 67 | ||
@@ -99,7 +99,7 @@ describe('Test video imports API validator', function () { | |||
99 | path, | 99 | path, |
100 | token: server.accessToken, | 100 | token: server.accessToken, |
101 | fields, | 101 | fields, |
102 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 102 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
103 | }) | 103 | }) |
104 | }) | 104 | }) |
105 | 105 | ||
@@ -251,7 +251,7 @@ describe('Test video imports API validator', function () { | |||
251 | path, | 251 | path, |
252 | token: server.accessToken, | 252 | token: server.accessToken, |
253 | fields: baseCorrectParams, | 253 | fields: baseCorrectParams, |
254 | statusCodeExpected: HttpStatusCode.OK_200 | 254 | expectedStatus: HttpStatusCode.OK_200 |
255 | }) | 255 | }) |
256 | }) | 256 | }) |
257 | 257 | ||
@@ -276,7 +276,7 @@ describe('Test video imports API validator', function () { | |||
276 | path, | 276 | path, |
277 | token: server.accessToken, | 277 | token: server.accessToken, |
278 | fields: baseCorrectParams, | 278 | fields: baseCorrectParams, |
279 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 279 | expectedStatus: HttpStatusCode.CONFLICT_409 |
280 | }) | 280 | }) |
281 | }) | 281 | }) |
282 | 282 | ||
@@ -304,7 +304,7 @@ describe('Test video imports API validator', function () { | |||
304 | path, | 304 | path, |
305 | token: server.accessToken, | 305 | token: server.accessToken, |
306 | fields, | 306 | fields, |
307 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 307 | expectedStatus: HttpStatusCode.CONFLICT_409 |
308 | }) | 308 | }) |
309 | 309 | ||
310 | fields = omit(fields, 'magnetUri') | 310 | fields = omit(fields, 'magnetUri') |
@@ -318,7 +318,7 @@ describe('Test video imports API validator', function () { | |||
318 | token: server.accessToken, | 318 | token: server.accessToken, |
319 | fields, | 319 | fields, |
320 | attaches, | 320 | attaches, |
321 | statusCodeExpected: HttpStatusCode.CONFLICT_409 | 321 | expectedStatus: HttpStatusCode.CONFLICT_409 |
322 | }) | 322 | }) |
323 | }) | 323 | }) |
324 | }) | 324 | }) |
diff --git a/server/tests/api/check-params/video-playlists.ts b/server/tests/api/check-params/video-playlists.ts index 9d054b176..7dcb4935a 100644 --- a/server/tests/api/check-params/video-playlists.ts +++ b/server/tests/api/check-params/video-playlists.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 5 | import { |
6 | checkBadCountPagination, | 6 | checkBadCountPagination, |
7 | checkBadSortPagination, | 7 | checkBadSortPagination, |
@@ -119,7 +119,7 @@ describe('Test video playlists API validator', function () { | |||
119 | await makeGetRequest({ | 119 | await makeGetRequest({ |
120 | url: server.url, | 120 | url: server.url, |
121 | path: accountPath, | 121 | path: accountPath, |
122 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404, | 122 | expectedStatus: HttpStatusCode.NOT_FOUND_404, |
123 | token: server.accessToken | 123 | token: server.accessToken |
124 | }) | 124 | }) |
125 | }) | 125 | }) |
@@ -130,18 +130,18 @@ describe('Test video playlists API validator', function () { | |||
130 | await makeGetRequest({ | 130 | await makeGetRequest({ |
131 | url: server.url, | 131 | url: server.url, |
132 | path: accountPath, | 132 | path: accountPath, |
133 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404, | 133 | expectedStatus: HttpStatusCode.NOT_FOUND_404, |
134 | token: server.accessToken | 134 | token: server.accessToken |
135 | }) | 135 | }) |
136 | }) | 136 | }) |
137 | 137 | ||
138 | it('Should success with the correct parameters', async function () { | 138 | it('Should success with the correct parameters', async function () { |
139 | await makeGetRequest({ url: server.url, path: globalPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) | 139 | await makeGetRequest({ url: server.url, path: globalPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken }) |
140 | await makeGetRequest({ url: server.url, path: accountPath, statusCodeExpected: HttpStatusCode.OK_200, token: server.accessToken }) | 140 | await makeGetRequest({ url: server.url, path: accountPath, expectedStatus: HttpStatusCode.OK_200, token: server.accessToken }) |
141 | await makeGetRequest({ | 141 | await makeGetRequest({ |
142 | url: server.url, | 142 | url: server.url, |
143 | path: videoChannelPath, | 143 | path: videoChannelPath, |
144 | statusCodeExpected: HttpStatusCode.OK_200, | 144 | expectedStatus: HttpStatusCode.OK_200, |
145 | token: server.accessToken | 145 | token: server.accessToken |
146 | }) | 146 | }) |
147 | }) | 147 | }) |
@@ -159,7 +159,7 @@ describe('Test video playlists API validator', function () { | |||
159 | }) | 159 | }) |
160 | 160 | ||
161 | it('Should success with the correct parameters', async function () { | 161 | it('Should success with the correct parameters', async function () { |
162 | await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', statusCodeExpected: HttpStatusCode.OK_200 }) | 162 | await makeGetRequest({ url: server.url, path: path + playlist.shortUUID + '/videos', expectedStatus: HttpStatusCode.OK_200 }) |
163 | }) | 163 | }) |
164 | }) | 164 | }) |
165 | 165 | ||
@@ -580,7 +580,7 @@ describe('Test video playlists API validator', function () { | |||
580 | url: server.url, | 580 | url: server.url, |
581 | path, | 581 | path, |
582 | query: { videoIds: [ 1, 2 ] }, | 582 | query: { videoIds: [ 1, 2 ] }, |
583 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 583 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
584 | }) | 584 | }) |
585 | }) | 585 | }) |
586 | 586 | ||
@@ -613,7 +613,7 @@ describe('Test video playlists API validator', function () { | |||
613 | token: server.accessToken, | 613 | token: server.accessToken, |
614 | path, | 614 | path, |
615 | query: { videoIds: [ 1, 2 ] }, | 615 | query: { videoIds: [ 1, 2 ] }, |
616 | statusCodeExpected: HttpStatusCode.OK_200 | 616 | expectedStatus: HttpStatusCode.OK_200 |
617 | }) | 617 | }) |
618 | }) | 618 | }) |
619 | }) | 619 | }) |
diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts index e4e799cc7..c2c69904f 100644 --- a/server/tests/api/check-params/videos-filter.ts +++ b/server/tests/api/check-params/videos-filter.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/models' | ||
4 | import { | 5 | import { |
5 | cleanupTests, | 6 | cleanupTests, |
6 | createSingleServer, | 7 | createSingleServer, |
@@ -8,11 +9,10 @@ import { | |||
8 | PeerTubeServer, | 9 | PeerTubeServer, |
9 | setAccessTokensToServers, | 10 | setAccessTokensToServers, |
10 | setDefaultVideoChannel | 11 | setDefaultVideoChannel |
11 | } from '../../../../shared/extra-utils' | 12 | } from '@shared/extra-utils' |
12 | import { UserRole } from '../../../../shared/models/users' | 13 | import { UserRole } from '@shared/models' |
13 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
14 | 14 | ||
15 | async function testEndpoints (server: PeerTubeServer, token: string, filter: string, statusCodeExpected: HttpStatusCode) { | 15 | async function testEndpoints (server: PeerTubeServer, token: string, filter: string, expectedStatus: HttpStatusCode) { |
16 | const paths = [ | 16 | const paths = [ |
17 | '/api/v1/video-channels/root_channel/videos', | 17 | '/api/v1/video-channels/root_channel/videos', |
18 | '/api/v1/accounts/root/videos', | 18 | '/api/v1/accounts/root/videos', |
@@ -28,7 +28,7 @@ async function testEndpoints (server: PeerTubeServer, token: string, filter: str | |||
28 | query: { | 28 | query: { |
29 | filter | 29 | filter |
30 | }, | 30 | }, |
31 | statusCodeExpected | 31 | expectedStatus |
32 | }) | 32 | }) |
33 | } | 33 | } |
34 | } | 34 | } |
@@ -89,7 +89,7 @@ describe('Test video filters validators', function () { | |||
89 | await makeGetRequest({ | 89 | await makeGetRequest({ |
90 | url: server.url, | 90 | url: server.url, |
91 | path: '/feeds/videos.json', | 91 | path: '/feeds/videos.json', |
92 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401, | 92 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401, |
93 | query: { | 93 | query: { |
94 | filter | 94 | filter |
95 | } | 95 | } |
@@ -101,7 +101,7 @@ describe('Test video filters validators', function () { | |||
101 | await makeGetRequest({ | 101 | await makeGetRequest({ |
102 | url: server.url, | 102 | url: server.url, |
103 | path: '/feeds/videos.json', | 103 | path: '/feeds/videos.json', |
104 | statusCodeExpected: HttpStatusCode.OK_200, | 104 | expectedStatus: HttpStatusCode.OK_200, |
105 | query: { | 105 | query: { |
106 | filter: 'local' | 106 | filter: 'local' |
107 | } | 107 | } |
diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index 3c1f479e4..7283a4d28 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { | 5 | import { |
6 | checkBadCountPagination, | 6 | checkBadCountPagination, |
7 | checkBadStartPagination, | 7 | checkBadStartPagination, |
@@ -37,7 +37,7 @@ describe('Test videos history API validator', function () { | |||
37 | 37 | ||
38 | it('Should fail with an unauthenticated user', async function () { | 38 | it('Should fail with an unauthenticated user', async function () { |
39 | const fields = { currentTime: 5 } | 39 | const fields = { currentTime: 5 } |
40 | await makePutBodyRequest({ url: server.url, path: watchingPath, fields, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 40 | await makePutBodyRequest({ url: server.url, path: watchingPath, fields, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
41 | }) | 41 | }) |
42 | 42 | ||
43 | it('Should fail with an incorrect video id', async function () { | 43 | it('Should fail with an incorrect video id', async function () { |
@@ -48,7 +48,7 @@ describe('Test videos history API validator', function () { | |||
48 | path, | 48 | path, |
49 | fields, | 49 | fields, |
50 | token: server.accessToken, | 50 | token: server.accessToken, |
51 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 51 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
52 | }) | 52 | }) |
53 | }) | 53 | }) |
54 | 54 | ||
@@ -61,7 +61,7 @@ describe('Test videos history API validator', function () { | |||
61 | path, | 61 | path, |
62 | fields, | 62 | fields, |
63 | token: server.accessToken, | 63 | token: server.accessToken, |
64 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 64 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
65 | }) | 65 | }) |
66 | }) | 66 | }) |
67 | 67 | ||
@@ -72,7 +72,7 @@ describe('Test videos history API validator', function () { | |||
72 | path: watchingPath, | 72 | path: watchingPath, |
73 | fields, | 73 | fields, |
74 | token: server.accessToken, | 74 | token: server.accessToken, |
75 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 75 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
76 | }) | 76 | }) |
77 | }) | 77 | }) |
78 | 78 | ||
@@ -84,7 +84,7 @@ describe('Test videos history API validator', function () { | |||
84 | path: watchingPath, | 84 | path: watchingPath, |
85 | fields, | 85 | fields, |
86 | token: server.accessToken, | 86 | token: server.accessToken, |
87 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 87 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
88 | }) | 88 | }) |
89 | }) | 89 | }) |
90 | }) | 90 | }) |
@@ -99,17 +99,17 @@ describe('Test videos history API validator', function () { | |||
99 | }) | 99 | }) |
100 | 100 | ||
101 | it('Should fail with an unauthenticated user', async function () { | 101 | it('Should fail with an unauthenticated user', async function () { |
102 | await makeGetRequest({ url: server.url, path: myHistoryPath, statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 102 | await makeGetRequest({ url: server.url, path: myHistoryPath, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
103 | }) | 103 | }) |
104 | 104 | ||
105 | it('Should succeed with the correct params', async function () { | 105 | it('Should succeed with the correct params', async function () { |
106 | await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, statusCodeExpected: HttpStatusCode.OK_200 }) | 106 | await makeGetRequest({ url: server.url, token: server.accessToken, path: myHistoryPath, expectedStatus: HttpStatusCode.OK_200 }) |
107 | }) | 107 | }) |
108 | }) | 108 | }) |
109 | 109 | ||
110 | describe('When removing user videos history', function () { | 110 | describe('When removing user videos history', function () { |
111 | it('Should fail with an unauthenticated user', async function () { | 111 | it('Should fail with an unauthenticated user', async function () { |
112 | await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 }) | 112 | await makePostBodyRequest({ url: server.url, path: myHistoryPath + '/remove', expectedStatus: HttpStatusCode.UNAUTHORIZED_401 }) |
113 | }) | 113 | }) |
114 | 114 | ||
115 | it('Should fail with a bad beforeDate parameter', async function () { | 115 | it('Should fail with a bad beforeDate parameter', async function () { |
@@ -119,7 +119,7 @@ describe('Test videos history API validator', function () { | |||
119 | token: server.accessToken, | 119 | token: server.accessToken, |
120 | path: myHistoryRemove, | 120 | path: myHistoryRemove, |
121 | fields: body, | 121 | fields: body, |
122 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 122 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
123 | }) | 123 | }) |
124 | }) | 124 | }) |
125 | 125 | ||
@@ -130,7 +130,7 @@ describe('Test videos history API validator', function () { | |||
130 | token: server.accessToken, | 130 | token: server.accessToken, |
131 | path: myHistoryRemove, | 131 | path: myHistoryRemove, |
132 | fields: body, | 132 | fields: body, |
133 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 133 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
134 | }) | 134 | }) |
135 | }) | 135 | }) |
136 | 136 | ||
@@ -139,7 +139,7 @@ describe('Test videos history API validator', function () { | |||
139 | url: server.url, | 139 | url: server.url, |
140 | token: server.accessToken, | 140 | token: server.accessToken, |
141 | path: myHistoryRemove, | 141 | path: myHistoryRemove, |
142 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 142 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
143 | }) | 143 | }) |
144 | }) | 144 | }) |
145 | }) | 145 | }) |
diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index c60de2640..e11ca0c82 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts | |||
@@ -4,7 +4,7 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { HttpStatusCode, randomInt } from '@shared/core-utils' | 7 | import { randomInt } from '@shared/core-utils' |
8 | import { | 8 | import { |
9 | checkBadCountPagination, | 9 | checkBadCountPagination, |
10 | checkBadSortPagination, | 10 | checkBadSortPagination, |
@@ -16,11 +16,11 @@ import { | |||
16 | makeGetRequest, | 16 | makeGetRequest, |
17 | makePutBodyRequest, | 17 | makePutBodyRequest, |
18 | makeUploadRequest, | 18 | makeUploadRequest, |
19 | root, | ||
20 | PeerTubeServer, | 19 | PeerTubeServer, |
20 | root, | ||
21 | setAccessTokensToServers | 21 | setAccessTokensToServers |
22 | } from '@shared/extra-utils' | 22 | } from '@shared/extra-utils' |
23 | import { PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' | 23 | import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models' |
24 | 24 | ||
25 | const expect = chai.expect | 25 | const expect = chai.expect |
26 | 26 | ||
@@ -69,11 +69,11 @@ describe('Test videos API validator', function () { | |||
69 | }) | 69 | }) |
70 | 70 | ||
71 | it('Should fail with a bad skipVideos query', async function () { | 71 | it('Should fail with a bad skipVideos query', async function () { |
72 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: 'toto' } }) | 72 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: 'toto' } }) |
73 | }) | 73 | }) |
74 | 74 | ||
75 | it('Should success with the correct parameters', async function () { | 75 | it('Should success with the correct parameters', async function () { |
76 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200, query: { skipCount: false } }) | 76 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200, query: { skipCount: false } }) |
77 | }) | 77 | }) |
78 | }) | 78 | }) |
79 | 79 | ||
@@ -83,7 +83,7 @@ describe('Test videos API validator', function () { | |||
83 | await makeGetRequest({ | 83 | await makeGetRequest({ |
84 | url: server.url, | 84 | url: server.url, |
85 | path: join(path, 'search'), | 85 | path: join(path, 'search'), |
86 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 86 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
87 | }) | 87 | }) |
88 | }) | 88 | }) |
89 | 89 | ||
@@ -100,7 +100,7 @@ describe('Test videos API validator', function () { | |||
100 | }) | 100 | }) |
101 | 101 | ||
102 | it('Should success with the correct parameters', async function () { | 102 | it('Should success with the correct parameters', async function () { |
103 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) | 103 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 }) |
104 | }) | 104 | }) |
105 | }) | 105 | }) |
106 | 106 | ||
@@ -120,7 +120,7 @@ describe('Test videos API validator', function () { | |||
120 | }) | 120 | }) |
121 | 121 | ||
122 | it('Should success with the correct parameters', async function () { | 122 | it('Should success with the correct parameters', async function () { |
123 | await makeGetRequest({ url: server.url, token: server.accessToken, path, statusCodeExpected: HttpStatusCode.OK_200 }) | 123 | await makeGetRequest({ url: server.url, token: server.accessToken, path, expectedStatus: HttpStatusCode.OK_200 }) |
124 | }) | 124 | }) |
125 | }) | 125 | }) |
126 | 126 | ||
@@ -144,7 +144,7 @@ describe('Test videos API validator', function () { | |||
144 | }) | 144 | }) |
145 | 145 | ||
146 | it('Should success with the correct parameters', async function () { | 146 | it('Should success with the correct parameters', async function () { |
147 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) | 147 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 }) |
148 | }) | 148 | }) |
149 | }) | 149 | }) |
150 | 150 | ||
@@ -168,7 +168,7 @@ describe('Test videos API validator', function () { | |||
168 | }) | 168 | }) |
169 | 169 | ||
170 | it('Should success with the correct parameters', async function () { | 170 | it('Should success with the correct parameters', async function () { |
171 | await makeGetRequest({ url: server.url, path, statusCodeExpected: HttpStatusCode.OK_200 }) | 171 | await makeGetRequest({ url: server.url, path, expectedStatus: HttpStatusCode.OK_200 }) |
172 | }) | 172 | }) |
173 | }) | 173 | }) |
174 | 174 | ||
@@ -506,7 +506,7 @@ describe('Test videos API validator', function () { | |||
506 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', | 506 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06', |
507 | token: server.accessToken, | 507 | token: server.accessToken, |
508 | fields, | 508 | fields, |
509 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 509 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
510 | }) | 510 | }) |
511 | }) | 511 | }) |
512 | 512 | ||
@@ -660,7 +660,7 @@ describe('Test videos API validator', function () { | |||
660 | path: path + video.shortUUID, | 660 | path: path + video.shortUUID, |
661 | token: userAccessToken, | 661 | token: userAccessToken, |
662 | fields, | 662 | fields, |
663 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 663 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
664 | }) | 664 | }) |
665 | }) | 665 | }) |
666 | 666 | ||
@@ -692,7 +692,7 @@ describe('Test videos API validator', function () { | |||
692 | path: path + video.shortUUID, | 692 | path: path + video.shortUUID, |
693 | token: server.accessToken, | 693 | token: server.accessToken, |
694 | fields, | 694 | fields, |
695 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 695 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
696 | }) | 696 | }) |
697 | }) | 697 | }) |
698 | }) | 698 | }) |
@@ -702,7 +702,7 @@ describe('Test videos API validator', function () { | |||
702 | const res = await makeGetRequest({ | 702 | const res = await makeGetRequest({ |
703 | url: server.url, | 703 | url: server.url, |
704 | path, | 704 | path, |
705 | statusCodeExpected: HttpStatusCode.OK_200 | 705 | expectedStatus: HttpStatusCode.OK_200 |
706 | }) | 706 | }) |
707 | 707 | ||
708 | expect(res.body.data).to.be.an('array') | 708 | expect(res.body.data).to.be.an('array') |
@@ -762,7 +762,7 @@ describe('Test videos API validator', function () { | |||
762 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', | 762 | path: path + '4da6fde3-88f7-4d16-b119-108df5630b06/rate', |
763 | token: server.accessToken, | 763 | token: server.accessToken, |
764 | fields, | 764 | fields, |
765 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 765 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
766 | }) | 766 | }) |
767 | }) | 767 | }) |
768 | 768 | ||
@@ -782,7 +782,7 @@ describe('Test videos API validator', function () { | |||
782 | path: path + videoId + '/rate', | 782 | path: path + videoId + '/rate', |
783 | token: server.accessToken, | 783 | token: server.accessToken, |
784 | fields, | 784 | fields, |
785 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 785 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
786 | }) | 786 | }) |
787 | }) | 787 | }) |
788 | }) | 788 | }) |
@@ -792,7 +792,7 @@ describe('Test videos API validator', function () { | |||
792 | await makeDeleteRequest({ | 792 | await makeDeleteRequest({ |
793 | url: server.url, | 793 | url: server.url, |
794 | path, | 794 | path, |
795 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 795 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
796 | }) | 796 | }) |
797 | }) | 797 | }) |
798 | 798 | ||
@@ -812,7 +812,7 @@ describe('Test videos API validator', function () { | |||
812 | 812 | ||
813 | it('Shoud report the appropriate error', async function () { | 813 | it('Shoud report the appropriate error', async function () { |
814 | const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) | 814 | const body = await server.videos.remove({ id: 'hello', expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
815 | const error = body as unknown as PeerTubeProblemDocument | 815 | const error = body as PeerTubeProblemDocument |
816 | 816 | ||
817 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') | 817 | expect(error.docs).to.equal('https://docs.joinpeertube.org/api-rest-reference.html#operation/delVideo') |
818 | 818 | ||
diff --git a/server/tests/api/live/live-save-replay.ts b/server/tests/api/live/live-save-replay.ts index d403f27bf..095c51b97 100644 --- a/server/tests/api/live/live-save-replay.ts +++ b/server/tests/api/live/live-save-replay.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { FfmpegCommand } from 'fluent-ffmpeg' | 5 | import { FfmpegCommand } from 'fluent-ffmpeg' |
6 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { | 7 | import { |
8 | checkLiveCleanup, | 8 | checkLiveCleanup, |
9 | cleanupTests, | 9 | cleanupTests, |
diff --git a/server/tests/api/live/live.ts b/server/tests/api/live/live.ts index 7cfac522c..88995910c 100644 --- a/server/tests/api/live/live.ts +++ b/server/tests/api/live/live.ts | |||
@@ -4,7 +4,7 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' | 6 | import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { | 8 | import { |
9 | checkLiveCleanup, | 9 | checkLiveCleanup, |
10 | checkLiveSegmentHash, | 10 | checkLiveSegmentHash, |
diff --git a/server/tests/api/moderation/abuses.ts b/server/tests/api/moderation/abuses.ts index 360b9de35..8d6360eb3 100644 --- a/server/tests/api/moderation/abuses.ts +++ b/server/tests/api/moderation/abuses.ts | |||
@@ -5,8 +5,8 @@ import * as chai from 'chai' | |||
5 | import { | 5 | import { |
6 | AbusesCommand, | 6 | AbusesCommand, |
7 | cleanupTests, | 7 | cleanupTests, |
8 | doubleFollow, | ||
9 | createMultipleServers, | 8 | createMultipleServers, |
9 | doubleFollow, | ||
10 | PeerTubeServer, | 10 | PeerTubeServer, |
11 | setAccessTokensToServers, | 11 | setAccessTokensToServers, |
12 | waitJobs | 12 | waitJobs |
@@ -65,7 +65,7 @@ describe('Test abuses', function () { | |||
65 | expect(data.length).to.equal(2) | 65 | expect(data.length).to.equal(2) |
66 | 66 | ||
67 | servers[0].store.video = data.find(video => video.name === 'my super name for server 1') | 67 | servers[0].store.video = data.find(video => video.name === 'my super name for server 1') |
68 | servers[1].store.video = data.find(video => video.name === 'my super name for server 2') | 68 | servers[1].store.video = data.find(video => video.name === 'my super name for server 2') |
69 | }) | 69 | }) |
70 | 70 | ||
71 | it('Should not have abuses', async function () { | 71 | it('Should not have abuses', async function () { |
@@ -402,8 +402,8 @@ describe('Test abuses', function () { | |||
402 | before(async function () { | 402 | before(async function () { |
403 | this.timeout(50000) | 403 | this.timeout(50000) |
404 | 404 | ||
405 | servers[0].store.video = await await servers[0].videos.quickUpload({ name: 'server 1' }) | 405 | servers[0].store.video = await servers[0].videos.quickUpload({ name: 'server 1' }) |
406 | servers[1].store.video = await await servers[1].videos.quickUpload({ name: 'server 2' }) | 406 | servers[1].store.video = await servers[1].videos.quickUpload({ name: 'server 2' }) |
407 | 407 | ||
408 | await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' }) | 408 | await servers[0].comments.createThread({ videoId: servers[0].store.video.id, text: 'comment server 1' }) |
409 | await servers[1].comments.createThread({ videoId: servers[1].store.video.id, text: 'comment server 2' }) | 409 | await servers[1].comments.createThread({ videoId: servers[1].store.video.id, text: 'comment server 2' }) |
diff --git a/server/tests/api/redundancy/redundancy-constraints.ts b/server/tests/api/redundancy/redundancy-constraints.ts index 217691fb6..71b93901e 100644 --- a/server/tests/api/redundancy/redundancy-constraints.ts +++ b/server/tests/api/redundancy/redundancy-constraints.ts | |||
@@ -117,7 +117,7 @@ describe('Test redundancy constraints', function () { | |||
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | await await killallServers([ localServer ]) | 120 | await killallServers([ localServer ]) |
121 | await localServer.run(config) | 121 | await localServer.run(config) |
122 | 122 | ||
123 | await uploadWrapper('video 2 server 2') | 123 | await uploadWrapper('video 2 server 2') |
diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 9d5d96efd..921a48856 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts | |||
@@ -5,7 +5,7 @@ import * as chai from 'chai' | |||
5 | import { readdir } from 'fs-extra' | 5 | import { readdir } from 'fs-extra' |
6 | import * as magnetUtil from 'magnet-uri' | 6 | import * as magnetUtil from 'magnet-uri' |
7 | import { join } from 'path' | 7 | import { join } from 'path' |
8 | import { HttpStatusCode } from '@shared/core-utils' | 8 | import { HttpStatusCode } from '@shared/models' |
9 | import { | 9 | import { |
10 | checkSegmentHash, | 10 | checkSegmentHash, |
11 | checkVideoFilesWereRemoved, | 11 | checkVideoFilesWereRemoved, |
@@ -129,13 +129,13 @@ async function check2Webseeds (videoUUID?: string) { | |||
129 | 129 | ||
130 | await makeGetRequest({ | 130 | await makeGetRequest({ |
131 | url: servers[0].url, | 131 | url: servers[0].url, |
132 | statusCodeExpected: HttpStatusCode.OK_200, | 132 | expectedStatus: HttpStatusCode.OK_200, |
133 | path: '/static/redundancy/' + `${videoUUID}-${file.resolution.id}.mp4`, | 133 | path: '/static/redundancy/' + `${videoUUID}-${file.resolution.id}.mp4`, |
134 | contentType: null | 134 | contentType: null |
135 | }) | 135 | }) |
136 | await makeGetRequest({ | 136 | await makeGetRequest({ |
137 | url: servers[1].url, | 137 | url: servers[1].url, |
138 | statusCodeExpected: HttpStatusCode.OK_200, | 138 | expectedStatus: HttpStatusCode.OK_200, |
139 | path: `/static/webseed/${videoUUID}-${file.resolution.id}.mp4`, | 139 | path: `/static/webseed/${videoUUID}-${file.resolution.id}.mp4`, |
140 | contentType: null | 140 | contentType: null |
141 | }) | 141 | }) |
diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index f5896ec25..b33f28266 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts | |||
@@ -149,7 +149,7 @@ describe('Test ActivityPub video channels search', function () { | |||
149 | 149 | ||
150 | const { total, data } = await servers[0].videos.listByChannel({ | 150 | const { total, data } = await servers[0].videos.listByChannel({ |
151 | token: null, | 151 | token: null, |
152 | videoChannelName: 'channel1_server2@localhost:' + servers[1].port | 152 | handle: 'channel1_server2@localhost:' + servers[1].port |
153 | }) | 153 | }) |
154 | expect(total).to.equal(0) | 154 | expect(total).to.equal(0) |
155 | expect(data).to.have.lengthOf(0) | 155 | expect(data).to.have.lengthOf(0) |
@@ -157,7 +157,7 @@ describe('Test ActivityPub video channels search', function () { | |||
157 | 157 | ||
158 | it('Should list video channel videos of server 2 with token', async function () { | 158 | it('Should list video channel videos of server 2 with token', async function () { |
159 | const { total, data } = await servers[0].videos.listByChannel({ | 159 | const { total, data } = await servers[0].videos.listByChannel({ |
160 | videoChannelName: 'channel1_server2@localhost:' + servers[1].port | 160 | handle: 'channel1_server2@localhost:' + servers[1].port |
161 | }) | 161 | }) |
162 | 162 | ||
163 | expect(total).to.equal(1) | 163 | expect(total).to.equal(1) |
@@ -206,8 +206,8 @@ describe('Test ActivityPub video channels search', function () { | |||
206 | 206 | ||
207 | await waitJobs(servers) | 207 | await waitJobs(servers) |
208 | 208 | ||
209 | const videoChannelName = 'channel1_server2@localhost:' + servers[1].port | 209 | const handle = 'channel1_server2@localhost:' + servers[1].port |
210 | const { total, data } = await servers[0].videos.listByChannel({ videoChannelName, sort: '-createdAt' }) | 210 | const { total, data } = await servers[0].videos.listByChannel({ handle, sort: '-createdAt' }) |
211 | 211 | ||
212 | expect(total).to.equal(2) | 212 | expect(total).to.equal(2) |
213 | expect(data[0].name).to.equal('video 2 server 2') | 213 | expect(data[0].name).to.equal('video 2 server 2') |
diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index a7191c5ef..a1c2f0f39 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
@@ -498,7 +498,7 @@ describe('Test config', function () { | |||
498 | const res = await makeGetRequest({ | 498 | const res = await makeGetRequest({ |
499 | url: server.url, | 499 | url: server.url, |
500 | path: '/api/v1/config', | 500 | path: '/api/v1/config', |
501 | statusCodeExpected: 200 | 501 | expectedStatus: 200 |
502 | }) | 502 | }) |
503 | 503 | ||
504 | expect(res.headers['x-frame-options']).to.exist | 504 | expect(res.headers['x-frame-options']).to.exist |
@@ -517,7 +517,7 @@ describe('Test config', function () { | |||
517 | const res = await makeGetRequest({ | 517 | const res = await makeGetRequest({ |
518 | url: server.url, | 518 | url: server.url, |
519 | path: '/api/v1/config', | 519 | path: '/api/v1/config', |
520 | statusCodeExpected: 200 | 520 | expectedStatus: 200 |
521 | }) | 521 | }) |
522 | 522 | ||
523 | expect(res.headers['x-frame-options']).to.not.exist | 523 | expect(res.headers['x-frame-options']).to.not.exist |
diff --git a/server/tests/api/server/contact-form.ts b/server/tests/api/server/contact-form.ts index f0905bb3b..fc5d0ad6a 100644 --- a/server/tests/api/server/contact-form.ts +++ b/server/tests/api/server/contact-form.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | ContactFormCommand, | 8 | ContactFormCommand, |
diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index b202cf8a7..4c5b296ee 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 6 | import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' |
7 | 7 | ||
8 | const expect = chai.expect | 8 | const expect = chai.expect |
diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts index 4ed593b76..bd7b215db 100644 --- a/server/tests/api/server/follow-constraints.ts +++ b/server/tests/api/server/follow-constraints.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 6 | import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' |
7 | import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' | 7 | import { PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' |
8 | 8 | ||
@@ -54,30 +54,30 @@ describe('Test follow constraints', function () { | |||
54 | }) | 54 | }) |
55 | 55 | ||
56 | it('Should list local account videos', async function () { | 56 | it('Should list local account videos', async function () { |
57 | const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[0].port }) | 57 | const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[0].port }) |
58 | 58 | ||
59 | expect(total).to.equal(1) | 59 | expect(total).to.equal(1) |
60 | expect(data).to.have.lengthOf(1) | 60 | expect(data).to.have.lengthOf(1) |
61 | }) | 61 | }) |
62 | 62 | ||
63 | it('Should list remote account videos', async function () { | 63 | it('Should list remote account videos', async function () { |
64 | const { total, data } = await servers[0].videos.listByAccount({ accountName: 'root@localhost:' + servers[1].port }) | 64 | const { total, data } = await servers[0].videos.listByAccount({ handle: 'root@localhost:' + servers[1].port }) |
65 | 65 | ||
66 | expect(total).to.equal(1) | 66 | expect(total).to.equal(1) |
67 | expect(data).to.have.lengthOf(1) | 67 | expect(data).to.have.lengthOf(1) |
68 | }) | 68 | }) |
69 | 69 | ||
70 | it('Should list local channel videos', async function () { | 70 | it('Should list local channel videos', async function () { |
71 | const videoChannelName = 'root_channel@localhost:' + servers[0].port | 71 | const handle = 'root_channel@localhost:' + servers[0].port |
72 | const { total, data } = await servers[0].videos.listByChannel({ videoChannelName }) | 72 | const { total, data } = await servers[0].videos.listByChannel({ handle }) |
73 | 73 | ||
74 | expect(total).to.equal(1) | 74 | expect(total).to.equal(1) |
75 | expect(data).to.have.lengthOf(1) | 75 | expect(data).to.have.lengthOf(1) |
76 | }) | 76 | }) |
77 | 77 | ||
78 | it('Should list remote channel videos', async function () { | 78 | it('Should list remote channel videos', async function () { |
79 | const videoChannelName = 'root_channel@localhost:' + servers[1].port | 79 | const handle = 'root_channel@localhost:' + servers[1].port |
80 | const { total, data } = await servers[0].videos.listByChannel({ videoChannelName }) | 80 | const { total, data } = await servers[0].videos.listByChannel({ handle }) |
81 | 81 | ||
82 | expect(total).to.equal(1) | 82 | expect(total).to.equal(1) |
83 | expect(data).to.have.lengthOf(1) | 83 | expect(data).to.have.lengthOf(1) |
@@ -94,30 +94,30 @@ describe('Test follow constraints', function () { | |||
94 | }) | 94 | }) |
95 | 95 | ||
96 | it('Should list local account videos', async function () { | 96 | it('Should list local account videos', async function () { |
97 | const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port }) | 97 | const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port }) |
98 | 98 | ||
99 | expect(total).to.equal(1) | 99 | expect(total).to.equal(1) |
100 | expect(data).to.have.lengthOf(1) | 100 | expect(data).to.have.lengthOf(1) |
101 | }) | 101 | }) |
102 | 102 | ||
103 | it('Should list remote account videos', async function () { | 103 | it('Should list remote account videos', async function () { |
104 | const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port }) | 104 | const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port }) |
105 | 105 | ||
106 | expect(total).to.equal(1) | 106 | expect(total).to.equal(1) |
107 | expect(data).to.have.lengthOf(1) | 107 | expect(data).to.have.lengthOf(1) |
108 | }) | 108 | }) |
109 | 109 | ||
110 | it('Should list local channel videos', async function () { | 110 | it('Should list local channel videos', async function () { |
111 | const videoChannelName = 'root_channel@localhost:' + servers[0].port | 111 | const handle = 'root_channel@localhost:' + servers[0].port |
112 | const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName }) | 112 | const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle }) |
113 | 113 | ||
114 | expect(total).to.equal(1) | 114 | expect(total).to.equal(1) |
115 | expect(data).to.have.lengthOf(1) | 115 | expect(data).to.have.lengthOf(1) |
116 | }) | 116 | }) |
117 | 117 | ||
118 | it('Should list remote channel videos', async function () { | 118 | it('Should list remote channel videos', async function () { |
119 | const videoChannelName = 'root_channel@localhost:' + servers[1].port | 119 | const handle = 'root_channel@localhost:' + servers[1].port |
120 | const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName }) | 120 | const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle }) |
121 | 121 | ||
122 | expect(total).to.equal(1) | 122 | expect(total).to.equal(1) |
123 | expect(data).to.have.lengthOf(1) | 123 | expect(data).to.have.lengthOf(1) |
@@ -158,7 +158,7 @@ describe('Test follow constraints', function () { | |||
158 | it('Should list local account videos', async function () { | 158 | it('Should list local account videos', async function () { |
159 | const { total, data } = await servers[0].videos.listByAccount({ | 159 | const { total, data } = await servers[0].videos.listByAccount({ |
160 | token: undefined, | 160 | token: undefined, |
161 | accountName: 'root@localhost:' + servers[0].port | 161 | handle: 'root@localhost:' + servers[0].port |
162 | }) | 162 | }) |
163 | 163 | ||
164 | expect(total).to.equal(1) | 164 | expect(total).to.equal(1) |
@@ -168,7 +168,7 @@ describe('Test follow constraints', function () { | |||
168 | it('Should not list remote account videos', async function () { | 168 | it('Should not list remote account videos', async function () { |
169 | const { total, data } = await servers[0].videos.listByAccount({ | 169 | const { total, data } = await servers[0].videos.listByAccount({ |
170 | token: undefined, | 170 | token: undefined, |
171 | accountName: 'root@localhost:' + servers[1].port | 171 | handle: 'root@localhost:' + servers[1].port |
172 | }) | 172 | }) |
173 | 173 | ||
174 | expect(total).to.equal(0) | 174 | expect(total).to.equal(0) |
@@ -176,16 +176,16 @@ describe('Test follow constraints', function () { | |||
176 | }) | 176 | }) |
177 | 177 | ||
178 | it('Should list local channel videos', async function () { | 178 | it('Should list local channel videos', async function () { |
179 | const videoChannelName = 'root_channel@localhost:' + servers[0].port | 179 | const handle = 'root_channel@localhost:' + servers[0].port |
180 | const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName }) | 180 | const { total, data } = await servers[0].videos.listByChannel({ token: undefined, handle }) |
181 | 181 | ||
182 | expect(total).to.equal(1) | 182 | expect(total).to.equal(1) |
183 | expect(data).to.have.lengthOf(1) | 183 | expect(data).to.have.lengthOf(1) |
184 | }) | 184 | }) |
185 | 185 | ||
186 | it('Should not list remote channel videos', async function () { | 186 | it('Should not list remote channel videos', async function () { |
187 | const videoChannelName = 'root_channel@localhost:' + servers[1].port | 187 | const handle = 'root_channel@localhost:' + servers[1].port |
188 | const { total, data } = await servers[0].videos.listByChannel({ token: undefined, videoChannelName }) | 188 | const { total, data } = await servers[0].videos.listByChannel({ token: undefined, handle }) |
189 | 189 | ||
190 | expect(total).to.equal(0) | 190 | expect(total).to.equal(0) |
191 | expect(data).to.have.lengthOf(0) | 191 | expect(data).to.have.lengthOf(0) |
@@ -202,30 +202,30 @@ describe('Test follow constraints', function () { | |||
202 | }) | 202 | }) |
203 | 203 | ||
204 | it('Should list local account videos', async function () { | 204 | it('Should list local account videos', async function () { |
205 | const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[0].port }) | 205 | const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[0].port }) |
206 | 206 | ||
207 | expect(total).to.equal(1) | 207 | expect(total).to.equal(1) |
208 | expect(data).to.have.lengthOf(1) | 208 | expect(data).to.have.lengthOf(1) |
209 | }) | 209 | }) |
210 | 210 | ||
211 | it('Should list remote account videos', async function () { | 211 | it('Should list remote account videos', async function () { |
212 | const { total, data } = await servers[0].videos.listByAccount({ token: userToken, accountName: 'root@localhost:' + servers[1].port }) | 212 | const { total, data } = await servers[0].videos.listByAccount({ token: userToken, handle: 'root@localhost:' + servers[1].port }) |
213 | 213 | ||
214 | expect(total).to.equal(1) | 214 | expect(total).to.equal(1) |
215 | expect(data).to.have.lengthOf(1) | 215 | expect(data).to.have.lengthOf(1) |
216 | }) | 216 | }) |
217 | 217 | ||
218 | it('Should list local channel videos', async function () { | 218 | it('Should list local channel videos', async function () { |
219 | const videoChannelName = 'root_channel@localhost:' + servers[0].port | 219 | const handle = 'root_channel@localhost:' + servers[0].port |
220 | const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName }) | 220 | const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle }) |
221 | 221 | ||
222 | expect(total).to.equal(1) | 222 | expect(total).to.equal(1) |
223 | expect(data).to.have.lengthOf(1) | 223 | expect(data).to.have.lengthOf(1) |
224 | }) | 224 | }) |
225 | 225 | ||
226 | it('Should list remote channel videos', async function () { | 226 | it('Should list remote channel videos', async function () { |
227 | const videoChannelName = 'root_channel@localhost:' + servers[1].port | 227 | const handle = 'root_channel@localhost:' + servers[1].port |
228 | const { total, data } = await servers[0].videos.listByChannel({ token: userToken, videoChannelName }) | 228 | const { total, data } = await servers[0].videos.listByChannel({ token: userToken, handle }) |
229 | 229 | ||
230 | expect(total).to.equal(1) | 230 | expect(total).to.equal(1) |
231 | expect(data).to.have.lengthOf(1) | 231 | expect(data).to.have.lengthOf(1) |
diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index 5f20b0093..d22e843e0 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | CommentsCommand, | 8 | CommentsCommand, |
diff --git a/server/tests/api/server/homepage.ts b/server/tests/api/server/homepage.ts index c291037f2..7eae3df20 100644 --- a/server/tests/api/server/homepage.ts +++ b/server/tests/api/server/homepage.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | CustomPagesCommand, | 8 | CustomPagesCommand, |
diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts index f45222f2f..efa890ad4 100644 --- a/server/tests/api/server/no-client.ts +++ b/server/tests/api/server/no-client.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | import 'mocha' | 1 | import 'mocha' |
2 | import * as request from 'supertest' | 2 | import * as request from 'supertest' |
3 | import { PeerTubeServer } from '../../../../shared/extra-utils' | 3 | import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/extra-utils' |
4 | import { cleanupTests, createSingleServer } from '../../../../shared/extra-utils/server/servers' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | ||
6 | 5 | ||
7 | describe('Start and stop server without web client routes', function () { | 6 | describe('Start and stop server without web client routes', function () { |
8 | let server: PeerTubeServer | 7 | let server: PeerTubeServer |
diff --git a/server/tests/api/server/plugins.ts b/server/tests/api/server/plugins.ts index db03d026a..334adfe9d 100644 --- a/server/tests/api/server/plugins.ts +++ b/server/tests/api/server/plugins.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts index c20b7a5f0..13b22bc0e 100644 --- a/server/tests/api/server/reverse-proxy.ts +++ b/server/tests/api/server/reverse-proxy.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { expect } from 'chai' | 3 | import { expect } from 'chai' |
4 | import { HttpStatusCode } from '@shared/core-utils' | 4 | import { HttpStatusCode } from '@shared/models' |
5 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' | 5 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' |
6 | 6 | ||
7 | describe('Test application behind a reverse proxy', function () { | 7 | 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 e629966bb..e304e5d67 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts | |||
@@ -131,7 +131,7 @@ describe('Test users with multiple servers', function () { | |||
131 | 131 | ||
132 | it('Should list account videos', async function () { | 132 | it('Should list account videos', async function () { |
133 | for (const server of servers) { | 133 | for (const server of servers) { |
134 | const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port }) | 134 | const { total, data } = await server.videos.listByAccount({ handle: 'user1@localhost:' + servers[0].port }) |
135 | 135 | ||
136 | expect(total).to.equal(1) | 136 | expect(total).to.equal(1) |
137 | expect(data).to.be.an('array') | 137 | expect(data).to.be.an('array') |
@@ -148,7 +148,7 @@ describe('Test users with multiple servers', function () { | |||
148 | await waitJobs(servers) | 148 | await waitJobs(servers) |
149 | 149 | ||
150 | for (const server of servers) { | 150 | for (const server of servers) { |
151 | const { total, data } = await server.videos.listByAccount({ accountName: 'user1@localhost:' + servers[0].port, search: 'Kami' }) | 151 | const { total, data } = await server.videos.listByAccount({ handle: 'user1@localhost:' + servers[0].port, search: 'Kami' }) |
152 | 152 | ||
153 | expect(total).to.equal(1) | 153 | expect(total).to.equal(1) |
154 | expect(data).to.be.an('array') | 154 | expect(data).to.be.an('array') |
diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts index 5dbe2af59..56fc25048 100644 --- a/server/tests/api/users/users-verification.ts +++ b/server/tests/api/users/users-verification.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 6 | import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' |
7 | 7 | ||
8 | const expect = chai.expect | 8 | const expect = chai.expect |
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 6ae5410b3..be80c2616 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
@@ -215,7 +215,7 @@ describe('Test users', function () { | |||
215 | path: path + videoId, | 215 | path: path + videoId, |
216 | token: 'wrong token', | 216 | token: 'wrong token', |
217 | fields: data, | 217 | fields: data, |
218 | statusCodeExpected: HttpStatusCode.UNAUTHORIZED_401 | 218 | expectedStatus: HttpStatusCode.UNAUTHORIZED_401 |
219 | } | 219 | } |
220 | await makePutBodyRequest(options) | 220 | await makePutBodyRequest(options) |
221 | }) | 221 | }) |
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index 562079a15..edf2773cd 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import * as request from 'supertest' | 5 | import * as request from 'supertest' |
6 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { | 7 | import { |
8 | buildAbsoluteFixturePath, | 8 | buildAbsoluteFixturePath, |
9 | checkTmpIsEmpty, | 9 | checkTmpIsEmpty, |
diff --git a/server/tests/api/videos/resumable-upload.ts b/server/tests/api/videos/resumable-upload.ts index b4fc5ee09..0e62972c2 100644 --- a/server/tests/api/videos/resumable-upload.ts +++ b/server/tests/api/videos/resumable-upload.ts | |||
@@ -4,7 +4,7 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { pathExists, readdir, stat } from 'fs-extra' | 5 | import { pathExists, readdir, stat } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { | 8 | import { |
9 | buildAbsoluteFixturePath, | 9 | buildAbsoluteFixturePath, |
10 | cleanupTests, | 10 | cleanupTests, |
diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index cefddb68e..792550101 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | ChangeOwnershipCommand, | 7 | ChangeOwnershipCommand, |
8 | cleanupTests, | 8 | cleanupTests, |
diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 140fee7fe..eeaec5ad2 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts | |||
@@ -324,7 +324,7 @@ describe('Test video channels', function () { | |||
324 | 324 | ||
325 | for (const server of servers) { | 325 | for (const server of servers) { |
326 | const channelURI = 'second_video_channel@localhost:' + servers[0].port | 326 | const channelURI = 'second_video_channel@localhost:' + servers[0].port |
327 | const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI }) | 327 | const { total, data } = await server.videos.listByChannel({ handle: channelURI }) |
328 | 328 | ||
329 | expect(total).to.equal(1) | 329 | expect(total).to.equal(1) |
330 | expect(data).to.be.an('array') | 330 | expect(data).to.be.an('array') |
@@ -347,13 +347,13 @@ describe('Test video channels', function () { | |||
347 | for (const server of servers) { | 347 | for (const server of servers) { |
348 | { | 348 | { |
349 | const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port | 349 | const secondChannelURI = 'second_video_channel@localhost:' + servers[0].port |
350 | const { total } = await server.videos.listByChannel({ videoChannelName: secondChannelURI }) | 350 | const { total } = await server.videos.listByChannel({ handle: secondChannelURI }) |
351 | expect(total).to.equal(0) | 351 | expect(total).to.equal(0) |
352 | } | 352 | } |
353 | 353 | ||
354 | { | 354 | { |
355 | const channelURI = 'root_channel@localhost:' + servers[0].port | 355 | const channelURI = 'root_channel@localhost:' + servers[0].port |
356 | const { total, data } = await server.videos.listByChannel({ videoChannelName: channelURI }) | 356 | const { total, data } = await server.videos.listByChannel({ handle: channelURI }) |
357 | expect(total).to.equal(1) | 357 | expect(total).to.equal(1) |
358 | 358 | ||
359 | expect(data).to.be.an('array') | 359 | expect(data).to.be.an('array') |
diff --git a/server/tests/api/videos/video-hls.ts b/server/tests/api/videos/video-hls.ts index 4c4b18887..df030110b 100644 --- a/server/tests/api/videos/video-hls.ts +++ b/server/tests/api/videos/video-hls.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { | 7 | import { |
8 | checkDirectoryIsEmpty, | 8 | checkDirectoryIsEmpty, |
9 | checkResolutionsInMasterPlaylist, | 9 | checkResolutionsInMasterPlaylist, |
diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index b25dcda20..0a9e5ce3f 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts | |||
@@ -19,8 +19,10 @@ describe('Test video NSFW policy', function () { | |||
19 | 19 | ||
20 | async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) { | 20 | async function getVideosFunctions (token?: string, query: { nsfw?: BooleanBothQuery } = {}) { |
21 | const user = await server.users.getMyInfo() | 21 | const user = await server.users.getMyInfo() |
22 | const videoChannelName = user.videoChannels[0].name | 22 | |
23 | const channelName = user.videoChannels[0].name | ||
23 | const accountName = user.account.name + '@' + user.account.host | 24 | const accountName = user.account.name + '@' + user.account.host |
25 | |||
24 | const hasQuery = Object.keys(query).length !== 0 | 26 | const hasQuery = Object.keys(query).length !== 0 |
25 | let promises: Promise<ResultList<Video>>[] | 27 | let promises: Promise<ResultList<Video>>[] |
26 | 28 | ||
@@ -28,8 +30,8 @@ describe('Test video NSFW policy', function () { | |||
28 | promises = [ | 30 | promises = [ |
29 | server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }), | 31 | server.search.advancedVideoSearch({ token, search: { search: 'n', sort: '-publishedAt', ...query } }), |
30 | server.videos.listWithToken({ token, ...query }), | 32 | server.videos.listWithToken({ token, ...query }), |
31 | server.videos.listByAccount({ token, accountName, ...query }), | 33 | server.videos.listByAccount({ token, handle: channelName, ...query }), |
32 | server.videos.listByChannel({ token, videoChannelName, ...query }) | 34 | server.videos.listByChannel({ token, handle: accountName, ...query }) |
33 | ] | 35 | ] |
34 | 36 | ||
35 | // Overviews do not support video filters | 37 | // Overviews do not support video filters |
@@ -45,8 +47,8 @@ describe('Test video NSFW policy', function () { | |||
45 | promises = [ | 47 | promises = [ |
46 | server.search.searchVideos({ search: 'n', sort: '-publishedAt' }), | 48 | server.search.searchVideos({ search: 'n', sort: '-publishedAt' }), |
47 | server.videos.list(), | 49 | server.videos.list(), |
48 | server.videos.listByAccount({ accountName }), | 50 | server.videos.listByAccount({ handle: channelName }), |
49 | server.videos.listByChannel({ videoChannelName }) | 51 | server.videos.listByChannel({ handle: accountName }) |
50 | ] | 52 | ] |
51 | 53 | ||
52 | // Overviews do not support video filters | 54 | // Overviews do not support video filters |
diff --git a/server/tests/api/videos/video-playlists.ts b/server/tests/api/videos/video-playlists.ts index 71ca3e63a..9a28a421a 100644 --- a/server/tests/api/videos/video-playlists.ts +++ b/server/tests/api/videos/video-playlists.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | checkPlaylistFilesWereRemoved, | 7 | checkPlaylistFilesWereRemoved, |
8 | cleanupTests, | 8 | cleanupTests, |
diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index 5ec626155..06011082d 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, doubleFollow, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' | 6 | import { cleanupTests, doubleFollow, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' |
7 | import { VideoCreateResult, VideoPrivacy } from '@shared/models' | 7 | import { VideoCreateResult, VideoPrivacy } from '@shared/models' |
8 | 8 | ||
diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 2465d2d89..7510472e3 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts | |||
@@ -4,7 +4,7 @@ import 'mocha' | |||
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { | 8 | import { |
9 | buildAbsoluteFixturePath, | 9 | buildAbsoluteFixturePath, |
10 | cleanupTests, | 10 | cleanupTests, |
@@ -384,8 +384,8 @@ describe('Test video transcoding', function () { | |||
384 | 384 | ||
385 | expect(videoDetails.files).to.have.lengthOf(1) | 385 | expect(videoDetails.files).to.have.lengthOf(1) |
386 | 386 | ||
387 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 }) | 387 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 }) |
388 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 }) | 388 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: HttpStatusCode.OK_200 }) |
389 | 389 | ||
390 | const magnetUri = videoDetails.files[0].magnetUri | 390 | const magnetUri = videoDetails.files[0].magnetUri |
391 | expect(magnetUri).to.contain('.mp4') | 391 | expect(magnetUri).to.contain('.mp4') |
@@ -408,8 +408,8 @@ describe('Test video transcoding', function () { | |||
408 | 408 | ||
409 | expect(videoDetails.files).to.have.lengthOf(1) | 409 | expect(videoDetails.files).to.have.lengthOf(1) |
410 | 410 | ||
411 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, statusCodeExpected: HttpStatusCode.OK_200 }) | 411 | await makeGetRequest({ url: server.url, path: videoDetails.thumbnailPath, expectedStatus: HttpStatusCode.OK_200 }) |
412 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, statusCodeExpected: HttpStatusCode.OK_200 }) | 412 | await makeGetRequest({ url: server.url, path: videoDetails.previewPath, expectedStatus: HttpStatusCode.OK_200 }) |
413 | 413 | ||
414 | const magnetUri = videoDetails.files[0].magnetUri | 414 | const magnetUri = videoDetails.files[0].magnetUri |
415 | expect(magnetUri).to.contain('.mp4') | 415 | expect(magnetUri).to.contain('.mp4') |
diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts index db9150655..88dff3e7f 100644 --- a/server/tests/api/videos/videos-filter.ts +++ b/server/tests/api/videos/videos-filter.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | doubleFollow, | 8 | doubleFollow, |
@@ -13,7 +13,7 @@ import { | |||
13 | } from '@shared/extra-utils' | 13 | } from '@shared/extra-utils' |
14 | import { UserRole, Video, VideoPrivacy } from '@shared/models' | 14 | import { UserRole, Video, VideoPrivacy } from '@shared/models' |
15 | 15 | ||
16 | async function getVideosNames (server: PeerTubeServer, token: string, filter: string, statusCodeExpected = HttpStatusCode.OK_200) { | 16 | async function getVideosNames (server: PeerTubeServer, token: string, filter: string, expectedStatus = HttpStatusCode.OK_200) { |
17 | const paths = [ | 17 | const paths = [ |
18 | '/api/v1/video-channels/root_channel/videos', | 18 | '/api/v1/video-channels/root_channel/videos', |
19 | '/api/v1/accounts/root/videos', | 19 | '/api/v1/accounts/root/videos', |
@@ -32,7 +32,7 @@ async function getVideosNames (server: PeerTubeServer, token: string, filter: st | |||
32 | sort: 'createdAt', | 32 | sort: 'createdAt', |
33 | filter | 33 | filter |
34 | }, | 34 | }, |
35 | statusCodeExpected | 35 | expectedStatus |
36 | }) | 36 | }) |
37 | 37 | ||
38 | videosResults.push(res.body.data.map(v => v.name)) | 38 | videosResults.push(res.body.data.map(v => v.name)) |
diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index 55e53cb94..acb9d1a46 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
diff --git a/server/tests/cli/prune-storage.ts b/server/tests/cli/prune-storage.ts index 5bf86462b..2bd4a466b 100644 --- a/server/tests/cli/prune-storage.ts +++ b/server/tests/cli/prune-storage.ts | |||
@@ -5,7 +5,7 @@ import * as chai from 'chai' | |||
5 | import { createFile, readdir } from 'fs-extra' | 5 | import { createFile, readdir } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { buildUUID } from '@server/helpers/uuid' | 7 | import { buildUUID } from '@server/helpers/uuid' |
8 | import { HttpStatusCode } from '@shared/core-utils' | 8 | import { HttpStatusCode } from '@shared/models' |
9 | import { | 9 | import { |
10 | cleanupTests, | 10 | cleanupTests, |
11 | CLICommand, | 11 | CLICommand, |
@@ -91,7 +91,7 @@ describe('Test prune storage scripts', function () { | |||
91 | await makeGetRequest({ | 91 | await makeGetRequest({ |
92 | url: servers[0].url, | 92 | url: servers[0].url, |
93 | path: account.avatar.path, | 93 | path: account.avatar.path, |
94 | statusCodeExpected: HttpStatusCode.OK_200 | 94 | expectedStatus: HttpStatusCode.OK_200 |
95 | }) | 95 | }) |
96 | } | 96 | } |
97 | 97 | ||
@@ -100,7 +100,7 @@ describe('Test prune storage scripts', function () { | |||
100 | await makeGetRequest({ | 100 | await makeGetRequest({ |
101 | url: servers[1].url, | 101 | url: servers[1].url, |
102 | path: account.avatar.path, | 102 | path: account.avatar.path, |
103 | statusCodeExpected: HttpStatusCode.OK_200 | 103 | expectedStatus: HttpStatusCode.OK_200 |
104 | }) | 104 | }) |
105 | } | 105 | } |
106 | 106 | ||
diff --git a/server/tests/cli/regenerate-thumbnails.ts b/server/tests/cli/regenerate-thumbnails.ts index d532a5c2b..595d842ef 100644 --- a/server/tests/cli/regenerate-thumbnails.ts +++ b/server/tests/cli/regenerate-thumbnails.ts | |||
@@ -2,7 +2,7 @@ import 'mocha' | |||
2 | import { expect } from 'chai' | 2 | import { expect } from 'chai' |
3 | import { writeFile } from 'fs-extra' | 3 | import { writeFile } from 'fs-extra' |
4 | import { basename, join } from 'path' | 4 | import { basename, join } from 'path' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { Video } from '@shared/models' | 6 | import { Video } from '@shared/models' |
7 | import { | 7 | import { |
8 | cleanupTests, | 8 | cleanupTests, |
diff --git a/server/tests/client.ts b/server/tests/client.ts index 959b34653..6255c6961 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { omit } from 'lodash' | 5 | import { omit } from 'lodash' |
6 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { Account, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models' | 7 | import { Account, HTMLServerConfig, ServerConfig, VideoPlaylistCreateResult, VideoPlaylistPrivacy } from '@shared/models' |
8 | import { | 8 | import { |
9 | cleanupTests, | 9 | cleanupTests, |
@@ -114,7 +114,7 @@ describe('Test a client controllers', function () { | |||
114 | url: servers[0].url, | 114 | url: servers[0].url, |
115 | path: basePath + id, | 115 | path: basePath + id, |
116 | accept: 'text/html', | 116 | accept: 'text/html', |
117 | statusCodeExpected: HttpStatusCode.OK_200 | 117 | expectedStatus: HttpStatusCode.OK_200 |
118 | }) | 118 | }) |
119 | 119 | ||
120 | const port = servers[0].port | 120 | const port = servers[0].port |
@@ -135,7 +135,7 @@ describe('Test a client controllers', function () { | |||
135 | url: servers[0].url, | 135 | url: servers[0].url, |
136 | path: basePath + id, | 136 | path: basePath + id, |
137 | accept: 'text/html', | 137 | accept: 'text/html', |
138 | statusCodeExpected: HttpStatusCode.OK_200 | 138 | expectedStatus: HttpStatusCode.OK_200 |
139 | }) | 139 | }) |
140 | 140 | ||
141 | const port = servers[0].port | 141 | const port = servers[0].port |
@@ -153,7 +153,7 @@ describe('Test a client controllers', function () { | |||
153 | describe('Open Graph', function () { | 153 | describe('Open Graph', function () { |
154 | 154 | ||
155 | async function accountPageTest (path: string) { | 155 | async function accountPageTest (path: string) { |
156 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 156 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
157 | const text = res.text | 157 | const text = res.text |
158 | 158 | ||
159 | expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`) | 159 | expect(text).to.contain(`<meta property="og:title" content="${account.displayName}" />`) |
@@ -163,7 +163,7 @@ describe('Test a client controllers', function () { | |||
163 | } | 163 | } |
164 | 164 | ||
165 | async function channelPageTest (path: string) { | 165 | async function channelPageTest (path: string) { |
166 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 166 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
167 | const text = res.text | 167 | const text = res.text |
168 | 168 | ||
169 | expect(text).to.contain(`<meta property="og:title" content="${servers[0].store.channel.displayName}" />`) | 169 | expect(text).to.contain(`<meta property="og:title" content="${servers[0].store.channel.displayName}" />`) |
@@ -173,7 +173,7 @@ describe('Test a client controllers', function () { | |||
173 | } | 173 | } |
174 | 174 | ||
175 | async function watchVideoPageTest (path: string) { | 175 | async function watchVideoPageTest (path: string) { |
176 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 176 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
177 | const text = res.text | 177 | const text = res.text |
178 | 178 | ||
179 | expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`) | 179 | expect(text).to.contain(`<meta property="og:title" content="${videoName}" />`) |
@@ -183,7 +183,7 @@ describe('Test a client controllers', function () { | |||
183 | } | 183 | } |
184 | 184 | ||
185 | async function watchPlaylistPageTest (path: string) { | 185 | async function watchPlaylistPageTest (path: string) { |
186 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 186 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
187 | const text = res.text | 187 | const text = res.text |
188 | 188 | ||
189 | expect(text).to.contain(`<meta property="og:title" content="${playlistName}" />`) | 189 | expect(text).to.contain(`<meta property="og:title" content="${playlistName}" />`) |
@@ -226,7 +226,7 @@ describe('Test a client controllers', function () { | |||
226 | describe('Not whitelisted', function () { | 226 | describe('Not whitelisted', function () { |
227 | 227 | ||
228 | async function accountPageTest (path: string) { | 228 | async function accountPageTest (path: string) { |
229 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 229 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
230 | const text = res.text | 230 | const text = res.text |
231 | 231 | ||
232 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') | 232 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') |
@@ -236,7 +236,7 @@ describe('Test a client controllers', function () { | |||
236 | } | 236 | } |
237 | 237 | ||
238 | async function channelPageTest (path: string) { | 238 | async function channelPageTest (path: string) { |
239 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 239 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
240 | const text = res.text | 240 | const text = res.text |
241 | 241 | ||
242 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') | 242 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') |
@@ -246,7 +246,7 @@ describe('Test a client controllers', function () { | |||
246 | } | 246 | } |
247 | 247 | ||
248 | async function watchVideoPageTest (path: string) { | 248 | async function watchVideoPageTest (path: string) { |
249 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 249 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
250 | const text = res.text | 250 | const text = res.text |
251 | 251 | ||
252 | expect(text).to.contain('<meta property="twitter:card" content="summary_large_image" />') | 252 | expect(text).to.contain('<meta property="twitter:card" content="summary_large_image" />') |
@@ -256,7 +256,7 @@ describe('Test a client controllers', function () { | |||
256 | } | 256 | } |
257 | 257 | ||
258 | async function watchPlaylistPageTest (path: string) { | 258 | async function watchPlaylistPageTest (path: string) { |
259 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 259 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
260 | const text = res.text | 260 | const text = res.text |
261 | 261 | ||
262 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') | 262 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') |
@@ -307,7 +307,7 @@ describe('Test a client controllers', function () { | |||
307 | }) | 307 | }) |
308 | 308 | ||
309 | async function accountPageTest (path: string) { | 309 | async function accountPageTest (path: string) { |
310 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 310 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
311 | const text = res.text | 311 | const text = res.text |
312 | 312 | ||
313 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') | 313 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') |
@@ -315,7 +315,7 @@ describe('Test a client controllers', function () { | |||
315 | } | 315 | } |
316 | 316 | ||
317 | async function channelPageTest (path: string) { | 317 | async function channelPageTest (path: string) { |
318 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 318 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
319 | const text = res.text | 319 | const text = res.text |
320 | 320 | ||
321 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') | 321 | expect(text).to.contain('<meta property="twitter:card" content="summary" />') |
@@ -323,7 +323,7 @@ describe('Test a client controllers', function () { | |||
323 | } | 323 | } |
324 | 324 | ||
325 | async function watchVideoPageTest (path: string) { | 325 | async function watchVideoPageTest (path: string) { |
326 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 326 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
327 | const text = res.text | 327 | const text = res.text |
328 | 328 | ||
329 | expect(text).to.contain('<meta property="twitter:card" content="player" />') | 329 | expect(text).to.contain('<meta property="twitter:card" content="player" />') |
@@ -331,7 +331,7 @@ describe('Test a client controllers', function () { | |||
331 | } | 331 | } |
332 | 332 | ||
333 | async function watchPlaylistPageTest (path: string) { | 333 | async function watchPlaylistPageTest (path: string) { |
334 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', statusCodeExpected: HttpStatusCode.OK_200 }) | 334 | const res = await makeGetRequest({ url: servers[0].url, path, accept: 'text/html', expectedStatus: HttpStatusCode.OK_200 }) |
335 | const text = res.text | 335 | const text = res.text |
336 | 336 | ||
337 | expect(text).to.contain('<meta property="twitter:card" content="player" />') | 337 | expect(text).to.contain('<meta property="twitter:card" content="player" />') |
diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts index aaaf23278..12b4a1b8d 100644 --- a/server/tests/external-plugins/auth-ldap.ts +++ b/server/tests/external-plugins/auth-ldap.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 6 | import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' |
7 | 7 | ||
8 | describe('Official plugin auth-ldap', function () { | 8 | 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 9cb86310b..78b13eded 100644 --- a/server/tests/external-plugins/auto-block-videos.ts +++ b/server/tests/external-plugins/auto-block-videos.ts | |||
@@ -43,10 +43,10 @@ describe('Official plugin auto-block videos', function () { | |||
43 | blocklistServer = new MockBlocklist() | 43 | blocklistServer = new MockBlocklist() |
44 | port = await blocklistServer.initialize() | 44 | port = await blocklistServer.initialize() |
45 | 45 | ||
46 | await await servers[0].videos.quickUpload({ name: 'video server 1' }) | 46 | await servers[0].videos.quickUpload({ name: 'video server 1' }) |
47 | await await servers[1].videos.quickUpload({ name: 'video server 2' }) | 47 | await servers[1].videos.quickUpload({ name: 'video server 2' }) |
48 | await await servers[1].videos.quickUpload({ name: 'video 2 server 2' }) | 48 | await servers[1].videos.quickUpload({ name: 'video 2 server 2' }) |
49 | await await servers[1].videos.quickUpload({ name: 'video 3 server 2' }) | 49 | await servers[1].videos.quickUpload({ name: 'video 3 server 2' }) |
50 | 50 | ||
51 | { | 51 | { |
52 | const { data } = await servers[0].videos.list() | 52 | const { data } = await servers[0].videos.list() |
diff --git a/server/tests/external-plugins/auto-mute.ts b/server/tests/external-plugins/auto-mute.ts index 771201505..b2046313b 100644 --- a/server/tests/external-plugins/auto-mute.ts +++ b/server/tests/external-plugins/auto-mute.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | doubleFollow, | 8 | doubleFollow, |
@@ -34,8 +34,8 @@ describe('Official plugin auto-mute', function () { | |||
34 | blocklistServer = new MockBlocklist() | 34 | blocklistServer = new MockBlocklist() |
35 | port = await blocklistServer.initialize() | 35 | port = await blocklistServer.initialize() |
36 | 36 | ||
37 | await await servers[0].videos.quickUpload({ name: 'video server 1' }) | 37 | await servers[0].videos.quickUpload({ name: 'video server 1' }) |
38 | await await servers[1].videos.quickUpload({ name: 'video server 2' }) | 38 | await servers[1].videos.quickUpload({ name: 'video server 2' }) |
39 | 39 | ||
40 | await doubleFollow(servers[0], servers[1]) | 40 | await doubleFollow(servers[0], servers[1]) |
41 | }) | 41 | }) |
@@ -162,7 +162,7 @@ describe('Official plugin auto-mute', function () { | |||
162 | await makeGetRequest({ | 162 | await makeGetRequest({ |
163 | url: servers[0].url, | 163 | url: servers[0].url, |
164 | path: '/plugins/auto-mute/router/api/v1/mute-list', | 164 | path: '/plugins/auto-mute/router/api/v1/mute-list', |
165 | statusCodeExpected: HttpStatusCode.FORBIDDEN_403 | 165 | expectedStatus: HttpStatusCode.FORBIDDEN_403 |
166 | }) | 166 | }) |
167 | }) | 167 | }) |
168 | 168 | ||
@@ -179,7 +179,7 @@ describe('Official plugin auto-mute', function () { | |||
179 | await makeGetRequest({ | 179 | await makeGetRequest({ |
180 | url: servers[0].url, | 180 | url: servers[0].url, |
181 | path: '/plugins/auto-mute/router/api/v1/mute-list', | 181 | path: '/plugins/auto-mute/router/api/v1/mute-list', |
182 | statusCodeExpected: HttpStatusCode.OK_200 | 182 | expectedStatus: HttpStatusCode.OK_200 |
183 | }) | 183 | }) |
184 | }) | 184 | }) |
185 | 185 | ||
@@ -201,7 +201,7 @@ describe('Official plugin auto-mute', function () { | |||
201 | const res = await makeGetRequest({ | 201 | const res = await makeGetRequest({ |
202 | url: servers[0].url, | 202 | url: servers[0].url, |
203 | path: '/plugins/auto-mute/router/api/v1/mute-list', | 203 | path: '/plugins/auto-mute/router/api/v1/mute-list', |
204 | statusCodeExpected: HttpStatusCode.OK_200 | 204 | expectedStatus: HttpStatusCode.OK_200 |
205 | }) | 205 | }) |
206 | 206 | ||
207 | const data = res.body.data | 207 | const data = res.body.data |
diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 7735299d3..543c431dd 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import * as xmlParser from 'fast-xml-parser' | 5 | import * as xmlParser from 'fast-xml-parser' |
6 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { | 7 | import { |
8 | cleanupTests, | 8 | cleanupTests, |
9 | doubleFollow, | 9 | doubleFollow, |
diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts index a4f344fcc..4d9c07f1a 100644 --- a/server/tests/misc-endpoints.ts +++ b/server/tests/misc-endpoints.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 6 | import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' |
7 | import { VideoPrivacy } from '@shared/models' | 7 | import { VideoPrivacy } from '@shared/models' |
8 | 8 | ||
@@ -24,7 +24,7 @@ describe('Test misc endpoints', function () { | |||
24 | const res = await makeGetRequest({ | 24 | const res = await makeGetRequest({ |
25 | url: server.url, | 25 | url: server.url, |
26 | path: '/.well-known/security.txt', | 26 | path: '/.well-known/security.txt', |
27 | statusCodeExpected: HttpStatusCode.OK_200 | 27 | expectedStatus: HttpStatusCode.OK_200 |
28 | }) | 28 | }) |
29 | 29 | ||
30 | expect(res.text).to.contain('security issue') | 30 | expect(res.text).to.contain('security issue') |
@@ -34,7 +34,7 @@ describe('Test misc endpoints', function () { | |||
34 | const res = await makeGetRequest({ | 34 | const res = await makeGetRequest({ |
35 | url: server.url, | 35 | url: server.url, |
36 | path: '/.well-known/nodeinfo', | 36 | path: '/.well-known/nodeinfo', |
37 | statusCodeExpected: HttpStatusCode.OK_200 | 37 | expectedStatus: HttpStatusCode.OK_200 |
38 | }) | 38 | }) |
39 | 39 | ||
40 | expect(res.body.links).to.be.an('array') | 40 | expect(res.body.links).to.be.an('array') |
@@ -46,7 +46,7 @@ describe('Test misc endpoints', function () { | |||
46 | const res = await makeGetRequest({ | 46 | const res = await makeGetRequest({ |
47 | url: server.url, | 47 | url: server.url, |
48 | path: '/.well-known/dnt-policy.txt', | 48 | path: '/.well-known/dnt-policy.txt', |
49 | statusCodeExpected: HttpStatusCode.OK_200 | 49 | expectedStatus: HttpStatusCode.OK_200 |
50 | }) | 50 | }) |
51 | 51 | ||
52 | expect(res.text).to.contain('http://www.w3.org/TR/tracking-dnt') | 52 | expect(res.text).to.contain('http://www.w3.org/TR/tracking-dnt') |
@@ -56,7 +56,7 @@ describe('Test misc endpoints', function () { | |||
56 | const res = await makeGetRequest({ | 56 | const res = await makeGetRequest({ |
57 | url: server.url, | 57 | url: server.url, |
58 | path: '/.well-known/dnt', | 58 | path: '/.well-known/dnt', |
59 | statusCodeExpected: HttpStatusCode.OK_200 | 59 | expectedStatus: HttpStatusCode.OK_200 |
60 | }) | 60 | }) |
61 | 61 | ||
62 | expect(res.body.tracking).to.equal('N') | 62 | expect(res.body.tracking).to.equal('N') |
@@ -66,7 +66,7 @@ describe('Test misc endpoints', function () { | |||
66 | const res = await makeGetRequest({ | 66 | const res = await makeGetRequest({ |
67 | url: server.url, | 67 | url: server.url, |
68 | path: '/.well-known/change-password', | 68 | path: '/.well-known/change-password', |
69 | statusCodeExpected: HttpStatusCode.FOUND_302 | 69 | expectedStatus: HttpStatusCode.FOUND_302 |
70 | }) | 70 | }) |
71 | 71 | ||
72 | expect(res.header.location).to.equal('/my-account/settings') | 72 | expect(res.header.location).to.equal('/my-account/settings') |
@@ -79,7 +79,7 @@ describe('Test misc endpoints', function () { | |||
79 | const res = await makeGetRequest({ | 79 | const res = await makeGetRequest({ |
80 | url: server.url, | 80 | url: server.url, |
81 | path: '/.well-known/webfinger?resource=' + resource, | 81 | path: '/.well-known/webfinger?resource=' + resource, |
82 | statusCodeExpected: HttpStatusCode.OK_200 | 82 | expectedStatus: HttpStatusCode.OK_200 |
83 | }) | 83 | }) |
84 | 84 | ||
85 | const data = res.body | 85 | const data = res.body |
@@ -104,7 +104,7 @@ describe('Test misc endpoints', function () { | |||
104 | const res = await makeGetRequest({ | 104 | const res = await makeGetRequest({ |
105 | url: server.url, | 105 | url: server.url, |
106 | path: '/robots.txt', | 106 | path: '/robots.txt', |
107 | statusCodeExpected: HttpStatusCode.OK_200 | 107 | expectedStatus: HttpStatusCode.OK_200 |
108 | }) | 108 | }) |
109 | 109 | ||
110 | expect(res.text).to.contain('User-agent') | 110 | expect(res.text).to.contain('User-agent') |
@@ -114,7 +114,7 @@ describe('Test misc endpoints', function () { | |||
114 | await makeGetRequest({ | 114 | await makeGetRequest({ |
115 | url: server.url, | 115 | url: server.url, |
116 | path: '/security.txt', | 116 | path: '/security.txt', |
117 | statusCodeExpected: HttpStatusCode.MOVED_PERMANENTLY_301 | 117 | expectedStatus: HttpStatusCode.MOVED_PERMANENTLY_301 |
118 | }) | 118 | }) |
119 | }) | 119 | }) |
120 | 120 | ||
@@ -122,7 +122,7 @@ describe('Test misc endpoints', function () { | |||
122 | const res = await makeGetRequest({ | 122 | const res = await makeGetRequest({ |
123 | url: server.url, | 123 | url: server.url, |
124 | path: '/nodeinfo/2.0.json', | 124 | path: '/nodeinfo/2.0.json', |
125 | statusCodeExpected: HttpStatusCode.OK_200 | 125 | expectedStatus: HttpStatusCode.OK_200 |
126 | }) | 126 | }) |
127 | 127 | ||
128 | expect(res.body.software.name).to.equal('peertube') | 128 | expect(res.body.software.name).to.equal('peertube') |
@@ -137,7 +137,7 @@ describe('Test misc endpoints', function () { | |||
137 | const res = await makeGetRequest({ | 137 | const res = await makeGetRequest({ |
138 | url: server.url, | 138 | url: server.url, |
139 | path: '/sitemap.xml', | 139 | path: '/sitemap.xml', |
140 | statusCodeExpected: HttpStatusCode.OK_200 | 140 | expectedStatus: HttpStatusCode.OK_200 |
141 | }) | 141 | }) |
142 | 142 | ||
143 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') | 143 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') |
@@ -148,7 +148,7 @@ describe('Test misc endpoints', function () { | |||
148 | const res = await makeGetRequest({ | 148 | const res = await makeGetRequest({ |
149 | url: server.url, | 149 | url: server.url, |
150 | path: '/sitemap.xml', | 150 | path: '/sitemap.xml', |
151 | statusCodeExpected: HttpStatusCode.OK_200 | 151 | expectedStatus: HttpStatusCode.OK_200 |
152 | }) | 152 | }) |
153 | 153 | ||
154 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') | 154 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') |
@@ -171,7 +171,7 @@ describe('Test misc endpoints', function () { | |||
171 | const res = await makeGetRequest({ | 171 | const res = await makeGetRequest({ |
172 | url: server.url, | 172 | url: server.url, |
173 | path: '/sitemap.xml?t=1', // avoid using cache | 173 | path: '/sitemap.xml?t=1', // avoid using cache |
174 | statusCodeExpected: HttpStatusCode.OK_200 | 174 | expectedStatus: HttpStatusCode.OK_200 |
175 | }) | 175 | }) |
176 | 176 | ||
177 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') | 177 | expect(res.text).to.contain('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"') |
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index c0834a14c..a2828603a 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | decodeQueryString, | 8 | decodeQueryString, |
@@ -20,15 +20,15 @@ async function loginExternal (options: { | |||
20 | authName: string | 20 | authName: string |
21 | username: string | 21 | username: string |
22 | query?: any | 22 | query?: any |
23 | statusCodeExpected?: HttpStatusCode | 23 | expectedStatus?: HttpStatusCode |
24 | statusCodeExpectedStep2?: HttpStatusCode | 24 | expectedStatusStep2?: HttpStatusCode |
25 | }) { | 25 | }) { |
26 | const res = await options.server.plugins.getExternalAuth({ | 26 | const res = await options.server.plugins.getExternalAuth({ |
27 | npmName: options.npmName, | 27 | npmName: options.npmName, |
28 | npmVersion: '0.0.1', | 28 | npmVersion: '0.0.1', |
29 | authName: options.authName, | 29 | authName: options.authName, |
30 | query: options.query, | 30 | query: options.query, |
31 | expectedStatus: options.statusCodeExpected || HttpStatusCode.FOUND_302 | 31 | expectedStatus: options.expectedStatus || HttpStatusCode.FOUND_302 |
32 | }) | 32 | }) |
33 | 33 | ||
34 | if (res.status !== HttpStatusCode.FOUND_302) return | 34 | if (res.status !== HttpStatusCode.FOUND_302) return |
@@ -39,7 +39,7 @@ async function loginExternal (options: { | |||
39 | const resLogin = await options.server.login.loginUsingExternalToken({ | 39 | const resLogin = await options.server.login.loginUsingExternalToken({ |
40 | username: options.username, | 40 | username: options.username, |
41 | externalAuthToken: externalAuthToken as string, | 41 | externalAuthToken: externalAuthToken as string, |
42 | expectedStatus: options.statusCodeExpectedStep2 | 42 | expectedStatus: options.expectedStatusStep2 |
43 | }) | 43 | }) |
44 | 44 | ||
45 | return resLogin.body | 45 | return resLogin.body |
@@ -268,7 +268,7 @@ describe('Test external auth plugins', function () { | |||
268 | username: 'kefka' | 268 | username: 'kefka' |
269 | }, | 269 | }, |
270 | username: 'kefka', | 270 | username: 'kefka', |
271 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 271 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
272 | }) | 272 | }) |
273 | }) | 273 | }) |
274 | 274 | ||
@@ -293,7 +293,7 @@ describe('Test external auth plugins', function () { | |||
293 | username: 'cyan' | 293 | username: 'cyan' |
294 | }, | 294 | }, |
295 | username: 'cyan', | 295 | username: 'cyan', |
296 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 296 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
297 | }) | 297 | }) |
298 | 298 | ||
299 | await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) | 299 | await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) |
@@ -307,7 +307,7 @@ describe('Test external auth plugins', function () { | |||
307 | npmName: 'test-external-auth-two', | 307 | npmName: 'test-external-auth-two', |
308 | authName: 'external-auth-4', | 308 | authName: 'external-auth-4', |
309 | username: 'kefka2', | 309 | username: 'kefka2', |
310 | statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 | 310 | expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400 |
311 | }) | 311 | }) |
312 | 312 | ||
313 | await loginExternal({ | 313 | await loginExternal({ |
@@ -315,7 +315,7 @@ describe('Test external auth plugins', function () { | |||
315 | npmName: 'test-external-auth-two', | 315 | npmName: 'test-external-auth-two', |
316 | authName: 'external-auth-4', | 316 | authName: 'external-auth-4', |
317 | username: 'kefka', | 317 | username: 'kefka', |
318 | statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 | 318 | expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400 |
319 | }) | 319 | }) |
320 | }) | 320 | }) |
321 | 321 | ||
@@ -327,7 +327,7 @@ describe('Test external auth plugins', function () { | |||
327 | npmName: 'test-external-auth-two', | 327 | npmName: 'test-external-auth-two', |
328 | authName: 'external-auth-6', | 328 | authName: 'external-auth-6', |
329 | username: 'existing_user', | 329 | username: 'existing_user', |
330 | statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 | 330 | expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400 |
331 | }) | 331 | }) |
332 | }) | 332 | }) |
333 | 333 | ||
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index df52bb3b5..ba84dd27a 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createMultipleServers, | 8 | createMultipleServers, |
@@ -71,28 +71,28 @@ describe('Test plugin filter hooks', function () { | |||
71 | }) | 71 | }) |
72 | 72 | ||
73 | it('Should run filter:api.accounts.videos.list.params', async function () { | 73 | it('Should run filter:api.accounts.videos.list.params', async function () { |
74 | const { data } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 }) | 74 | const { data } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }) |
75 | 75 | ||
76 | // 1 plugin do +1 to the count parameter | 76 | // 1 plugin do +1 to the count parameter |
77 | expect(data).to.have.lengthOf(3) | 77 | expect(data).to.have.lengthOf(3) |
78 | }) | 78 | }) |
79 | 79 | ||
80 | it('Should run filter:api.accounts.videos.list.result', async function () { | 80 | it('Should run filter:api.accounts.videos.list.result', async function () { |
81 | const { total } = await servers[0].videos.listByAccount({ accountName: 'root', start: 0, count: 2 }) | 81 | const { total } = await servers[0].videos.listByAccount({ handle: 'root', start: 0, count: 2 }) |
82 | 82 | ||
83 | // Plugin do +2 to the total result | 83 | // Plugin do +2 to the total result |
84 | expect(total).to.equal(12) | 84 | expect(total).to.equal(12) |
85 | }) | 85 | }) |
86 | 86 | ||
87 | it('Should run filter:api.video-channels.videos.list.params', async function () { | 87 | it('Should run filter:api.video-channels.videos.list.params', async function () { |
88 | const { data } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 }) | 88 | const { data } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 }) |
89 | 89 | ||
90 | // 1 plugin do +3 to the count parameter | 90 | // 1 plugin do +3 to the count parameter |
91 | expect(data).to.have.lengthOf(5) | 91 | expect(data).to.have.lengthOf(5) |
92 | }) | 92 | }) |
93 | 93 | ||
94 | it('Should run filter:api.video-channels.videos.list.result', async function () { | 94 | it('Should run filter:api.video-channels.videos.list.result', async function () { |
95 | const { total } = await servers[0].videos.listByChannel({ videoChannelName: 'root_channel', start: 0, count: 2 }) | 95 | const { total } = await servers[0].videos.listByChannel({ handle: 'root_channel', start: 0, count: 2 }) |
96 | 96 | ||
97 | // Plugin do +3 to the total result | 97 | // Plugin do +3 to the total result |
98 | expect(total).to.equal(13) | 98 | expect(total).to.equal(13) |
diff --git a/server/tests/plugins/id-and-pass-auth.ts b/server/tests/plugins/id-and-pass-auth.ts index 981bcad91..a73d76caa 100644 --- a/server/tests/plugins/id-and-pass-auth.ts +++ b/server/tests/plugins/id-and-pass-auth.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' | 6 | import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/extra-utils' |
7 | import { UserRole } from '@shared/models' | 7 | import { UserRole } from '@shared/models' |
8 | 8 | ||
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index 1d87b84ae..5cb664bda 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | checkVideoFilesWereRemoved, | 7 | checkVideoFilesWereRemoved, |
8 | cleanupTests, | 8 | cleanupTests, |
@@ -24,7 +24,7 @@ function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) | |||
24 | url: server.url, | 24 | url: server.url, |
25 | path: '/plugins/test-four/router/commander', | 25 | path: '/plugins/test-four/router/commander', |
26 | fields: body, | 26 | fields: body, |
27 | statusCodeExpected: HttpStatusCode.NO_CONTENT_204 | 27 | expectedStatus: HttpStatusCode.NO_CONTENT_204 |
28 | }) | 28 | }) |
29 | } | 29 | } |
30 | 30 | ||
@@ -67,7 +67,7 @@ describe('Test plugin helpers', function () { | |||
67 | const res = await makeGetRequest({ | 67 | const res = await makeGetRequest({ |
68 | url: servers[0].url, | 68 | url: servers[0].url, |
69 | path: '/plugins/test-four/router/server-config', | 69 | path: '/plugins/test-four/router/server-config', |
70 | statusCodeExpected: HttpStatusCode.OK_200 | 70 | expectedStatus: HttpStatusCode.OK_200 |
71 | }) | 71 | }) |
72 | 72 | ||
73 | expect(res.body.serverConfig).to.exist | 73 | expect(res.body.serverConfig).to.exist |
@@ -88,7 +88,7 @@ describe('Test plugin helpers', function () { | |||
88 | const res = await makeGetRequest({ | 88 | const res = await makeGetRequest({ |
89 | url: servers[0].url, | 89 | url: servers[0].url, |
90 | path: '/plugins/test-four/router/static-route', | 90 | path: '/plugins/test-four/router/static-route', |
91 | statusCodeExpected: HttpStatusCode.OK_200 | 91 | expectedStatus: HttpStatusCode.OK_200 |
92 | }) | 92 | }) |
93 | 93 | ||
94 | expect(res.body.staticRoute).to.equal('/plugins/test-four/0.0.1/static/') | 94 | expect(res.body.staticRoute).to.equal('/plugins/test-four/0.0.1/static/') |
@@ -100,7 +100,7 @@ describe('Test plugin helpers', function () { | |||
100 | const res = await makeGetRequest({ | 100 | const res = await makeGetRequest({ |
101 | url: servers[0].url, | 101 | url: servers[0].url, |
102 | path: baseRouter + 'router-route', | 102 | path: baseRouter + 'router-route', |
103 | statusCodeExpected: HttpStatusCode.OK_200 | 103 | expectedStatus: HttpStatusCode.OK_200 |
104 | }) | 104 | }) |
105 | 105 | ||
106 | expect(res.body.routerRoute).to.equal(baseRouter) | 106 | expect(res.body.routerRoute).to.equal(baseRouter) |
@@ -113,7 +113,7 @@ describe('Test plugin helpers', function () { | |||
113 | await makeGetRequest({ | 113 | await makeGetRequest({ |
114 | url: servers[0].url, | 114 | url: servers[0].url, |
115 | path: '/plugins/test-four/router/user', | 115 | path: '/plugins/test-four/router/user', |
116 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 116 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
117 | }) | 117 | }) |
118 | }) | 118 | }) |
119 | 119 | ||
@@ -122,7 +122,7 @@ describe('Test plugin helpers', function () { | |||
122 | url: servers[0].url, | 122 | url: servers[0].url, |
123 | token: servers[0].accessToken, | 123 | token: servers[0].accessToken, |
124 | path: '/plugins/test-four/router/user', | 124 | path: '/plugins/test-four/router/user', |
125 | statusCodeExpected: HttpStatusCode.OK_200 | 125 | expectedStatus: HttpStatusCode.OK_200 |
126 | }) | 126 | }) |
127 | 127 | ||
128 | expect(res.body.username).to.equal('root') | 128 | expect(res.body.username).to.equal('root') |
@@ -140,12 +140,12 @@ describe('Test plugin helpers', function () { | |||
140 | this.timeout(60000) | 140 | this.timeout(60000) |
141 | 141 | ||
142 | { | 142 | { |
143 | const res = await await servers[0].videos.quickUpload({ name: 'video server 1' }) | 143 | const res = await servers[0].videos.quickUpload({ name: 'video server 1' }) |
144 | videoUUIDServer1 = res.uuid | 144 | videoUUIDServer1 = res.uuid |
145 | } | 145 | } |
146 | 146 | ||
147 | { | 147 | { |
148 | await await servers[1].videos.quickUpload({ name: 'video server 2' }) | 148 | await servers[1].videos.quickUpload({ name: 'video server 2' }) |
149 | } | 149 | } |
150 | 150 | ||
151 | await waitJobs(servers) | 151 | await waitJobs(servers) |
@@ -224,7 +224,7 @@ describe('Test plugin helpers', function () { | |||
224 | let videoUUID: string | 224 | let videoUUID: string |
225 | 225 | ||
226 | before(async () => { | 226 | before(async () => { |
227 | const res = await await servers[0].videos.quickUpload({ name: 'video1' }) | 227 | const res = await servers[0].videos.quickUpload({ name: 'video1' }) |
228 | videoUUID = res.uuid | 228 | videoUUID = res.uuid |
229 | }) | 229 | }) |
230 | 230 | ||
diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts index dec8ca4bb..becb7c47b 100644 --- a/server/tests/plugins/plugin-router.ts +++ b/server/tests/plugins/plugin-router.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
@@ -34,7 +34,7 @@ describe('Test plugin helpers', function () { | |||
34 | const res = await makeGetRequest({ | 34 | const res = await makeGetRequest({ |
35 | url: server.url, | 35 | url: server.url, |
36 | path: path + 'ping', | 36 | path: path + 'ping', |
37 | statusCodeExpected: HttpStatusCode.OK_200 | 37 | expectedStatus: HttpStatusCode.OK_200 |
38 | }) | 38 | }) |
39 | 39 | ||
40 | expect(res.body.message).to.equal('pong') | 40 | expect(res.body.message).to.equal('pong') |
@@ -47,7 +47,7 @@ describe('Test plugin helpers', function () { | |||
47 | url: server.url, | 47 | url: server.url, |
48 | path: path + 'is-authenticated', | 48 | path: path + 'is-authenticated', |
49 | token: server.accessToken, | 49 | token: server.accessToken, |
50 | statusCodeExpected: 200 | 50 | expectedStatus: 200 |
51 | }) | 51 | }) |
52 | 52 | ||
53 | expect(res.body.isAuthenticated).to.equal(true) | 53 | expect(res.body.isAuthenticated).to.equal(true) |
@@ -55,7 +55,7 @@ describe('Test plugin helpers', function () { | |||
55 | const secRes = await makeGetRequest({ | 55 | const secRes = await makeGetRequest({ |
56 | url: server.url, | 56 | url: server.url, |
57 | path: path + 'is-authenticated', | 57 | path: path + 'is-authenticated', |
58 | statusCodeExpected: 200 | 58 | expectedStatus: 200 |
59 | }) | 59 | }) |
60 | 60 | ||
61 | expect(secRes.body.isAuthenticated).to.equal(false) | 61 | expect(secRes.body.isAuthenticated).to.equal(false) |
@@ -74,7 +74,7 @@ describe('Test plugin helpers', function () { | |||
74 | url: server.url, | 74 | url: server.url, |
75 | path: path + 'form/post/mirror', | 75 | path: path + 'form/post/mirror', |
76 | fields: body, | 76 | fields: body, |
77 | statusCodeExpected: HttpStatusCode.OK_200 | 77 | expectedStatus: HttpStatusCode.OK_200 |
78 | }) | 78 | }) |
79 | 79 | ||
80 | expect(res.body).to.deep.equal(body) | 80 | expect(res.body).to.deep.equal(body) |
@@ -88,14 +88,14 @@ describe('Test plugin helpers', function () { | |||
88 | await makeGetRequest({ | 88 | await makeGetRequest({ |
89 | url: server.url, | 89 | url: server.url, |
90 | path: path + 'ping', | 90 | path: path + 'ping', |
91 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 91 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
92 | }) | 92 | }) |
93 | 93 | ||
94 | await makePostBodyRequest({ | 94 | await makePostBodyRequest({ |
95 | url: server.url, | 95 | url: server.url, |
96 | path: path + 'ping', | 96 | path: path + 'ping', |
97 | fields: {}, | 97 | fields: {}, |
98 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 98 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
99 | }) | 99 | }) |
100 | } | 100 | } |
101 | }) | 101 | }) |
diff --git a/server/tests/plugins/plugin-storage.ts b/server/tests/plugins/plugin-storage.ts index 5745914a5..90dafa3e1 100644 --- a/server/tests/plugins/plugin-storage.ts +++ b/server/tests/plugins/plugin-storage.ts | |||
@@ -4,7 +4,7 @@ import 'mocha' | |||
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { pathExists, readdir, readFile } from 'fs-extra' | 5 | import { pathExists, readdir, readFile } from 'fs-extra' |
6 | import { join } from 'path' | 6 | import { join } from 'path' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { | 8 | import { |
9 | cleanupTests, | 9 | cleanupTests, |
10 | createSingleServer, | 10 | createSingleServer, |
@@ -63,7 +63,7 @@ describe('Test plugin storage', function () { | |||
63 | url: server.url, | 63 | url: server.url, |
64 | token: server.accessToken, | 64 | token: server.accessToken, |
65 | path: '/plugins/test-six/router/create-file', | 65 | path: '/plugins/test-six/router/create-file', |
66 | statusCodeExpected: HttpStatusCode.OK_200 | 66 | expectedStatus: HttpStatusCode.OK_200 |
67 | }) | 67 | }) |
68 | 68 | ||
69 | const content = await getFileContent() | 69 | const content = await getFileContent() |
diff --git a/server/tests/plugins/plugin-unloading.ts b/server/tests/plugins/plugin-unloading.ts index 6c405b7f5..faf9cc599 100644 --- a/server/tests/plugins/plugin-unloading.ts +++ b/server/tests/plugins/plugin-unloading.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { expect } from 'chai' | 4 | import { expect } from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { | 6 | import { |
7 | cleanupTests, | 7 | cleanupTests, |
8 | createSingleServer, | 8 | createSingleServer, |
@@ -30,7 +30,7 @@ describe('Test plugins module unloading', function () { | |||
30 | const res = await makeGetRequest({ | 30 | const res = await makeGetRequest({ |
31 | url: server.url, | 31 | url: server.url, |
32 | path: requestPath, | 32 | path: requestPath, |
33 | statusCodeExpected: HttpStatusCode.OK_200 | 33 | expectedStatus: HttpStatusCode.OK_200 |
34 | }) | 34 | }) |
35 | 35 | ||
36 | expect(res.body.message).to.match(/^\d+$/) | 36 | expect(res.body.message).to.match(/^\d+$/) |
@@ -41,7 +41,7 @@ describe('Test plugins module unloading', function () { | |||
41 | const res = await makeGetRequest({ | 41 | const res = await makeGetRequest({ |
42 | url: server.url, | 42 | url: server.url, |
43 | path: requestPath, | 43 | path: requestPath, |
44 | statusCodeExpected: HttpStatusCode.OK_200 | 44 | expectedStatus: HttpStatusCode.OK_200 |
45 | }) | 45 | }) |
46 | 46 | ||
47 | expect(res.body.message).to.be.equal(value) | 47 | expect(res.body.message).to.be.equal(value) |
@@ -53,7 +53,7 @@ describe('Test plugins module unloading', function () { | |||
53 | await makeGetRequest({ | 53 | await makeGetRequest({ |
54 | url: server.url, | 54 | url: server.url, |
55 | path: requestPath, | 55 | path: requestPath, |
56 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 56 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
57 | }) | 57 | }) |
58 | }) | 58 | }) |
59 | 59 | ||
@@ -63,7 +63,7 @@ describe('Test plugins module unloading', function () { | |||
63 | const res = await makeGetRequest({ | 63 | const res = await makeGetRequest({ |
64 | url: server.url, | 64 | url: server.url, |
65 | path: requestPath, | 65 | path: requestPath, |
66 | statusCodeExpected: HttpStatusCode.OK_200 | 66 | expectedStatus: HttpStatusCode.OK_200 |
67 | }) | 67 | }) |
68 | 68 | ||
69 | expect(res.body.message).to.match(/^\d+$/) | 69 | expect(res.body.message).to.match(/^\d+$/) |
diff --git a/server/tests/plugins/video-constants.ts b/server/tests/plugins/video-constants.ts index 953916e8e..dd3b40225 100644 --- a/server/tests/plugins/video-constants.ts +++ b/server/tests/plugins/video-constants.ts | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' | 6 | import { cleanupTests, createSingleServer, PluginsCommand, PeerTubeServer, setAccessTokensToServers } from '@shared/extra-utils' |
7 | import { VideoPlaylistPrivacy } from '@shared/models' | 7 | import { VideoPlaylistPrivacy } from '@shared/models' |
8 | 8 | ||
diff --git a/server/tools/peertube-redundancy.ts b/server/tools/peertube-redundancy.ts index 5fda68c8e..bcaae63a3 100644 --- a/server/tools/peertube-redundancy.ts +++ b/server/tools/peertube-redundancy.ts | |||
@@ -6,7 +6,7 @@ import { Command, program } from 'commander' | |||
6 | import { uniq } from 'lodash' | 6 | import { uniq } from 'lodash' |
7 | import { URL } from 'url' | 7 | import { URL } from 'url' |
8 | import validator from 'validator' | 8 | import validator from 'validator' |
9 | import { HttpStatusCode } from '@shared/core-utils/miscs/http-error-codes' | 9 | import { HttpStatusCode } from '@shared/models' |
10 | import { VideoRedundanciesTarget } from '@shared/models' | 10 | import { VideoRedundanciesTarget } from '@shared/models' |
11 | import { assignToken, buildServer, getServerCredentials } from './cli' | 11 | import { assignToken, buildServer, getServerCredentials } from './cli' |
12 | 12 | ||
diff --git a/server/typings/express/index.d.ts b/server/typings/express/index.d.ts index 1a8dc3430..5469f3b83 100644 --- a/server/typings/express/index.d.ts +++ b/server/typings/express/index.d.ts | |||
@@ -22,8 +22,7 @@ import { MPlugin, MServer, MServerBlocklist } from '@server/types/models/server' | |||
22 | import { MVideoImportDefault } from '@server/types/models/video/video-import' | 22 | import { MVideoImportDefault } from '@server/types/models/video/video-import' |
23 | import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element' | 23 | import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/types/models/video/video-playlist-element' |
24 | import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate' | 24 | import { MAccountVideoRateAccountVideo } from '@server/types/models/video/video-rate' |
25 | import { HttpMethod } from '@shared/core-utils/miscs/http-methods' | 25 | import { HttpMethod, PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models' |
26 | import { PeerTubeProblemDocumentData, ServerErrorCode, VideoCreate } from '@shared/models' | ||
27 | import { File as UploadXFile, Metadata } from '@uploadx/core' | 26 | import { File as UploadXFile, Metadata } from '@uploadx/core' |
28 | import { RegisteredPlugin } from '../../lib/plugins/plugin-manager' | 27 | import { RegisteredPlugin } from '../../lib/plugins/plugin-manager' |
29 | import { | 28 | import { |
diff --git a/shared/core-utils/miscs/index.ts b/shared/core-utils/miscs/index.ts index 251df1de2..afd147f24 100644 --- a/shared/core-utils/miscs/index.ts +++ b/shared/core-utils/miscs/index.ts | |||
@@ -1,5 +1,3 @@ | |||
1 | export * from './date' | 1 | export * from './date' |
2 | export * from './miscs' | 2 | export * from './miscs' |
3 | export * from './types' | 3 | export * from './types' |
4 | export * from './http-error-codes' | ||
5 | export * from './http-methods' | ||
diff --git a/shared/extra-utils/bulk/bulk-command.ts b/shared/extra-utils/bulk/bulk-command.ts index 6dac6034f..b5c5673ce 100644 --- a/shared/extra-utils/bulk/bulk-command.ts +++ b/shared/extra-utils/bulk/bulk-command.ts | |||
@@ -1,6 +1,4 @@ | |||
1 | 1 | import { BulkRemoveCommentsOfBody, HttpStatusCode } from '@shared/models' | |
2 | import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model' | ||
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 3 | ||
6 | export class BulkCommand extends AbstractCommand { | 4 | 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 0dd77503e..6042233d4 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 @@ | |||
1 | import { CustomPage } from '@shared/models' | 1 | import { CustomPage } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class CustomPagesCommand extends AbstractCommand { | 5 | export class CustomPagesCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/feeds/feeds-command.ts b/shared/extra-utils/feeds/feeds-command.ts index 2da4110a7..3c95f9536 100644 --- a/shared/extra-utils/feeds/feeds-command.ts +++ b/shared/extra-utils/feeds/feeds-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | 1 | ||
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | type FeedType = 'videos' | 'video-comments' | 'subscriptions' | 5 | 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 f34c58c47..5912e814f 100644 --- a/shared/extra-utils/logs/logs-command.ts +++ b/shared/extra-utils/logs/logs-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { LogLevel } from '../../models/server/log-level.type' | 2 | import { LogLevel } from '../../models/server/log-level.type' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
diff --git a/shared/extra-utils/miscs/checks.ts b/shared/extra-utils/miscs/checks.ts index c81460330..7fc92f804 100644 --- a/shared/extra-utils/miscs/checks.ts +++ b/shared/extra-utils/miscs/checks.ts | |||
@@ -4,7 +4,7 @@ import { expect } from 'chai' | |||
4 | import { pathExists, readFile } from 'fs-extra' | 4 | import { pathExists, readFile } from 'fs-extra' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { root } from '@server/helpers/core-utils' | 6 | import { root } from '@server/helpers/core-utils' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { makeGetRequest } from '../requests' | 8 | import { makeGetRequest } from '../requests' |
9 | import { PeerTubeServer } from '../server' | 9 | import { PeerTubeServer } from '../server' |
10 | 10 | ||
@@ -20,7 +20,7 @@ async function testImage (url: string, imageName: string, imagePath: string, ext | |||
20 | const res = await makeGetRequest({ | 20 | const res = await makeGetRequest({ |
21 | url, | 21 | url, |
22 | path: imagePath, | 22 | path: imagePath, |
23 | statusCodeExpected: HttpStatusCode.OK_200 | 23 | expectedStatus: HttpStatusCode.OK_200 |
24 | }) | 24 | }) |
25 | 25 | ||
26 | const body = res.body | 26 | const body = res.body |
diff --git a/shared/extra-utils/moderation/abuses-command.ts b/shared/extra-utils/moderation/abuses-command.ts index 03da0c85a..72f2c9951 100644 --- a/shared/extra-utils/moderation/abuses-command.ts +++ b/shared/extra-utils/moderation/abuses-command.ts | |||
@@ -10,7 +10,7 @@ import { | |||
10 | ResultList, | 10 | ResultList, |
11 | UserAbuse | 11 | UserAbuse |
12 | } from '@shared/models' | 12 | } from '@shared/models' |
13 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 13 | import { HttpStatusCode } from '@shared/models' |
14 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 14 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
15 | import { unwrapBody } from '../requests/requests' | 15 | import { unwrapBody } from '../requests/requests' |
16 | 16 | ||
diff --git a/shared/extra-utils/overviews/overviews-command.ts b/shared/extra-utils/overviews/overviews-command.ts index e15644d94..d4a2ac254 100644 --- a/shared/extra-utils/overviews/overviews-command.ts +++ b/shared/extra-utils/overviews/overviews-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { VideosOverview } from '@shared/models' | 2 | import { VideosOverview } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
diff --git a/shared/extra-utils/requests/check-api-params.ts b/shared/extra-utils/requests/check-api-params.ts index 7df63b004..26ba1e913 100644 --- a/shared/extra-utils/requests/check-api-params.ts +++ b/shared/extra-utils/requests/check-api-params.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { makeGetRequest } from './requests' | 2 | import { makeGetRequest } from './requests' |
3 | 3 | ||
4 | function checkBadStartPagination (url: string, path: string, token?: string, query = {}) { | 4 | function checkBadStartPagination (url: string, path: string, token?: string, query = {}) { |
@@ -7,7 +7,7 @@ function checkBadStartPagination (url: string, path: string, token?: string, que | |||
7 | path, | 7 | path, |
8 | token, | 8 | token, |
9 | query: { ...query, start: 'hello' }, | 9 | query: { ...query, start: 'hello' }, |
10 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 10 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
11 | }) | 11 | }) |
12 | } | 12 | } |
13 | 13 | ||
@@ -17,7 +17,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin | |||
17 | path, | 17 | path, |
18 | token, | 18 | token, |
19 | query: { ...query, count: 'hello' }, | 19 | query: { ...query, count: 'hello' }, |
20 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 20 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
21 | }) | 21 | }) |
22 | 22 | ||
23 | await makeGetRequest({ | 23 | await makeGetRequest({ |
@@ -25,7 +25,7 @@ async function checkBadCountPagination (url: string, path: string, token?: strin | |||
25 | path, | 25 | path, |
26 | token, | 26 | token, |
27 | query: { ...query, count: 2000 }, | 27 | query: { ...query, count: 2000 }, |
28 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 28 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
29 | }) | 29 | }) |
30 | } | 30 | } |
31 | 31 | ||
@@ -35,7 +35,7 @@ function checkBadSortPagination (url: string, path: string, token?: string, quer | |||
35 | path, | 35 | path, |
36 | token, | 36 | token, |
37 | query: { ...query, sort: 'hello' }, | 37 | query: { ...query, sort: 'hello' }, |
38 | statusCodeExpected: HttpStatusCode.BAD_REQUEST_400 | 38 | expectedStatus: HttpStatusCode.BAD_REQUEST_400 |
39 | }) | 39 | }) |
40 | } | 40 | } |
41 | 41 | ||
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts index 60c9b938b..70f790222 100644 --- a/shared/extra-utils/requests/requests.ts +++ b/shared/extra-utils/requests/requests.ts | |||
@@ -1,111 +1,82 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ | 1 | /* eslint-disable @typescript-eslint/no-floating-promises */ |
2 | 2 | ||
3 | import { isAbsolute, join } from 'path' | ||
4 | import { decode } from 'querystring' | 3 | import { decode } from 'querystring' |
5 | import * as request from 'supertest' | 4 | import * as request from 'supertest' |
6 | import { URL } from 'url' | 5 | import { URL } from 'url' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/models' |
8 | import { buildAbsoluteFixturePath, root } from '../miscs/tests' | 7 | import { buildAbsoluteFixturePath } from '../miscs/tests' |
9 | 8 | ||
10 | function makeRawRequest (url: string, statusCodeExpected?: HttpStatusCode, range?: string) { | 9 | export type CommonRequestParams = { |
11 | const { host, protocol, pathname } = new URL(url) | ||
12 | |||
13 | return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, statusCodeExpected, range }) | ||
14 | } | ||
15 | |||
16 | function makeGetRequest (options: { | ||
17 | url: string | 10 | url: string |
18 | path?: string | 11 | path?: string |
19 | query?: any | ||
20 | token?: string | ||
21 | statusCodeExpected?: HttpStatusCode | ||
22 | contentType?: string | 12 | contentType?: string |
23 | range?: string | 13 | range?: string |
24 | redirects?: number | 14 | redirects?: number |
25 | accept?: string | 15 | accept?: string |
26 | host?: string | 16 | host?: string |
27 | }) { | 17 | token?: string |
28 | if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 | 18 | headers?: { [ name: string ]: string } |
29 | if (options.contentType === undefined) options.contentType = 'application/json' | 19 | type?: string |
30 | 20 | xForwardedFor?: string | |
31 | const req = request(options.url).get(options.path) | 21 | expectedStatus?: HttpStatusCode |
22 | } | ||
32 | 23 | ||
33 | if (options.contentType) req.set('Accept', options.contentType) | 24 | function makeRawRequest (url: string, expectedStatus?: HttpStatusCode, range?: string) { |
34 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | 25 | const { host, protocol, pathname } = new URL(url) |
35 | if (options.query) req.query(options.query) | ||
36 | if (options.range) req.set('Range', options.range) | ||
37 | if (options.accept) req.set('Accept', options.accept) | ||
38 | if (options.host) req.set('Host', options.host) | ||
39 | if (options.redirects) req.redirects(options.redirects) | ||
40 | 26 | ||
41 | return req.expect(options.statusCodeExpected) | 27 | return makeGetRequest({ url: `${protocol}//${host}`, path: pathname, expectedStatus, range }) |
42 | } | 28 | } |
43 | 29 | ||
44 | function makeDeleteRequest (options: { | 30 | function makeGetRequest (options: CommonRequestParams & { |
45 | url: string | 31 | query?: any |
46 | path: string | ||
47 | token?: string | ||
48 | statusCodeExpected?: HttpStatusCode | ||
49 | }) { | 32 | }) { |
50 | if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 | 33 | const req = request(options.url).get(options.path) |
34 | .query(options.query) | ||
51 | 35 | ||
52 | const req = request(options.url) | 36 | return buildRequest(req, { contentType: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) |
53 | .delete(options.path) | 37 | } |
54 | .set('Accept', 'application/json') | ||
55 | 38 | ||
56 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | 39 | function makeHTMLRequest (url: string, path: string) { |
40 | return makeGetRequest({ | ||
41 | url, | ||
42 | path, | ||
43 | accept: 'text/html', | ||
44 | expectedStatus: HttpStatusCode.OK_200 | ||
45 | }) | ||
46 | } | ||
57 | 47 | ||
58 | return req.expect(options.statusCodeExpected) | 48 | function makeActivityPubGetRequest (url: string, path: string, expectedStatus = HttpStatusCode.OK_200) { |
49 | return makeGetRequest({ | ||
50 | url, | ||
51 | path, | ||
52 | expectedStatus: expectedStatus, | ||
53 | accept: 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8' | ||
54 | }) | ||
59 | } | 55 | } |
60 | 56 | ||
61 | function makeUploadRequest (options: { | 57 | function makeDeleteRequest (options: CommonRequestParams) { |
62 | url: string | 58 | const req = request(options.url).delete(options.path) |
59 | |||
60 | return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) | ||
61 | } | ||
62 | |||
63 | function makeUploadRequest (options: CommonRequestParams & { | ||
63 | method?: 'POST' | 'PUT' | 64 | method?: 'POST' | 'PUT' |
64 | path: string | ||
65 | token?: string | ||
66 | 65 | ||
67 | fields: { [ fieldName: string ]: any } | 66 | fields: { [ fieldName: string ]: any } |
68 | attaches?: { [ attachName: string ]: any | any[] } | 67 | attaches?: { [ attachName: string ]: any | any[] } |
69 | |||
70 | headers?: { [ name: string ]: string } | ||
71 | |||
72 | statusCodeExpected?: HttpStatusCode | ||
73 | }) { | 68 | }) { |
74 | if (options.statusCodeExpected === undefined) { | 69 | let req = options.method === 'PUT' |
75 | options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 | 70 | ? request(options.url).put(options.path) |
76 | } | 71 | : request(options.url).post(options.path) |
77 | 72 | ||
78 | let req: request.Test | 73 | req = buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) |
79 | if (options.method === 'PUT') { | ||
80 | req = request(options.url).put(options.path) | ||
81 | } else { | ||
82 | req = request(options.url).post(options.path) | ||
83 | } | ||
84 | 74 | ||
85 | req.set('Accept', 'application/json') | 75 | buildFields(req, options.fields) |
86 | |||
87 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | ||
88 | |||
89 | Object.keys(options.headers || {}).forEach(name => { | ||
90 | req.set(name, options.headers[name]) | ||
91 | }) | ||
92 | |||
93 | Object.keys(options.fields).forEach(field => { | ||
94 | const value = options.fields[field] | ||
95 | |||
96 | if (value === undefined) return | ||
97 | |||
98 | if (Array.isArray(value)) { | ||
99 | for (let i = 0; i < value.length; i++) { | ||
100 | req.field(field + '[' + i + ']', value[i]) | ||
101 | } | ||
102 | } else { | ||
103 | req.field(field, value) | ||
104 | } | ||
105 | }) | ||
106 | 76 | ||
107 | Object.keys(options.attaches || {}).forEach(attach => { | 77 | Object.keys(options.attaches || {}).forEach(attach => { |
108 | const value = options.attaches[attach] | 78 | const value = options.attaches[attach] |
79 | |||
109 | if (Array.isArray(value)) { | 80 | if (Array.isArray(value)) { |
110 | req.attach(attach, buildAbsoluteFixturePath(value[0]), value[1]) | 81 | req.attach(attach, buildAbsoluteFixturePath(value[0]), value[1]) |
111 | } else { | 82 | } else { |
@@ -113,40 +84,16 @@ function makeUploadRequest (options: { | |||
113 | } | 84 | } |
114 | }) | 85 | }) |
115 | 86 | ||
116 | if (options.statusCodeExpected) { | ||
117 | req.expect(options.statusCodeExpected) | ||
118 | } | ||
119 | |||
120 | return req | 87 | return req |
121 | } | 88 | } |
122 | 89 | ||
123 | function makePostBodyRequest (options: { | 90 | function makePostBodyRequest (options: CommonRequestParams & { |
124 | url: string | ||
125 | path: string | ||
126 | token?: string | ||
127 | fields?: { [ fieldName: string ]: any } | 91 | fields?: { [ fieldName: string ]: any } |
128 | headers?: { [ name: string ]: string } | ||
129 | type?: string | ||
130 | xForwardedFor?: string | ||
131 | statusCodeExpected?: HttpStatusCode | ||
132 | }) { | 92 | }) { |
133 | if (!options.fields) options.fields = {} | 93 | const req = request(options.url).post(options.path) |
134 | if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 | 94 | .send(options.fields) |
135 | |||
136 | const req = request(options.url) | ||
137 | .post(options.path) | ||
138 | .set('Accept', 'application/json') | ||
139 | 95 | ||
140 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | 96 | return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) |
141 | if (options.xForwardedFor) req.set('X-Forwarded-For', options.xForwardedFor) | ||
142 | if (options.type) req.type(options.type) | ||
143 | |||
144 | Object.keys(options.headers || {}).forEach(name => { | ||
145 | req.set(name, options.headers[name]) | ||
146 | }) | ||
147 | |||
148 | return req.send(options.fields) | ||
149 | .expect(options.statusCodeExpected) | ||
150 | } | 97 | } |
151 | 98 | ||
152 | function makePutBodyRequest (options: { | 99 | function makePutBodyRequest (options: { |
@@ -154,58 +101,12 @@ function makePutBodyRequest (options: { | |||
154 | path: string | 101 | path: string |
155 | token?: string | 102 | token?: string |
156 | fields: { [ fieldName: string ]: any } | 103 | fields: { [ fieldName: string ]: any } |
157 | statusCodeExpected?: HttpStatusCode | 104 | expectedStatus?: HttpStatusCode |
158 | }) { | ||
159 | if (!options.statusCodeExpected) options.statusCodeExpected = HttpStatusCode.BAD_REQUEST_400 | ||
160 | |||
161 | const req = request(options.url) | ||
162 | .put(options.path) | ||
163 | .set('Accept', 'application/json') | ||
164 | |||
165 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | ||
166 | |||
167 | return req.send(options.fields) | ||
168 | .expect(options.statusCodeExpected) | ||
169 | } | ||
170 | |||
171 | function makeHTMLRequest (url: string, path: string) { | ||
172 | return request(url) | ||
173 | .get(path) | ||
174 | .set('Accept', 'text/html') | ||
175 | .expect(HttpStatusCode.OK_200) | ||
176 | } | ||
177 | |||
178 | function makeActivityPubGetRequest (url: string, path: string, expectedStatus = HttpStatusCode.OK_200) { | ||
179 | return makeGetRequest({ | ||
180 | url, | ||
181 | path, | ||
182 | statusCodeExpected: expectedStatus, | ||
183 | accept: 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8' | ||
184 | }) | ||
185 | } | ||
186 | |||
187 | function updateImageRequest (options: { | ||
188 | url: string | ||
189 | path: string | ||
190 | accessToken: string | ||
191 | fixture: string | ||
192 | fieldname: string | ||
193 | }) { | 105 | }) { |
194 | let filePath = '' | 106 | const req = request(options.url).put(options.path) |
195 | if (isAbsolute(options.fixture)) { | 107 | .send(options.fields) |
196 | filePath = options.fixture | ||
197 | } else { | ||
198 | filePath = join(root(), 'server', 'tests', 'fixtures', options.fixture) | ||
199 | } | ||
200 | 108 | ||
201 | return makeUploadRequest({ | 109 | return buildRequest(req, { accept: 'application/json', expectedStatus: HttpStatusCode.BAD_REQUEST_400, ...options }) |
202 | url: options.url, | ||
203 | path: options.path, | ||
204 | token: options.accessToken, | ||
205 | fields: {}, | ||
206 | attaches: { [options.fieldname]: filePath }, | ||
207 | statusCodeExpected: HttpStatusCode.OK_200 | ||
208 | }) | ||
209 | } | 110 | } |
210 | 111 | ||
211 | function decodeQueryString (path: string) { | 112 | function decodeQueryString (path: string) { |
@@ -233,6 +134,49 @@ export { | |||
233 | makeRawRequest, | 134 | makeRawRequest, |
234 | makeActivityPubGetRequest, | 135 | makeActivityPubGetRequest, |
235 | unwrapBody, | 136 | unwrapBody, |
236 | unwrapText, | 137 | unwrapText |
237 | updateImageRequest | 138 | } |
139 | |||
140 | // --------------------------------------------------------------------------- | ||
141 | |||
142 | function buildRequest (req: request.Test, options: CommonRequestParams) { | ||
143 | if (options.contentType) req.set('Accept', options.contentType) | ||
144 | if (options.token) req.set('Authorization', 'Bearer ' + options.token) | ||
145 | if (options.range) req.set('Range', options.range) | ||
146 | if (options.accept) req.set('Accept', options.accept) | ||
147 | if (options.host) req.set('Host', options.host) | ||
148 | if (options.redirects) req.redirects(options.redirects) | ||
149 | if (options.expectedStatus) req.expect(options.expectedStatus) | ||
150 | if (options.xForwardedFor) req.set('X-Forwarded-For', options.xForwardedFor) | ||
151 | if (options.type) req.type(options.type) | ||
152 | |||
153 | Object.keys(options.headers || {}).forEach(name => { | ||
154 | req.set(name, options.headers[name]) | ||
155 | }) | ||
156 | |||
157 | return req | ||
158 | } | ||
159 | |||
160 | function buildFields (req: request.Test, fields: { [ fieldName: string ]: any }, namespace?: string) { | ||
161 | if (!fields) return | ||
162 | |||
163 | let formKey: string | ||
164 | |||
165 | for (const key of Object.keys(fields)) { | ||
166 | if (namespace) formKey = `${namespace}[${key}]` | ||
167 | else formKey = key | ||
168 | |||
169 | if (fields[key] === undefined) continue | ||
170 | |||
171 | if (Array.isArray(fields[key]) && fields[key].length === 0) { | ||
172 | req.field(key, null) | ||
173 | continue | ||
174 | } | ||
175 | |||
176 | if (fields[key] !== null && typeof fields[key] === 'object') { | ||
177 | buildFields(req, fields[key], formKey) | ||
178 | } else { | ||
179 | req.field(formKey, fields[key]) | ||
180 | } | ||
181 | } | ||
238 | } | 182 | } |
diff --git a/shared/extra-utils/search/search-command.ts b/shared/extra-utils/search/search-command.ts index 7539a21ec..09f5d3f1d 100644 --- a/shared/extra-utils/search/search-command.ts +++ b/shared/extra-utils/search/search-command.ts | |||
@@ -7,7 +7,7 @@ import { | |||
7 | VideoPlaylistsSearchQuery, | 7 | VideoPlaylistsSearchQuery, |
8 | VideosSearchQuery | 8 | VideosSearchQuery |
9 | } from '@shared/models' | 9 | } from '@shared/models' |
10 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 10 | import { HttpStatusCode } from '@shared/models' |
11 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 11 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
12 | 12 | ||
13 | export class SearchCommand extends AbstractCommand { | 13 | export class SearchCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/server/config-command.ts b/shared/extra-utils/server/config-command.ts index f5d7fc5e3..6e875fdf6 100644 --- a/shared/extra-utils/server/config-command.ts +++ b/shared/extra-utils/server/config-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { merge } from 'lodash' | 1 | import { merge } from 'lodash' |
2 | import { DeepPartial, HttpStatusCode } from '@shared/core-utils' | 2 | import { DeepPartial } from '@shared/core-utils' |
3 | import { About, ServerConfig } from '@shared/models' | 3 | import { About, ServerConfig, HttpStatusCode } from '@shared/models' |
4 | import { CustomConfig } from '../../models/server/custom-config.model' | 4 | import { CustomConfig } from '../../models/server/custom-config.model' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
6 | 6 | ||
diff --git a/shared/extra-utils/server/contact-form-command.ts b/shared/extra-utils/server/contact-form-command.ts index 8d034552b..0e8fd6d84 100644 --- a/shared/extra-utils/server/contact-form-command.ts +++ b/shared/extra-utils/server/contact-form-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { ContactForm } from '../../models/server' | 2 | import { ContactForm } from '../../models/server' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
diff --git a/shared/extra-utils/server/debug-command.ts b/shared/extra-utils/server/debug-command.ts index 8b24b3067..36704836d 100644 --- a/shared/extra-utils/server/debug-command.ts +++ b/shared/extra-utils/server/debug-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Debug, SendDebugCommand } from '@shared/models' | 1 | import { Debug, SendDebugCommand } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class DebugCommand extends AbstractCommand { | 5 | export class DebugCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/server/follows-command.ts b/shared/extra-utils/server/follows-command.ts index 4e9ed9494..694f5ea24 100644 --- a/shared/extra-utils/server/follows-command.ts +++ b/shared/extra-utils/server/follows-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from 'lodash' |
2 | import { ActivityPubActorType, ActorFollow, FollowState, ResultList } from '@shared/models' | 2 | import { ActivityPubActorType, ActorFollow, FollowState, ResultList } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | import { PeerTubeServer } from './server' | 5 | import { PeerTubeServer } from './server' |
6 | 6 | ||
diff --git a/shared/extra-utils/server/jobs-command.ts b/shared/extra-utils/server/jobs-command.ts index 392b868c1..09a299e5b 100644 --- a/shared/extra-utils/server/jobs-command.ts +++ b/shared/extra-utils/server/jobs-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from 'lodash' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { Job, JobState, JobType, ResultList } from '../../models' | 3 | import { Job, JobState, JobType, ResultList } from '../../models' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 5 | ||
diff --git a/shared/extra-utils/server/plugins-command.ts b/shared/extra-utils/server/plugins-command.ts index 98049ce19..59bc79b3d 100644 --- a/shared/extra-utils/server/plugins-command.ts +++ b/shared/extra-utils/server/plugins-command.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import { readJSON, writeJSON } from 'fs-extra' | 3 | import { readJSON, writeJSON } from 'fs-extra' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { root } from '@server/helpers/core-utils' | 5 | import { root } from '@server/helpers/core-utils' |
6 | import { HttpStatusCode } from '@shared/core-utils' | 6 | import { HttpStatusCode } from '@shared/models' |
7 | import { | 7 | import { |
8 | PeerTubePlugin, | 8 | PeerTubePlugin, |
9 | PeerTubePluginIndex, | 9 | PeerTubePluginIndex, |
diff --git a/shared/extra-utils/server/redundancy-command.ts b/shared/extra-utils/server/redundancy-command.ts index 728332fdd..137d7f01c 100644 --- a/shared/extra-utils/server/redundancy-command.ts +++ b/shared/extra-utils/server/redundancy-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' | 1 | import { ResultList, VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class RedundancyCommand extends AbstractCommand { | 5 | export class RedundancyCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/server/server.ts b/shared/extra-utils/server/server.ts index cc6df2efe..b33bb9d1e 100644 --- a/shared/extra-utils/server/server.ts +++ b/shared/extra-utils/server/server.ts | |||
@@ -254,7 +254,7 @@ export class PeerTubeServer { | |||
254 | 254 | ||
255 | process.on('exit', () => { | 255 | process.on('exit', () => { |
256 | try { | 256 | try { |
257 | process.kill(self.server.app.pid) | 257 | process.kill(self.app.pid) |
258 | } catch { /* empty */ } | 258 | } catch { /* empty */ } |
259 | }) | 259 | }) |
260 | 260 | ||
diff --git a/shared/extra-utils/server/servers-command.ts b/shared/extra-utils/server/servers-command.ts index 1a7b2aade..107e2b4ad 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' | |||
2 | import { copy, ensureDir, readFile, remove } from 'fs-extra' | 2 | import { copy, ensureDir, readFile, remove } from 'fs-extra' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { root } from '@server/helpers/core-utils' | 4 | import { root } from '@server/helpers/core-utils' |
5 | import { HttpStatusCode } from '@shared/core-utils' | 5 | import { HttpStatusCode } from '@shared/models' |
6 | import { getFileSize } from '@uploadx/core' | 6 | import { getFileSize } from '@uploadx/core' |
7 | import { isGithubCI, wait } from '../miscs' | 7 | import { isGithubCI, wait } from '../miscs' |
8 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 8 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/server/stats-command.ts b/shared/extra-utils/server/stats-command.ts index f0f02ca08..6db473588 100644 --- a/shared/extra-utils/server/stats-command.ts +++ b/shared/extra-utils/server/stats-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ServerStats } from '@shared/models' | 1 | import { ServerStats } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class StatsCommand extends AbstractCommand { | 5 | export class StatsCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/shared/abstract-command.ts b/shared/extra-utils/shared/abstract-command.ts index 967f8f2ac..021045e49 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 { | |||
24 | // If we automatically send the server token if the token is not provided | 24 | // If we automatically send the server token if the token is not provided |
25 | implicitToken: boolean | 25 | implicitToken: boolean |
26 | defaultExpectedStatus: number | 26 | defaultExpectedStatus: number |
27 | } | ||
28 | 27 | ||
29 | interface InternalGetCommandOptions extends InternalCommonCommandOptions { | 28 | // Common optional request parameters |
30 | query?: { [ id: string ]: any } | ||
31 | contentType?: string | 29 | contentType?: string |
32 | accept?: string | 30 | accept?: string |
33 | redirects?: number | 31 | redirects?: number |
34 | range?: string | 32 | range?: string |
35 | host?: string | 33 | host?: string |
34 | headers?: { [ name: string ]: string } | ||
35 | requestType?: string | ||
36 | xForwardedFor?: string | ||
37 | } | ||
38 | |||
39 | interface InternalGetCommandOptions extends InternalCommonCommandOptions { | ||
40 | query?: { [ id: string ]: any } | ||
36 | } | 41 | } |
37 | 42 | ||
38 | abstract class AbstractCommand { | 43 | abstract class AbstractCommand { |
@@ -59,7 +64,7 @@ abstract class AbstractCommand { | |||
59 | ...options, | 64 | ...options, |
60 | 65 | ||
61 | token: this.buildCommonRequestToken(options), | 66 | token: this.buildCommonRequestToken(options), |
62 | defaultExpectedStatus: this.buildStatusCodeExpected(options), | 67 | defaultExpectedStatus: this.buildExpectedStatus(options), |
63 | 68 | ||
64 | url: `${protocol}//${host}`, | 69 | url: `${protocol}//${host}`, |
65 | path: pathname, | 70 | path: pathname, |
@@ -68,17 +73,12 @@ abstract class AbstractCommand { | |||
68 | } | 73 | } |
69 | 74 | ||
70 | protected getRequest (options: InternalGetCommandOptions) { | 75 | protected getRequest (options: InternalGetCommandOptions) { |
71 | const { redirects, query, contentType, accept, range, host } = options | 76 | const { query } = options |
72 | 77 | ||
73 | return makeGetRequest({ | 78 | return makeGetRequest({ |
74 | ...this.buildCommonRequestOptions(options), | 79 | ...this.buildCommonRequestOptions(options), |
75 | 80 | ||
76 | redirects, | 81 | query |
77 | query, | ||
78 | contentType, | ||
79 | range, | ||
80 | host, | ||
81 | accept | ||
82 | }) | 82 | }) |
83 | } | 83 | } |
84 | 84 | ||
@@ -100,51 +100,41 @@ abstract class AbstractCommand { | |||
100 | 100 | ||
101 | protected postBodyRequest (options: InternalCommonCommandOptions & { | 101 | protected postBodyRequest (options: InternalCommonCommandOptions & { |
102 | fields?: { [ fieldName: string ]: any } | 102 | fields?: { [ fieldName: string ]: any } |
103 | headers?: { [ name: string ]: string } | ||
104 | type?: string | ||
105 | xForwardedFor?: string | ||
106 | }) { | 103 | }) { |
107 | const { type, fields, xForwardedFor, headers } = options | 104 | const { fields } = options |
108 | 105 | ||
109 | return makePostBodyRequest({ | 106 | return makePostBodyRequest({ |
110 | ...this.buildCommonRequestOptions(options), | 107 | ...this.buildCommonRequestOptions(options), |
111 | 108 | ||
112 | fields, | 109 | fields |
113 | xForwardedFor, | ||
114 | type, | ||
115 | headers | ||
116 | }) | 110 | }) |
117 | } | 111 | } |
118 | 112 | ||
119 | protected postUploadRequest (options: InternalCommonCommandOptions & { | 113 | protected postUploadRequest (options: InternalCommonCommandOptions & { |
120 | fields?: { [ fieldName: string ]: any } | 114 | fields?: { [ fieldName: string ]: any } |
121 | attaches?: { [ fieldName: string ]: any } | 115 | attaches?: { [ fieldName: string ]: any } |
122 | headers?: { [ name: string ]: string } | ||
123 | }) { | 116 | }) { |
124 | const { fields, attaches, headers } = options | 117 | const { fields, attaches } = options |
125 | 118 | ||
126 | return makeUploadRequest({ | 119 | return makeUploadRequest({ |
127 | ...this.buildCommonRequestOptions(options), | 120 | ...this.buildCommonRequestOptions(options), |
128 | 121 | ||
129 | method: 'POST', | 122 | method: 'POST', |
130 | fields, | 123 | fields, |
131 | attaches, | 124 | attaches |
132 | headers | ||
133 | }) | 125 | }) |
134 | } | 126 | } |
135 | 127 | ||
136 | protected putUploadRequest (options: InternalCommonCommandOptions & { | 128 | protected putUploadRequest (options: InternalCommonCommandOptions & { |
137 | fields?: { [ fieldName: string ]: any } | 129 | fields?: { [ fieldName: string ]: any } |
138 | attaches?: { [ fieldName: string ]: any } | 130 | attaches?: { [ fieldName: string ]: any } |
139 | headers?: { [ name: string ]: string } | ||
140 | }) { | 131 | }) { |
141 | const { fields, attaches, headers } = options | 132 | const { fields, attaches } = options |
142 | 133 | ||
143 | return makeUploadRequest({ | 134 | return makeUploadRequest({ |
144 | ...this.buildCommonRequestOptions(options), | 135 | ...this.buildCommonRequestOptions(options), |
145 | 136 | ||
146 | method: 'PUT', | 137 | method: 'PUT', |
147 | headers, | ||
148 | fields, | 138 | fields, |
149 | attaches | 139 | attaches |
150 | }) | 140 | }) |
@@ -154,12 +144,9 @@ abstract class AbstractCommand { | |||
154 | fixture: string | 144 | fixture: string |
155 | fieldname: string | 145 | fieldname: string |
156 | }) { | 146 | }) { |
157 | let filePath = '' | 147 | const filePath = isAbsolute(options.fixture) |
158 | if (isAbsolute(options.fixture)) { | 148 | ? options.fixture |
159 | filePath = options.fixture | 149 | : join(root(), 'server', 'tests', 'fixtures', options.fixture) |
160 | } else { | ||
161 | filePath = join(root(), 'server', 'tests', 'fixtures', options.fixture) | ||
162 | } | ||
163 | 150 | ||
164 | return this.postUploadRequest({ | 151 | return this.postUploadRequest({ |
165 | ...options, | 152 | ...options, |
@@ -170,14 +157,23 @@ abstract class AbstractCommand { | |||
170 | } | 157 | } |
171 | 158 | ||
172 | protected buildCommonRequestOptions (options: InternalCommonCommandOptions) { | 159 | protected buildCommonRequestOptions (options: InternalCommonCommandOptions) { |
173 | const { url, path } = options | 160 | const { url, path, redirects, contentType, accept, range, host, headers, requestType, xForwardedFor } = options |
174 | 161 | ||
175 | return { | 162 | return { |
176 | url: url ?? this.server.url, | 163 | url: url ?? this.server.url, |
177 | path, | 164 | path, |
178 | 165 | ||
179 | token: this.buildCommonRequestToken(options), | 166 | token: this.buildCommonRequestToken(options), |
180 | statusCodeExpected: this.buildStatusCodeExpected(options) | 167 | expectedStatus: this.buildExpectedStatus(options), |
168 | |||
169 | redirects, | ||
170 | contentType, | ||
171 | range, | ||
172 | host, | ||
173 | accept, | ||
174 | headers, | ||
175 | type: requestType, | ||
176 | xForwardedFor | ||
181 | } | 177 | } |
182 | } | 178 | } |
183 | 179 | ||
@@ -191,7 +187,7 @@ abstract class AbstractCommand { | |||
191 | return token !== undefined ? token : fallbackToken | 187 | return token !== undefined ? token : fallbackToken |
192 | } | 188 | } |
193 | 189 | ||
194 | protected buildStatusCodeExpected (options: Pick<InternalCommonCommandOptions, 'expectedStatus' | 'defaultExpectedStatus'>) { | 190 | protected buildExpectedStatus (options: Pick<InternalCommonCommandOptions, 'expectedStatus' | 'defaultExpectedStatus'>) { |
195 | const { expectedStatus, defaultExpectedStatus } = options | 191 | const { expectedStatus, defaultExpectedStatus } = options |
196 | 192 | ||
197 | return expectedStatus !== undefined ? expectedStatus : defaultExpectedStatus | 193 | return expectedStatus !== undefined ? expectedStatus : defaultExpectedStatus |
diff --git a/shared/extra-utils/users/accounts-command.ts b/shared/extra-utils/users/accounts-command.ts index 4cd1d2158..08977e58b 100644 --- a/shared/extra-utils/users/accounts-command.ts +++ b/shared/extra-utils/users/accounts-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList } from '@shared/models' | 1 | import { ResultList } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { Account } from '../../models/actors' | 3 | import { Account } from '../../models/actors' |
4 | import { AccountVideoRate, VideoRateType } from '../../models/videos' | 4 | import { AccountVideoRate, VideoRateType } from '../../models/videos' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/users/blocklist-command.ts b/shared/extra-utils/users/blocklist-command.ts index 089b5a579..a9431acf3 100644 --- a/shared/extra-utils/users/blocklist-command.ts +++ b/shared/extra-utils/users/blocklist-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { HttpStatusCode } from '@shared/core-utils' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { AccountBlock, ResultList, ServerBlock } from '@shared/models' | 4 | import { AccountBlock, ResultList, ServerBlock } from '@shared/models' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
6 | 6 | ||
diff --git a/shared/extra-utils/users/index.ts b/shared/extra-utils/users/index.ts index e6107afa5..fbb454e8f 100644 --- a/shared/extra-utils/users/index.ts +++ b/shared/extra-utils/users/index.ts | |||
@@ -7,4 +7,3 @@ export * from './notifications' | |||
7 | export * from './notifications-command' | 7 | export * from './notifications-command' |
8 | export * from './subscriptions-command' | 8 | export * from './subscriptions-command' |
9 | export * from './users-command' | 9 | export * from './users-command' |
10 | export * from './users' | ||
diff --git a/shared/extra-utils/users/login-command.ts b/shared/extra-utils/users/login-command.ts index 10c3db851..b39577260 100644 --- a/shared/extra-utils/users/login-command.ts +++ b/shared/extra-utils/users/login-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { PeerTubeProblemDocument } from '@shared/models' | 2 | import { PeerTubeProblemDocument } from '@shared/models' |
3 | import { unwrapBody } from '../requests' | 3 | import { unwrapBody } from '../requests' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
@@ -26,7 +26,7 @@ export class LoginCommand extends AbstractCommand { | |||
26 | ...options, | 26 | ...options, |
27 | 27 | ||
28 | path, | 28 | path, |
29 | type: 'form', | 29 | requestType: 'form', |
30 | fields: body, | 30 | fields: body, |
31 | implicitToken: false, | 31 | implicitToken: false, |
32 | defaultExpectedStatus: HttpStatusCode.OK_200 | 32 | defaultExpectedStatus: HttpStatusCode.OK_200 |
@@ -72,7 +72,7 @@ export class LoginCommand extends AbstractCommand { | |||
72 | ...options, | 72 | ...options, |
73 | 73 | ||
74 | path, | 74 | path, |
75 | type: 'form', | 75 | requestType: 'form', |
76 | fields: body, | 76 | fields: body, |
77 | implicitToken: false, | 77 | implicitToken: false, |
78 | defaultExpectedStatus: HttpStatusCode.OK_200 | 78 | defaultExpectedStatus: HttpStatusCode.OK_200 |
@@ -88,7 +88,7 @@ export class LoginCommand extends AbstractCommand { | |||
88 | ...options, | 88 | ...options, |
89 | 89 | ||
90 | path, | 90 | path, |
91 | type: 'form', | 91 | requestType: 'form', |
92 | implicitToken: false, | 92 | implicitToken: false, |
93 | defaultExpectedStatus: HttpStatusCode.OK_200 | 93 | defaultExpectedStatus: HttpStatusCode.OK_200 |
94 | })) | 94 | })) |
@@ -111,7 +111,7 @@ export class LoginCommand extends AbstractCommand { | |||
111 | ...options, | 111 | ...options, |
112 | 112 | ||
113 | path, | 113 | path, |
114 | type: 'form', | 114 | requestType: 'form', |
115 | fields: body, | 115 | fields: body, |
116 | implicitToken: false, | 116 | implicitToken: false, |
117 | defaultExpectedStatus: HttpStatusCode.OK_200 | 117 | defaultExpectedStatus: HttpStatusCode.OK_200 |
diff --git a/shared/extra-utils/users/notifications-command.ts b/shared/extra-utils/users/notifications-command.ts index dfe574ca1..a51fcc3af 100644 --- a/shared/extra-utils/users/notifications-command.ts +++ b/shared/extra-utils/users/notifications-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList } from '@shared/models' | 1 | import { ResultList } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { UserNotification, UserNotificationSetting } from '../../models/users' | 3 | import { UserNotification, UserNotificationSetting } from '../../models/users' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 5 | ||
diff --git a/shared/extra-utils/users/subscriptions-command.ts b/shared/extra-utils/users/subscriptions-command.ts index e998eb426..a69d2a194 100644 --- a/shared/extra-utils/users/subscriptions-command.ts +++ b/shared/extra-utils/users/subscriptions-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList, Video, VideoChannel } from '@shared/models' | 1 | import { ResultList, Video, VideoChannel } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class SubscriptionsCommand extends AbstractCommand { | 5 | export class SubscriptionsCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/users/users-command.ts b/shared/extra-utils/users/users-command.ts index 59dc6d018..f3a251e65 100644 --- a/shared/extra-utils/users/users-command.ts +++ b/shared/extra-utils/users/users-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { omit, pick } from 'lodash' | 1 | import { omit, pick } from 'lodash' |
2 | import { HttpStatusCode } from '@shared/core-utils' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { | 3 | import { |
4 | MyUser, | 4 | MyUser, |
5 | ResultList, | 5 | ResultList, |
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts deleted file mode 100644 index 6cf61d60e..000000000 --- a/shared/extra-utils/users/users.ts +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | import * as request from 'supertest' | ||
2 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
3 | |||
4 | // FIXME: delete once videos does not use it anymore | ||
5 | function xxxgetMyUserInformation (url: string, accessToken: string, specialStatus = HttpStatusCode.OK_200) { | ||
6 | const path = '/api/v1/users/me' | ||
7 | |||
8 | return request(url) | ||
9 | .get(path) | ||
10 | .set('Accept', 'application/json') | ||
11 | .set('Authorization', 'Bearer ' + accessToken) | ||
12 | .expect(specialStatus) | ||
13 | .expect('Content-Type', /json/) | ||
14 | } | ||
15 | |||
16 | // --------------------------------------------------------------------------- | ||
17 | |||
18 | export { | ||
19 | xxxgetMyUserInformation | ||
20 | } | ||
diff --git a/shared/extra-utils/videos/blacklist-command.ts b/shared/extra-utils/videos/blacklist-command.ts index fdae6b469..9404d4c08 100644 --- a/shared/extra-utils/videos/blacklist-command.ts +++ b/shared/extra-utils/videos/blacklist-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | import { ResultList } from '@shared/models' | 2 | import { ResultList } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { VideoBlacklist, VideoBlacklistType } from '../../models/videos' | 4 | import { VideoBlacklist, VideoBlacklistType } from '../../models/videos' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
6 | 6 | ||
diff --git a/shared/extra-utils/videos/captions-command.ts b/shared/extra-utils/videos/captions-command.ts index ac3bde7a9..04dd32f84 100644 --- a/shared/extra-utils/videos/captions-command.ts +++ b/shared/extra-utils/videos/captions-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { ResultList, VideoCaption } from '@shared/models' | 2 | import { ResultList, VideoCaption } from '@shared/models' |
3 | import { buildAbsoluteFixturePath } from '../miscs' | 3 | import { buildAbsoluteFixturePath } from '../miscs' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/videos/captions.ts b/shared/extra-utils/videos/captions.ts index 2246bd133..ff8a43366 100644 --- a/shared/extra-utils/videos/captions.ts +++ b/shared/extra-utils/videos/captions.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { expect } from 'chai' | 1 | import { expect } from 'chai' |
2 | import * as request from 'supertest' | 2 | import * as request from 'supertest' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | 4 | ||
5 | async function testCaptionFile (url: string, captionPath: string, containsString: string) { | 5 | async function testCaptionFile (url: string, captionPath: string, containsString: string) { |
6 | const res = await request(url) | 6 | 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 03f77a95f..ef6f07536 100644 --- a/shared/extra-utils/videos/change-ownership-command.ts +++ b/shared/extra-utils/videos/change-ownership-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | import { ResultList, VideoChangeOwnership } from '@shared/models' | 2 | import { ResultList, VideoChangeOwnership } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 5 | ||
6 | export class ChangeOwnershipCommand extends AbstractCommand { | 6 | export class ChangeOwnershipCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/videos/channels-command.ts b/shared/extra-utils/videos/channels-command.ts index a98c5cc93..e5393ff56 100644 --- a/shared/extra-utils/videos/channels-command.ts +++ b/shared/extra-utils/videos/channels-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from 'lodash' |
2 | import { ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' | 2 | import { ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' | 4 | import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model' |
5 | import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' | 5 | import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model' |
6 | import { unwrapBody } from '../requests' | 6 | import { unwrapBody } from '../requests' |
diff --git a/shared/extra-utils/videos/comments-command.ts b/shared/extra-utils/videos/comments-command.ts index b31f3e2dd..7368f3ea2 100644 --- a/shared/extra-utils/videos/comments-command.ts +++ b/shared/extra-utils/videos/comments-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { pick } from 'lodash' | 1 | import { pick } from 'lodash' |
2 | import { HttpStatusCode } from '@shared/models' | ||
2 | import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models' | 3 | import { ResultList, VideoComment, VideoCommentThreads, VideoCommentThreadTree } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
4 | import { unwrapBody } from '../requests' | 4 | import { unwrapBody } from '../requests' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
6 | 6 | ||
diff --git a/shared/extra-utils/videos/history-command.ts b/shared/extra-utils/videos/history-command.ts index 8a144a312..41afc6bc6 100644 --- a/shared/extra-utils/videos/history-command.ts +++ b/shared/extra-utils/videos/history-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { HttpStatusCode } from '@shared/models' | ||
1 | import { ResultList, Video } from '@shared/models' | 2 | import { ResultList, Video } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class HistoryCommand extends AbstractCommand { | 5 | export class HistoryCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/videos/imports-command.ts b/shared/extra-utils/videos/imports-command.ts index de8b65829..d30f9745b 100644 --- a/shared/extra-utils/videos/imports-command.ts +++ b/shared/extra-utils/videos/imports-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | import { HttpStatusCode } from '@shared/models' | ||
2 | import { ResultList } from '@shared/models' | 3 | import { ResultList } from '@shared/models' |
3 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
4 | import { VideoImport, VideoImportCreate } from '../../models/videos' | 4 | import { VideoImport, VideoImportCreate } from '../../models/videos' |
5 | import { unwrapBody } from '../requests' | 5 | import { unwrapBody } from '../requests' |
6 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 6 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/videos/live-command.ts b/shared/extra-utils/videos/live-command.ts index fd66c9924..9dfe3087e 100644 --- a/shared/extra-utils/videos/live-command.ts +++ b/shared/extra-utils/videos/live-command.ts | |||
@@ -3,8 +3,8 @@ | |||
3 | import { readdir } from 'fs-extra' | 3 | import { readdir } from 'fs-extra' |
4 | import { omit } from 'lodash' | 4 | import { omit } from 'lodash' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { HttpStatusCode } from '@shared/models' | ||
6 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' | 7 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models' |
7 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
8 | import { wait } from '../miscs' | 8 | import { wait } from '../miscs' |
9 | import { unwrapBody } from '../requests' | 9 | import { unwrapBody } from '../requests' |
10 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 10 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/videos/playlists-command.ts b/shared/extra-utils/videos/playlists-command.ts index cbfc7e10f..40162c30d 100644 --- a/shared/extra-utils/videos/playlists-command.ts +++ b/shared/extra-utils/videos/playlists-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { omit, pick } from 'lodash' | 1 | import { omit, pick } from 'lodash' |
2 | import { HttpStatusCode } from '@shared/core-utils' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { | 3 | import { |
4 | BooleanBothQuery, | 4 | BooleanBothQuery, |
5 | ResultList, | 5 | ResultList, |
diff --git a/shared/extra-utils/videos/services-command.ts b/shared/extra-utils/videos/services-command.ts index 313b7878c..06760df42 100644 --- a/shared/extra-utils/videos/services-command.ts +++ b/shared/extra-utils/videos/services-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
3 | 3 | ||
4 | export class ServicesCommand extends AbstractCommand { | 4 | 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 fab3eb556..9662685da 100644 --- a/shared/extra-utils/videos/streaming-playlists-command.ts +++ b/shared/extra-utils/videos/streaming-playlists-command.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | 1 | import { HttpStatusCode } from '@shared/models' | |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | ||
3 | import { unwrapBody, unwrapText } from '../requests' | 2 | import { unwrapBody, unwrapText } from '../requests' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 4 | ||
diff --git a/shared/extra-utils/videos/streaming-playlists.ts b/shared/extra-utils/videos/streaming-playlists.ts index 002ae08b2..007d3d98d 100644 --- a/shared/extra-utils/videos/streaming-playlists.ts +++ b/shared/extra-utils/videos/streaming-playlists.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { expect } from 'chai' | 1 | import { expect } from 'chai' |
2 | import { sha256 } from '@server/helpers/core-utils' | 2 | import { sha256 } from '@server/helpers/core-utils' |
3 | import { HttpStatusCode } from '@shared/core-utils' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { VideoStreamingPlaylist } from '@shared/models' | 4 | import { VideoStreamingPlaylist } from '@shared/models' |
5 | import { PeerTubeServer } from '../server' | 5 | import { PeerTubeServer } from '../server' |
6 | 6 | ||
diff --git a/shared/extra-utils/videos/videos-command.ts b/shared/extra-utils/videos/videos-command.ts index feef5a771..f46d386f4 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' | |||
7 | import validator from 'validator' | 7 | import validator from 'validator' |
8 | import { buildUUID } from '@server/helpers/uuid' | 8 | import { buildUUID } from '@server/helpers/uuid' |
9 | import { loadLanguages } from '@server/initializers/constants' | 9 | import { loadLanguages } from '@server/initializers/constants' |
10 | import { HttpStatusCode } from '@shared/core-utils' | 10 | import { HttpStatusCode } from '@shared/models' |
11 | import { | 11 | import { |
12 | ResultList, | 12 | ResultList, |
13 | UserVideoRateType, | 13 | UserVideoRateType, |
@@ -234,10 +234,10 @@ export class VideosCommand extends AbstractCommand { | |||
234 | } | 234 | } |
235 | 235 | ||
236 | listByAccount (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { | 236 | listByAccount (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { |
237 | accountName: string | 237 | handle: string |
238 | }) { | 238 | }) { |
239 | const { accountName, search } = options | 239 | const { handle, search } = options |
240 | const path = '/api/v1/accounts/' + accountName + '/videos' | 240 | const path = '/api/v1/accounts/' + handle + '/videos' |
241 | 241 | ||
242 | return this.getRequestBody<ResultList<Video>>({ | 242 | return this.getRequestBody<ResultList<Video>>({ |
243 | ...options, | 243 | ...options, |
@@ -250,10 +250,10 @@ export class VideosCommand extends AbstractCommand { | |||
250 | } | 250 | } |
251 | 251 | ||
252 | listByChannel (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { | 252 | listByChannel (options: OverrideCommandOptions & VideosWithSearchCommonQuery & { |
253 | videoChannelName: string | 253 | handle: string |
254 | }) { | 254 | }) { |
255 | const { videoChannelName } = options | 255 | const { handle } = options |
256 | const path = '/api/v1/video-channels/' + videoChannelName + '/videos' | 256 | const path = '/api/v1/video-channels/' + handle + '/videos' |
257 | 257 | ||
258 | return this.getRequestBody<ResultList<Video>>({ | 258 | return this.getRequestBody<ResultList<Video>>({ |
259 | ...options, | 259 | ...options, |
@@ -309,13 +309,13 @@ export class VideosCommand extends AbstractCommand { | |||
309 | }) { | 309 | }) { |
310 | const path = '/api/v1/videos/' + options.id | 310 | const path = '/api/v1/videos/' + options.id |
311 | 311 | ||
312 | return this.deleteRequest({ | 312 | return unwrapBody(this.deleteRequest({ |
313 | ...options, | 313 | ...options, |
314 | 314 | ||
315 | path, | 315 | path, |
316 | implicitToken: true, | 316 | implicitToken: true, |
317 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 | 317 | defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204 |
318 | }) | 318 | })) |
319 | } | 319 | } |
320 | 320 | ||
321 | async removeAll () { | 321 | async removeAll () { |
@@ -396,7 +396,7 @@ export class VideosCommand extends AbstractCommand { | |||
396 | 396 | ||
397 | async buildResumeUpload (options: OverrideCommandOptions & { | 397 | async buildResumeUpload (options: OverrideCommandOptions & { |
398 | attributes: VideoEdit | 398 | attributes: VideoEdit |
399 | }) { | 399 | }): Promise<VideoCreateResult> { |
400 | const { attributes, expectedStatus } = options | 400 | const { attributes, expectedStatus } = options |
401 | 401 | ||
402 | let size = 0 | 402 | let size = 0 |
@@ -414,7 +414,8 @@ export class VideosCommand extends AbstractCommand { | |||
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | const initializeSessionRes = await this.prepareResumableUpload({ ...options, attributes, size, mimetype }) | 417 | // Do not check status automatically, we'll check it manually |
418 | const initializeSessionRes = await this.prepareResumableUpload({ ...options, expectedStatus: null, attributes, size, mimetype }) | ||
418 | const initStatus = initializeSessionRes.status | 419 | const initStatus = initializeSessionRes.status |
419 | 420 | ||
420 | if (videoFilePath && initStatus === HttpStatusCode.CREATED_201) { | 421 | if (videoFilePath && initStatus === HttpStatusCode.CREATED_201) { |
@@ -425,7 +426,7 @@ export class VideosCommand extends AbstractCommand { | |||
425 | 426 | ||
426 | const result = await this.sendResumableChunks({ ...options, pathUploadId, videoFilePath, size }) | 427 | const result = await this.sendResumableChunks({ ...options, pathUploadId, videoFilePath, size }) |
427 | 428 | ||
428 | return result.body.video | 429 | return result.body?.video || result.body as any |
429 | } | 430 | } |
430 | 431 | ||
431 | const expectedInitStatus = expectedStatus === HttpStatusCode.OK_200 | 432 | const expectedInitStatus = expectedStatus === HttpStatusCode.OK_200 |
@@ -434,7 +435,7 @@ export class VideosCommand extends AbstractCommand { | |||
434 | 435 | ||
435 | expect(initStatus).to.equal(expectedInitStatus) | 436 | expect(initStatus).to.equal(expectedInitStatus) |
436 | 437 | ||
437 | return initializeSessionRes.body.video as VideoCreateResult | 438 | return initializeSessionRes.body.video || initializeSessionRes.body |
438 | } | 439 | } |
439 | 440 | ||
440 | async prepareResumableUpload (options: OverrideCommandOptions & { | 441 | async prepareResumableUpload (options: OverrideCommandOptions & { |
@@ -455,7 +456,10 @@ export class VideosCommand extends AbstractCommand { | |||
455 | 'X-Upload-Content-Length': size.toString() | 456 | 'X-Upload-Content-Length': size.toString() |
456 | }, | 457 | }, |
457 | fields: { filename: attributes.fixture, ...this.buildUploadFields(options.attributes) }, | 458 | fields: { filename: attributes.fixture, ...this.buildUploadFields(options.attributes) }, |
459 | // Fixture will be sent later | ||
460 | attaches: this.buildUploadAttaches(omit(options.attributes, 'fixture')), | ||
458 | implicitToken: true, | 461 | implicitToken: true, |
462 | |||
459 | defaultExpectedStatus: null | 463 | defaultExpectedStatus: null |
460 | }) | 464 | }) |
461 | } | 465 | } |
@@ -539,10 +543,10 @@ export class VideosCommand extends AbstractCommand { | |||
539 | 543 | ||
540 | const attributes = { name, additionalParams } | 544 | const attributes = { name, additionalParams } |
541 | 545 | ||
542 | if (wait) await waitJobs([ this.server ]) | ||
543 | |||
544 | const result = await this.upload({ ...options, attributes }) | 546 | const result = await this.upload({ ...options, attributes }) |
545 | 547 | ||
548 | if (wait) await waitJobs([ this.server ]) | ||
549 | |||
546 | return { ...result, name } | 550 | return { ...result, name } |
547 | } | 551 | } |
548 | 552 | ||
@@ -566,7 +570,7 @@ export class VideosCommand extends AbstractCommand { | |||
566 | } | 570 | } |
567 | 571 | ||
568 | private buildUploadFields (attributes: VideoEdit) { | 572 | private buildUploadFields (attributes: VideoEdit) { |
569 | return omit(attributes, [ 'thumbnailfile', 'previewfile' ]) | 573 | return omit(attributes, [ 'fixture', 'thumbnailfile', 'previewfile' ]) |
570 | } | 574 | } |
571 | 575 | ||
572 | private buildUploadAttaches (attributes: VideoEdit) { | 576 | private buildUploadAttaches (attributes: VideoEdit) { |
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts index b41533808..a96073c56 100644 --- a/shared/extra-utils/videos/videos.ts +++ b/shared/extra-utils/videos/videos.ts | |||
@@ -4,7 +4,7 @@ import { expect } from 'chai' | |||
4 | import { pathExists, readdir } from 'fs-extra' | 4 | import { pathExists, readdir } from 'fs-extra' |
5 | import { join } from 'path' | 5 | import { join } from 'path' |
6 | import { getLowercaseExtension } from '@server/helpers/core-utils' | 6 | import { getLowercaseExtension } from '@server/helpers/core-utils' |
7 | import { HttpStatusCode } from '@shared/core-utils' | 7 | import { HttpStatusCode } from '@shared/models' |
8 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' | 8 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' |
9 | import { dateIsValid, testImage, webtorrentAdd } from '../miscs' | 9 | import { dateIsValid, testImage, webtorrentAdd } from '../miscs' |
10 | import { makeRawRequest } from '../requests/requests' | 10 | import { makeRawRequest } from '../requests/requests' |
diff --git a/shared/core-utils/miscs/http-error-codes.ts b/shared/models/http/http-error-codes.ts index b2fbdfc5a..b2fbdfc5a 100644 --- a/shared/core-utils/miscs/http-error-codes.ts +++ b/shared/models/http/http-error-codes.ts | |||
diff --git a/shared/core-utils/miscs/http-methods.ts b/shared/models/http/http-methods.ts index 1cfa458b9..1cfa458b9 100644 --- a/shared/core-utils/miscs/http-methods.ts +++ b/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 000000000..ec991afe0 --- /dev/null +++ b/shared/models/http/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './http-error-codes' | ||
2 | export * from './http-methods' | ||
diff --git a/shared/models/index.ts b/shared/models/index.ts index 5c2bc480e..78723d830 100644 --- a/shared/models/index.ts +++ b/shared/models/index.ts | |||
@@ -4,6 +4,7 @@ export * from './bulk' | |||
4 | export * from './common' | 4 | export * from './common' |
5 | export * from './custom-markup' | 5 | export * from './custom-markup' |
6 | export * from './feeds' | 6 | export * from './feeds' |
7 | export * from './http' | ||
7 | export * from './joinpeertube' | 8 | export * from './joinpeertube' |
8 | export * from './moderation' | 9 | export * from './moderation' |
9 | export * from './overviews' | 10 | export * from './overviews' |
diff --git a/shared/models/server/peertube-problem-document.model.ts b/shared/models/server/peertube-problem-document.model.ts index e391d5aad..8dd96f7a3 100644 --- a/shared/models/server/peertube-problem-document.model.ts +++ b/shared/models/server/peertube-problem-document.model.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '../../core-utils' | 1 | import { HttpStatusCode } from '../../models' |
2 | import { OAuth2ErrorCode, ServerErrorCode } from './server-error-code.enum' | 2 | import { OAuth2ErrorCode, ServerErrorCode } from './server-error-code.enum' |
3 | 3 | ||
4 | export interface PeerTubeProblemDocumentData { | 4 | export interface PeerTubeProblemDocumentData { |