import express from 'express'
import RateLimit from 'express-rate-limit'
import { logger } from '@server/helpers/logger'
-import { buildUUID } from '@shared/core-utils/uuid'
import { CONFIG } from '@server/initializers/config'
import { getAuthNameFromRefreshGrant, getBypassFromExternalAuth, getBypassFromPasswordGrant } from '@server/lib/auth/external-auth'
import { handleOAuthToken } from '@server/lib/auth/oauth'
import { BypassLogin, revokeToken } from '@server/lib/auth/oauth-model'
import { Hooks } from '@server/lib/plugins/hooks'
import { asyncMiddleware, authenticate, openapiOperationDoc } from '@server/middlewares'
+import { buildUUID } from '@shared/core-utils'
import { ScopedToken } from '@shared/models/users/user-scoped-token'
const tokensRouter = express.Router()
import express from 'express'
import { join } from 'path'
-import { uuidToShort } from '@shared/core-utils/uuid'
import { scheduleRefreshIfNeeded } from '@server/lib/activitypub/playlists'
import { Hooks } from '@server/lib/plugins/hooks'
import { getServerActor } from '@server/models/application/application'
import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/types/models'
+import { uuidToShort } from '@shared/core-utils'
import { VideoPlaylistCreateResult, VideoPlaylistElementCreateResult } from '@shared/models'
import { HttpStatusCode } from '../../../shared/models/http/http-error-codes'
import { VideoPlaylistCreate } from '../../../shared/models/videos/playlist/video-playlist-create.model'
import express from 'express'
import { createReqFiles } from '@server/helpers/express-utils'
-import { buildUUID, uuidToShort } from '@shared/core-utils/uuid'
import { CONFIG } from '@server/initializers/config'
import { ASSETS_PATH, MIMETYPES } from '@server/initializers/constants'
import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'
import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator } from '@server/middlewares/validators/videos/video-live'
import { VideoLiveModel } from '@server/models/video/video-live'
import { MVideoDetails, MVideoFullLight } from '@server/types/models'
+import { buildUUID, uuidToShort } from '@shared/core-utils'
import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared'
import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { logger } from '../../../helpers/logger'
import express from 'express'
import { move } from 'fs-extra'
import { basename } from 'path'
-import { getLowercaseExtension } from '@shared/core-utils'
import { getResumableUploadPath } from '@server/helpers/upload'
-import { uuidToShort } from '@shared/core-utils/uuid'
import { createTorrentAndSetInfoHash } from '@server/helpers/webtorrent'
import { getLocalVideoActivityPubUrl } from '@server/lib/activitypub/url'
import { generateWebTorrentVideoFilename } from '@server/lib/paths'
import { buildNextVideoState } from '@server/lib/video-state'
import { openapiOperationDoc } from '@server/middlewares/doc'
import { MVideo, MVideoFile, MVideoFullLight } from '@server/types/models'
+import { getLowercaseExtension, uuidToShort } from '@shared/core-utils'
import { VideoCreate, VideoState } from '../../../../shared'
import { HttpStatusCode } from '../../../../shared/models'
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
import { UploadFilesForCheck } from 'express'
import { sep } from 'path'
import validator from 'validator'
-import { isShortUUID, shortToUUID } from '@shared/core-utils/uuid'
+import { isShortUUID, shortToUUID } from '@shared/core-utils'
function exists (value: any) {
return value !== undefined && value !== null
import { copy, readFile, remove, rename } from 'fs-extra'
import Jimp, { read } from 'jimp'
-import { getLowercaseExtension } from '@shared/core-utils'
+import { buildUUID, getLowercaseExtension } from '@shared/core-utils'
import { convertWebPToJPG, processGIF } from './ffmpeg-utils'
import { logger } from './logger'
-import { buildUUID } from '@shared/core-utils/uuid'
function generateImageFilename (extension = '.jpg') {
return buildUUID() + extension
import { cloneDeep } from 'lodash'
import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants'
import { MActor } from '../types/models'
-import { sha256 } from '@shared/core-utils/crypto'
+import { sha256 } from '@shared/core-utils/common/crypto'
import { createPrivateKey, getPublicKey, promisify1, promisify2 } from './core-utils'
import { jsonld } from './custom-jsonld-signature'
import { logger } from './logger'
import { join } from 'path'
import { ResultList } from '../../shared'
import { CONFIG } from '../initializers/config'
-import { sha256 } from '@shared/core-utils/crypto'
+import { sha256 } from '@shared/core-utils/common/crypto'
import { execPromise, execPromise2, randomBytesPromise } from './core-utils'
import { logger } from './logger'
import { MStreamingPlaylistVideo } from '@server/types/models/video/video-streaming-playlist'
import { CONFIG } from '../initializers/config'
import { promisify2 } from './core-utils'
-import { sha1 } from '@shared/core-utils/crypto'
+import { sha1 } from '@shared/core-utils/common/crypto'
import { logger } from './logger'
import { generateVideoImportTmpPath } from './utils'
import { extractVideo } from './video'
import { randomBytes } from 'crypto'
import { invert } from 'lodash'
import { join } from 'path'
-import { randomInt } from '../../shared/core-utils/common/miscs'
+import { randomInt, root } from '@shared/core-utils'
import {
AbuseState,
JobType,
import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model'
import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model'
-import { root } from '../../shared/core-utils'
// Do not use barrels, remain constants as independent as possible
import { isTestInstance, sanitizeHost, sanitizeUrl } from '../helpers/core-utils'
import { CONFIG, registerConfigChangedHandler } from './config'
-import { buildUUID } from '@shared/core-utils/uuid'
+import { buildUUID } from '@shared/core-utils'
import * as Sequelize from 'sequelize'
async function up (utils: {
import * as Sequelize from 'sequelize'
-import { buildUUID } from '@shared/core-utils/uuid'
+import { buildUUID } from '@shared/core-utils'
import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos'
import { WEBSERVER } from '../constants'
import * as Sequelize from 'sequelize'
-import { buildUUID } from '@shared/core-utils/uuid'
+import { buildUUID } from '@shared/core-utils'
async function up (utils: {
transaction: Sequelize.Transaction
-import { getLowercaseExtension } from '@shared/core-utils'
import { isActivityPubUrlValid } from '@server/helpers/custom-validators/activitypub/misc'
-import { buildUUID } from '@shared/core-utils/uuid'
import { MIMETYPES } from '@server/initializers/constants'
import { ActorModel } from '@server/models/actor/actor'
import { FilteredModelAttributes } from '@server/types'
+import { buildUUID, getLowercaseExtension } from '@shared/core-utils'
import { ActivityPubActor, ActorImageType } from '@shared/models'
function getActorAttributesFromObject (
UnauthorizedClientError,
UnsupportedGrantTypeError
} from 'oauth2-server'
-import { sha1 } from '@shared/core-utils/crypto'
+import { sha1 } from '@shared/core-utils/common/crypto'
import { randomBytesPromise } from '@server/helpers/core-utils'
import { MOAuthClient } from '@server/types/models'
import { OAUTH_LIFETIME } from '../../initializers/constants'
import { HttpStatusCode } from '../../shared/models/http/http-error-codes'
import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos'
import { isTestInstance } from '../helpers/core-utils'
-import { sha256 } from '@shared/core-utils/crypto'
+import { sha256 } from '@shared/core-utils/common/crypto'
import { logger } from '../helpers/logger'
import { mdToPlainText } from '../helpers/markdown'
import { CONFIG } from '../initializers/config'
import { flatten, uniq } from 'lodash'
import { basename, dirname, join } from 'path'
import { MStreamingPlaylistFilesVideo, MVideo, MVideoUUID } from '@server/types/models'
-import { sha256 } from '@shared/core-utils/crypto'
+import { sha256 } from '@shared/core-utils/common/crypto'
import { getAudioStreamCodec, getVideoStreamCodec, getVideoStreamSize } from '../helpers/ffprobe-utils'
import { logger } from '../helpers/logger'
import { doRequest, doRequestAndSaveToFile } from '../helpers/requests'
import { queue } from 'async'
import LRUCache from 'lru-cache'
import { join } from 'path'
-import { getLowercaseExtension } from '@shared/core-utils'
-import { buildUUID } from '@shared/core-utils/uuid'
import { ActorModel } from '@server/models/actor/actor'
+import { buildUUID, getLowercaseExtension } from '@shared/core-utils'
import { ActivityPubActorType, ActorImageType } from '@shared/models'
import { retryTransactionWrapper } from '../helpers/database-utils'
import { processImage } from '../helpers/image-utils'
import { join } from 'path'
-import { buildUUID } from '@shared/core-utils/uuid'
import { CONFIG } from '@server/initializers/config'
import { HLS_REDUNDANCY_DIRECTORY, HLS_STREAMING_PLAYLIST_DIRECTORY } from '@server/initializers/constants'
import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoFile, MVideoUUID } from '@server/types/models'
-import { removeFragmentedMP4Ext } from '@shared/core-utils'
+import { buildUUID, removeFragmentedMP4Ext } from '@shared/core-utils'
// ################## Video file name ##################
import { Transaction } from 'sequelize/types'
-import { buildUUID } from '@shared/core-utils/uuid'
import { UserModel } from '@server/models/user/user'
import { MActorDefault } from '@server/types/models/actor'
+import { buildUUID } from '@shared/core-utils'
import { ActivityPubActorType } from '../../shared/models/activitypub'
import { UserNotificationSetting, UserNotificationSettingValue } from '../../shared/models/users'
import { SERVER_ACTOR_NAME, WEBSERVER } from '../initializers/constants'
import { remove } from 'fs-extra'
import { extname, join } from 'path'
-import { buildUUID } from '@shared/core-utils/uuid'
import { extractVideo } from '@server/helpers/video'
import { CONFIG } from '@server/initializers/config'
import {
MVideoFileVideo,
MVideoUUID
} from '@server/types/models'
+import { buildUUID } from '@shared/core-utils'
import { VideoStorage } from '@shared/models'
import { makeHLSFileAvailable, makeWebTorrentFileAvailable } from './object-storage'
import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from './paths'
import { FindOptions, ModelIndexesOptions, Op, WhereOptions } from 'sequelize'
import { AllowNull, BelongsTo, Column, CreatedAt, Default, ForeignKey, Is, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'
-import { uuidToShort } from '@shared/core-utils/uuid'
import { UserNotificationIncludes, UserNotificationModelForApi } from '@server/types/models/user'
+import { uuidToShort } from '@shared/core-utils'
import { AttributesOnly } from '@shared/typescript-utils'
import { UserNotification, UserNotificationType } from '../../../shared'
import { isBooleanValid } from '../../helpers/custom-validators/misc'
-import { uuidToShort } from '@shared/core-utils/uuid'
import { generateMagnetUri } from '@server/helpers/webtorrent'
import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls'
import { VideoViews } from '@server/lib/video-views'
+import { uuidToShort } from '@shared/core-utils'
import { VideoFile, VideosCommonQueryAfterSanitize } from '@shared/models'
import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects'
import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos'
Table,
UpdatedAt
} from 'sequelize-typescript'
-import { buildUUID } from '@shared/core-utils/uuid'
import { MVideo, MVideoCaption, MVideoCaptionFormattable, MVideoCaptionVideo } from '@server/types/models'
+import { buildUUID } from '@shared/core-utils'
import { AttributesOnly } from '@shared/typescript-utils'
import { VideoCaption } from '../../../shared/models/videos/caption/video-caption.model'
import { isVideoCaptionLanguageValid } from '../../helpers/custom-validators/video-captions'
UpdatedAt
} from 'sequelize-typescript'
import { MAccountId, MChannelId } from '@server/types/models'
-import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils'
-import { buildUUID, uuidToShort } from '@shared/core-utils/uuid'
+import { buildPlaylistEmbedPath, buildPlaylistWatchPath, buildUUID, pick, uuidToShort } from '@shared/core-utils'
import { AttributesOnly } from '@shared/typescript-utils'
import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object'
import { AttributesOnly } from '@shared/typescript-utils'
import { VideoStorage } from '@shared/models'
import { VideoStreamingPlaylistType } from '../../../shared/models/videos/video-streaming-playlist.type'
-import { sha1 } from '@shared/core-utils/crypto'
+import { sha1 } from '@shared/core-utils/common/crypto'
import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
import { isArrayOf } from '../../helpers/custom-validators/misc'
import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos'
import { VideoPathManager } from '@server/lib/video-path-manager'
import { getServerActor } from '@server/models/application/application'
import { ModelCache } from '@server/models/model-cache'
-import { buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils'
-import { uuidToShort } from '@shared/core-utils/uuid'
+import { buildVideoEmbedPath, buildVideoWatchPath, pick, uuidToShort } from '@shared/core-utils'
import { VideoFile, VideoInclude } from '@shared/models'
import { AttributesOnly } from '@shared/typescript-utils'
import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared'
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
import {
cleanupTests,
createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
- wait,
waitJobs
} from '@shared/server-commands'
import 'mocha'
import * as chai from 'chai'
-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
+import {
+ cleanupTests,
+ createMultipleServers,
+ doubleFollow,
+ PeerTubeServer,
+ setAccessTokensToServers,
+ waitJobs
+} from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import { expect } from 'chai'
import { cloneDeep } from 'lodash'
-import { buildAbsoluteFixturePath, buildRequestStub } from '@shared/server-commands'
+import { buildRequestStub } from '@server/tests/shared'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
import { buildSignedActivity } from '../../../helpers/activitypub'
import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto'
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
- wait,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
describe('Test AP refresher', function () {
let servers: PeerTubeServer[] = []
import { buildDigest } from '@server/helpers/peertube-crypto'
import { HTTP_SIGNATURE } from '@server/initializers/constants'
import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils'
-import { buildAbsoluteFixturePath, cleanupTests, createMultipleServers, killallServers, PeerTubeServer, wait } from '@shared/server-commands'
import { makeFollowRequest, makePOSTAPRequest } from '@server/tests/shared'
+import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
import { HttpStatusCode } from '@shared/models'
+import { cleanupTests, createMultipleServers, killallServers, PeerTubeServer } from '@shared/server-commands'
const expect = chai.expect
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
+import { AbuseCreate, AbuseState, HttpStatusCode } from '@shared/models'
import {
AbusesCommand,
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
doubleFollow,
setAccessTokensToServers,
waitJobs
} from '@shared/server-commands'
-import { AbuseCreate, AbuseState, HttpStatusCode } from '@shared/models'
describe('Test abuses API validators', function () {
const basePath = '/api/v1/abuses/'
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
- cleanupTests,
- createSingleServer,
- PeerTubeServer
-} from '@shared/server-commands'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
import { HttpStatusCode } from '@shared/models'
+import { cleanupTests, createSingleServer, PeerTubeServer } from '@shared/server-commands'
describe('Test accounts API validators', function () {
const path = '/api/v1/accounts/'
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
+import { HttpStatusCode } from '@shared/models'
import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode } from '@shared/models'
describe('Test blocklist API validators', function () {
let servers: PeerTubeServer[]
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { MockSmtpServer } from '@server/tests/shared'
import { HttpStatusCode } from '@shared/models'
-import {
- cleanupTests,
- ContactFormCommand,
- createSingleServer,
- killallServers,
- MockSmtpServer,
- PeerTubeServer
-} from '@shared/server-commands'
+import { cleanupTests, ContactFormCommand, createSingleServer, killallServers, PeerTubeServer } from '@shared/server-commands'
describe('Test contact form API validators', function () {
let server: PeerTubeServer
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
+import { HttpStatusCode } from '@shared/models'
import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
makeDeleteRequest,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode } from '@shared/models'
describe('Test server follows API validators', function () {
let server: PeerTubeServer
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
- cleanupTests,
- createSingleServer,
- makeGetRequest,
- PeerTubeServer,
- setAccessTokensToServers
-} from '@shared/server-commands'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
import { HttpStatusCode } from '@shared/models'
+import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
describe('Test jobs API validators', function () {
const path = '/api/v1/jobs/failed'
import 'mocha'
import { omit } from 'lodash'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
+import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models'
import {
- buildAbsoluteFixturePath,
cleanupTests,
createSingleServer,
LiveCommand,
setAccessTokensToServers,
stopFfmpeg
} from '@shared/server-commands'
-import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models'
describe('Test video lives API validator', function () {
const path = '/api/v1/videos/live'
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
+import { HttpStatusCode, UserRole, VideoCreateResult } from '@shared/models'
import {
- buildAbsoluteFixturePath,
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
makeGetRequest,
makePutBodyRequest,
makeUploadRequest,
- MockSmtpServer,
PeerTubeServer,
setAccessTokensToServers,
UsersCommand
} from '@shared/server-commands'
-import { HttpStatusCode, UserRole, VideoCreateResult } from '@shared/models'
describe('Test my user API validators', function () {
const path = '/api/v1/users/'
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
+import { HttpStatusCode, PeerTubePlugin, PluginType } from '@shared/models'
import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
makeGetRequest,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, PeerTubePlugin, PluginType } from '@shared/models'
describe('Test server plugins API validators', function () {
let server: PeerTubeServer
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
+import { HttpStatusCode, VideoCreateResult } from '@shared/models'
import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createMultipleServers,
doubleFollow,
setAccessTokensToServers,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, VideoCreateResult } from '@shared/models'
describe('Test server redundancy API validators', function () {
let servers: PeerTubeServer[]
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
- cleanupTests,
- createSingleServer,
- makeGetRequest,
- PeerTubeServer,
- setAccessTokensToServers
-} from '@shared/server-commands'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
import { HttpStatusCode } from '@shared/models'
+import { cleanupTests, createSingleServer, makeGetRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
function updateSearchIndex (server: PeerTubeServer, enabled: boolean, disableLocalSearch = false) {
return server.config.updateCustomSubConfig({
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
import { HttpStatusCode, UserRole } from '@shared/models'
+import {
+ cleanupTests,
+ createMultipleServers,
+ doubleFollow,
+ PeerTubeServer,
+ setAccessTokensToServers,
+ waitJobs
+} from '@shared/server-commands'
describe('Test transcoding API validators', function () {
let servers: PeerTubeServer[]
import 'mocha'
import { expect } from 'chai'
+import { FIXTURE_URLS } from '@server/tests/shared'
import { randomInt } from '@shared/core-utils'
+import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models'
import {
cleanupTests,
createSingleServer,
- FIXTURE_URLS,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
VideosCommand,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, VideoImportState, VideoPrivacy } from '@shared/models'
describe('Test upload quota', function () {
let server: PeerTubeServer
import 'mocha'
import { io } from 'socket.io-client'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models'
import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
makeGetRequest,
makePostBodyRequest,
makePutBodyRequest,
PeerTubeServer,
- setAccessTokensToServers,
- wait
+ setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, UserNotificationSetting, UserNotificationSettingValue } from '@shared/models'
describe('Test user notifications API validators', function () {
let server: PeerTubeServer
import 'mocha'
import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
makeDeleteRequest,
waitJobs
} from '@shared/server-commands'
import { HttpStatusCode } from '@shared/models'
+import { checkBadStartPagination, checkBadCountPagination, checkBadSortPagination } from '@server/tests/shared'
describe('Test user subscriptions API validators', function () {
const path = '/api/v1/users/me/subscriptions'
import 'mocha'
import { omit } from 'lodash'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, MockSmtpServer } from '@server/tests/shared'
+import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models'
import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
killallServers,
makeGetRequest,
makePostBodyRequest,
makePutBodyRequest,
- MockSmtpServer,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, UserAdminFlag, UserRole } from '@shared/models'
describe('Test users admin API validators', function () {
const path = '/api/v1/users/'
import 'mocha'
import { omit } from 'lodash'
-import {
- cleanupTests,
- createSingleServer,
- makePostBodyRequest,
- MockSmtpServer,
- PeerTubeServer,
- setAccessTokensToServers
-} from '@shared/server-commands'
+import { MockSmtpServer } from '@server/tests/shared'
import { HttpStatusCode, UserRole } from '@shared/models'
+import { cleanupTests, createSingleServer, makePostBodyRequest, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
describe('Test users API validators', function () {
const path = '/api/v1/users/'
import 'mocha'
import { expect } from 'chai'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
+import { HttpStatusCode, VideoBlacklistType } from '@shared/models'
import {
BlacklistCommand,
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createMultipleServers,
doubleFollow,
setAccessTokensToServers,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, VideoBlacklistType } from '@shared/models'
describe('Test video blacklist API validators', function () {
let servers: PeerTubeServer[]
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
+import { HttpStatusCode, VideoCreateResult } from '@shared/models'
import {
- buildAbsoluteFixturePath,
cleanupTests,
createSingleServer,
makeDeleteRequest,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, VideoCreateResult } from '@shared/models'
describe('Test video captions API validator', function () {
const path = '/api/v1/videos/'
import 'mocha'
import * as chai from 'chai'
import { omit } from 'lodash'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
+import { HttpStatusCode, VideoChannelUpdate } from '@shared/models'
import {
- buildAbsoluteFixturePath,
ChannelsCommand,
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
makeGetRequest,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, VideoChannelUpdate } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
+import { HttpStatusCode, VideoCreateResult } from '@shared/models'
import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
makeDeleteRequest,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, VideoCreateResult } from '@shared/models'
const expect = chai.expect
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
import { HttpStatusCode, UserRole } from '@shared/models'
+import {
+ cleanupTests,
+ createMultipleServers,
+ doubleFollow,
+ PeerTubeServer,
+ setAccessTokensToServers,
+ waitJobs
+} from '@shared/server-commands'
describe('Test videos files', function () {
let servers: PeerTubeServer[]
import 'mocha'
import { omit } from 'lodash'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, FIXTURE_URLS } from '@server/tests/shared'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
+import { HttpStatusCode, VideoPrivacy } from '@shared/models'
import {
- buildAbsoluteFixturePath,
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
- FIXTURE_URLS,
makeGetRequest,
makePostBodyRequest,
makeUploadRequest,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, VideoPrivacy } from '@shared/models'
describe('Test video imports API validator', function () {
const path = '/api/v1/videos/imports'
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
- cleanupTests,
- createSingleServer,
- makeGetRequest,
- PeerTubeServer,
- PlaylistsCommand,
- setAccessTokensToServers,
- setDefaultVideoChannel
-} from '@shared/server-commands'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@server/tests/shared'
import {
HttpStatusCode,
VideoPlaylistCreate,
VideoPlaylistReorder,
VideoPlaylistType
} from '@shared/models'
+import {
+ cleanupTests,
+ createSingleServer,
+ makeGetRequest,
+ PeerTubeServer,
+ PlaylistsCommand,
+ setAccessTokensToServers,
+ setDefaultVideoChannel
+} from '@shared/server-commands'
describe('Test video playlists API validator', function () {
let server: PeerTubeServer
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
+import { checkBadCountPagination, checkBadStartPagination } from '@server/tests/shared'
+import { HttpStatusCode } from '@shared/models'
import {
- checkBadCountPagination,
- checkBadStartPagination,
cleanupTests,
createSingleServer,
makeGetRequest,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode } from '@shared/models'
describe('Test videos history API validator', function () {
const myHistoryPath = '/api/v1/users/me/history/videos'
import * as chai from 'chai'
import { omit } from 'lodash'
import { join } from 'path'
-import { randomInt } from '@shared/core-utils'
+import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination, checkUploadVideoParam } from '@server/tests/shared'
+import { randomInt, root } from '@shared/core-utils'
+import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
import {
- checkBadCountPagination,
- checkBadSortPagination,
- checkBadStartPagination,
- checkUploadVideoParam,
cleanupTests,
createSingleServer,
makeDeleteRequest,
makePutBodyRequest,
makeUploadRequest,
PeerTubeServer,
- root,
setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, PeerTubeProblemDocument, VideoCreateResult, VideoPrivacy } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
import { VideoPrivacy } from '@shared/models'
import {
- checkLiveCleanupAfterSave,
cleanupTests,
ConfigCommand,
createMultipleServers,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
- wait,
waitJobs
-} from '../../../../shared/server-commands'
+} from '@shared/server-commands'
+import { checkLiveCleanupAfterSave } from '../../shared'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
import { LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models'
import {
cleanupTests,
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
- wait,
waitJobs
-} from '../../../../shared/server-commands'
+} from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
import { VideoPrivacy } from '@shared/models'
import {
- buildAbsoluteFixturePath,
cleanupTests,
createSingleServer,
PeerTubeServer,
stopFfmpeg,
testFfmpegStreamError,
waitUntilLivePublishedOnAllServers
-} from '../../../../shared/server-commands'
+} from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
+import { checkLiveCleanupAfterSave } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models'
import {
- checkLiveCleanupAfterSave,
cleanupTests,
ConfigCommand,
createMultipleServers,
setDefaultVideoChannel,
stopFfmpeg,
testFfmpegStreamError,
- wait,
waitJobs,
waitUntilLivePublishedOnAllServers,
waitUntilLiveSavedOnAllServers
} from '@shared/server-commands'
-import { HttpStatusCode, LiveVideoCreate, VideoPrivacy, VideoState } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
import { VideoPrivacy, VideoState } from '@shared/models'
import {
cleanupTests,
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
- wait,
waitJobs,
waitUntilLivePublishedOnAllServers
-} from '../../../../shared/server-commands'
+} from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
+import { wait } from '@shared/core-utils'
import { VideoPrivacy } from '@shared/models'
import {
cleanupTests,
setAccessTokensToServers,
setDefaultVideoChannel,
stopFfmpeg,
- wait,
waitJobs,
waitUntilLivePublishedOnAllServers
-} from '../../../../shared/server-commands'
+} from '@shared/server-commands'
const expect = chai.expect
import * as chai from 'chai'
import { basename, join } from 'path'
import { ffprobePromise, getVideoStreamFromFile } from '@server/helpers/ffprobe-utils'
+import { checkLiveCleanupAfterSave, checkLiveSegmentHash, checkResolutionsInMasterPlaylist, testImage } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import {
+ HttpStatusCode,
+ LiveVideo,
+ LiveVideoCreate,
+ VideoDetails,
+ VideoPrivacy,
+ VideoState,
+ VideoStreamingPlaylistType
+} from '@shared/models'
import {
- checkLiveCleanupAfterSave,
- checkLiveSegmentHash,
- checkResolutionsInMasterPlaylist,
cleanupTests,
createMultipleServers,
doubleFollow,
setDefaultVideoChannel,
stopFfmpeg,
testFfmpegStreamError,
- testImage,
- wait,
waitJobs,
waitUntilLivePublishedOnAllServers
} from '@shared/server-commands'
-import {
- HttpStatusCode,
- LiveVideo,
- LiveVideoCreate,
- VideoDetails,
- VideoPrivacy,
- VideoState,
- VideoStreamingPlaylistType
-} from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
import { UserNotificationType } from '@shared/models'
+import {
+ cleanupTests,
+ createMultipleServers,
+ doubleFollow,
+ PeerTubeServer,
+ setAccessTokensToServers,
+ waitJobs
+} from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
import { orderBy } from 'lodash'
+import { FIXTURE_URLS } from '@server/tests/shared'
+import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models'
import {
BlacklistCommand,
cleanupTests,
createMultipleServers,
doubleFollow,
- FIXTURE_URLS,
killallServers,
PeerTubeServer,
setAccessTokensToServers,
waitJobs
} from '@shared/server-commands'
-import { UserAdminFlag, UserRole, VideoBlacklist, VideoBlacklistType } from '@shared/models'
const expect = chai.expect
CheckerBaseParams,
checkNewPeerTubeVersion,
checkNewPluginVersion,
- cleanupTests,
MockJoinPeerTubeVersions,
MockSmtpServer,
- PeerTubeServer,
- prepareNotificationsTest,
- wait
-} from '@shared/server-commands'
+ prepareNotificationsTest
+} from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
import { PluginType, UserNotification, UserNotificationType } from '@shared/models'
+import { cleanupTests, PeerTubeServer } from '@shared/server-commands'
describe('Test admin notifications', function () {
let server: PeerTubeServer
checkCommentMention,
CheckerBaseParams,
checkNewCommentOnMyVideo,
- cleanupTests,
MockSmtpServer,
- PeerTubeServer,
- prepareNotificationsTest,
- waitJobs
-} from '@shared/server-commands'
+ prepareNotificationsTest
+} from '@server/tests/shared'
import { UserNotification } from '@shared/models'
+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'
const expect = chai.expect
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import { buildUUID } from '@shared/core-utils/uuid'
import {
checkAbuseStateChange,
checkAutoInstanceFollowing,
checkUserRegistered,
checkVideoAutoBlacklistForModerators,
checkVideoIsPublished,
- cleanupTests,
MockInstancesIndex,
MockSmtpServer,
- PeerTubeServer,
- prepareNotificationsTest,
- wait,
- waitJobs
-} from '@shared/server-commands'
+ prepareNotificationsTest
+} from '@server/tests/shared'
+import { buildUUID, wait } from '@shared/core-utils'
import { AbuseState, CustomConfig, UserNotification, UserRole, VideoPrivacy } from '@shared/models'
+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'
describe('Test moderation notifications', function () {
let servers: PeerTubeServer[] = []
import {
CheckerBaseParams,
checkNewVideoFromSubscription,
- cleanupTests,
getAllNotificationsSettings,
MockSmtpServer,
- PeerTubeServer,
- prepareNotificationsTest,
- waitJobs
-} from '@shared/server-commands'
+ prepareNotificationsTest
+} from '@server/tests/shared'
import { UserNotification, UserNotificationSettingValue } from '@shared/models'
+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import { buildUUID } from '@shared/core-utils/uuid'
import {
CheckerBaseParams,
checkMyVideoImportIsFinished,
checkNewActorFollow,
checkNewVideoFromSubscription,
checkVideoIsPublished,
- cleanupTests,
FIXTURE_URLS,
MockSmtpServer,
- PeerTubeServer,
prepareNotificationsTest,
- uploadRandomVideoOnServers,
- wait,
- waitJobs
-} from '@shared/server-commands'
+ uploadRandomVideoOnServers
+} from '@server/tests/shared'
+import { buildUUID, wait } from '@shared/core-utils'
import { UserNotification, UserNotificationType, VideoPrivacy } from '@shared/models'
+import { cleanupTests, PeerTubeServer, waitJobs } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
import { FfmpegCommand } from 'fluent-ffmpeg'
+import { expectStartWith } from '@server/tests/shared'
+import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { HttpStatusCode, LiveVideoCreate, VideoFile, VideoPrivacy } from '@shared/models'
import {
- areObjectStorageTestsDisabled,
createMultipleServers,
doubleFollow,
- expectStartWith,
killallServers,
makeRawRequest,
ObjectStorageCommand,
waitUntilLivePublishedOnAllServers,
waitUntilLiveSavedOnAllServers
} from '@shared/server-commands'
-import { HttpStatusCode, LiveVideoCreate, VideoFile, VideoPrivacy } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { expectStartWith, FIXTURE_URLS } from '@server/tests/shared'
+import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { HttpStatusCode, VideoPrivacy } from '@shared/models'
import {
- areObjectStorageTestsDisabled,
createSingleServer,
- expectStartWith,
- FIXTURE_URLS,
killallServers,
makeRawRequest,
ObjectStorageCommand,
setDefaultVideoChannel,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, VideoPrivacy } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
import { merge } from 'lodash'
+import { checkTmpIsEmpty, expectLogDoesNotContain, expectStartWith, MockObjectStorage } from '@server/tests/shared'
+import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { HttpStatusCode, VideoDetails } from '@shared/models'
import {
- areObjectStorageTestsDisabled,
- checkTmpIsEmpty,
cleanupTests,
createMultipleServers,
createSingleServer,
doubleFollow,
- expectLogDoesNotContain,
- expectStartWith,
killallServers,
makeRawRequest,
- MockObjectStorage,
ObjectStorageCommand,
PeerTubeServer,
setAccessTokensToServers,
waitJobs,
webtorrentAdd
} from '@shared/server-commands'
-import { HttpStatusCode, VideoDetails } from '@shared/models'
const expect = chai.expect
import 'mocha'
import { expect } from 'chai'
-import { cleanupTests, createSingleServer, killallServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
import { VideoPrivacy } from '@shared/models'
+import {
+ cleanupTests,
+ createSingleServer,
+ killallServers,
+ PeerTubeServer,
+ setAccessTokensToServers,
+ waitJobs
+} from '@shared/server-commands'
describe('Test redundancy constraints', function () {
let remoteServer: PeerTubeServer
import { readdir } from 'fs-extra'
import magnetUtil from 'magnet-uri'
import { basename, join } from 'path'
+import { checkSegmentHash, checkVideoFilesWereRemoved, saveVideoInServers } from '@server/tests/shared'
+import { root, wait } from '@shared/core-utils'
+import {
+ HttpStatusCode,
+ VideoDetails,
+ VideoFile,
+ VideoPrivacy,
+ VideoRedundancyStrategy,
+ VideoRedundancyStrategyWithManual
+} from '@shared/models'
import {
- checkSegmentHash,
- checkVideoFilesWereRemoved,
cleanupTests,
createMultipleServers,
doubleFollow,
killallServers,
makeRawRequest,
PeerTubeServer,
- root,
- saveVideoInServers,
setAccessTokensToServers,
- wait,
waitJobs
} from '@shared/server-commands'
-import {
- HttpStatusCode,
- VideoDetails,
- VideoFile,
- VideoPrivacy,
- VideoRedundancyStrategy,
- VideoRedundancyStrategyWithManual
-} from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
+import { VideoChannel } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
PeerTubeServer,
SearchCommand,
setAccessTokensToServers,
- wait,
waitJobs
} from '@shared/server-commands'
-import { VideoChannel } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
+import { VideoPlaylistPrivacy } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
SearchCommand,
setAccessTokensToServers,
setDefaultVideoChannel,
- wait,
waitJobs
} from '@shared/server-commands'
-import { VideoPlaylistPrivacy } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
+import { VideoPrivacy } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
PeerTubeServer,
SearchCommand,
setAccessTokensToServers,
- wait,
waitJobs
} from '@shared/server-commands'
-import { VideoPrivacy } from '@shared/models'
const expect = chai.expect
SearchCommand,
setAccessTokensToServers,
setDefaultVideoChannel,
- stopFfmpeg,
- wait
+ stopFfmpeg
} from '@shared/server-commands'
import { VideoPrivacy } from '@shared/models'
+import { wait } from '@shared/core-utils'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import {
- cleanupTests,
- createMultipleServers,
- MockInstancesIndex,
- PeerTubeServer,
- setAccessTokensToServers,
- wait,
- waitJobs
-} from '@shared/server-commands'
+import { MockInstancesIndex } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import {
- cleanupTests,
- createSingleServer,
- FIXTURE_URLS,
- PeerTubeServer,
- setAccessTokensToServers,
- setDefaultVideoChannel
-} from '@shared/server-commands'
+import { FIXTURE_URLS } from '@server/tests/shared'
import { VideoDetails, VideoPrivacy } from '@shared/models'
+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { parallelTests } from '@shared/core-utils'
+import { CustomConfig, HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createSingleServer,
killallServers,
makeGetRequest,
- parallelTests,
PeerTubeServer,
setAccessTokensToServers
} from '@shared/server-commands'
-import { CustomConfig, HttpStatusCode } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { MockSmtpServer } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
ContactFormCommand,
createSingleServer,
- MockSmtpServer,
PeerTubeServer,
setAccessTokensToServers,
- wait,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
+import { MockSmtpServer } from '@server/tests/shared'
import { HttpStatusCode } from '@shared/models'
+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import {
- cleanupTests,
- createMultipleServers,
- dateIsValid,
- expectAccountFollows,
- expectChannelsFollows,
- PeerTubeServer,
- setAccessTokensToServers,
- testCaptionFile,
- waitJobs
-} from '@shared/server-commands'
+import { completeVideoCheck, dateIsValid, expectAccountFollows, expectChannelsFollows, testCaptionFile } from '@server/tests/shared'
import { VideoCreateResult, VideoPrivacy } from '@shared/models'
-import { completeVideoCheck } from '@server/tests/shared/video'
+import { cleanupTests, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { completeVideoCheck } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@shared/models'
import {
cleanupTests,
CommentsCommand,
killallServers,
PeerTubeServer,
setAccessTokensToServers,
- wait,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, JobState, VideoCreateResult, VideoPrivacy } from '@shared/models'
-import { completeVideoCheck } from '@server/tests/shared/video'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { dateIsValid } from '@server/tests/shared'
import {
cleanupTests,
createMultipleServers,
- dateIsValid,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
import 'mocha'
import * as chai from 'chai'
+import { testHelloWorldRegisteredSettings } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode, PluginType } from '@shared/models'
import {
cleanupTests,
createSingleServer,
killallServers,
PeerTubeServer,
PluginsCommand,
- setAccessTokensToServers,
- testHelloWorldRegisteredSettings,
- wait
+ setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, PluginType } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { FIXTURE_URLS, MockProxy } from '@server/tests/shared'
+import { HttpStatusCode, VideoPrivacy } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
doubleFollow,
- FIXTURE_URLS,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
waitJobs
} from '@shared/server-commands'
-import { MockProxy } from '@shared/server-commands/mock-servers/mock-proxy'
-import { HttpStatusCode, VideoPrivacy } from '@shared/models'
const expect = chai.expect
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
-import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/server-commands'
+import { wait } from '@shared/core-utils'
import { HttpStatusCode } from '@shared/models'
+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
describe('Test application behind a reverse proxy', function () {
let server: PeerTubeServer
import 'mocha'
import * as chai from 'chai'
-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
import { Job } from '@shared/models'
+import {
+ cleanupTests,
+ createMultipleServers,
+ doubleFollow,
+ PeerTubeServer,
+ setAccessTokensToServers,
+ waitJobs
+} from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
+import { ActivityType, VideoPlaylistPrivacy } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
- wait,
waitJobs
} from '@shared/server-commands'
-import { ActivityType, VideoPlaylistPrivacy } from '@shared/models'
const expect = chai.expect
checkActorFilesWereRemoved,
checkTmpIsEmpty,
checkVideoFilesWereRemoved,
+ saveVideoInServers,
+ testImage
+} from '@server/tests/shared'
+import { MyUser } from '@shared/models'
+import {
cleanupTests,
createMultipleServers,
doubleFollow,
PeerTubeServer,
- saveVideoInServers,
setAccessTokensToServers,
- testImage,
waitJobs
} from '@shared/server-commands'
-import { MyUser } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import { cleanupTests, createSingleServer, MockSmtpServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
+import { MockSmtpServer } from '@server/tests/shared'
import { HttpStatusCode } from '@shared/models'
+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { testImage } from '@server/tests/shared'
+import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
import {
cleanupTests,
createSingleServer,
makePutBodyRequest,
PeerTubeServer,
setAccessTokensToServers,
- testImage,
waitJobs
} from '@shared/server-commands'
-import { AbuseState, HttpStatusCode, OAuth2ErrorCode, UserAdminFlag, UserRole, Video, VideoPlaylistType } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
import { getAudioStream, getVideoStreamSize } from '@server/helpers/ffprobe-utils'
-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
+import {
+ cleanupTests,
+ createMultipleServers,
+ doubleFollow,
+ PeerTubeServer,
+ setAccessTokensToServers,
+ waitJobs
+} from '@shared/server-commands'
const expect = chai.expect
import * as chai from 'chai'
import request from 'supertest'
import {
- buildAbsoluteFixturePath,
checkTmpIsEmpty,
checkVideoFilesWereRemoved,
+ completeVideoCheck,
+ dateIsValid,
+ saveVideoInServers,
+ testImage
+} from '@server/tests/shared'
+import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
+import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
+import {
cleanupTests,
createMultipleServers,
- dateIsValid,
doubleFollow,
PeerTubeServer,
- saveVideoInServers,
setAccessTokensToServers,
- testImage,
- wait,
waitJobs,
webtorrentAdd
} from '@shared/server-commands'
-import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
-import { completeVideoCheck } from '@server/tests/shared/video'
const expect = chai.expect
import * as chai from 'chai'
import { pathExists, readdir, stat } from 'fs-extra'
import { join } from 'path'
-import {
- buildAbsoluteFixturePath,
- cleanupTests,
- createSingleServer,
- PeerTubeServer,
- setAccessTokensToServers,
- setDefaultVideoChannel
-} from '@shared/server-commands'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
import { HttpStatusCode, VideoPrivacy } from '@shared/models'
+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import {
- checkVideoFilesWereRemoved,
- cleanupTests,
- createSingleServer,
- PeerTubeServer,
- setAccessTokensToServers,
- testImage,
- wait
-} from '@shared/server-commands'
+import { checkVideoFilesWereRemoved, completeVideoCheck, testImage } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
import { Video, VideoPrivacy } from '@shared/models'
-import { completeVideoCheck } from '@server/tests/shared/video'
+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { checkVideoFilesWereRemoved, testCaptionFile } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
import {
- checkVideoFilesWereRemoved,
cleanupTests,
createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
- testCaptionFile,
- wait,
waitJobs
} from '@shared/server-commands'
import * as chai from 'chai'
import { basename } from 'path'
import { ACTOR_IMAGES_SIZE } from '@server/initializers/constants'
+import { testFileExistsOrNot, testImage } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import { User, VideoChannel } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
- testFileExistsOrNot,
- testImage,
- wait,
waitJobs
} from '@shared/server-commands'
-import { User, VideoChannel } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import {
- cleanupTests,
- CommentsCommand,
- createSingleServer,
- dateIsValid,
- PeerTubeServer,
- setAccessTokensToServers,
- testImage
-} from '@shared/server-commands'
+import { dateIsValid, testImage } from '@server/tests/shared'
+import { cleanupTests, CommentsCommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { expectStartWith } from '@server/tests/shared'
+import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { HttpStatusCode, VideoDetails } from '@shared/models'
import {
- areObjectStorageTestsDisabled,
cleanupTests,
createMultipleServers,
doubleFollow,
expectNoFailedTranscodingJob,
- expectStartWith,
makeRawRequest,
ObjectStorageCommand,
PeerTubeServer,
setAccessTokensToServers,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, VideoDetails } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
+import {
+ cleanupTests,
+ createMultipleServers,
+ doubleFollow,
+ PeerTubeServer,
+ setAccessTokensToServers,
+ waitJobs
+} from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import { expect } from 'chai'
-import { cleanupTests, createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
+import {
+ cleanupTests,
+ createMultipleServers,
+ doubleFollow,
+ PeerTubeServer,
+ setAccessTokensToServers,
+ waitJobs
+} from '@shared/server-commands'
describe('Test videos files', function () {
let servers: PeerTubeServer[]
import 'mocha'
import * as chai from 'chai'
import { basename, join } from 'path'
-import { removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils'
import {
- areObjectStorageTestsDisabled,
checkDirectoryIsEmpty,
checkResolutionsInMasterPlaylist,
checkSegmentHash,
checkTmpIsEmpty,
+ expectStartWith,
+ hlsInfohashExist
+} from '@server/tests/shared'
+import { areObjectStorageTestsDisabled, removeFragmentedMP4Ext, uuidRegex } from '@shared/core-utils'
+import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models'
+import {
cleanupTests,
createMultipleServers,
doubleFollow,
- expectStartWith,
- hlsInfohashExist,
makeRawRequest,
ObjectStorageCommand,
PeerTubeServer,
waitJobs,
webtorrentAdd
} from '@shared/server-commands'
-import { HttpStatusCode, VideoStreamingPlaylistType } from '@shared/models'
import { DEFAULT_AUDIO_RESOLUTION } from '../../../initializers/constants'
const expect = chai.expect
import { expect } from 'chai'
import { pathExists, readdir, remove } from 'fs-extra'
import { join } from 'path'
+import { FIXTURE_URLS, testCaptionFile, testImage } from '@server/tests/shared'
+import { areHttpImportTestsDisabled } from '@shared/core-utils'
+import { VideoPrivacy, VideoResolution } from '@shared/models'
import {
- areHttpImportTestsDisabled,
cleanupTests,
createMultipleServers,
createSingleServer,
doubleFollow,
- FIXTURE_URLS,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
- testCaptionFile,
- testImage,
waitJobs
} from '@shared/server-commands'
-import { VideoPrivacy, VideoResolution } from '@shared/models'
async function checkVideosServer1 (server: PeerTubeServer, idHttp: string, idMagnet: string, idTorrent: string) {
const videoHttp = await server.videos.get({ id: idHttp })
import 'mocha'
import * as chai from 'chai'
+import { testImage } from '@server/tests/shared'
+import { VideoPlaylistPrivacy } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
- testImage,
waitJobs
-} from '../../../../shared/server-commands'
-import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model'
+} from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { checkPlaylistFilesWereRemoved, testImage } from '@server/tests/shared'
+import { wait } from '@shared/core-utils'
+import {
+ HttpStatusCode,
+ VideoPlaylist,
+ VideoPlaylistCreateResult,
+ VideoPlaylistElementType,
+ VideoPlaylistPrivacy,
+ VideoPlaylistType,
+ VideoPrivacy
+} from '@shared/models'
import {
- checkPlaylistFilesWereRemoved,
cleanupTests,
createMultipleServers,
doubleFollow,
PlaylistsCommand,
setAccessTokensToServers,
setDefaultVideoChannel,
- testImage,
- wait,
waitJobs
} from '@shared/server-commands'
-import {
- HttpStatusCode,
- VideoPlaylist,
- VideoPlaylistCreateResult,
- VideoPlaylistElementType,
- VideoPlaylistPrivacy,
- VideoPlaylistType,
- VideoPrivacy
-} from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import {
- cleanupTests,
- createSingleServer,
- doubleFollow,
- PeerTubeServer,
- setAccessTokensToServers,
- wait,
- waitJobs
-} from '@shared/server-commands'
+import { wait } from '@shared/core-utils'
import { HttpStatusCode, VideoCreateResult, VideoPrivacy } from '@shared/models'
+import { cleanupTests, createSingleServer, doubleFollow, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
+import { VideoPrivacy } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
doubleFollow,
PeerTubeServer,
setAccessTokensToServers,
- wait,
waitJobs
} from '@shared/server-commands'
-import { VideoPrivacy } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
import { omit } from 'lodash'
-import { getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils'
+import { canDoQuickTranscode } from '@server/helpers/ffprobe-utils'
+import { generateHighBitrateVideo, generateVideoWithFramerate } from '@server/tests/shared'
+import { buildAbsoluteFixturePath, getMaxBitrate, getMinLimitBitrate } from '@shared/core-utils'
+import { getAudioStream, getMetadataFromFile, getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils'
+import { HttpStatusCode, VideoState } from '@shared/models'
import {
- buildAbsoluteFixturePath,
cleanupTests,
createMultipleServers,
doubleFollow,
- generateHighBitrateVideo,
- generateVideoWithFramerate,
makeGetRequest,
PeerTubeServer,
setAccessTokensToServers,
waitJobs,
webtorrentAdd
} from '@shared/server-commands'
-import { HttpStatusCode, VideoState } from '@shared/models'
-import {
- canDoQuickTranscode,
- getAudioStream,
- getMetadataFromFile,
- getVideoFileBitrate,
- getVideoFileFPS,
- getVideoFileResolution
-} from '../../../helpers/ffprobe-utils'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode, Video } from '@shared/models'
import {
cleanupTests,
createSingleServer,
HistoryCommand,
killallServers,
PeerTubeServer,
- setAccessTokensToServers,
- wait
+ setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, Video } from '@shared/models'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
-import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, wait } from '@shared/server-commands'
+import { wait } from '@shared/core-utils'
import { VideosOverview } from '@shared/models'
+import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { wait } from '@shared/core-utils'
import {
cleanupTests,
createMultipleServers,
killallServers,
PeerTubeServer,
setAccessTokensToServers,
- wait,
waitJobs
-} from '../../../../shared/server-commands'
+} from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import * as chai from 'chai'
+import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models'
import {
- areObjectStorageTestsDisabled,
cleanupTests,
createMultipleServers,
doubleFollow,
- expectStartWith,
makeRawRequest,
ObjectStorageCommand,
PeerTubeServer,
setAccessTokensToServers,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, VideoDetails, VideoFile, VideoInclude } from '@shared/models'
+import { expectStartWith } from '../shared'
const expect = chai.expect
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-
+import { areObjectStorageTestsDisabled } from '@shared/core-utils'
+import { HttpStatusCode, VideoDetails } from '@shared/models'
import {
- areObjectStorageTestsDisabled,
cleanupTests,
createMultipleServers,
doubleFollow,
- expectStartWith,
makeRawRequest,
ObjectStorageCommand,
PeerTubeServer,
setAccessTokensToServers,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, VideoDetails } from '@shared/models'
+import { expectStartWith } from '../shared'
async function checkFiles (origin: PeerTubeServer, video: VideoDetails, inObjectStorage: boolean) {
for (const file of video.files) {
import 'mocha'
import * as chai from 'chai'
+import { areObjectStorageTestsDisabled } from '@shared/core-utils'
import { HttpStatusCode, VideoFile } from '@shared/models'
import {
- areObjectStorageTestsDisabled,
cleanupTests,
createMultipleServers,
doubleFollow,
- expectStartWith,
makeRawRequest,
ObjectStorageCommand,
PeerTubeServer,
setAccessTokensToServers,
waitJobs
-} from '../../../shared/server-commands'
+} from '@shared/server-commands'
+import { expectStartWith } from '../shared'
const expect = chai.expect
import 'mocha'
import { expect } from 'chai'
+import { areHttpImportTestsDisabled, buildAbsoluteFixturePath } from '@shared/core-utils'
import {
- areHttpImportTestsDisabled,
- buildAbsoluteFixturePath,
cleanupTests,
CLICommand,
createSingleServer,
doubleFollow,
- FIXTURE_URLS,
PeerTubeServer,
setAccessTokensToServers,
- testHelloWorldRegisteredSettings,
waitJobs
-} from '../../../shared/server-commands'
+} from '@shared/server-commands'
+import { FIXTURE_URLS, testHelloWorldRegisteredSettings } from '../shared'
describe('Test CLI wrapper', function () {
let server: PeerTubeServer
PeerTubeServer,
PluginsCommand,
setAccessTokensToServers
-} from '../../../shared/server-commands'
+} from '@shared/server-commands'
describe('Test plugin scripts', function () {
let server: PeerTubeServer
import 'mocha'
import * as chai from 'chai'
-import { buildAbsoluteFixturePath, CLICommand } from '@shared/server-commands'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
+import { CLICommand } from '@shared/server-commands'
import { VideoResolution } from '../../../shared/models/videos'
const expect = chai.expect
import * as chai from 'chai'
import { createFile, readdir } from 'fs-extra'
import { join } from 'path'
-import { buildUUID } from '@shared/core-utils/uuid'
+import { buildUUID, wait } from '@shared/core-utils'
+import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
import {
cleanupTests,
CLICommand,
PeerTubeServer,
setAccessTokensToServers,
setDefaultVideoChannel,
- wait,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, VideoPlaylistPrivacy } from '@shared/models'
const expect = chai.expect
import 'mocha'
-import { cleanupTests, CLICommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '../../../shared/server-commands'
+import { cleanupTests, CLICommand, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
describe('Test reset password scripts', function () {
let server: PeerTubeServer
import 'mocha'
import { expect } from 'chai'
+import { wait } from '@shared/core-utils'
+import { Video } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
doubleFollow,
killallServers,
- MockBlocklist,
PeerTubeServer,
- setAccessTokensToServers,
- wait
+ setAccessTokensToServers
} from '@shared/server-commands'
-import { Video } from '@shared/models'
+import { MockBlocklist } from '../shared'
async function check (server: PeerTubeServer, videoUUID: string, exists = true) {
const { data } = await server.videos.list()
import 'mocha'
import { expect } from 'chai'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
doubleFollow,
killallServers,
makeGetRequest,
- MockBlocklist,
PeerTubeServer,
- setAccessTokensToServers,
- wait
+ setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode } from '@shared/models'
+import { MockBlocklist } from '../shared'
describe('Official plugin auto-mute', function () {
const autoMuteListPath = '/plugins/auto-mute/router/api/v1/mute-list'
import { expect } from 'chai'
import { readFile, remove } from 'fs-extra'
import { join } from 'path'
+import { buildAbsoluteFixturePath, root } from '@shared/core-utils'
import { processImage } from '../../../server/helpers/image-utils'
-import { buildAbsoluteFixturePath, root } from '../../../shared/server-commands'
async function checkBuffers (path1: string, path2: string, equals: boolean) {
const [ buf1, buf2 ] = await Promise.all([
import { expect } from 'chai'
import { pathExists, remove } from 'fs-extra'
import { join } from 'path'
-import { Mock429 } from '@shared/server-commands/mock-servers/mock-429'
-import { FIXTURE_URLS, root, wait } from '../../../shared/server-commands'
+import { root, wait } from '@shared/core-utils'
import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests'
+import { FIXTURE_URLS, Mock429 } from '../shared'
describe('Request helpers', function () {
const destPath1 = join(root(), 'test-output-1.txt')
import 'mocha'
import { expect } from 'chai'
+import { wait } from '@shared/core-utils'
+import { HttpStatusCode, UserRole } from '@shared/models'
import {
cleanupTests,
createSingleServer,
decodeQueryString,
PeerTubeServer,
PluginsCommand,
- setAccessTokensToServers,
- wait
+ setAccessTokensToServers
} from '@shared/server-commands'
-import { HttpStatusCode, UserRole } from '@shared/models'
async function loginExternal (options: {
server: PeerTubeServer
import 'mocha'
import * as chai from 'chai'
+import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
import {
cleanupTests,
createMultipleServers,
doubleFollow,
- FIXTURE_URLS,
makeRawRequest,
PeerTubeServer,
PluginsCommand,
setDefaultVideoChannel,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, VideoDetails, VideoImportState, VideoPlaylist, VideoPlaylistPrivacy, VideoPrivacy } from '@shared/models'
+import { FIXTURE_URLS } from '../shared'
const expect = chai.expect
PeerTubeServer,
PluginsCommand,
setAccessTokensToServers
-} from '../../../shared/server-commands'
+} from '@shared/server-commands'
const expect = chai.expect
import 'mocha'
import { expect } from 'chai'
-import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers, wait } from '@shared/server-commands'
+import { wait } from '@shared/core-utils'
import { HttpStatusCode, UserRole } from '@shared/models'
+import { cleanupTests, createSingleServer, PeerTubeServer, PluginsCommand, setAccessTokensToServers } from '@shared/server-commands'
describe('Test id and pass auth plugins', function () {
let server: PeerTubeServer
import 'mocha'
import { expect } from 'chai'
import { pathExists } from 'fs-extra'
+import { HttpStatusCode, ThumbnailType } from '@shared/models'
import {
- checkVideoFilesWereRemoved,
cleanupTests,
createMultipleServers,
doubleFollow,
setAccessTokensToServers,
waitJobs
} from '@shared/server-commands'
-import { HttpStatusCode, ThumbnailType } from '@shared/models'
+import { checkVideoFilesWereRemoved } from '../shared'
function postCommand (server: PeerTubeServer, command: string, bodyArg?: object) {
const body = { command }
import { join } from 'path'
import { root } from '@shared/core-utils'
import { Account, VideoChannel } from '@shared/models'
-import { PeerTubeServer } from '../server'
+import { PeerTubeServer } from '@shared/server-commands'
async function expectChannelsFollows (options: {
server: PeerTubeServer
import { join } from 'path'
import { root } from '@shared/core-utils'
import { HttpStatusCode } from '@shared/models'
-import { makeGetRequest } from '../requests'
-import { PeerTubeServer } from '../server'
+import { makeGetRequest, PeerTubeServer } from '@shared/server-commands'
// Default interval -> 5 minutes
function dateIsValid (dateString: string, interval = 300000) {
expect(await pathExists(join(base, filePath))).to.equal(exist)
}
+function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
+ return makeGetRequest({
+ url,
+ path,
+ token,
+ query: { ...query, start: 'hello' },
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
+ })
+}
+
+async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {
+ await makeGetRequest({
+ url,
+ path,
+ token,
+ query: { ...query, count: 'hello' },
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
+ })
+
+ await makeGetRequest({
+ url,
+ path,
+ token,
+ query: { ...query, count: 2000 },
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
+ })
+}
+
+function checkBadSortPagination (url: string, path: string, token?: string, query = {}) {
+ return makeGetRequest({
+ url,
+ path,
+ token,
+ query: { ...query, sort: 'hello' },
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
+ })
+}
+
export {
dateIsValid,
testImage,
expectLogDoesNotContain,
testFileExistsOrNot,
- expectStartWith
+ expectStartWith,
+ checkBadStartPagination,
+ checkBadCountPagination,
+ checkBadSortPagination
}
import { pathExists, readdir } from 'fs-extra'
import { join } from 'path'
import { root } from '@shared/core-utils'
-import { PeerTubeServer } from './server'
+import { PeerTubeServer } from '@shared/server-commands'
async function checkTmpIsEmpty (server: PeerTubeServer) {
await checkDirectoryIsEmpty(server, 'tmp', [ 'plugins-global.css', 'hls', 'resumable-uploads' ])
import ffmpeg from 'fluent-ffmpeg'
import { ensureDir, pathExists } from 'fs-extra'
import { dirname } from 'path'
-import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils/ffprobe'
-import { getMaxBitrate } from '@shared/core-utils'
-import { buildAbsoluteFixturePath } from './tests'
+import { buildAbsoluteFixturePath, getMaxBitrate } from '@shared/core-utils'
+import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '@shared/extra-utils'
async function ensureHasTooBigBitrate (fixturePath: string) {
const bitrate = await getVideoFileBitrate(fixturePath)
+export * from './mock-servers'
+export * from './actors'
+export * from './captions'
+export * from './checks'
+export * from './directories'
+export * from './generate'
+export * from './live'
+export * from './notifications'
+export * from './playlists'
+export * from './plugins'
export * from './requests'
-export * from './video'
+export * from './streaming-playlists'
+export * from './tests'
+export * from './tracker'
+export * from './videos'
--- /dev/null
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
+
+import { expect } from 'chai'
+import { pathExists, readdir } from 'fs-extra'
+import { join } from 'path'
+import { PeerTubeServer } from '@shared/server-commands'
+
+async function checkLiveCleanupAfterSave (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) {
+ const basePath = server.servers.buildDirectory('streaming-playlists')
+ const hlsPath = join(basePath, 'hls', videoUUID)
+
+ if (resolutions.length === 0) {
+ const result = await pathExists(hlsPath)
+ expect(result).to.be.false
+
+ return
+ }
+
+ const files = await readdir(hlsPath)
+
+ // fragmented file and playlist per resolution + master playlist + segments sha256 json file
+ expect(files).to.have.lengthOf(resolutions.length * 2 + 2)
+
+ for (const resolution of resolutions) {
+ const fragmentedFile = files.find(f => f.endsWith(`-${resolution}-fragmented.mp4`))
+ expect(fragmentedFile).to.exist
+
+ const playlistFile = files.find(f => f.endsWith(`${resolution}.m3u8`))
+ expect(playlistFile).to.exist
+ }
+
+ const masterPlaylistFile = files.find(f => f.endsWith('-master.m3u8'))
+ expect(masterPlaylistFile).to.exist
+
+ const shaFile = files.find(f => f.endsWith('-segments-sha256.json'))
+ expect(shaFile).to.exist
+}
+
+export {
+ checkLiveCleanupAfterSave
+}
+export * from './mock-429'
export * from './mock-email'
export * from './mock-instances-index'
export * from './mock-joinpeertube-versions'
-export * from './mock-plugin-blocklist'
export * from './mock-object-storage'
+export * from './mock-plugin-blocklist'
+export * from './mock-proxy'
import express from 'express'
import { Server } from 'http'
-import { getPort, randomListen, terminateServer } from './utils'
+import { getPort, randomListen, terminateServer } from './shared'
export class Mock429 {
private server: Server
import { ChildProcess } from 'child_process'
import MailDev from '@peertube/maildev'
-import { randomInt } from '@shared/core-utils'
-import { parallelTests } from '../miscs'
+import { parallelTests, randomInt } from '@shared/core-utils'
class MockSmtpServer {
import express from 'express'
import { Server } from 'http'
-import { getPort, randomListen, terminateServer } from './utils'
+import { getPort, randomListen, terminateServer } from './shared'
export class MockInstancesIndex {
private server: Server
import express from 'express'
import { Server } from 'http'
-import { getPort, randomListen } from './utils'
+import { getPort, randomListen } from './shared'
export class MockJoinPeerTubeVersions {
private server: Server
import got, { RequestError } from 'got'
import { Server } from 'http'
import { pipeline } from 'stream'
-import { ObjectStorageCommand } from '../server'
-import { getPort, randomListen, terminateServer } from './utils'
+import { ObjectStorageCommand } from '@shared/server-commands'
+import { getPort, randomListen, terminateServer } from './shared'
export class MockObjectStorage {
private server: Server
import express, { Request, Response } from 'express'
import { Server } from 'http'
-import { getPort, randomListen, terminateServer } from './utils'
+import { getPort, randomListen, terminateServer } from './shared'
type BlocklistResponse = {
data: {
-
import { createServer, Server } from 'http'
import proxy from 'proxy'
-import { getPort, terminateServer } from './utils'
+import { getPort, terminateServer } from './shared'
class MockProxy {
private server: Server
import { expect } from 'chai'
import { inspect } from 'util'
-import { AbuseState, PluginType } from '@shared/models'
-import { UserNotification, UserNotificationSetting, UserNotificationSettingValue, UserNotificationType } from '../../models/users'
-import { MockSmtpServer } from '../mock-servers/mock-email'
-import { PeerTubeServer } from '../server'
-import { doubleFollow } from '../server/follows'
-import { createMultipleServers } from '../server/servers'
-import { setAccessTokensToServers } from './login'
+import {
+ AbuseState,
+ PluginType,
+ UserNotification,
+ UserNotificationSetting,
+ UserNotificationSettingValue,
+ UserNotificationType
+} from '@shared/models'
+import { createMultipleServers, doubleFollow, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands'
+import { MockSmtpServer } from './mock-servers'
type CheckerBaseParams = {
server: PeerTubeServer
import { expect } from 'chai'
import { readdir } from 'fs-extra'
import { join } from 'path'
-import { root } from '../miscs'
+import { root } from '@shared/core-utils'
async function checkPlaylistFilesWereRemoved (
playlistUUID: string,
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { expect } from 'chai'
-import { PeerTubeServer } from './server'
+import { PeerTubeServer } from '@shared/server-commands'
async function testHelloWorldRegisteredSettings (server: PeerTubeServer) {
const body = await server.plugins.getRegisteredSettings({ npmName: 'peertube-plugin-hello-world' })
-import { doRequest } from '@server/helpers/requests'
import { activityPubContextify } from '@server/helpers/activitypub'
-import { HTTP_SIGNATURE } from '@server/initializers/constants'
-import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils'
+import { buildDigest } from '@server/helpers/peertube-crypto'
+import { doRequest } from '@server/helpers/requests'
+import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@server/initializers/constants'
export function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) {
const options = {
key: by.privateKey,
headers: HTTP_SIGNATURE.HEADERS_TO_SIGN
}
- const headers = buildGlobalHeaders(body)
+ const headers = {
+ 'digest': buildDigest(body),
+ 'content-type': 'application/activity+json',
+ 'accept': ACTIVITY_PUB.ACCEPT_HEADER
+ }
return makePOSTAPRequest(to.url + '/inbox', body, httpSignature, headers)
}
import { expect } from 'chai'
import { basename } from 'path'
-import { sha256 } from '@shared/core-utils/crypto'
import { removeFragmentedMP4Ext } from '@shared/core-utils'
+import { sha256 } from '@shared/core-utils/common/crypto'
import { HttpStatusCode, VideoStreamingPlaylist } from '@shared/models'
-import { PeerTubeServer } from '../server'
+import { PeerTubeServer } from '@shared/server-commands'
async function checkSegmentHash (options: {
server: PeerTubeServer
--- /dev/null
+const FIXTURE_URLS = {
+ peertube_long: 'https://peertube2.cpy.re/videos/watch/122d093a-1ede-43bd-bd34-59d2931ffc5e',
+ peertube_short: 'https://peertube2.cpy.re/w/3fbif9S3WmtTP8gGsC5HBd',
+
+ youtube: 'https://www.youtube.com/watch?v=msX3jv1XdvM',
+
+ /**
+ * The video is used to check format-selection correctness wrt. HDR,
+ * which brings its own set of oddities outside of a MediaSource.
+ *
+ * The video needs to have the following format_ids:
+ * (which you can check by using `youtube-dl <url> -F`):
+ * - (webm vp9)
+ * - (mp4 avc1)
+ * - (webm vp9.2 HDR)
+ */
+ youtubeHDR: 'https://www.youtube.com/watch?v=RQgnBB9z_N4',
+
+ // eslint-disable-next-line max-len
+ magnet: 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Flazy-static%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4',
+
+ badVideo: 'https://download.cpy.re/peertube/bad_video.mp4',
+ goodVideo: 'https://download.cpy.re/peertube/good_video.mp4',
+ goodVideo720: 'https://download.cpy.re/peertube/good_video_720.mp4',
+
+ file4K: 'https://download.cpy.re/peertube/4k_file.txt'
+}
+
+function buildRequestStub (): any {
+ return { }
+}
+
+export {
+ FIXTURE_URLS,
+
+ buildRequestStub
+}
import { expect } from 'chai'
-import { sha1 } from '@shared/core-utils/crypto'
-import { makeGetRequest } from '../requests'
+import { sha1 } from '@shared/core-utils'
+import { makeGetRequest } from '@shared/server-commands'
async function hlsInfohashExist (serverUrl: string, masterPlaylistUrl: string, fileNumber: number) {
const path = '/tracker/announce'
-/* eslint-disable @typescript-eslint/no-unused-expressions */
-import { dateIsValid, makeRawRequest, PeerTubeServer, testImage, webtorrentAdd } from '@shared/server-commands'
+/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
+
import { expect } from 'chai'
+import { pathExists, readdir } from 'fs-extra'
+import { basename, join } from 'path'
import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '@server/initializers/constants'
import { getLowercaseExtension, uuidRegex } from '@shared/core-utils'
+import { HttpStatusCode, VideoCaption, VideoDetails } from '@shared/models'
+import { makeRawRequest, PeerTubeServer, VideoEdit, waitJobs, webtorrentAdd } from '@shared/server-commands'
+import { dateIsValid, testImage } from './checks'
loadLanguages()
-export async function completeVideoCheck (
+async function completeVideoCheck (
server: PeerTubeServer,
video: any,
attributes: {
await testImage(server.url, attributes.previewfile, videoDetails.previewPath)
}
}
+
+async function checkVideoFilesWereRemoved (options: {
+ server: PeerTubeServer
+ video: VideoDetails
+ captions?: VideoCaption[]
+ onlyVideoFiles?: boolean // default false
+}) {
+ const { video, server, captions = [], onlyVideoFiles = false } = options
+
+ const webtorrentFiles = video.files || []
+ const hlsFiles = video.streamingPlaylists[0]?.files || []
+
+ const thumbnailName = basename(video.thumbnailPath)
+ const previewName = basename(video.previewPath)
+
+ const torrentNames = webtorrentFiles.concat(hlsFiles).map(f => basename(f.torrentUrl))
+
+ const captionNames = captions.map(c => basename(c.captionPath))
+
+ const webtorrentFilenames = webtorrentFiles.map(f => basename(f.fileUrl))
+ const hlsFilenames = hlsFiles.map(f => basename(f.fileUrl))
+
+ let directories: { [ directory: string ]: string[] } = {
+ videos: webtorrentFilenames,
+ redundancy: webtorrentFilenames,
+ [join('playlists', 'hls')]: hlsFilenames,
+ [join('redundancy', 'hls')]: hlsFilenames
+ }
+
+ if (onlyVideoFiles !== true) {
+ directories = {
+ ...directories,
+
+ thumbnails: [ thumbnailName ],
+ previews: [ previewName ],
+ torrents: torrentNames,
+ captions: captionNames
+ }
+ }
+
+ for (const directory of Object.keys(directories)) {
+ const directoryPath = server.servers.buildDirectory(directory)
+
+ const directoryExists = await pathExists(directoryPath)
+ if (directoryExists === false) continue
+
+ const existingFiles = await readdir(directoryPath)
+ for (const existingFile of existingFiles) {
+ for (const shouldNotExist of directories[directory]) {
+ expect(existingFile, `File ${existingFile} should not exist in ${directoryPath}`).to.not.contain(shouldNotExist)
+ }
+ }
+ }
+}
+
+async function saveVideoInServers (servers: PeerTubeServer[], uuid: string) {
+ for (const server of servers) {
+ server.store.videoDetails = await server.videos.get({ id: uuid })
+ }
+}
+
+function checkUploadVideoParam (
+ server: PeerTubeServer,
+ token: string,
+ attributes: Partial<VideoEdit>,
+ expectedStatus = HttpStatusCode.OK_200,
+ mode: 'legacy' | 'resumable' = 'legacy'
+) {
+ return mode === 'legacy'
+ ? server.videos.buildLegacyUpload({ token, attributes, expectedStatus })
+ : server.videos.buildResumeUpload({ token, attributes, expectedStatus })
+}
+
+// serverNumber starts from 1
+async function uploadRandomVideoOnServers (
+ servers: PeerTubeServer[],
+ serverNumber: number,
+ additionalParams?: VideoEdit & { prefixName?: string }
+) {
+ const server = servers.find(s => s.serverNumber === serverNumber)
+ const res = await server.videos.randomUpload({ wait: false, additionalParams })
+
+ await waitJobs(servers)
+
+ return res
+}
+
+// ---------------------------------------------------------------------------
+
+export {
+ completeVideoCheck,
+ checkUploadVideoParam,
+ uploadRandomVideoOnServers,
+ checkVideoFilesWereRemoved,
+ saveVideoInServers
+}
return createHash('sha1').update(str).digest(encoding)
}
+// high excluded
+function randomInt (low: number, high: number) {
+ return Math.floor(Math.random() * (high - low) + low)
+}
+
export {
+ randomInt,
sha256,
sha1
}
--- /dev/null
+function parallelTests () {
+ return process.env.MOCHA_PARALLEL === 'true'
+}
+
+function isGithubCI () {
+ return !!process.env.GITHUB_WORKSPACE
+}
+
+function areHttpImportTestsDisabled () {
+ const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true'
+
+ if (disabled) console.log('DISABLE_HTTP_IMPORT_TESTS env set to "true" so import tests are disabled')
+
+ return disabled
+}
+
+function areObjectStorageTestsDisabled () {
+ const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true'
+
+ if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled')
+
+ return disabled
+}
+
+export {
+ parallelTests,
+ isGithubCI,
+ areHttpImportTestsDisabled,
+ areObjectStorageTestsDisabled
+}
+export * from './array'
+export * from './crypto'
export * from './date'
-export * from './miscs'
+export * from './env'
+export * from './object'
+export * from './path'
export * from './regexp'
+export * from './time'
export * from './promises'
export * from './url'
+export * from './version'
--- /dev/null
+function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> {
+ const result: any = {}
+
+ for (const key of keys) {
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
+ result[key] = object[key]
+ }
+ }
+
+ return result
+}
+
+function sortObjectComparator (key: string, order: 'asc' | 'desc') {
+ return (a: any, b: any) => {
+ if (a[key] < b[key]) {
+ return order === 'asc' ? -1 : 1
+ }
+
+ if (a[key] > b[key]) {
+ return order === 'asc' ? 1 : -1
+ }
+
+ return 0
+ }
+}
+
+export {
+ pick,
+ sortObjectComparator
+}
rootPath = __dirname
+ if (basename(rootPath) === 'common') rootPath = resolve(rootPath, '..')
if (basename(rootPath) === 'core-utils') rootPath = resolve(rootPath, '..')
if (basename(rootPath) === 'shared') rootPath = resolve(rootPath, '..')
if (basename(rootPath) === 'server') rootPath = resolve(rootPath, '..')
return ext.toLowerCase()
}
+function buildAbsoluteFixturePath (path: string, customCIPath = false) {
+ if (isAbsolute(path)) return path
+
+ if (customCIPath && process.env.GITHUB_WORKSPACE) {
+ return join(process.env.GITHUB_WORKSPACE, 'fixtures', path)
+ }
+
+ return join(root(), 'server', 'tests', 'fixtures', path)
+}
+
export {
root,
buildPath,
+ buildAbsoluteFixturePath,
getLowercaseExtension
}
--- /dev/null
+function wait (milliseconds: number) {
+ return new Promise(resolve => setTimeout(resolve, milliseconds))
+}
+
+export {
+ wait
+}
-// high excluded
-function randomInt (low: number, high: number) {
- return Math.floor(Math.random() * (high - low) + low)
-}
-
// Thanks https://stackoverflow.com/a/16187766
function compareSemVer (a: string, b: string) {
const regExStrip0 = /(\.0+)+$/
return segmentsA.length - segmentsB.length
}
-function sortObjectComparator (key: string, order: 'asc' | 'desc') {
- return (a: any, b: any) => {
- if (a[key] < b[key]) {
- return order === 'asc' ? -1 : 1
- }
-
- if (a[key] > b[key]) {
- return order === 'asc' ? 1 : -1
- }
-
- return 0
- }
-}
-
export {
- randomInt,
- compareSemVer,
- sortObjectComparator
+ compareSemVer
}
export * from './abuse'
export * from './common'
export * from './i18n'
-export * from './path'
export * from './plugins'
export * from './renderer'
export * from './users'
-export * from './utils'
export * from './videos'
-export * from './uuid'
+++ /dev/null
-export * from './array'
-export * from './object'
+++ /dev/null
-function pick <O extends object, K extends keyof O> (object: O, keys: K[]): Pick<O, K> {
- const result: any = {}
-
- for (const key of keys) {
- if (Object.prototype.hasOwnProperty.call(object, key)) {
- result[key] = object[key]
- }
- }
-
- return result
-}
-
-export {
- pick
-}
export * from './bitrate'
export * from './privacy'
+export * from './uuid'
--- /dev/null
+import { stat } from 'fs-extra'
+
+async function getFileSize (path: string) {
+ const stats = await stat(path)
+
+ return stats.size
+}
+
+export {
+ getFileSize
+}
export * from './ffprobe'
+export * from './file'
export * from './user-register.model'
export * from './user-right.enum'
export * from './user-role'
+export * from './user-scoped-token'
export * from './user-update-me.model'
export * from './user-update.model'
export * from './user-video-quota.model'
export * from './feeds'
export * from './logs'
export * from './miscs'
-export * from './mock-servers'
export * from './moderation'
export * from './overviews'
export * from './requests'
-import { HttpStatusCode } from '@shared/models'
-import { LogLevel } from '../../models/server/log-level.type'
+import { HttpStatusCode, LogLevel } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class LogsCommand extends AbstractCommand {
-export * from './checks'
-export * from './generate'
export * from './sql-command'
-export * from './tests'
export * from './webtorrent'
import { QueryTypes, Sequelize } from 'sequelize'
-import { AbstractCommand } from '../shared/abstract-command'
+import { AbstractCommand } from '../shared'
export class SQLCommand extends AbstractCommand {
private sequelize: Sequelize
+++ /dev/null
-import { stat } from 'fs-extra'
-import { basename, isAbsolute, join, resolve } from 'path'
-
-const FIXTURE_URLS = {
- peertube_long: 'https://peertube2.cpy.re/videos/watch/122d093a-1ede-43bd-bd34-59d2931ffc5e',
- peertube_short: 'https://peertube2.cpy.re/w/3fbif9S3WmtTP8gGsC5HBd',
-
- youtube: 'https://www.youtube.com/watch?v=msX3jv1XdvM',
-
- /**
- * The video is used to check format-selection correctness wrt. HDR,
- * which brings its own set of oddities outside of a MediaSource.
- *
- * The video needs to have the following format_ids:
- * (which you can check by using `youtube-dl <url> -F`):
- * - (webm vp9)
- * - (mp4 avc1)
- * - (webm vp9.2 HDR)
- */
- youtubeHDR: 'https://www.youtube.com/watch?v=RQgnBB9z_N4',
-
- // eslint-disable-next-line max-len
- magnet: 'magnet:?xs=https%3A%2F%2Fpeertube2.cpy.re%2Flazy-static%2Ftorrents%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.torrent&xt=urn:btih:0f498834733e8057ed5c6f2ee2b4efd8d84a76ee&dn=super+peertube2+video&tr=https%3A%2F%2Fpeertube2.cpy.re%2Ftracker%2Fannounce&tr=wss%3A%2F%2Fpeertube2.cpy.re%3A443%2Ftracker%2Fsocket&ws=https%3A%2F%2Fpeertube2.cpy.re%2Fstatic%2Fwebseed%2Fb209ca00-c8bb-4b2b-b421-1ede169f3dbc-720.mp4',
-
- badVideo: 'https://download.cpy.re/peertube/bad_video.mp4',
- goodVideo: 'https://download.cpy.re/peertube/good_video.mp4',
- goodVideo720: 'https://download.cpy.re/peertube/good_video_720.mp4',
-
- file4K: 'https://download.cpy.re/peertube/4k_file.txt'
-}
-
-function parallelTests () {
- return process.env.MOCHA_PARALLEL === 'true'
-}
-
-function isGithubCI () {
- return !!process.env.GITHUB_WORKSPACE
-}
-
-function areHttpImportTestsDisabled () {
- const disabled = process.env.DISABLE_HTTP_IMPORT_TESTS === 'true'
-
- if (disabled) console.log('DISABLE_HTTP_IMPORT_TESTS env set to "true" so import tests are disabled')
-
- return disabled
-}
-
-function areObjectStorageTestsDisabled () {
- const disabled = process.env.ENABLE_OBJECT_STORAGE_TESTS !== 'true'
-
- if (disabled) console.log('ENABLE_OBJECT_STORAGE_TESTS env is not set to "true" so object storage tests are disabled')
-
- return disabled
-}
-
-function buildAbsoluteFixturePath (path: string, customCIPath = false) {
- if (isAbsolute(path)) return path
-
- if (customCIPath && process.env.GITHUB_WORKSPACE) {
- return join(process.env.GITHUB_WORKSPACE, 'fixtures', path)
- }
-
- return join(root(), 'server', 'tests', 'fixtures', path)
-}
-
-function root () {
- // We are in /miscs
- let root = join(__dirname, '..', '..', '..')
-
- if (basename(root) === 'dist') root = resolve(root, '..')
-
- return root
-}
-
-function wait (milliseconds: number) {
- return new Promise(resolve => setTimeout(resolve, milliseconds))
-}
-
-async function getFileSize (path: string) {
- const stats = await stat(path)
-
- return stats.size
-}
-
-function buildRequestStub (): any {
- return { }
-}
-
-export {
- FIXTURE_URLS,
-
- parallelTests,
- isGithubCI,
- areHttpImportTestsDisabled,
- buildAbsoluteFixturePath,
- getFileSize,
- buildRequestStub,
- areObjectStorageTestsDisabled,
- wait,
- root
-}
+++ /dev/null
-import { HttpStatusCode } from '@shared/models'
-import { makeGetRequest } from './requests'
-
-function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
- return makeGetRequest({
- url,
- path,
- token,
- query: { ...query, start: 'hello' },
- expectedStatus: HttpStatusCode.BAD_REQUEST_400
- })
-}
-
-async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {
- await makeGetRequest({
- url,
- path,
- token,
- query: { ...query, count: 'hello' },
- expectedStatus: HttpStatusCode.BAD_REQUEST_400
- })
-
- await makeGetRequest({
- url,
- path,
- token,
- query: { ...query, count: 2000 },
- expectedStatus: HttpStatusCode.BAD_REQUEST_400
- })
-}
-
-function checkBadSortPagination (url: string, path: string, token?: string, query = {}) {
- return makeGetRequest({
- url,
- path,
- token,
- query: { ...query, sort: 'hello' },
- expectedStatus: HttpStatusCode.BAD_REQUEST_400
- })
-}
-
-// ---------------------------------------------------------------------------
-
-export {
- checkBadStartPagination,
- checkBadCountPagination,
- checkBadSortPagination
-}
-// Don't include activitypub that import stuff from server
-export * from './check-api-params'
export * from './requests'
import { decode } from 'querystring'
import request from 'supertest'
import { URL } from 'url'
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
import { HttpStatusCode } from '@shared/models'
-import { buildAbsoluteFixturePath } from '../miscs/tests'
export type CommonRequestParams = {
url: string
import { merge } from 'lodash'
+import { About, CustomConfig, HttpStatusCode, ServerConfig } from '@shared/models'
import { DeepPartial } from '@shared/typescript-utils'
-import { About, HttpStatusCode, ServerConfig } from '@shared/models'
-import { CustomConfig } from '../../models/server/custom-config.model'
-import { AbstractCommand, OverrideCommandOptions } from '../shared'
+import { AbstractCommand, OverrideCommandOptions } from '../shared/abstract-command'
export class ConfigCommand extends AbstractCommand {
export * from './config-command'
export * from './contact-form-command'
export * from './debug-command'
-export * from './directories'
export * from './follows-command'
export * from './follows'
export * from './jobs'
export * from './jobs-command'
export * from './object-storage-command'
export * from './plugins-command'
-export * from './plugins'
export * from './redundancy-command'
export * from './server'
export * from './servers-command'
export * from './servers'
export * from './stats-command'
-export * from './tracker'
import { pick } from '@shared/core-utils'
-import { HttpStatusCode } from '@shared/models'
-import { Job, JobState, JobType, ResultList } from '../../models'
+import { HttpStatusCode, Job, JobState, JobType, ResultList } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class JobsCommand extends AbstractCommand {
import { expect } from 'chai'
+import { wait } from '@shared/core-utils'
import { JobState, JobType } from '../../models'
-import { wait } from '../miscs'
import { PeerTubeServer } from './server'
async function waitJobs (serversArg: PeerTubeServer[] | PeerTubeServer, skipDelayed = false) {
import { ChildProcess, fork } from 'child_process'
import { copy } from 'fs-extra'
import { join } from 'path'
-import { root, randomInt } from '@shared/core-utils'
-import { Video, VideoChannel, VideoCreateResult, VideoDetails } from '../../models/videos'
+import { parallelTests, randomInt, root } from '@shared/core-utils'
+import { Video, VideoChannel, VideoCreateResult, VideoDetails } from '@shared/models'
import { BulkCommand } from '../bulk'
import { CLICommand } from '../cli'
import { CustomPagesCommand } from '../custom-pages'
import { FeedCommand } from '../feeds'
import { LogsCommand } from '../logs'
-import { parallelTests, SQLCommand } from '../miscs'
+import { SQLCommand } from '../miscs'
import { AbusesCommand } from '../moderation'
import { OverviewsCommand } from '../overviews'
import { SearchCommand } from '../search'
import { DebugCommand } from './debug-command'
import { FollowsCommand } from './follows-command'
import { JobsCommand } from './jobs-command'
+import { ObjectStorageCommand } from './object-storage-command'
import { PluginsCommand } from './plugins-command'
import { RedundancyCommand } from './redundancy-command'
import { ServersCommand } from './servers-command'
import { StatsCommand } from './stats-command'
-import { ObjectStorageCommand } from './object-storage-command'
export type RunServerOptions = {
hideLogs?: boolean
import { exec } from 'child_process'
import { copy, ensureDir, readFile, remove } from 'fs-extra'
import { basename, join } from 'path'
-import { root } from '@shared/core-utils'
+import { isGithubCI, root, wait } from '@shared/core-utils'
+import { getFileSize } from '@shared/extra-utils'
import { HttpStatusCode } from '@shared/models'
-import { getFileSize, isGithubCI, wait } from '../miscs'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class ServersCommand extends AbstractCommand {
import { ensureDir } from 'fs-extra'
-import { isGithubCI } from '../miscs'
+import { isGithubCI } from '@shared/core-utils'
import { PeerTubeServer, RunServerOptions } from './server'
async function createSingleServer (serverNumber: number, configOverride?: Object, options: RunServerOptions = {}) {
import { isAbsolute, join } from 'path'
-import { root } from '../miscs/tests'
+import { root } from '@shared/core-utils'
import {
makeDeleteRequest,
makeGetRequest,
-import { HttpStatusCode, ResultList } from '@shared/models'
-import { Account, ActorFollow } from '../../models/actors'
-import { AccountVideoRate, VideoRateType } from '../../models/videos'
+import { Account, AccountVideoRate, ActorFollow, HttpStatusCode, ResultList, VideoRateType } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class AccountsCommand extends AbstractCommand {
export * from './accounts-command'
-export * from './actors'
export * from './blocklist-command'
export * from './login'
export * from './login-command'
-export * from './notifications'
export * from './notifications-command'
export * from './subscriptions-command'
export * from './users-command'
-import { HttpStatusCode, ResultList } from '@shared/models'
-import { UserNotification, UserNotificationSetting } from '../../models/users'
+import { HttpStatusCode, ResultList, UserNotification, UserNotificationSetting } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class NotificationsCommand extends AbstractCommand {
HttpStatusCode,
MyUser,
ResultList,
+ ScopedToken,
User,
UserAdminFlag,
UserCreateResult,
UserVideoQuota,
UserVideoRate
} from '@shared/models'
-import { ScopedToken } from '@shared/models/users/user-scoped-token'
import { unwrapBody } from '../requests'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
-import { HttpStatusCode, ResultList } from '@shared/models'
-import { VideoBlacklist, VideoBlacklistType } from '../../models/videos'
+import { HttpStatusCode, ResultList, VideoBlacklist, VideoBlacklistType } from '@shared/models'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class BlacklistCommand extends AbstractCommand {
+import { buildAbsoluteFixturePath } from '@shared/core-utils'
import { HttpStatusCode, ResultList, VideoCaption } from '@shared/models'
-import { buildAbsoluteFixturePath } from '../miscs'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export class CaptionsCommand extends AbstractCommand {
import { pick } from '@shared/core-utils'
-import { ActorFollow, HttpStatusCode, ResultList, VideoChannel, VideoChannelCreateResult } from '@shared/models'
-import { VideoChannelCreate } from '../../models/videos/channel/video-channel-create.model'
-import { VideoChannelUpdate } from '../../models/videos/channel/video-channel-update.model'
+import {
+ ActorFollow,
+ HttpStatusCode,
+ ResultList,
+ VideoChannel,
+ VideoChannelCreate,
+ VideoChannelCreateResult,
+ VideoChannelUpdate
+} from '@shared/models'
import { unwrapBody } from '../requests'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
export * from './blacklist-command'
export * from './captions-command'
-export * from './captions'
export * from './change-ownership-command'
export * from './channels'
export * from './channels-command'
export * from './live-command'
export * from './live'
export * from './playlists-command'
-export * from './playlists'
export * from './services-command'
export * from './streaming-playlists-command'
-export * from './streaming-playlists'
export * from './comments-command'
export * from './videos-command'
-export * from './videos'
import { readdir } from 'fs-extra'
import { omit } from 'lodash'
import { join } from 'path'
+import { wait } from '@shared/core-utils'
import { HttpStatusCode, LiveVideo, LiveVideoCreate, LiveVideoUpdate, VideoCreateResult, VideoDetails, VideoState } from '@shared/models'
-import { wait } from '../miscs'
import { unwrapBody } from '../requests'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
import { sendRTMPStream, testFfmpegStreamError } from './live'
-/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-
-import { expect } from 'chai'
import ffmpeg, { FfmpegCommand } from 'fluent-ffmpeg'
-import { pathExists, readdir } from 'fs-extra'
-import { join } from 'path'
-import { buildAbsoluteFixturePath, wait } from '../miscs'
+import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
import { PeerTubeServer } from '../server/server'
function sendRTMPStream (options: {
}
}
-async function checkLiveCleanupAfterSave (server: PeerTubeServer, videoUUID: string, resolutions: number[] = []) {
- const basePath = server.servers.buildDirectory('streaming-playlists')
- const hlsPath = join(basePath, 'hls', videoUUID)
-
- if (resolutions.length === 0) {
- const result = await pathExists(hlsPath)
- expect(result).to.be.false
-
- return
- }
-
- const files = await readdir(hlsPath)
-
- // fragmented file and playlist per resolution + master playlist + segments sha256 json file
- expect(files).to.have.lengthOf(resolutions.length * 2 + 2)
-
- for (const resolution of resolutions) {
- const fragmentedFile = files.find(f => f.endsWith(`-${resolution}-fragmented.mp4`))
- expect(fragmentedFile).to.exist
-
- const playlistFile = files.find(f => f.endsWith(`${resolution}.m3u8`))
- expect(playlistFile).to.exist
- }
-
- const masterPlaylistFile = files.find(f => f.endsWith('-master.m3u8'))
- expect(masterPlaylistFile).to.exist
-
- const shaFile = files.find(f => f.endsWith('-segments-sha256.json'))
- expect(shaFile).to.exist
-}
-
export {
sendRTMPStream,
waitFfmpegUntilError,
testFfmpegStreamError,
stopFfmpeg,
waitUntilLivePublishedOnAllServers,
- waitUntilLiveSavedOnAllServers,
- checkLiveCleanupAfterSave
+ waitUntilLiveSavedOnAllServers
}
import got, { Response as GotResponse } from 'got'
import { omit } from 'lodash'
import validator from 'validator'
-import { buildUUID } from '@shared/core-utils/uuid'
-import { pick } from '@shared/core-utils'
+import { buildAbsoluteFixturePath, buildUUID, pick, wait } from '@shared/core-utils'
import {
HttpStatusCode,
ResultList,
VideosCommonQuery,
VideoTranscodingCreate
} from '@shared/models'
-import { buildAbsoluteFixturePath, wait } from '../miscs'
import { unwrapBody } from '../requests'
import { waitJobs } from '../server'
import { AbstractCommand, OverrideCommandOptions } from '../shared'
+++ /dev/null
-/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */
-
-import { expect } from 'chai'
-import { pathExists, readdir } from 'fs-extra'
-import { basename, join } from 'path'
-import { HttpStatusCode, VideoCaption, VideoDetails } from '@shared/models'
-import { waitJobs } from '../server'
-import { PeerTubeServer } from '../server/server'
-import { VideoEdit } from './videos-command'
-
-async function checkVideoFilesWereRemoved (options: {
- server: PeerTubeServer
- video: VideoDetails
- captions?: VideoCaption[]
- onlyVideoFiles?: boolean // default false
-}) {
- const { video, server, captions = [], onlyVideoFiles = false } = options
-
- const webtorrentFiles = video.files || []
- const hlsFiles = video.streamingPlaylists[0]?.files || []
-
- const thumbnailName = basename(video.thumbnailPath)
- const previewName = basename(video.previewPath)
-
- const torrentNames = webtorrentFiles.concat(hlsFiles).map(f => basename(f.torrentUrl))
-
- const captionNames = captions.map(c => basename(c.captionPath))
-
- const webtorrentFilenames = webtorrentFiles.map(f => basename(f.fileUrl))
- const hlsFilenames = hlsFiles.map(f => basename(f.fileUrl))
-
- let directories: { [ directory: string ]: string[] } = {
- videos: webtorrentFilenames,
- redundancy: webtorrentFilenames,
- [join('playlists', 'hls')]: hlsFilenames,
- [join('redundancy', 'hls')]: hlsFilenames
- }
-
- if (onlyVideoFiles !== true) {
- directories = {
- ...directories,
-
- thumbnails: [ thumbnailName ],
- previews: [ previewName ],
- torrents: torrentNames,
- captions: captionNames
- }
- }
-
- for (const directory of Object.keys(directories)) {
- const directoryPath = server.servers.buildDirectory(directory)
-
- const directoryExists = await pathExists(directoryPath)
- if (directoryExists === false) continue
-
- const existingFiles = await readdir(directoryPath)
- for (const existingFile of existingFiles) {
- for (const shouldNotExist of directories[directory]) {
- expect(existingFile, `File ${existingFile} should not exist in ${directoryPath}`).to.not.contain(shouldNotExist)
- }
- }
- }
-}
-
-async function saveVideoInServers (servers: PeerTubeServer[], uuid: string) {
- for (const server of servers) {
- server.store.videoDetails = await server.videos.get({ id: uuid })
- }
-}
-
-function checkUploadVideoParam (
- server: PeerTubeServer,
- token: string,
- attributes: Partial<VideoEdit>,
- expectedStatus = HttpStatusCode.OK_200,
- mode: 'legacy' | 'resumable' = 'legacy'
-) {
- return mode === 'legacy'
- ? server.videos.buildLegacyUpload({ token, attributes, expectedStatus })
- : server.videos.buildResumeUpload({ token, attributes, expectedStatus })
-}
-
-// serverNumber starts from 1
-async function uploadRandomVideoOnServers (
- servers: PeerTubeServer[],
- serverNumber: number,
- additionalParams?: VideoEdit & { prefixName?: string }
-) {
- const server = servers.find(s => s.serverNumber === serverNumber)
- const res = await server.videos.randomUpload({ wait: false, additionalParams })
-
- await waitJobs(servers)
-
- return res
-}
-
-// ---------------------------------------------------------------------------
-
-export {
- checkUploadVideoParam,
- uploadRandomVideoOnServers,
- checkVideoFilesWereRemoved,
- saveVideoInServers
-}