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 | |
parent | 5beb89f223539f1e415a976ff104f772526b4d20 (diff) | |
download | PeerTube-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.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/users/users.ts | 32 |
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 | ||
16 | function getJSONfeed (url: string, feed: FeedType, query: any = {}) { | 16 | function 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 @@ | |||
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, |