diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-25 11:04:18 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-25 11:07:56 +0100 |
commit | 18490b07650d77d7fe376970b749af5a8c672fd6 (patch) | |
tree | 89741e63e34c2659487c9afa8309755064cb0c39 /shared/extra-utils/users | |
parent | 5beb89f223539f1e415a976ff104f772526b4d20 (diff) | |
download | PeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.tar.gz PeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.tar.zst PeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.zip |
Fix migration and test
Diffstat (limited to 'shared/extra-utils/users')
-rw-r--r-- | shared/extra-utils/users/users.ts | 32 |
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 @@ | |||
1 | import { omit } from 'lodash' | ||
1 | import * as request from 'supertest' | 2 | import * as request from 'supertest' |
2 | import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' | 3 | import { UserUpdateMe } from '../../models/users' |
3 | import { UserAdminFlag } from '../../models/users/user-flag.model' | 4 | import { UserAdminFlag } from '../../models/users/user-flag.model' |
4 | import { UserRegister } from '../../models/users/user-register.model' | 5 | import { UserRegister } from '../../models/users/user-register.model' |
5 | import { UserRole } from '../../models/users/user-role' | 6 | import { UserRole } from '../../models/users/user-role' |
7 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' | ||
6 | import { ServerInfo } from '../server/servers' | 8 | import { ServerInfo } from '../server/servers' |
7 | import { userLogin } from './login' | 9 | import { userLogin } from './login' |
8 | import { UserUpdateMe } from '../../models/users' | ||
9 | import { omit } from 'lodash' | ||
10 | 10 | ||
11 | type CreateUserArgs = { | 11 | type 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 | ||
112 | function getUserScopedTokens (url: string, accessToken: string, specialStatus = 200) { | 112 | function 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 | |||
123 | function 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 | ||
123 | function deleteMe (url: string, accessToken: string, specialStatus = 204) { | 134 | function 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, |