Move AP request in requests file

This commit is contained in:
Chocobozzz 2021-07-06 15:33:39 +02:00
parent af971e06c6
commit 2d1ad5b960
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 15 additions and 22 deletions

View File

@ -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
}

View File

@ -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')

View File

@ -2,7 +2,6 @@
import 'mocha'
import * as chai from 'chai'
import { Response } from 'superagent'
import {
addAccountToAccountBlocklist,
cleanupTests,

View File

@ -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'

View File

@ -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

View File

@ -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
}