diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index cd7ea01aa..df05ee452 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts @@ -13,7 +13,6 @@ import { forwardVideoRelatedActivity } from '../send/utils' import { Redis } from '../../redis' import { createOrUpdateCacheFile } from '../cache-file' import { getVideoDislikeActivityPubUrl } from '../url' -import { VideoModel } from '../../../models/video/video' async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { const activityObject = activity.object diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts index ea0682634..6d90d8643 100644 --- a/server/tests/api/activitypub/client.ts +++ b/server/tests/api/activitypub/client.ts @@ -8,10 +8,10 @@ import { flushTests, killallServers, makeActivityPubGetRequest, - runServer, ServerInfo, - setAccessTokensToServers, uploadVideo -} from '../../utils' + setAccessTokensToServers, + uploadVideo +} from '../../../../shared/utils' const expect = chai.expect diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts index a42c606c6..03609c1a9 100644 --- a/server/tests/api/activitypub/fetch.ts +++ b/server/tests/api/activitypub/fetch.ts @@ -11,12 +11,13 @@ import { killallServers, ServerInfo, setAccessTokensToServers, + setActorField, + setVideoField, uploadVideo, - userLogin -} from '../../utils' + userLogin, + waitJobs +} from '../../../../shared/utils' import * as chai from 'chai' -import { setActorField, setVideoField } from '../../utils/miscs/sql' -import { waitJobs } from '../../utils/server/jobs' import { Video } from '../../../../shared/models/videos' const expect = chai.expect diff --git a/server/tests/api/activitypub/helpers.ts b/server/tests/api/activitypub/helpers.ts index 51256a922..ac6e755c3 100644 --- a/server/tests/api/activitypub/helpers.ts +++ b/server/tests/api/activitypub/helpers.ts @@ -2,7 +2,7 @@ import 'mocha' import { expect } from 'chai' -import { buildRequestStub } from '../../utils' +import { buildRequestStub } from '../../../../shared/utils/miscs/stubs' import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto' import { cloneDeep } from 'lodash' import { buildSignedActivity } from '../../../helpers/activitypub' diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts index 67e04f79e..332ea7ed1 100644 --- a/server/tests/api/activitypub/refresher.ts +++ b/server/tests/api/activitypub/refresher.ts @@ -1,10 +1,19 @@ /* tslint:disable:no-unused-expression */ import 'mocha' -import { doubleFollow, getVideo, reRunServer } from '../../utils' -import { flushAndRunMultipleServers, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo, wait } from '../../utils/index' -import { waitJobs } from '../../utils/server/jobs' -import { setVideoField } from '../../utils/miscs/sql' +import { + doubleFollow, + flushAndRunMultipleServers, + getVideo, + killallServers, + reRunServer, + ServerInfo, + setAccessTokensToServers, + uploadVideo, + wait, + setVideoField, + waitJobs +} from '../../../../shared/utils' describe('Test AP refresher', function () { let servers: ServerInfo[] = [] diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts index 7349749f1..342ae0fa1 100644 --- a/server/tests/api/activitypub/security.ts +++ b/server/tests/api/activitypub/security.ts @@ -2,13 +2,19 @@ import 'mocha' -import { flushAndRunMultipleServers, flushTests, killallServers, ServerInfo } from '../../utils' +import { + flushAndRunMultipleServers, + flushTests, + killallServers, + makeFollowRequest, + makePOSTAPRequest, + ServerInfo, + setActorField +} from '../../../../shared/utils' import { HTTP_SIGNATURE } from '../../../initializers' import { buildDigest, buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils' import * as chai from 'chai' -import { setActorField } from '../../utils/miscs/sql' import { activityPubContextify, buildSignedActivity } from '../../../helpers/activitypub' -import { makeFollowRequest, makePOSTAPRequest } from '../../utils/requests/activitypub' const expect = chai.expect diff --git a/server/tests/api/check-params/accounts.ts b/server/tests/api/check-params/accounts.ts index 9e0b1e35c..567fd072c 100644 --- a/server/tests/api/check-params/accounts.ts +++ b/server/tests/api/check-params/accounts.ts @@ -2,9 +2,13 @@ import 'mocha' -import { flushTests, killallServers, runServer, ServerInfo } from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' -import { getAccount } from '../../utils/users/accounts' +import { flushTests, killallServers, runServer, ServerInfo } from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' +import { getAccount } from '../../../../shared/utils/users/accounts' describe('Test users API validators', function () { const path = '/api/v1/accounts/' diff --git a/server/tests/api/check-params/blocklist.ts b/server/tests/api/check-params/blocklist.ts index c745ac975..c20453c16 100644 --- a/server/tests/api/check-params/blocklist.ts +++ b/server/tests/api/check-params/blocklist.ts @@ -13,8 +13,12 @@ import { makePostBodyRequest, ServerInfo, setAccessTokensToServers, userLogin -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' describe('Test blocklist API validators', function () { let servers: ServerInfo[] diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index d807f910b..ffae380c1 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts @@ -7,7 +7,7 @@ import { CustomConfig } from '../../../../shared/models/server/custom-config.mod import { createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePutBodyRequest, runServer, ServerInfo, setAccessTokensToServers, userLogin, immutableAssign -} from '../../utils' +} from '../../../../shared/utils' describe('Test config API validators', function () { const path = '/api/v1/config/custom' diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index cdc95c81a..2ad1575a3 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts @@ -5,8 +5,12 @@ import 'mocha' import { createUser, flushTests, killallServers, makeDeleteRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers, userLogin -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' describe('Test server follows API validators', function () { let server: ServerInfo diff --git a/server/tests/api/check-params/jobs.ts b/server/tests/api/check-params/jobs.ts index ce3ac8809..89760ff98 100644 --- a/server/tests/api/check-params/jobs.ts +++ b/server/tests/api/check-params/jobs.ts @@ -2,9 +2,21 @@ import 'mocha' -import { createUser, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, userLogin } from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' -import { makeGetRequest } from '../../utils/requests/requests' +import { + createUser, + flushTests, + killallServers, + runServer, + ServerInfo, + setAccessTokensToServers, + userLogin +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' +import { makeGetRequest } from '../../../../shared/utils/requests/requests' describe('Test jobs API validators', function () { const path = '/api/v1/jobs/failed' diff --git a/server/tests/api/check-params/redundancy.ts b/server/tests/api/check-params/redundancy.ts index aa588e3dd..ff4726ceb 100644 --- a/server/tests/api/check-params/redundancy.ts +++ b/server/tests/api/check-params/redundancy.ts @@ -12,7 +12,7 @@ import { ServerInfo, setAccessTokensToServers, userLogin -} from '../../utils' +} from '../../../../shared/utils' describe('Test server redundancy API validators', function () { let servers: ServerInfo[] diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts index eabf602ac..aa81965f3 100644 --- a/server/tests/api/check-params/search.ts +++ b/server/tests/api/check-params/search.ts @@ -2,8 +2,12 @@ import 'mocha' -import { flushTests, immutableAssign, killallServers, makeGetRequest, runServer, ServerInfo } from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' +import { flushTests, immutableAssign, killallServers, makeGetRequest, runServer, ServerInfo } from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' describe('Test videos API validator', function () { let server: ServerInfo diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts index fcde7e179..28591af9d 100644 --- a/server/tests/api/check-params/services.ts +++ b/server/tests/api/check-params/services.ts @@ -2,7 +2,15 @@ import 'mocha' -import { flushTests, killallServers, makeGetRequest, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils' +import { + flushTests, + killallServers, + makeGetRequest, + runServer, + ServerInfo, + setAccessTokensToServers, + uploadVideo +} from '../../../../shared/utils' describe('Test services API validators', function () { let server: ServerInfo diff --git a/server/tests/api/check-params/user-subscriptions.ts b/server/tests/api/check-params/user-subscriptions.ts index 6af7ed43b..8a9ced7c1 100644 --- a/server/tests/api/check-params/user-subscriptions.ts +++ b/server/tests/api/check-params/user-subscriptions.ts @@ -13,9 +13,14 @@ import { ServerInfo, setAccessTokensToServers, userLogin -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils' + +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' +import { waitJobs } from '../../../../shared/utils/server/jobs' describe('Test user subscriptions API validators', function () { const path = '/api/v1/users/me/subscriptions' diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index ee225dc2e..05f42bca9 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -9,11 +9,15 @@ import { createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest, makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers, updateUser, uploadVideo, userLogin, deleteMe, unblockUser, blockUser -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' -import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../utils/videos/video-imports' +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' +import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/utils/videos/video-imports' import { VideoPrivacy } from '../../../../shared/models/videos' -import { waitJobs } from '../../utils/server/jobs' +import { waitJobs } from '../../../../shared/utils/server/jobs' import { expect } from 'chai' describe('Test users API validators', function () { diff --git a/server/tests/api/check-params/video-abuses.ts b/server/tests/api/check-params/video-abuses.ts index d2bed6a2a..a79ab4201 100644 --- a/server/tests/api/check-params/video-abuses.ts +++ b/server/tests/api/check-params/video-abuses.ts @@ -15,8 +15,12 @@ import { updateVideoAbuse, uploadVideo, userLogin -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' import { VideoAbuseState } from '../../../../shared/models/videos' describe('Test video abuses API validators', function () { diff --git a/server/tests/api/check-params/video-blacklist.ts b/server/tests/api/check-params/video-blacklist.ts index 473216236..8e1206db3 100644 --- a/server/tests/api/check-params/video-blacklist.ts +++ b/server/tests/api/check-params/video-blacklist.ts @@ -15,8 +15,12 @@ import { setAccessTokensToServers, uploadVideo, userLogin -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' import { VideoDetails } from '../../../../shared/models/videos' import { expect } from 'chai' diff --git a/server/tests/api/check-params/video-captions.ts b/server/tests/api/check-params/video-captions.ts index 8d46971a1..e4d36fd4f 100644 --- a/server/tests/api/check-params/video-captions.ts +++ b/server/tests/api/check-params/video-captions.ts @@ -13,9 +13,9 @@ import { setAccessTokensToServers, uploadVideo, userLogin -} from '../../utils' +} from '../../../../shared/utils' import { join } from 'path' -import { createVideoCaption } from '../../utils/videos/video-captions' +import { createVideoCaption } from '../../../../shared/utils/videos/video-captions' describe('Test video captions API validator', function () { const path = '/api/v1/videos/' diff --git a/server/tests/api/check-params/video-channels.ts b/server/tests/api/check-params/video-channels.ts index e5696224d..14e4deaf7 100644 --- a/server/tests/api/check-params/video-channels.ts +++ b/server/tests/api/check-params/video-channels.ts @@ -20,8 +20,12 @@ import { ServerInfo, setAccessTokensToServers, userLogin -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' import { User } from '../../../../shared/models/users' import { join } from 'path' diff --git a/server/tests/api/check-params/video-comments.ts b/server/tests/api/check-params/video-comments.ts index 5241832fe..5981780ed 100644 --- a/server/tests/api/check-params/video-comments.ts +++ b/server/tests/api/check-params/video-comments.ts @@ -6,9 +6,13 @@ import { createUser, flushTests, killallServers, makeDeleteRequest, makeGetRequest, makePostBodyRequest, runServer, ServerInfo, setAccessTokensToServers, uploadVideo, userLogin -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' -import { addVideoCommentThread } from '../../utils/videos/video-comments' +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' +import { addVideoCommentThread } from '../../../../shared/utils/videos/video-comments' const expect = chai.expect diff --git a/server/tests/api/check-params/video-imports.ts b/server/tests/api/check-params/video-imports.ts index b51f3d2cd..7bf187007 100644 --- a/server/tests/api/check-params/video-imports.ts +++ b/server/tests/api/check-params/video-imports.ts @@ -18,9 +18,13 @@ import { setAccessTokensToServers, updateCustomSubConfig, userLogin -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' -import { getMagnetURI, getYoutubeVideoUrl } from '../../utils/videos/video-imports' +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' +import { getMagnetURI, getYoutubeVideoUrl } from '../../../../shared/utils/videos/video-imports' describe('Test video imports API validator', function () { const path = '/api/v1/videos/imports' diff --git a/server/tests/api/check-params/videos-filter.ts b/server/tests/api/check-params/videos-filter.ts index 784cd8ba1..e998c8a3d 100644 --- a/server/tests/api/check-params/videos-filter.ts +++ b/server/tests/api/check-params/videos-filter.ts @@ -11,7 +11,7 @@ import { ServerInfo, setAccessTokensToServers, userLogin -} from '../../utils' +} from '../../../../shared/utils' import { UserRole } from '../../../../shared/models/users' const expect = chai.expect diff --git a/server/tests/api/check-params/videos-history.ts b/server/tests/api/check-params/videos-history.ts index 808c3b616..09c6f7861 100644 --- a/server/tests/api/check-params/videos-history.ts +++ b/server/tests/api/check-params/videos-history.ts @@ -11,7 +11,7 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../../utils' +} from '../../../../shared/utils' const expect = chai.expect diff --git a/server/tests/api/check-params/videos.ts b/server/tests/api/check-params/videos.ts index 699f135c7..d94eccf8e 100644 --- a/server/tests/api/check-params/videos.ts +++ b/server/tests/api/check-params/videos.ts @@ -8,9 +8,13 @@ import { VideoPrivacy } from '../../../../shared/models/videos/video-privacy.enu import { createUser, flushTests, getMyUserInformation, getVideo, getVideosList, immutableAssign, killallServers, makeDeleteRequest, makeGetRequest, makeUploadRequest, makePutBodyRequest, removeVideo, runServer, ServerInfo, setAccessTokensToServers, userLogin -} from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' -import { getAccountsList } from '../../utils/users/accounts' +} from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' +import { getAccountsList } from '../../../../shared/utils/users/accounts' const expect = chai.expect diff --git a/server/tests/api/redundancy/redundancy.ts b/server/tests/api/redundancy/redundancy.ts index 5b29a503a..9d3ce8153 100644 --- a/server/tests/api/redundancy/redundancy.ts +++ b/server/tests/api/redundancy/redundancy.ts @@ -18,15 +18,16 @@ import { wait, waitUntilLog, checkVideoFilesWereRemoved, removeVideo, getVideoWithToken -} from '../../utils' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils' +import { waitJobs } from '../../../../shared/utils/server/jobs' + import * as magnetUtil from 'magnet-uri' -import { updateRedundancy } from '../../utils/server/redundancy' +import { updateRedundancy } from '../../../../shared/utils/server/redundancy' import { ActorFollow } from '../../../../shared/models/actors' import { readdir } from 'fs-extra' import { join } from 'path' import { VideoRedundancyStrategy } from '../../../../shared/models/redundancy' -import { getStats } from '../../utils/server/stats' +import { getStats } from '../../../../shared/utils/server/stats' import { ServerStats } from '../../../../shared/models/server/server-stats.model' const expect = chai.expect diff --git a/server/tests/api/search/search-activitypub-video-channels.ts b/server/tests/api/search/search-activitypub-video-channels.ts index a287c5bdf..a411e973b 100644 --- a/server/tests/api/search/search-activitypub-video-channels.ts +++ b/server/tests/api/search/search-activitypub-video-channels.ts @@ -17,10 +17,10 @@ import { uploadVideo, userLogin, wait -} from '../../utils' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils' +import { waitJobs } from '../../../../shared/utils/server/jobs' import { VideoChannel } from '../../../../shared/models/videos' -import { searchVideoChannel } from '../../utils/search/video-channels' +import { searchVideoChannel } from '../../../../shared/utils/search/video-channels' const expect = chai.expect diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index 28f4fac50..f881917e7 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts @@ -16,8 +16,8 @@ import { uploadVideo, wait, searchVideo -} from '../../utils' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils' +import { waitJobs } from '../../../../shared/utils/server/jobs' import { Video, VideoPrivacy } from '../../../../shared/models/videos' const expect = chai.expect diff --git a/server/tests/api/search/search-videos.ts b/server/tests/api/search/search-videos.ts index f1392ffea..50da837da 100644 --- a/server/tests/api/search/search-videos.ts +++ b/server/tests/api/search/search-videos.ts @@ -13,7 +13,7 @@ import { uploadVideo, wait, immutableAssign -} from '../../utils' +} from '../../../../shared/utils' const expect = chai.expect diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index facd1688d..c5c360a17 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts @@ -4,8 +4,11 @@ import 'mocha' import * as chai from 'chai' import { About } from '../../../../shared/models/server/about.model' import { CustomConfig } from '../../../../shared/models/server/custom-config.model' -import { deleteCustomConfig, getAbout, killallServers, reRunServer } from '../../utils' import { + deleteCustomConfig, + getAbout, + killallServers, + reRunServer, flushTests, getConfig, getCustomConfig, @@ -13,7 +16,7 @@ import { runServer, setAccessTokensToServers, updateCustomConfig -} from '../../utils/index' +} from '../../../../shared/utils' const expect = chai.expect diff --git a/server/tests/api/server/email.ts b/server/tests/api/server/email.ts index 713a27143..13df772c6 100644 --- a/server/tests/api/server/email.ts +++ b/server/tests/api/server/email.ts @@ -14,11 +14,14 @@ import { unblockUser, uploadVideo, userLogin, - verifyEmail -} from '../../utils' -import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' -import { mockSmtpServer } from '../../utils/miscs/email' -import { waitJobs } from '../../utils/server/jobs' + verifyEmail, + flushTests, + killallServers, + ServerInfo, + setAccessTokensToServers +} from '../../../../shared/utils' +import { mockSmtpServer } from '../../../../shared/utils/miscs/email' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/server/follow-constraints.ts b/server/tests/api/server/follow-constraints.ts index 3135fc568..8bb073c41 100644 --- a/server/tests/api/server/follow-constraints.ts +++ b/server/tests/api/server/follow-constraints.ts @@ -2,11 +2,21 @@ import * as chai from 'chai' import 'mocha' -import { doubleFollow, getAccountVideos, getVideo, getVideoChannelVideos, getVideoWithToken } from '../../utils' -import { flushAndRunMultipleServers, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils/index' -import { unfollow } from '../../utils/server/follows' -import { userLogin } from '../../utils/users/login' -import { createUser } from '../../utils/users/users' +import { + doubleFollow, + getAccountVideos, + getVideo, + getVideoChannelVideos, + getVideoWithToken, + flushAndRunMultipleServers, + killallServers, + ServerInfo, + setAccessTokensToServers, + uploadVideo +} from '../../../../shared/utils' +import { unfollow } from '../../../../shared/utils/server/follows' +import { userLogin } from '../../../../shared/utils/users/login' +import { createUser } from '../../../../shared/utils/users/users' const expect = chai.expect diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index e80e93e7f..b0fc5d293 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts @@ -4,7 +4,7 @@ import * as chai from 'chai' import 'mocha' import { Video, VideoPrivacy } from '../../../../shared/models/videos' import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' -import { completeVideoCheck } from '../../utils' +import { completeVideoCheck } from '../../../../shared/utils' import { flushAndRunMultipleServers, getVideosList, @@ -12,21 +12,26 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../../utils/index' -import { dateIsValid } from '../../utils/miscs/miscs' -import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../../utils/server/follows' -import { expectAccountFollows } from '../../utils/users/accounts' -import { userLogin } from '../../utils/users/login' -import { createUser } from '../../utils/users/users' +} from '../../../../shared/utils/index' +import { dateIsValid } from '../../../../shared/utils/miscs/miscs' +import { + follow, + getFollowersListPaginationAndSort, + getFollowingListPaginationAndSort, + unfollow +} from '../../../../shared/utils/server/follows' +import { expectAccountFollows } from '../../../../shared/utils/users/accounts' +import { userLogin } from '../../../../shared/utils/users/login' +import { createUser } from '../../../../shared/utils/users/users' import { addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, getVideoThreadComments -} from '../../utils/videos/video-comments' -import { rateVideo } from '../../utils/videos/videos' -import { waitJobs } from '../../utils/server/jobs' -import { createVideoCaption, listVideoCaptions, testCaptionFile } from '../../utils/videos/video-captions' +} from '../../../../shared/utils/videos/video-comments' +import { rateVideo } from '../../../../shared/utils/videos/videos' +import { waitJobs } from '../../../../shared/utils/server/jobs' +import { createVideoCaption, listVideoCaptions, testCaptionFile } from '../../../../shared/utils/videos/video-captions' import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' const expect = chai.expect diff --git a/server/tests/api/server/handle-down.ts b/server/tests/api/server/handle-down.ts index 0421b2b40..8e162b69e 100644 --- a/server/tests/api/server/handle-down.ts +++ b/server/tests/api/server/handle-down.ts @@ -5,24 +5,31 @@ import 'mocha' import { JobState, Video } from '../../../../shared/models' import { VideoPrivacy } from '../../../../shared/models/videos' import { VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' -import { completeVideoCheck, getVideo, immutableAssign, reRunServer, unfollow, updateVideo, viewVideo } from '../../utils' + import { + completeVideoCheck, + getVideo, + immutableAssign, + reRunServer, + unfollow, + viewVideo, flushAndRunMultipleServers, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo, + updateVideo, wait -} from '../../utils/index' -import { follow, getFollowersListPaginationAndSort } from '../../utils/server/follows' -import { getJobsListPaginationAndSort, waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils' +import { follow, getFollowersListPaginationAndSort } from '../../../../shared/utils/server/follows' +import { getJobsListPaginationAndSort, waitJobs } from '../../../../shared/utils/server/jobs' import { addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, getVideoThreadComments -} from '../../utils/videos/video-comments' +} from '../../../../shared/utils/videos/video-comments' const expect = chai.expect diff --git a/server/tests/api/server/jobs.ts b/server/tests/api/server/jobs.ts index cd59d9a1b..52948b1d6 100644 --- a/server/tests/api/server/jobs.ts +++ b/server/tests/api/server/jobs.ts @@ -2,12 +2,12 @@ import * as chai from 'chai' import 'mocha' -import { killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { getJobsList, getJobsListPaginationAndSort, waitJobs } from '../../utils/server/jobs' -import { flushAndRunMultipleServers } from '../../utils/server/servers' -import { uploadVideo } from '../../utils/videos/videos' -import { dateIsValid } from '../../utils/miscs/miscs' +import { killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { getJobsList, getJobsListPaginationAndSort, waitJobs } from '../../../../shared/utils/server/jobs' +import { flushAndRunMultipleServers } from '../../../../shared/utils/server/servers' +import { uploadVideo } from '../../../../shared/utils/videos/videos' +import { dateIsValid } from '../../../../shared/utils/miscs/miscs' const expect = chai.expect diff --git a/server/tests/api/server/no-client.ts b/server/tests/api/server/no-client.ts index 6d6ce8532..3b95ce945 100644 --- a/server/tests/api/server/no-client.ts +++ b/server/tests/api/server/no-client.ts @@ -4,8 +4,8 @@ import { flushTests, killallServers, ServerInfo -} from '../../utils/index' -import { runServer } from '../../utils/server/servers' +} from '../../../../shared/utils' +import { runServer } from '../../../../shared/utils/server/servers' describe('Start and stop server without web client routes', function () { let server: ServerInfo diff --git a/server/tests/api/server/redundancy.ts b/server/tests/api/server/redundancy.ts new file mode 100644 index 000000000..8053d0491 --- /dev/null +++ b/server/tests/api/server/redundancy.ts @@ -0,0 +1,479 @@ +/* tslint:disable:no-unused-expression */ + +import * as chai from 'chai' +import 'mocha' +import { VideoDetails } from '../../../../shared/models/videos' +import { + doubleFollow, + flushAndRunMultipleServers, + getFollowingListPaginationAndSort, + getVideo, + immutableAssign, + killallServers, makeGetRequest, + root, + ServerInfo, + setAccessTokensToServers, unfollow, + uploadVideo, + viewVideo, + wait, + waitUntilLog, + checkVideoFilesWereRemoved, removeVideo +} from '../../../../shared/utils' +import { waitJobs } from '../../../../shared/utils/server/jobs' +import * as magnetUtil from 'magnet-uri' +import { updateRedundancy } from '../../../../shared/utils/server/redundancy' +import { ActorFollow } from '../../../../shared/models/actors' +import { readdir } from 'fs-extra' +import { join } from 'path' +import { VideoRedundancyStrategy } from '../../../../shared/models/redundancy' +import { getStats } from '../../../../shared/utils/server/stats' +import { ServerStats } from '../../../../shared/models/server/server-stats.model' + +const expect = chai.expect + +let servers: ServerInfo[] = [] +let video1Server2UUID: string + +function checkMagnetWebseeds (file: { magnetUri: string, resolution: { id: number } }, baseWebseeds: string[], server: ServerInfo) { + const parsed = magnetUtil.decode(file.magnetUri) + + for (const ws of baseWebseeds) { + const found = parsed.urlList.find(url => url === `${ws}-${file.resolution.id}.mp4`) + expect(found, `Webseed ${ws} not found in ${file.magnetUri} on server ${server.url}`).to.not.be.undefined + } + + expect(parsed.urlList).to.have.lengthOf(baseWebseeds.length) +} + +async function runServers (strategy: VideoRedundancyStrategy, additionalParams: any = {}) { + const config = { + redundancy: { + videos: { + check_interval: '5 seconds', + strategies: [ + immutableAssign({ + min_lifetime: '1 hour', + strategy: strategy, + size: '100KB' + }, additionalParams) + ] + } + } + } + servers = await flushAndRunMultipleServers(3, config) + + // Get the access tokens + await setAccessTokensToServers(servers) + + { + const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 1 server 2' }) + video1Server2UUID = res.body.video.uuid + + await viewVideo(servers[ 1 ].url, video1Server2UUID) + } + + await waitJobs(servers) + + // Server 1 and server 2 follow each other + await doubleFollow(servers[ 0 ], servers[ 1 ]) + // Server 1 and server 3 follow each other + await doubleFollow(servers[ 0 ], servers[ 2 ]) + // Server 2 and server 3 follow each other + await doubleFollow(servers[ 1 ], servers[ 2 ]) + + await waitJobs(servers) +} + +async function check1WebSeed (strategy: VideoRedundancyStrategy, videoUUID?: string) { + if (!videoUUID) videoUUID = video1Server2UUID + + const webseeds = [ + 'http://localhost:9002/static/webseed/' + videoUUID + ] + + for (const server of servers) { + { + const res = await getVideo(server.url, videoUUID) + + const video: VideoDetails = res.body + for (const f of video.files) { + checkMagnetWebseeds(f, webseeds, server) + } + } + } +} + +async function checkStatsWith2Webseed (strategy: VideoRedundancyStrategy) { + const res = await getStats(servers[0].url) + const data: ServerStats = res.body + + expect(data.videosRedundancy).to.have.lengthOf(1) + const stat = data.videosRedundancy[0] + + expect(stat.strategy).to.equal(strategy) + expect(stat.totalSize).to.equal(102400) + expect(stat.totalUsed).to.be.at.least(1).and.below(102401) + expect(stat.totalVideoFiles).to.equal(4) + expect(stat.totalVideos).to.equal(1) +} + +async function checkStatsWith1Webseed (strategy: VideoRedundancyStrategy) { + const res = await getStats(servers[0].url) + const data: ServerStats = res.body + + expect(data.videosRedundancy).to.have.lengthOf(1) + + const stat = data.videosRedundancy[0] + expect(stat.strategy).to.equal(strategy) + expect(stat.totalSize).to.equal(102400) + expect(stat.totalUsed).to.equal(0) + expect(stat.totalVideoFiles).to.equal(0) + expect(stat.totalVideos).to.equal(0) +} + +async function check2Webseeds (strategy: VideoRedundancyStrategy, videoUUID?: string) { + if (!videoUUID) videoUUID = video1Server2UUID + + const webseeds = [ + 'http://localhost:9001/static/webseed/' + videoUUID, + 'http://localhost:9002/static/webseed/' + videoUUID + ] + + for (const server of servers) { + const res = await getVideo(server.url, videoUUID) + + const video: VideoDetails = res.body + + for (const file of video.files) { + checkMagnetWebseeds(file, webseeds, server) + + // Only servers 1 and 2 have the video + if (server.serverNumber !== 3) { + await makeGetRequest({ + url: server.url, + statusCodeExpected: 200, + path: '/static/webseed/' + `${videoUUID}-${file.resolution.id}.mp4`, + contentType: null + }) + } + } + } + + for (const directory of [ 'test1', 'test2' ]) { + const files = await readdir(join(root(), directory, 'videos')) + expect(files).to.have.length.at.least(4) + + for (const resolution of [ 240, 360, 480, 720 ]) { + expect(files.find(f => f === `${videoUUID}-${resolution}.mp4`)).to.not.be.undefined + } + } +} + +async function enableRedundancyOnServer1 () { + await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, true) + + const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') + const follows: ActorFollow[] = res.body.data + const server2 = follows.find(f => f.following.host === 'localhost:9002') + const server3 = follows.find(f => f.following.host === 'localhost:9003') + + expect(server3).to.not.be.undefined + expect(server3.following.hostRedundancyAllowed).to.be.false + + expect(server2).to.not.be.undefined + expect(server2.following.hostRedundancyAllowed).to.be.true +} + +async function disableRedundancyOnServer1 () { + await updateRedundancy(servers[ 0 ].url, servers[ 0 ].accessToken, servers[ 1 ].host, false) + + const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 5, '-createdAt') + const follows: ActorFollow[] = res.body.data + const server2 = follows.find(f => f.following.host === 'localhost:9002') + const server3 = follows.find(f => f.following.host === 'localhost:9003') + + expect(server3).to.not.be.undefined + expect(server3.following.hostRedundancyAllowed).to.be.false + + expect(server2).to.not.be.undefined + expect(server2.following.hostRedundancyAllowed).to.be.false +} + +async function cleanServers () { + killallServers(servers) +} + +describe('Test videos redundancy', function () { + + describe('With most-views strategy', function () { + const strategy = 'most-views' + + before(function () { + this.timeout(120000) + + return runServers(strategy) + }) + + it('Should have 1 webseed on the first video', async function () { + await check1WebSeed(strategy) + await checkStatsWith1Webseed(strategy) + }) + + it('Should enable redundancy on server 1', function () { + return enableRedundancyOnServer1() + }) + + it('Should have 2 webseed on the first video', async function () { + this.timeout(40000) + + await waitJobs(servers) + await waitUntilLog(servers[0], 'Duplicated ', 4) + await waitJobs(servers) + + await check2Webseeds(strategy) + await checkStatsWith2Webseed(strategy) + }) + + it('Should undo redundancy on server 1 and remove duplicated videos', async function () { + this.timeout(40000) + + await disableRedundancyOnServer1() + + await waitJobs(servers) + await wait(5000) + + await check1WebSeed(strategy) + + await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ]) + }) + + after(function () { + return cleanServers() + }) + }) + + describe('With trending strategy', function () { + const strategy = 'trending' + + before(function () { + this.timeout(120000) + + return runServers(strategy) + }) + + it('Should have 1 webseed on the first video', async function () { + await check1WebSeed(strategy) + await checkStatsWith1Webseed(strategy) + }) + + it('Should enable redundancy on server 1', function () { + return enableRedundancyOnServer1() + }) + + it('Should have 2 webseed on the first video', async function () { + this.timeout(40000) + + await waitJobs(servers) + await waitUntilLog(servers[0], 'Duplicated ', 4) + await waitJobs(servers) + + await check2Webseeds(strategy) + await checkStatsWith2Webseed(strategy) + }) + + it('Should unfollow on server 1 and remove duplicated videos', async function () { + this.timeout(40000) + + await unfollow(servers[0].url, servers[0].accessToken, servers[1]) + + await waitJobs(servers) + await wait(5000) + + await check1WebSeed(strategy) + + await checkVideoFilesWereRemoved(video1Server2UUID, servers[0].serverNumber, [ 'videos' ]) + }) + + after(function () { + return cleanServers() + }) + }) + + describe('With recently added strategy', function () { + const strategy = 'recently-added' + + before(function () { + this.timeout(120000) + + return runServers(strategy, { min_views: 3 }) + }) + + it('Should have 1 webseed on the first video', async function () { + await check1WebSeed(strategy) + await checkStatsWith1Webseed(strategy) + }) + + it('Should enable redundancy on server 1', function () { + return enableRedundancyOnServer1() + }) + + it('Should still have 1 webseed on the first video', async function () { + this.timeout(40000) + + await waitJobs(servers) + await wait(15000) + await waitJobs(servers) + + await check1WebSeed(strategy) + await checkStatsWith1Webseed(strategy) + }) + + it('Should view 2 times the first video to have > min_views config', async function () { + this.timeout(40000) + + await viewVideo(servers[ 0 ].url, video1Server2UUID) + await viewVideo(servers[ 2 ].url, video1Server2UUID) + + await wait(10000) + await waitJobs(servers) + }) + + it('Should have 2 webseed on the first video', async function () { + this.timeout(40000) + + await waitJobs(servers) + await waitUntilLog(servers[0], 'Duplicated ', 4) + await waitJobs(servers) + + await check2Webseeds(strategy) + await checkStatsWith2Webseed(strategy) + }) + + it('Should remove the video and the redundancy files', async function () { + this.timeout(20000) + + await removeVideo(servers[1].url, servers[1].accessToken, video1Server2UUID) + + await waitJobs(servers) + + for (const server of servers) { + await checkVideoFilesWereRemoved(video1Server2UUID, server.serverNumber) + } + }) + + after(function () { + return cleanServers() + }) + }) + + describe('Test expiration', function () { + const strategy = 'recently-added' + + async function checkContains (servers: ServerInfo[], str: string) { + for (const server of servers) { + const res = await getVideo(server.url, video1Server2UUID) + const video: VideoDetails = res.body + + for (const f of video.files) { + expect(f.magnetUri).to.contain(str) + } + } + } + + async function checkNotContains (servers: ServerInfo[], str: string) { + for (const server of servers) { + const res = await getVideo(server.url, video1Server2UUID) + const video: VideoDetails = res.body + + for (const f of video.files) { + expect(f.magnetUri).to.not.contain(str) + } + } + } + + before(async function () { + this.timeout(120000) + + await runServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) + + await enableRedundancyOnServer1() + }) + + it('Should still have 2 webseeds after 10 seconds', async function () { + this.timeout(40000) + + await wait(10000) + + try { + await checkContains(servers, 'http%3A%2F%2Flocalhost%3A9001') + } catch { + // Maybe a server deleted a redundancy in the scheduler + await wait(2000) + + await checkContains(servers, 'http%3A%2F%2Flocalhost%3A9001') + } + }) + + it('Should stop server 1 and expire video redundancy', async function () { + this.timeout(40000) + + killallServers([ servers[0] ]) + + await wait(15000) + + await checkNotContains([ servers[1], servers[2] ], 'http%3A%2F%2Flocalhost%3A9001') + }) + + after(function () { + return killallServers([ servers[1], servers[2] ]) + }) + }) + + describe('Test file replacement', function () { + let video2Server2UUID: string + const strategy = 'recently-added' + + before(async function () { + this.timeout(120000) + + await runServers(strategy, { min_lifetime: '7 seconds', min_views: 0 }) + + await enableRedundancyOnServer1() + + await waitJobs(servers) + await waitUntilLog(servers[0], 'Duplicated ', 4) + await waitJobs(servers) + + await check2Webseeds(strategy) + await checkStatsWith2Webseed(strategy) + + const res = await uploadVideo(servers[ 1 ].url, servers[ 1 ].accessToken, { name: 'video 2 server 2' }) + video2Server2UUID = res.body.video.uuid + }) + + it('Should cache video 2 webseed on the first video', async function () { + this.timeout(120000) + + await waitJobs(servers) + + let checked = false + + while (checked === false) { + await wait(1000) + + try { + await check1WebSeed(strategy, video1Server2UUID) + await check2Webseeds(strategy, video2Server2UUID) + + checked = true + } catch { + checked = false + } + } + }) + + after(function () { + return cleanServers() + }) + }) +}) diff --git a/server/tests/api/server/reverse-proxy.ts b/server/tests/api/server/reverse-proxy.ts index e2c2a293e..d4c08c346 100644 --- a/server/tests/api/server/reverse-proxy.ts +++ b/server/tests/api/server/reverse-proxy.ts @@ -15,7 +15,7 @@ import { userLogin, viewVideo, wait -} from '../../utils' +} from '../../../../shared/utils' const expect = chai.expect import { @@ -23,7 +23,7 @@ import { flushTests, runServer, registerUser, getCustomConfig, setAccessTokensToServers, updateCustomConfig -} from '../../utils/index' +} from '../../../../shared/utils/index' describe('Test application behind a reverse proxy', function () { let server = null diff --git a/server/tests/api/server/stats.ts b/server/tests/api/server/stats.ts index cb229e876..517b4e542 100644 --- a/server/tests/api/server/stats.ts +++ b/server/tests/api/server/stats.ts @@ -13,11 +13,11 @@ import { uploadVideo, viewVideo, wait -} from '../../utils' -import { flushTests, setAccessTokensToServers } from '../../utils/index' -import { getStats } from '../../utils/server/stats' -import { addVideoCommentThread } from '../../utils/videos/video-comments' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils' +import { flushTests, setAccessTokensToServers } from '../../../../shared/utils/index' +import { getStats } from '../../../../shared/utils/server/stats' +import { addVideoCommentThread } from '../../../../shared/utils/videos/video-comments' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/server/tracker.ts b/server/tests/api/server/tracker.ts index 856f2f4d1..25ca00029 100644 --- a/server/tests/api/server/tracker.ts +++ b/server/tests/api/server/tracker.ts @@ -2,8 +2,8 @@ import * as magnetUtil from 'magnet-uri' import 'mocha' -import { getVideo, killallServers, runServer, ServerInfo, uploadVideo } from '../../utils' -import { flushTests, setAccessTokensToServers } from '../../utils/index' +import { getVideo, killallServers, runServer, ServerInfo, uploadVideo } from '../../../../shared/utils' +import { flushTests, setAccessTokensToServers } from '../../../../shared/utils/index' import { VideoDetails } from '../../../../shared/models/videos' import * as WebTorrent from 'webtorrent' diff --git a/server/tests/api/users/blocklist.ts b/server/tests/api/users/blocklist.ts index eed4b9f3e..4bca27a94 100644 --- a/server/tests/api/users/blocklist.ts +++ b/server/tests/api/users/blocklist.ts @@ -12,16 +12,16 @@ import { ServerInfo, uploadVideo, userLogin -} from '../../utils/index' -import { setAccessTokensToServers } from '../../utils/users/login' -import { getVideosListWithToken, getVideosList } from '../../utils/videos/videos' +} from '../../../../shared/utils/index' +import { setAccessTokensToServers } from '../../../../shared/utils/users/login' +import { getVideosListWithToken, getVideosList } from '../../../../shared/utils/videos/videos' import { addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, getVideoThreadComments -} from '../../utils/videos/video-comments' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/videos/video-comments' +import { waitJobs } from '../../../../shared/utils/server/jobs' import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' import { addAccountToAccountBlocklist, @@ -36,7 +36,7 @@ import { removeAccountFromServerBlocklist, removeServerFromAccountBlocklist, removeServerFromServerBlocklist -} from '../../utils/users/blocklist' +} from '../../../../shared/utils/users/blocklist' const expect = chai.expect diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 65b80540c..88a7187d6 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -2,18 +2,27 @@ import * as chai from 'chai' import 'mocha' -import { createUser, doubleFollow, flushAndRunMultipleServers, follow, getVideosList, unfollow, updateVideo, userLogin } from '../../utils' -import { killallServers, ServerInfo, uploadVideo } from '../../utils/index' -import { setAccessTokensToServers } from '../../utils/users/login' +import { + createUser, + doubleFollow, + flushAndRunMultipleServers, + follow, + getVideosList, + unfollow, + updateVideo, + userLogin +} from '../../../../shared/utils' +import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/utils/index' +import { setAccessTokensToServers } from '../../../../shared/utils/users/login' import { Video, VideoChannel } from '../../../../shared/models/videos' -import { waitJobs } from '../../utils/server/jobs' +import { waitJobs } from '../../../../shared/utils/server/jobs' import { addUserSubscription, listUserSubscriptions, listUserSubscriptionVideos, removeUserSubscription, getUserSubscription, areSubscriptionsExist -} from '../../utils/users/user-subscriptions' +} from '../../../../shared/utils/users/user-subscriptions' const expect = chai.expect diff --git a/server/tests/api/users/users-multiple-servers.ts b/server/tests/api/users/users-multiple-servers.ts index d8699db17..006d6cdf0 100644 --- a/server/tests/api/users/users-multiple-servers.ts +++ b/server/tests/api/users/users-multiple-servers.ts @@ -13,13 +13,13 @@ import { removeUser, updateMyUser, userLogin -} from '../../utils' -import { getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../utils/index' -import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../utils/users/accounts' -import { setAccessTokensToServers } from '../../utils/users/login' +} from '../../../../shared/utils' +import { getMyUserInformation, killallServers, ServerInfo, testImage, updateMyAvatar, uploadVideo } from '../../../../shared/utils/index' +import { checkActorFilesWereRemoved, getAccount, getAccountsList } from '../../../../shared/utils/users/accounts' +import { setAccessTokensToServers } from '../../../../shared/utils/users/login' import { User } from '../../../../shared/models/users' import { VideoChannel } from '../../../../shared/models/videos' -import { waitJobs } from '../../utils/server/jobs' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/users/users-verification.ts b/server/tests/api/users/users-verification.ts index fa5f5e371..b1733e45e 100644 --- a/server/tests/api/users/users-verification.ts +++ b/server/tests/api/users/users-verification.ts @@ -5,10 +5,10 @@ import 'mocha' import { registerUser, flushTests, getUserInformation, getMyUserInformation, killallServers, userLogin, login, runServer, ServerInfo, verifyEmail, updateCustomSubConfig -} from '../../utils' -import { setAccessTokensToServers } from '../../utils/users/login' -import { mockSmtpServer } from '../../utils/miscs/email' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils' +import { setAccessTokensToServers } from '../../../../shared/utils/users/login' +import { mockSmtpServer } from '../../../../shared/utils/miscs/email' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index e7bb845b9..4914c8ed5 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts @@ -32,10 +32,10 @@ import { updateUser, uploadVideo, userLogin -} from '../../utils/index' -import { follow } from '../../utils/server/follows' -import { setAccessTokensToServers } from '../../utils/users/login' -import { getMyVideos } from '../../utils/videos/videos' +} from '../../../../shared/utils/index' +import { follow } from '../../../../shared/utils/server/follows' +import { setAccessTokensToServers } from '../../../../shared/utils/users/login' +import { getMyVideos } from '../../../../shared/utils/videos/videos' const expect = chai.expect diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts index b9ace2885..aa38b6b33 100644 --- a/server/tests/api/videos/multiple-servers.ts +++ b/server/tests/api/videos/multiple-servers.ts @@ -31,15 +31,15 @@ import { viewVideo, wait, webtorrentAdd -} from '../../utils' +} from '../../../../shared/utils' import { addVideoCommentReply, addVideoCommentThread, deleteVideoComment, getVideoCommentThreads, getVideoThreadComments -} from '../../utils/videos/video-comments' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/videos/video-comments' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/services.ts b/server/tests/api/videos/services.ts index 2f1424292..2da86964f 100644 --- a/server/tests/api/videos/services.ts +++ b/server/tests/api/videos/services.ts @@ -2,8 +2,16 @@ import * as chai from 'chai' import 'mocha' -import { flushTests, getOEmbed, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils/index' -import { runServer } from '../../utils/server/servers' +import { + flushTests, + getOEmbed, + getVideosList, + killallServers, + ServerInfo, + setAccessTokensToServers, + uploadVideo +} from '../../../../shared/utils/index' +import { runServer } from '../../../../shared/utils/server/servers' const expect = chai.expect diff --git a/server/tests/api/videos/single-server.ts b/server/tests/api/videos/single-server.ts index 089c3df25..069dec67c 100644 --- a/server/tests/api/videos/single-server.ts +++ b/server/tests/api/videos/single-server.ts @@ -28,7 +28,7 @@ import { uploadVideo, viewVideo, wait -} from '../../utils' +} from '../../../../shared/utils' const expect = chai.expect diff --git a/server/tests/api/videos/video-abuse.ts b/server/tests/api/videos/video-abuse.ts index a17f3c8de..3a7b623da 100644 --- a/server/tests/api/videos/video-abuse.ts +++ b/server/tests/api/videos/video-abuse.ts @@ -14,9 +14,9 @@ import { setAccessTokensToServers, updateVideoAbuse, uploadVideo -} from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-blacklist-management.ts b/server/tests/api/videos/video-blacklist-management.ts index fab577b30..61411e30d 100644 --- a/server/tests/api/videos/video-blacklist-management.ts +++ b/server/tests/api/videos/video-blacklist-management.ts @@ -16,9 +16,9 @@ import { setAccessTokensToServers, updateVideoBlacklist, uploadVideo -} from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { waitJobs } from '../../../../shared/utils/server/jobs' import { VideoAbuse } from '../../../../shared/models/videos' const expect = chai.expect diff --git a/server/tests/api/videos/video-blacklist.ts b/server/tests/api/videos/video-blacklist.ts index de4c68f1d..1cce82d2a 100644 --- a/server/tests/api/videos/video-blacklist.ts +++ b/server/tests/api/videos/video-blacklist.ts @@ -11,9 +11,9 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts index 6e441410d..57bee713f 100644 --- a/server/tests/api/videos/video-captions.ts +++ b/server/tests/api/videos/video-captions.ts @@ -2,10 +2,17 @@ import * as chai from 'chai' import 'mocha' -import { checkVideoFilesWereRemoved, doubleFollow, flushAndRunMultipleServers, removeVideo, uploadVideo, wait } from '../../utils' -import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' -import { waitJobs } from '../../utils/server/jobs' -import { createVideoCaption, deleteVideoCaption, listVideoCaptions, testCaptionFile } from '../../utils/videos/video-captions' +import { + checkVideoFilesWereRemoved, + doubleFollow, + flushAndRunMultipleServers, + removeVideo, + uploadVideo, + wait +} from '../../../../shared/utils' +import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../../../shared/utils/index' +import { waitJobs } from '../../../../shared/utils/server/jobs' +import { createVideoCaption, deleteVideoCaption, listVideoCaptions, testCaptionFile } from '../../../../shared/utils/videos/video-captions' import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' const expect = chai.expect diff --git a/server/tests/api/videos/video-change-ownership.ts b/server/tests/api/videos/video-change-ownership.ts index 1578a471d..25675a966 100644 --- a/server/tests/api/videos/video-change-ownership.ts +++ b/server/tests/api/videos/video-change-ownership.ts @@ -18,8 +18,8 @@ import { uploadVideo, userLogin, getVideo -} from '../../utils' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils' +import { waitJobs } from '../../../../shared/utils/server/jobs' import { User } from '../../../../shared/models/users' import { VideoDetails } from '../../../../shared/models/videos' diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 41429a3d8..63514d69c 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -13,7 +13,7 @@ import { updateVideoChannelAvatar, uploadVideo, userLogin -} from '../../utils' +} from '../../../../shared/utils' import { addVideoChannel, deleteVideoChannel, @@ -26,8 +26,8 @@ import { ServerInfo, setAccessTokensToServers, updateVideoChannel -} from '../../utils/index' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts index d6e07c5b3..ce1b17e35 100644 --- a/server/tests/api/videos/video-comments.ts +++ b/server/tests/api/videos/video-comments.ts @@ -3,7 +3,7 @@ import * as chai from 'chai' import 'mocha' import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' -import { testImage } from '../../utils' +import { testImage } from '../../../../shared/utils' import { dateIsValid, flushTests, @@ -13,14 +13,14 @@ import { setAccessTokensToServers, updateMyAvatar, uploadVideo -} from '../../utils/index' +} from '../../../../shared/utils/index' import { addVideoCommentReply, addVideoCommentThread, deleteVideoComment, getVideoCommentThreads, getVideoThreadComments -} from '../../utils/videos/video-comments' +} from '../../../../shared/utils/videos/video-comments' const expect = chai.expect diff --git a/server/tests/api/videos/video-description.ts b/server/tests/api/videos/video-description.ts index dd5cd78c0..cbda0b9a6 100644 --- a/server/tests/api/videos/video-description.ts +++ b/server/tests/api/videos/video-description.ts @@ -12,9 +12,9 @@ import { setAccessTokensToServers, updateVideo, uploadVideo -} from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-imports.ts b/server/tests/api/videos/video-imports.ts index aaee79a4a..cd4988553 100644 --- a/server/tests/api/videos/video-imports.ts +++ b/server/tests/api/videos/video-imports.ts @@ -14,9 +14,9 @@ import { killallServers, ServerInfo, setAccessTokensToServers -} from '../../utils' -import { waitJobs } from '../../utils/server/jobs' -import { getMagnetURI, getYoutubeVideoUrl, importVideo, getMyVideoImports } from '../../utils/videos/video-imports' +} from '../../../../shared/utils' +import { waitJobs } from '../../../../shared/utils/server/jobs' +import { getMagnetURI, getYoutubeVideoUrl, importVideo, getMyVideoImports } from '../../../../shared/utils/videos/video-imports' const expect = chai.expect diff --git a/server/tests/api/videos/video-nsfw.ts b/server/tests/api/videos/video-nsfw.ts index eab7a6991..df1ee2eb9 100644 --- a/server/tests/api/videos/video-nsfw.ts +++ b/server/tests/api/videos/video-nsfw.ts @@ -2,10 +2,17 @@ import * as chai from 'chai' import 'mocha' -import { flushTests, getVideosList, killallServers, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils/index' -import { userLogin } from '../../utils/users/login' -import { createUser } from '../../utils/users/users' -import { getMyVideos } from '../../utils/videos/videos' +import { + flushTests, + getVideosList, + killallServers, + ServerInfo, + setAccessTokensToServers, + uploadVideo +} from '../../../../shared/utils/index' +import { userLogin } from '../../../../shared/utils/users/login' +import { createUser } from '../../../../shared/utils/users/users' +import { getMyVideos } from '../../../../shared/utils/videos/videos' import { getAccountVideos, getConfig, @@ -18,7 +25,7 @@ import { searchVideoWithToken, updateCustomConfig, updateMyUser -} from '../../utils' +} from '../../../../shared/utils' import { ServerConfig } from '../../../../shared/models' import { CustomConfig } from '../../../../shared/models/server/custom-config.model' import { User } from '../../../../shared/models/users' diff --git a/server/tests/api/videos/video-privacy.ts b/server/tests/api/videos/video-privacy.ts index 9fefca7e3..0b4e66369 100644 --- a/server/tests/api/videos/video-privacy.ts +++ b/server/tests/api/videos/video-privacy.ts @@ -10,12 +10,12 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../../utils/index' -import { doubleFollow } from '../../utils/server/follows' -import { userLogin } from '../../utils/users/login' -import { createUser } from '../../utils/users/users' -import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../utils/videos/videos' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils/index' +import { doubleFollow } from '../../../../shared/utils/server/follows' +import { userLogin } from '../../../../shared/utils/users/login' +import { createUser } from '../../../../shared/utils/users/users' +import { getMyVideos, getVideo, getVideoWithToken, updateVideo } from '../../../../shared/utils/videos/videos' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-schedule-update.ts b/server/tests/api/videos/video-schedule-update.ts index b226a9d50..632c4244c 100644 --- a/server/tests/api/videos/video-schedule-update.ts +++ b/server/tests/api/videos/video-schedule-update.ts @@ -15,8 +15,8 @@ import { updateVideo, uploadVideo, wait -} from '../../utils' -import { waitJobs } from '../../utils/server/jobs' +} from '../../../../shared/utils' +import { waitJobs } from '../../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/api/videos/video-transcoder.ts b/server/tests/api/videos/video-transcoder.ts index 23920d452..68cf00194 100644 --- a/server/tests/api/videos/video-transcoder.ts +++ b/server/tests/api/videos/video-transcoder.ts @@ -19,9 +19,10 @@ import { setAccessTokensToServers, uploadVideo, webtorrentAdd -} from '../../utils' +} from '../../../../shared/utils' import { join } from 'path' -import { waitJobs } from '../../utils/server/jobs' +import { waitJobs } from '../../../../shared/utils/server/jobs' +import { pathExists } from 'fs-extra' import { VIDEO_TRANSCODING_FPS } from '../../../../server/initializers/constants' const expect = chai.expect diff --git a/server/tests/api/videos/videos-filter.ts b/server/tests/api/videos/videos-filter.ts index a7588129f..59e37ad86 100644 --- a/server/tests/api/videos/videos-filter.ts +++ b/server/tests/api/videos/videos-filter.ts @@ -13,7 +13,7 @@ import { setAccessTokensToServers, uploadVideo, userLogin -} from '../../utils' +} from '../../../../shared/utils' import { Video, VideoPrivacy } from '../../../../shared/models/videos' import { UserRole } from '../../../../shared/models/users' diff --git a/server/tests/api/videos/videos-history.ts b/server/tests/api/videos/videos-history.ts index 6d289b288..40ae94f79 100644 --- a/server/tests/api/videos/videos-history.ts +++ b/server/tests/api/videos/videos-history.ts @@ -11,9 +11,9 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../../utils' +} from '../../../../shared/utils' import { Video, VideoDetails } from '../../../../shared/models/videos' -import { userWatchVideo } from '../../utils/videos/video-history' +import { userWatchVideo } from '../../../../shared/utils/videos/video-history' const expect = chai.expect diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts index 7d1f29c92..7221bcae6 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/server/tests/api/videos/videos-overview.ts @@ -2,8 +2,8 @@ import * as chai from 'chai' import 'mocha' -import { flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils' -import { getVideosOverview } from '../../utils/overviews/overviews' +import { flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../../../shared/utils' +import { getVideosOverview } from '../../../../shared/utils/overviews/overviews' import { VideosOverview } from '../../../../shared/models/overviews' const expect = chai.expect diff --git a/server/tests/cli/create-import-video-file-job.ts b/server/tests/cli/create-import-video-file-job.ts index 13bcfd209..4acda47b1 100644 --- a/server/tests/cli/create-import-video-file-job.ts +++ b/server/tests/cli/create-import-video-file-job.ts @@ -15,8 +15,8 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../utils' -import { waitJobs } from '../utils/server/jobs' +} from '../../../shared/utils' +import { waitJobs } from '../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/cli/create-transcoding-job.ts b/server/tests/cli/create-transcoding-job.ts index c2e3840c5..50be5fa19 100644 --- a/server/tests/cli/create-transcoding-job.ts +++ b/server/tests/cli/create-transcoding-job.ts @@ -15,8 +15,8 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo, wait -} from '../utils' -import { waitJobs } from '../utils/server/jobs' +} from '../../../shared/utils' +import { waitJobs } from '../../../shared/utils/server/jobs' const expect = chai.expect diff --git a/server/tests/cli/optimize-old-videos.ts b/server/tests/cli/optimize-old-videos.ts index 66dd39cce..6f6bc25a6 100644 --- a/server/tests/cli/optimize-old-videos.ts +++ b/server/tests/cli/optimize-old-videos.ts @@ -15,8 +15,8 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo, viewVideo, wait -} from '../utils' -import { waitJobs } from '../utils/server/jobs' +} from '../../../shared/utils' +import { waitJobs } from '../../../shared/utils/server/jobs' import { getVideoFileBitrate, getVideoFileFPS, getVideoFileResolution } from '../../helpers/ffmpeg-utils' import { VIDEO_TRANSCODING_FPS } from '../../initializers' import { join } from 'path' diff --git a/server/tests/cli/peertube.ts b/server/tests/cli/peertube.ts index 7a712bc4e..e2836d0c3 100644 --- a/server/tests/cli/peertube.ts +++ b/server/tests/cli/peertube.ts @@ -11,7 +11,7 @@ import { runServer, ServerInfo, setAccessTokensToServers -} from '../utils' +} from '../../../shared/utils' describe('Test CLI wrapper', function () { let server: ServerInfo diff --git a/server/tests/cli/reset-password.ts b/server/tests/cli/reset-password.ts index bf937d1c0..1b65f7e39 100644 --- a/server/tests/cli/reset-password.ts +++ b/server/tests/cli/reset-password.ts @@ -10,7 +10,7 @@ import { runServer, ServerInfo, setAccessTokensToServers -} from '../utils' +} from '../../../shared/utils' describe('Test reset password scripts', function () { let server: ServerInfo diff --git a/server/tests/cli/update-host.ts b/server/tests/cli/update-host.ts index b89e72ab7..811ea6a9f 100644 --- a/server/tests/cli/update-host.ts +++ b/server/tests/cli/update-host.ts @@ -3,8 +3,8 @@ import 'mocha' import * as chai from 'chai' import { VideoDetails } from '../../../shared/models/videos' -import { waitJobs } from '../utils/server/jobs' -import { addVideoCommentThread } from '../utils/videos/video-comments' +import { waitJobs } from '../../../shared/utils/server/jobs' +import { addVideoCommentThread } from '../../../shared/utils/videos/video-comments' import { addVideoChannel, createUser, @@ -21,8 +21,8 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../utils' -import { getAccountsList } from '../utils/users/accounts' +} from '../../../shared/utils' +import { getAccountsList } from '../../../shared/utils/users/accounts' const expect = chai.expect diff --git a/server/tests/client.ts b/server/tests/client.ts index b33a653b1..06b4a9c5a 100644 --- a/server/tests/client.ts +++ b/server/tests/client.ts @@ -15,7 +15,7 @@ import { updateCustomConfig, updateCustomSubConfig, uploadVideo -} from './utils' +} from '../../shared/utils' const expect = chai.expect diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 28fe3493b..a771474bc 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -13,10 +13,10 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo, userLogin -} from '../utils' +} from '../../../shared/utils' import * as libxmljs from 'libxmljs' -import { addVideoCommentThread } from '../utils/videos/video-comments' -import { waitJobs } from '../utils/server/jobs' +import { addVideoCommentThread } from '../../../shared/utils/videos/video-comments' +import { waitJobs } from '../../../shared/utils/server/jobs' import { User } from '../../../shared/models/users' chai.use(require('chai-xml')) diff --git a/server/tests/misc-endpoints.ts b/server/tests/misc-endpoints.ts index 4de47d693..5f82719da 100644 --- a/server/tests/misc-endpoints.ts +++ b/server/tests/misc-endpoints.ts @@ -12,7 +12,7 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from './utils' +} from '../../shared/utils' import { VideoPrivacy } from '../../shared/models/videos' const expect = chai.expect diff --git a/server/tests/real-world/populate-database.ts b/server/tests/real-world/populate-database.ts index a7fdbd1dc..016503498 100644 --- a/server/tests/real-world/populate-database.ts +++ b/server/tests/real-world/populate-database.ts @@ -10,7 +10,7 @@ import { ServerInfo, setAccessTokensToServers, uploadVideo -} from '../utils' +} from '../../../shared/utils' import * as Bluebird from 'bluebird' start() diff --git a/server/tests/real-world/real-world.ts b/server/tests/real-world/real-world.ts index a96469b11..ac3baaf9a 100644 --- a/server/tests/real-world/real-world.ts +++ b/server/tests/real-world/real-world.ts @@ -16,8 +16,8 @@ import { updateVideo, uploadVideo, viewVideo, wait -} from '../utils' -import { getJobsListPaginationAndSort } from '../utils/server/jobs' +} from '../../../shared/utils' +import { getJobsListPaginationAndSort } from '../../../shared/utils/server/jobs' interface ServerInfo extends DefaultServerInfo { requestsNumber: number diff --git a/server/tools/peertube-get-access-token.ts b/server/tools/peertube-get-access-token.ts index eb2571a03..a68665f5b 100644 --- a/server/tools/peertube-get-access-token.ts +++ b/server/tools/peertube-get-access-token.ts @@ -6,7 +6,7 @@ import { Server, Client, User -} from '../tests/utils/index' +} from '../../shared/utils' program .option('-u, --url ', 'Server url') diff --git a/server/tools/peertube-import-videos.ts b/server/tools/peertube-import-videos.ts index 21505b79d..1fe0a9348 100644 --- a/server/tools/peertube-import-videos.ts +++ b/server/tools/peertube-import-videos.ts @@ -6,7 +6,7 @@ import { join } from 'path' import { VideoPrivacy } from '../../shared/models/videos' import { doRequestAndSaveToFile } from '../helpers/requests' import { CONSTRAINTS_FIELDS } from '../initializers' -import { getClient, getVideoCategories, login, searchVideoWithSort, uploadVideo } from '../tests/utils' +import { getClient, getVideoCategories, login, searchVideoWithSort, uploadVideo } from '../../shared/utils/index' import { truncate } from 'lodash' import * as prompt from 'prompt' import { remove } from 'fs-extra' diff --git a/server/tools/peertube-upload.ts b/server/tools/peertube-upload.ts index 6248fb47d..cc7bd9b4c 100644 --- a/server/tools/peertube-upload.ts +++ b/server/tools/peertube-upload.ts @@ -1,8 +1,8 @@ import * as program from 'commander' import { access, constants } from 'fs-extra' import { isAbsolute } from 'path' -import { getClient, login } from '../tests/utils' -import { uploadVideo } from '../tests/utils/index' +import { getClient, login } from '../../shared/utils' +import { uploadVideo } from '../../shared/utils/' import { VideoPrivacy } from '../../shared/models/videos' import { netrc, getSettings } from './cli' diff --git a/server/tests/utils/cli/cli.ts b/shared/utils/cli/cli.ts similarity index 100% rename from server/tests/utils/cli/cli.ts rename to shared/utils/cli/cli.ts diff --git a/server/tests/utils/feeds/feeds.ts b/shared/utils/feeds/feeds.ts similarity index 100% rename from server/tests/utils/feeds/feeds.ts rename to shared/utils/feeds/feeds.ts diff --git a/server/tests/utils/index.ts b/shared/utils/index.ts similarity index 82% rename from server/tests/utils/index.ts rename to shared/utils/index.ts index 8349631c9..e08bbfd2a 100644 --- a/server/tests/utils/index.ts +++ b/shared/utils/index.ts @@ -2,11 +2,15 @@ export * from './server/activitypub' export * from './cli/cli' export * from './server/clients' export * from './server/config' +export * from './server/jobs' export * from './users/login' export * from './miscs/miscs' export * from './miscs/stubs' +export * from './miscs/sql' export * from './server/follows' +export * from './requests/activitypub' export * from './requests/requests' +export * from './requests/check-api-params' export * from './server/servers' export * from './videos/services' export * from './users/users' diff --git a/server/tests/utils/miscs/email.ts b/shared/utils/miscs/email.ts similarity index 100% rename from server/tests/utils/miscs/email.ts rename to shared/utils/miscs/email.ts diff --git a/server/tests/utils/miscs/miscs.ts b/shared/utils/miscs/miscs.ts similarity index 92% rename from server/tests/utils/miscs/miscs.ts rename to shared/utils/miscs/miscs.ts index 589daa420..91a93b631 100644 --- a/server/tests/utils/miscs/miscs.ts +++ b/shared/utils/miscs/miscs.ts @@ -33,8 +33,8 @@ function webtorrentAdd (torrent: string, refreshWebTorrent = false) { } function root () { - // We are in server/tests/utils/miscs - return join(__dirname, '..', '..', '..', '..') + // We are in /shared/utils/miscs + return join(__dirname, '..', '..', '..') } async function testImage (url: string, imageName: string, imagePath: string, extension = '.jpg') { @@ -44,7 +44,7 @@ async function testImage (url: string, imageName: string, imagePath: string, ext const body = res.body - const data = await readFile(join(__dirname, '..', '..', 'fixtures', imageName + extension)) + const data = await readFile(join(root(), 'server', 'tests', 'fixtures', imageName + extension)) const minLength = body.length - ((20 * body.length) / 100) const maxLength = body.length + ((20 * body.length) / 100) @@ -59,7 +59,7 @@ function buildAbsoluteFixturePath (path: string, customTravisPath = false) { if (customTravisPath && process.env.TRAVIS) return join(process.env.HOME, 'fixtures', path) - return join(__dirname, '..', '..', 'fixtures', path) + return join(root(), 'server', 'tests', 'fixtures', path) } async function generateHighBitrateVideo () { diff --git a/server/tests/utils/miscs/sql.ts b/shared/utils/miscs/sql.ts similarity index 100% rename from server/tests/utils/miscs/sql.ts rename to shared/utils/miscs/sql.ts diff --git a/server/tests/utils/miscs/stubs.ts b/shared/utils/miscs/stubs.ts similarity index 100% rename from server/tests/utils/miscs/stubs.ts rename to shared/utils/miscs/stubs.ts diff --git a/server/tests/utils/overviews/overviews.ts b/shared/utils/overviews/overviews.ts similarity index 100% rename from server/tests/utils/overviews/overviews.ts rename to shared/utils/overviews/overviews.ts diff --git a/server/tests/utils/requests/activitypub.ts b/shared/utils/requests/activitypub.ts similarity index 73% rename from server/tests/utils/requests/activitypub.ts rename to shared/utils/requests/activitypub.ts index 96fee60a8..e2348ace0 100644 --- a/server/tests/utils/requests/activitypub.ts +++ b/shared/utils/requests/activitypub.ts @@ -1,7 +1,7 @@ -import { doRequest } from '../../../helpers/requests' -import { HTTP_SIGNATURE } from '../../../initializers' -import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activitypub-http-utils' -import { activityPubContextify } from '../../../helpers/activitypub' +import { doRequest } from '../../../server/helpers/requests' +import { HTTP_SIGNATURE } from '../../../server/initializers' +import { buildGlobalHeaders } from '../../../server/lib/job-queue/handlers/utils/activitypub-http-utils' +import { activityPubContextify } from '../../../server/helpers/activitypub' function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) { const options = { diff --git a/server/tests/utils/requests/check-api-params.ts b/shared/utils/requests/check-api-params.ts similarity index 100% rename from server/tests/utils/requests/check-api-params.ts rename to shared/utils/requests/check-api-params.ts diff --git a/server/tests/utils/requests/requests.ts b/shared/utils/requests/requests.ts similarity index 96% rename from server/tests/utils/requests/requests.ts rename to shared/utils/requests/requests.ts index 5796540f7..77e9f6164 100644 --- a/server/tests/utils/requests/requests.ts +++ b/shared/utils/requests/requests.ts @@ -1,5 +1,5 @@ import * as request from 'supertest' -import { buildAbsoluteFixturePath } from '../miscs/miscs' +import { buildAbsoluteFixturePath, root } from '../miscs/miscs' import { isAbsolute, join } from 'path' function makeGetRequest (options: { @@ -142,7 +142,7 @@ function updateAvatarRequest (options: { if (isAbsolute(options.fixture)) { filePath = options.fixture } else { - filePath = join(__dirname, '..', '..', 'fixtures', options.fixture) + filePath = join(root(), 'server', 'tests', 'fixtures', options.fixture) } return makeUploadRequest({ diff --git a/server/tests/utils/search/video-channels.ts b/shared/utils/search/video-channels.ts similarity index 100% rename from server/tests/utils/search/video-channels.ts rename to shared/utils/search/video-channels.ts diff --git a/server/tests/utils/search/videos.ts b/shared/utils/search/videos.ts similarity index 96% rename from server/tests/utils/search/videos.ts rename to shared/utils/search/videos.ts index 8c0037ccc..ba4627017 100644 --- a/server/tests/utils/search/videos.ts +++ b/shared/utils/search/videos.ts @@ -1,7 +1,7 @@ /* tslint:disable:no-unused-expression */ import * as request from 'supertest' -import { VideosSearchQuery } from '../../../../shared/models/search' +import { VideosSearchQuery } from '../../models/search' import { immutableAssign } from '../miscs/miscs' function searchVideo (url: string, search: string) { diff --git a/server/tests/utils/server/activitypub.ts b/shared/utils/server/activitypub.ts similarity index 100% rename from server/tests/utils/server/activitypub.ts rename to shared/utils/server/activitypub.ts diff --git a/server/tests/utils/server/clients.ts b/shared/utils/server/clients.ts similarity index 100% rename from server/tests/utils/server/clients.ts rename to shared/utils/server/clients.ts diff --git a/server/tests/utils/server/config.ts b/shared/utils/server/config.ts similarity index 96% rename from server/tests/utils/server/config.ts rename to shared/utils/server/config.ts index aa3100d34..5b888b061 100644 --- a/server/tests/utils/server/config.ts +++ b/shared/utils/server/config.ts @@ -1,5 +1,5 @@ import { makeDeleteRequest, makeGetRequest, makePutBodyRequest } from '../requests/requests' -import { CustomConfig } from '../../../../shared/models/server/custom-config.model' +import { CustomConfig } from '../../models/server/custom-config.model' function getConfig (url: string) { const path = '/api/v1/config' diff --git a/server/tests/utils/server/follows.ts b/shared/utils/server/follows.ts similarity index 100% rename from server/tests/utils/server/follows.ts rename to shared/utils/server/follows.ts diff --git a/server/tests/utils/server/jobs.ts b/shared/utils/server/jobs.ts similarity index 97% rename from server/tests/utils/server/jobs.ts rename to shared/utils/server/jobs.ts index 26180ec72..7c7e89824 100644 --- a/server/tests/utils/server/jobs.ts +++ b/shared/utils/server/jobs.ts @@ -1,7 +1,7 @@ import * as request from 'supertest' -import { Job, JobState } from '../../../../shared/models' -import { ServerInfo } from './servers' +import { Job, JobState } from '../../models' import { wait } from '../miscs/miscs' +import { ServerInfo } from './servers' function getJobsList (url: string, accessToken: string, state: JobState) { const path = '/api/v1/jobs/' + state diff --git a/server/tests/utils/server/redundancy.ts b/shared/utils/server/redundancy.ts similarity index 100% rename from server/tests/utils/server/redundancy.ts rename to shared/utils/server/redundancy.ts diff --git a/server/tests/utils/server/servers.ts b/shared/utils/server/servers.ts similarity index 97% rename from server/tests/utils/server/servers.ts rename to shared/utils/server/servers.ts index f358a21f1..88d2b390c 100644 --- a/server/tests/utils/server/servers.ts +++ b/shared/utils/server/servers.ts @@ -115,7 +115,7 @@ function runServer (serverNumber: number, configOverride?: Object, args = []) { } return new Promise(res => { - server.app = fork(join(__dirname, '..', '..', '..', '..', 'dist', 'server.js'), args, options) + server.app = fork(join(root(), 'dist', 'server.js'), args, options) server.app.stdout.on('data', function onStdout (data) { let dontContinue = false diff --git a/server/tests/utils/server/stats.ts b/shared/utils/server/stats.ts similarity index 100% rename from server/tests/utils/server/stats.ts rename to shared/utils/server/stats.ts diff --git a/server/tests/utils/users/accounts.ts b/shared/utils/users/accounts.ts similarity index 96% rename from server/tests/utils/users/accounts.ts rename to shared/utils/users/accounts.ts index 257fa5b27..388eb6973 100644 --- a/server/tests/utils/users/accounts.ts +++ b/shared/utils/users/accounts.ts @@ -3,7 +3,7 @@ import { expect } from 'chai' import { existsSync, readdir } from 'fs-extra' import { join } from 'path' -import { Account } from '../../../../shared/models/actors' +import { Account } from '../../models/actors' import { root } from '../miscs/miscs' import { makeGetRequest } from '../requests/requests' diff --git a/server/tests/utils/users/blocklist.ts b/shared/utils/users/blocklist.ts similarity index 100% rename from server/tests/utils/users/blocklist.ts rename to shared/utils/users/blocklist.ts diff --git a/server/tests/utils/users/login.ts b/shared/utils/users/login.ts similarity index 100% rename from server/tests/utils/users/login.ts rename to shared/utils/users/login.ts diff --git a/server/tests/utils/users/user-subscriptions.ts b/shared/utils/users/user-subscriptions.ts similarity index 100% rename from server/tests/utils/users/user-subscriptions.ts rename to shared/utils/users/user-subscriptions.ts diff --git a/server/tests/utils/users/users.ts b/shared/utils/users/users.ts similarity index 98% rename from server/tests/utils/users/users.ts rename to shared/utils/users/users.ts index f12992315..554e42c01 100644 --- a/server/tests/utils/users/users.ts +++ b/shared/utils/users/users.ts @@ -1,8 +1,8 @@ import * as request from 'supertest' import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' -import { UserRole } from '../../../../shared/index' -import { NSFWPolicyType } from '../../../../shared/models/videos/nsfw-policy.type' +import { UserRole } from '../../index' +import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' function createUser ( url: string, diff --git a/server/tests/utils/videos/services.ts b/shared/utils/videos/services.ts similarity index 100% rename from server/tests/utils/videos/services.ts rename to shared/utils/videos/services.ts diff --git a/server/tests/utils/videos/video-abuses.ts b/shared/utils/videos/video-abuses.ts similarity index 94% rename from server/tests/utils/videos/video-abuses.ts rename to shared/utils/videos/video-abuses.ts index 4ad82ad8c..7f011ec0f 100644 --- a/server/tests/utils/videos/video-abuses.ts +++ b/shared/utils/videos/video-abuses.ts @@ -1,5 +1,5 @@ import * as request from 'supertest' -import { VideoAbuseUpdate } from '../../../../shared/models/videos/abuse/video-abuse-update.model' +import { VideoAbuseUpdate } from '../../models/videos/abuse/video-abuse-update.model' import { makeDeleteRequest, makePutBodyRequest } from '../requests/requests' function reportVideoAbuse (url: string, token: string, videoId: number | string, reason: string, specialStatus = 200) { diff --git a/server/tests/utils/videos/video-blacklist.ts b/shared/utils/videos/video-blacklist.ts similarity index 100% rename from server/tests/utils/videos/video-blacklist.ts rename to shared/utils/videos/video-blacklist.ts diff --git a/server/tests/utils/videos/video-captions.ts b/shared/utils/videos/video-captions.ts similarity index 100% rename from server/tests/utils/videos/video-captions.ts rename to shared/utils/videos/video-captions.ts diff --git a/server/tests/utils/videos/video-change-ownership.ts b/shared/utils/videos/video-change-ownership.ts similarity index 100% rename from server/tests/utils/videos/video-change-ownership.ts rename to shared/utils/videos/video-change-ownership.ts diff --git a/server/tests/utils/videos/video-channels.ts b/shared/utils/videos/video-channels.ts similarity index 97% rename from server/tests/utils/videos/video-channels.ts rename to shared/utils/videos/video-channels.ts index 70e8d1a6b..3935c261e 100644 --- a/server/tests/utils/videos/video-channels.ts +++ b/shared/utils/videos/video-channels.ts @@ -1,5 +1,5 @@ import * as request from 'supertest' -import { VideoChannelCreate, VideoChannelUpdate } from '../../../../shared/models/videos' +import { VideoChannelCreate, VideoChannelUpdate } from '../../models/videos' import { updateAvatarRequest } from '../requests/requests' function getVideoChannelsList (url: string, start: number, count: number, sort?: string) { diff --git a/server/tests/utils/videos/video-comments.ts b/shared/utils/videos/video-comments.ts similarity index 100% rename from server/tests/utils/videos/video-comments.ts rename to shared/utils/videos/video-comments.ts diff --git a/server/tests/utils/videos/video-history.ts b/shared/utils/videos/video-history.ts similarity index 100% rename from server/tests/utils/videos/video-history.ts rename to shared/utils/videos/video-history.ts diff --git a/server/tests/utils/videos/video-imports.ts b/shared/utils/videos/video-imports.ts similarity index 95% rename from server/tests/utils/videos/video-imports.ts rename to shared/utils/videos/video-imports.ts index eb985a5b1..3fa49b432 100644 --- a/server/tests/utils/videos/video-imports.ts +++ b/shared/utils/videos/video-imports.ts @@ -1,4 +1,5 @@ -import { VideoImportCreate } from '../../../../shared/models/videos' + +import { VideoImportCreate } from '../../models/videos' import { makeGetRequest, makeUploadRequest } from '../requests/requests' function getYoutubeVideoUrl () { diff --git a/server/tests/utils/videos/videos.ts b/shared/utils/videos/videos.ts similarity index 98% rename from server/tests/utils/videos/videos.ts rename to shared/utils/videos/videos.ts index d6c3e5dac..f5fcc6a8a 100644 --- a/server/tests/utils/videos/videos.ts +++ b/shared/utils/videos/videos.ts @@ -16,8 +16,9 @@ import { ServerInfo, testImage } from '../' -import { VideoDetails, VideoPrivacy } from '../../../../shared/models/videos' -import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants' + +import { VideoDetails, VideoPrivacy } from '../../models/videos' +import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' import { dateIsValid, webtorrentAdd } from '../miscs/miscs' type VideoAttributes = { @@ -416,7 +417,7 @@ function rateVideo (url: string, accessToken: string, id: number, rating: string function parseTorrentVideo (server: ServerInfo, videoUUID: string, resolution: number) { return new Promise((res, rej) => { const torrentName = videoUUID + '-' + resolution + '.torrent' - const torrentPath = join(__dirname, '..', '..', '..', '..', 'test' + server.serverNumber, 'torrents', torrentName) + const torrentPath = join(root(), 'test' + server.serverNumber, 'torrents', torrentName) readFile(torrentPath, (err, data) => { if (err) return rej(err)