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

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