aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/requests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-29 09:04:42 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commit9107d791e2eef9a1b24b0499dac8b9dbba8a792f (patch)
treef09b20f06008b094f3266b39063bc9785dfebf5f /shared/extra-utils/requests
parent4a8d113b9b57d97ff13ad1608798eabca99643e4 (diff)
downloadPeerTube-9107d791e2eef9a1b24b0499dac8b9dbba8a792f.tar.gz
PeerTube-9107d791e2eef9a1b24b0499dac8b9dbba8a792f.tar.zst
PeerTube-9107d791e2eef9a1b24b0499dac8b9dbba8a792f.zip
Add external login tests
Diffstat (limited to 'shared/extra-utils/requests')
-rw-r--r--shared/extra-utils/requests/requests.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts
index 61167f212..0e9d67f0b 100644
--- a/shared/extra-utils/requests/requests.ts
+++ b/shared/extra-utils/requests/requests.ts
@@ -4,6 +4,7 @@ import * as request from 'supertest'
4import { buildAbsoluteFixturePath, root } from '../miscs/miscs' 4import { buildAbsoluteFixturePath, root } from '../miscs/miscs'
5import { isAbsolute, join } from 'path' 5import { isAbsolute, join } from 'path'
6import { URL } from 'url' 6import { URL } from 'url'
7import { decode } from 'querystring'
7 8
8function get4KFileUrl () { 9function get4KFileUrl () {
9 return 'https://download.cpy.re/peertube/4k_file.txt' 10 return 'https://download.cpy.re/peertube/4k_file.txt'
@@ -23,6 +24,7 @@ function makeGetRequest (options: {
23 statusCodeExpected?: number 24 statusCodeExpected?: number
24 contentType?: string 25 contentType?: string
25 range?: string 26 range?: string
27 redirects?: number
26}) { 28}) {
27 if (!options.statusCodeExpected) options.statusCodeExpected = 400 29 if (!options.statusCodeExpected) options.statusCodeExpected = 400
28 if (options.contentType === undefined) options.contentType = 'application/json' 30 if (options.contentType === undefined) options.contentType = 'application/json'
@@ -33,6 +35,7 @@ function makeGetRequest (options: {
33 if (options.token) req.set('Authorization', 'Bearer ' + options.token) 35 if (options.token) req.set('Authorization', 'Bearer ' + options.token)
34 if (options.query) req.query(options.query) 36 if (options.query) req.query(options.query)
35 if (options.range) req.set('Range', options.range) 37 if (options.range) req.set('Range', options.range)
38 if (options.redirects) req.redirects(options.redirects)
36 39
37 return req.expect(options.statusCodeExpected) 40 return req.expect(options.statusCodeExpected)
38} 41}
@@ -171,12 +174,17 @@ function updateAvatarRequest (options: {
171 }) 174 })
172} 175}
173 176
177function decodeQueryString (path: string) {
178 return decode(path.split('?')[1])
179}
180
174// --------------------------------------------------------------------------- 181// ---------------------------------------------------------------------------
175 182
176export { 183export {
177 get4KFileUrl, 184 get4KFileUrl,
178 makeHTMLRequest, 185 makeHTMLRequest,
179 makeGetRequest, 186 makeGetRequest,
187 decodeQueryString,
180 makeUploadRequest, 188 makeUploadRequest,
181 makePostBodyRequest, 189 makePostBodyRequest,
182 makePutBodyRequest, 190 makePutBodyRequest,