aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-25 11:04:18 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-25 11:07:56 +0100
commit18490b07650d77d7fe376970b749af5a8c672fd6 (patch)
tree89741e63e34c2659487c9afa8309755064cb0c39 /shared
parent5beb89f223539f1e415a976ff104f772526b4d20 (diff)
downloadPeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.tar.gz
PeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.tar.zst
PeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.zip
Fix migration and test
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/feeds/feeds.ts4
-rw-r--r--shared/extra-utils/users/users.ts32
2 files changed, 24 insertions, 12 deletions
diff --git a/shared/extra-utils/feeds/feeds.ts b/shared/extra-utils/feeds/feeds.ts
index bafbb9f94..957d4499c 100644
--- a/shared/extra-utils/feeds/feeds.ts
+++ b/shared/extra-utils/feeds/feeds.ts
@@ -13,14 +13,14 @@ function getXMLfeed (url: string, feed: FeedType, format?: string) {
13 .expect('Content-Type', /xml/) 13 .expect('Content-Type', /xml/)
14} 14}
15 15
16function getJSONfeed (url: string, feed: FeedType, query: any = {}) { 16function getJSONfeed (url: string, feed: FeedType, query: any = {}, statusCodeExpected = 200) {
17 const path = '/feeds/' + feed + '.json' 17 const path = '/feeds/' + feed + '.json'
18 18
19 return request(url) 19 return request(url)
20 .get(path) 20 .get(path)
21 .query(query) 21 .query(query)
22 .set('Accept', 'application/json') 22 .set('Accept', 'application/json')
23 .expect(200) 23 .expect(statusCodeExpected)
24 .expect('Content-Type', /json/) 24 .expect('Content-Type', /json/)
25} 25}
26 26
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts
index 4d0986ce3..ebb8bc257 100644
--- a/shared/extra-utils/users/users.ts
+++ b/shared/extra-utils/users/users.ts
@@ -1,12 +1,12 @@
1import { omit } from 'lodash'
1import * as request from 'supertest' 2import * as request from 'supertest'
2import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' 3import { UserUpdateMe } from '../../models/users'
3import { UserAdminFlag } from '../../models/users/user-flag.model' 4import { UserAdminFlag } from '../../models/users/user-flag.model'
4import { UserRegister } from '../../models/users/user-register.model' 5import { UserRegister } from '../../models/users/user-register.model'
5import { UserRole } from '../../models/users/user-role' 6import { UserRole } from '../../models/users/user-role'
7import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests'
6import { ServerInfo } from '../server/servers' 8import { ServerInfo } from '../server/servers'
7import { userLogin } from './login' 9import { userLogin } from './login'
8import { UserUpdateMe } from '../../models/users'
9import { omit } from 'lodash'
10 10
11type CreateUserArgs = { 11type CreateUserArgs = {
12 url: string 12 url: string
@@ -109,15 +109,26 @@ function getMyUserInformation (url: string, accessToken: string, specialStatus =
109 .expect('Content-Type', /json/) 109 .expect('Content-Type', /json/)
110} 110}
111 111
112function getUserScopedTokens (url: string, accessToken: string, specialStatus = 200) { 112function getUserScopedTokens (url: string, token: string, statusCodeExpected = 200) {
113 const path = '/api/v1/users/scoped-tokens' 113 const path = '/api/v1/users/scoped-tokens'
114 114
115 return request(url) 115 return makeGetRequest({
116 .get(path) 116 url,
117 .set('Accept', 'application/json') 117 path,
118 .set('Authorization', 'Bearer ' + accessToken) 118 token,
119 .expect(specialStatus) 119 statusCodeExpected
120 .expect('Content-Type', /json/) 120 })
121}
122
123function renewUserScopedTokens (url: string, token: string, statusCodeExpected = 200) {
124 const path = '/api/v1/users/scoped-tokens'
125
126 return makePostBodyRequest({
127 url,
128 path,
129 token,
130 statusCodeExpected
131 })
121} 132}
122 133
123function deleteMe (url: string, accessToken: string, specialStatus = 204) { 134function deleteMe (url: string, accessToken: string, specialStatus = 204) {
@@ -359,6 +370,7 @@ export {
359 unblockUser, 370 unblockUser,
360 askResetPassword, 371 askResetPassword,
361 resetPassword, 372 resetPassword,
373 renewUserScopedTokens,
362 updateMyAvatar, 374 updateMyAvatar,
363 askSendVerifyEmail, 375 askSendVerifyEmail,
364 generateUserAccessToken, 376 generateUserAccessToken,