mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Use got instead of request
This commit is contained in:
@@ -79,9 +79,9 @@ describe('Test ActivityPub security', function () {
|
||||
Digest: buildDigest({ hello: 'coucou' })
|
||||
}
|
||||
|
||||
const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
|
||||
const { statusCode } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
|
||||
|
||||
expect(response.statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
expect(statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
})
|
||||
|
||||
it('Should fail with an invalid date', async function () {
|
||||
@@ -89,9 +89,9 @@ describe('Test ActivityPub security', function () {
|
||||
const headers = buildGlobalHeaders(body)
|
||||
headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT'
|
||||
|
||||
const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
|
||||
const { statusCode } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
|
||||
|
||||
expect(response.statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
expect(statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
})
|
||||
|
||||
it('Should fail with bad keys', async function () {
|
||||
@@ -101,9 +101,9 @@ describe('Test ActivityPub security', function () {
|
||||
const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
|
||||
const headers = buildGlobalHeaders(body)
|
||||
|
||||
const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
|
||||
const { statusCode } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
|
||||
|
||||
expect(response.statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
expect(statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
})
|
||||
|
||||
it('Should reject requests without appropriate signed headers', async function () {
|
||||
@@ -123,8 +123,8 @@ describe('Test ActivityPub security', function () {
|
||||
for (const badHeaders of badHeadersMatrix) {
|
||||
signatureOptions.headers = badHeaders
|
||||
|
||||
const { response } = await makePOSTAPRequest(url, body, signatureOptions, headers)
|
||||
expect(response.statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
const { statusCode } = await makePOSTAPRequest(url, body, signatureOptions, headers)
|
||||
expect(statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -132,9 +132,9 @@ describe('Test ActivityPub security', function () {
|
||||
const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
|
||||
const headers = buildGlobalHeaders(body)
|
||||
|
||||
const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
|
||||
const { statusCode } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
|
||||
|
||||
expect(response.statusCode).to.equal(HttpStatusCode.NO_CONTENT_204)
|
||||
expect(statusCode).to.equal(HttpStatusCode.NO_CONTENT_204)
|
||||
})
|
||||
|
||||
it('Should refresh the actor keys', async function () {
|
||||
@@ -150,9 +150,9 @@ describe('Test ActivityPub security', function () {
|
||||
const body = activityPubContextify(getAnnounceWithoutContext(servers[1]))
|
||||
const headers = buildGlobalHeaders(body)
|
||||
|
||||
const { response } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
|
||||
const { statusCode } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
|
||||
|
||||
expect(response.statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
expect(statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -183,9 +183,9 @@ describe('Test ActivityPub security', function () {
|
||||
|
||||
const headers = buildGlobalHeaders(signedBody)
|
||||
|
||||
const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
|
||||
const { statusCode } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
|
||||
|
||||
expect(response.statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
expect(statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
})
|
||||
|
||||
it('Should fail with an altered body', async function () {
|
||||
@@ -204,9 +204,9 @@ describe('Test ActivityPub security', function () {
|
||||
|
||||
const headers = buildGlobalHeaders(signedBody)
|
||||
|
||||
const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
|
||||
const { statusCode } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
|
||||
|
||||
expect(response.statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
expect(statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
})
|
||||
|
||||
it('Should succeed with a valid signature', async function () {
|
||||
@@ -220,9 +220,9 @@ describe('Test ActivityPub security', function () {
|
||||
|
||||
const headers = buildGlobalHeaders(signedBody)
|
||||
|
||||
const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
|
||||
const { statusCode } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
|
||||
|
||||
expect(response.statusCode).to.equal(HttpStatusCode.NO_CONTENT_204)
|
||||
expect(statusCode).to.equal(HttpStatusCode.NO_CONTENT_204)
|
||||
})
|
||||
|
||||
it('Should refresh the actor keys', async function () {
|
||||
@@ -243,9 +243,9 @@ describe('Test ActivityPub security', function () {
|
||||
|
||||
const headers = buildGlobalHeaders(signedBody)
|
||||
|
||||
const { response } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
|
||||
const { statusCode } = await makePOSTAPRequest(url, signedBody, baseHttpSignature(), headers)
|
||||
|
||||
expect(response.statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
expect(statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -348,8 +348,8 @@ describe('Test handle downs', function () {
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
await getVideo(servers[1].url, videoIdsServer1[i])
|
||||
await wait(1000)
|
||||
await waitJobs([ servers[1] ])
|
||||
await wait(1500)
|
||||
}
|
||||
|
||||
for (const id of videoIdsServer1) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||
|
||||
import 'mocha'
|
||||
import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests'
|
||||
import { get4KFileUrl, root, wait } from '../../../shared/extra-utils'
|
||||
import { join } from 'path'
|
||||
import { pathExists, remove } from 'fs-extra'
|
||||
import { expect } from 'chai'
|
||||
import { pathExists, remove } from 'fs-extra'
|
||||
import { join } from 'path'
|
||||
import { get4KFileUrl, root, wait } from '../../../shared/extra-utils'
|
||||
import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests'
|
||||
|
||||
describe('Request helpers', function () {
|
||||
const destPath1 = join(root(), 'test-output-1.txt')
|
||||
@@ -13,7 +13,7 @@ describe('Request helpers', function () {
|
||||
|
||||
it('Should throw an error when the bytes limit is exceeded for request', async function () {
|
||||
try {
|
||||
await doRequest({ uri: get4KFileUrl() }, 3)
|
||||
await doRequest(get4KFileUrl(), { bodyKBLimit: 3 })
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
@@ -23,7 +23,7 @@ describe('Request helpers', function () {
|
||||
|
||||
it('Should throw an error when the bytes limit is exceeded for request and save file', async function () {
|
||||
try {
|
||||
await doRequestAndSaveToFile({ uri: get4KFileUrl() }, destPath1, 3)
|
||||
await doRequestAndSaveToFile(get4KFileUrl(), destPath1, { bodyKBLimit: 3 })
|
||||
} catch {
|
||||
|
||||
await wait(500)
|
||||
@@ -35,8 +35,8 @@ describe('Request helpers', function () {
|
||||
})
|
||||
|
||||
it('Should succeed if the file is below the limit', async function () {
|
||||
await doRequest({ uri: get4KFileUrl() }, 5)
|
||||
await doRequestAndSaveToFile({ uri: get4KFileUrl() }, destPath2, 5)
|
||||
await doRequest(get4KFileUrl(), { bodyKBLimit: 5 })
|
||||
await doRequestAndSaveToFile(get4KFileUrl(), destPath2, { bodyKBLimit: 5 })
|
||||
|
||||
expect(await pathExists(destPath2)).to.be.true
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user