From 254d3579f5338f5fd775c17d15cdfc37078bcfb4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 16 Jul 2021 09:47:51 +0200 Subject: Use an object to represent a server --- server/tests/api/activitypub/cleaner.ts | 8 ++++---- server/tests/api/activitypub/client.ts | 8 ++++---- server/tests/api/activitypub/fetch.ts | 6 +++--- server/tests/api/activitypub/refresher.ts | 11 +++++------ server/tests/api/activitypub/security.ts | 17 ++++++++--------- 5 files changed, 24 insertions(+), 26 deletions(-) (limited to 'server/tests/api/activitypub') diff --git a/server/tests/api/activitypub/cleaner.ts b/server/tests/api/activitypub/cleaner.ts index 1421824da..a5ce449f3 100644 --- a/server/tests/api/activitypub/cleaner.ts +++ b/server/tests/api/activitypub/cleaner.ts @@ -5,8 +5,8 @@ import * as chai from 'chai' import { cleanupTests, doubleFollow, - flushAndRunMultipleServers, - ServerInfo, + createMultipleServers, + PeerTubeServer, setAccessTokensToServers, wait, waitJobs @@ -15,7 +15,7 @@ import { const expect = chai.expect describe('Test AP cleaner', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let videoUUID1: string let videoUUID2: string let videoUUID3: string @@ -30,7 +30,7 @@ describe('Test AP cleaner', function () { videos: { cleanup_remote_interactions: true } } } - servers = await flushAndRunMultipleServers(3, config) + servers = await createMultipleServers(3, config) // Get the access tokens await setAccessTokensToServers(servers) diff --git a/server/tests/api/activitypub/client.ts b/server/tests/api/activitypub/client.ts index 5845045a3..720231f02 100644 --- a/server/tests/api/activitypub/client.ts +++ b/server/tests/api/activitypub/client.ts @@ -6,9 +6,9 @@ import { HttpStatusCode } from '@shared/core-utils' import { cleanupTests, doubleFollow, - flushAndRunMultipleServers, + createMultipleServers, makeActivityPubGetRequest, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/extra-utils' @@ -17,7 +17,7 @@ import { VideoPlaylistPrivacy } from '@shared/models' const expect = chai.expect describe('Test activitypub', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let video: { id: number, uuid: string, shortUUID: string } let playlist: { id: number, uuid: string, shortUUID: string } @@ -62,7 +62,7 @@ describe('Test activitypub', function () { before(async function () { this.timeout(30000) - servers = await flushAndRunMultipleServers(2) + servers = await createMultipleServers(2) await setAccessTokensToServers(servers) await setDefaultVideoChannel(servers) diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts index 34694a773..ddfe6cfe0 100644 --- a/server/tests/api/activitypub/fetch.ts +++ b/server/tests/api/activitypub/fetch.ts @@ -2,19 +2,19 @@ import 'mocha' import * as chai from 'chai' -import { cleanupTests, doubleFollow, flushAndRunMultipleServers, ServerInfo, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' +import { cleanupTests, doubleFollow, createMultipleServers, PeerTubeServer, setAccessTokensToServers, waitJobs } from '@shared/extra-utils' const expect = chai.expect describe('Test ActivityPub fetcher', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] // --------------------------------------------------------------- before(async function () { this.timeout(60000) - servers = await flushAndRunMultipleServers(3) + servers = await createMultipleServers(3) // Get the access tokens await setAccessTokensToServers(servers) diff --git a/server/tests/api/activitypub/refresher.ts b/server/tests/api/activitypub/refresher.ts index d2f71e857..bbec0d309 100644 --- a/server/tests/api/activitypub/refresher.ts +++ b/server/tests/api/activitypub/refresher.ts @@ -5,10 +5,9 @@ import { HttpStatusCode } from '@shared/core-utils' import { cleanupTests, doubleFollow, - flushAndRunMultipleServers, + createMultipleServers, killallServers, - reRunServer, - ServerInfo, + PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel, wait, @@ -17,7 +16,7 @@ import { import { VideoPlaylistPrivacy } from '@shared/models' describe('Test AP refresher', function () { - let servers: ServerInfo[] = [] + let servers: PeerTubeServer[] = [] let videoUUID1: string let videoUUID2: string let videoUUID3: string @@ -27,7 +26,7 @@ describe('Test AP refresher', function () { before(async function () { this.timeout(60000) - servers = await flushAndRunMultipleServers(2, { transcoding: { enabled: false } }) + servers = await createMultipleServers(2, { transcoding: { enabled: false } }) // Get the access tokens await setAccessTokensToServers(servers) @@ -95,7 +94,7 @@ describe('Test AP refresher', function () { // The refresh should fail await waitJobs([ servers[0] ]) - await reRunServer(servers[1]) + await servers[1].run() await servers[0].videos.get({ id: videoUUID3 }) }) diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts index ab0eb256e..c173648b3 100644 --- a/server/tests/api/activitypub/security.ts +++ b/server/tests/api/activitypub/security.ts @@ -7,10 +7,9 @@ import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-c import { buildAbsoluteFixturePath, cleanupTests, - flushAndRunMultipleServers, + createMultipleServers, killallServers, - reRunServer, - ServerInfo, + PeerTubeServer, wait } from '../../../../shared/extra-utils' import { makeFollowRequest, makePOSTAPRequest } from '../../../../shared/extra-utils/requests/activitypub' @@ -20,7 +19,7 @@ import { buildGlobalHeaders } from '../../../lib/job-queue/handlers/utils/activi const expect = chai.expect -function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey: string, privateKey: string) { +function setKeysOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, publicKey: string, privateKey: string) { const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' return Promise.all([ @@ -29,7 +28,7 @@ function setKeysOfServer (onServer: ServerInfo, ofServer: ServerInfo, publicKey: ]) } -function setUpdatedAtOfServer (onServer: ServerInfo, ofServer: ServerInfo, updatedAt: string) { +function setUpdatedAtOfServer (onServer: PeerTubeServer, ofServer: PeerTubeServer, updatedAt: string) { const url = 'http://localhost:' + ofServer.port + '/accounts/peertube' return Promise.all([ @@ -38,7 +37,7 @@ function setUpdatedAtOfServer (onServer: ServerInfo, ofServer: ServerInfo, updat ]) } -function getAnnounceWithoutContext (server: ServerInfo) { +function getAnnounceWithoutContext (server: PeerTubeServer) { const json = require(buildAbsoluteFixturePath('./ap-json/peertube/announce-without-context.json')) const result: typeof json = {} @@ -54,7 +53,7 @@ function getAnnounceWithoutContext (server: ServerInfo) { } describe('Test ActivityPub security', function () { - let servers: ServerInfo[] + let servers: PeerTubeServer[] let url: string const keys = require(buildAbsoluteFixturePath('./ap-json/peertube/keys.json')) @@ -72,7 +71,7 @@ describe('Test ActivityPub security', function () { before(async function () { this.timeout(60000) - servers = await flushAndRunMultipleServers(3) + servers = await createMultipleServers(3) url = servers[0].url + '/inbox' @@ -172,7 +171,7 @@ describe('Test ActivityPub security', function () { // Invalid peertube actor cache await killallServers([ servers[1] ]) - await reRunServer(servers[1]) + await servers[1].run() const body = activityPubContextify(getAnnounceWithoutContext(servers[1])) const headers = buildGlobalHeaders(body) -- cgit v1.2.3