From 2d1ad5b96063d1e430ca99128a15e2e56cb614e0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Jul 2021 15:33:39 +0200 Subject: [PATCH] Move AP request in requests file --- .../notifications/moderation-notifications.ts | 2 +- .../api/search/search-activitypub-videos.ts | 2 +- server/tests/api/videos/videos-overview.ts | 1 - shared/extra-utils/index.ts | 1 - shared/extra-utils/requests/requests.ts | 16 +++++++++++++--- shared/extra-utils/server/activitypub.ts | 15 --------------- 6 files changed, 15 insertions(+), 22 deletions(-) delete mode 100644 shared/extra-utils/server/activitypub.ts diff --git a/server/tests/api/notifications/moderation-notifications.ts b/server/tests/api/notifications/moderation-notifications.ts index f77719c68..c4f63200a 100644 --- a/server/tests/api/notifications/moderation-notifications.ts +++ b/server/tests/api/notifications/moderation-notifications.ts @@ -235,7 +235,7 @@ describe('Test moderation notifications', function () { const video = resVideo.body.video { - const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) + const body = await servers[0].abusesCommand.report({ token: userAccessToken, videoId: video.id, reason: 'super reason' }) abuseId = body.abuse.id } diff --git a/server/tests/api/search/search-activitypub-videos.ts b/server/tests/api/search/search-activitypub-videos.ts index 1a5130ce9..7c6455258 100644 --- a/server/tests/api/search/search-activitypub-videos.ts +++ b/server/tests/api/search/search-activitypub-videos.ts @@ -72,7 +72,7 @@ describe('Test ActivityPub videos search', function () { it('Should search a local video', async function () { const search = 'http://localhost:' + servers[0].port + '/videos/watch/' + videoServer1UUID - const body = await command.searchVideos({ search }) + const body = await command.searchVideos({ search }) expect(body.total).to.equal(1) expect(body.data).to.be.an('array') diff --git a/server/tests/api/videos/videos-overview.ts b/server/tests/api/videos/videos-overview.ts index c8e3df4bd..b3ab9e070 100644 --- a/server/tests/api/videos/videos-overview.ts +++ b/server/tests/api/videos/videos-overview.ts @@ -2,7 +2,6 @@ import 'mocha' import * as chai from 'chai' -import { Response } from 'superagent' import { addAccountToAccountBlocklist, cleanupTests, diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index 067e6fb65..9e0f6374a 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts @@ -13,7 +13,6 @@ export * from './requests/requests' export * from './search' -export * from './server/activitypub' export * from './server/clients' export * from './server/config' export * from './server/debug' diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts index 8c26a3699..3fbaa31d6 100644 --- a/shared/extra-utils/requests/requests.ts +++ b/shared/extra-utils/requests/requests.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/no-floating-promises */ -import * as request from 'supertest' -import { buildAbsoluteFixturePath, root } from '../miscs/miscs' import { isAbsolute, join } from 'path' -import { URL } from 'url' import { decode } from 'querystring' +import * as request from 'supertest' +import { URL } from 'url' import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' +import { buildAbsoluteFixturePath, root } from '../miscs/miscs' function get4KFileUrl () { return 'https://download.cpy.re/peertube/4k_file.txt' @@ -154,6 +154,15 @@ function makeHTMLRequest (url: string, path: string) { .expect(HttpStatusCode.OK_200) } +function makeActivityPubGetRequest (url: string, path: string, expectedStatus = HttpStatusCode.OK_200) { + return makeGetRequest({ + url, + path, + statusCodeExpected: expectedStatus, + accept: 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8' + }) +} + function updateImageRequest (options: { url: string path: string @@ -202,6 +211,7 @@ export { makePutBodyRequest, makeDeleteRequest, makeRawRequest, + makeActivityPubGetRequest, unwrapBody, unwrapText, updateImageRequest diff --git a/shared/extra-utils/server/activitypub.ts b/shared/extra-utils/server/activitypub.ts deleted file mode 100644 index cf967ed7d..000000000 --- a/shared/extra-utils/server/activitypub.ts +++ /dev/null @@ -1,15 +0,0 @@ -import * as request from 'supertest' -import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' - -function makeActivityPubGetRequest (url: string, path: string, expectedStatus = HttpStatusCode.OK_200) { - return request(url) - .get(path) - .set('Accept', 'application/activity+json,text/html;q=0.9,\\*/\\*;q=0.8') - .expect(expectedStatus) -} - -// --------------------------------------------------------------------------- - -export { - makeActivityPubGetRequest -}