aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/users/users.ts
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/extra-utils/users/users.ts
parent5beb89f223539f1e415a976ff104f772526b4d20 (diff)
downloadPeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.tar.gz
PeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.tar.zst
PeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.zip
Fix migration and test
Diffstat (limited to 'shared/extra-utils/users/users.ts')
-rw-r--r--shared/extra-utils/users/users.ts32
1 files changed, 22 insertions, 10 deletions
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,