diff options
Diffstat (limited to 'shared/extra-utils/users')
-rw-r--r-- | shared/extra-utils/users/accounts.ts | 4 | ||||
-rw-r--r-- | shared/extra-utils/users/user-notifications.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/users/users.ts | 50 |
3 files changed, 45 insertions, 11 deletions
diff --git a/shared/extra-utils/users/accounts.ts b/shared/extra-utils/users/accounts.ts index f64a2dbad..627e17cc3 100644 --- a/shared/extra-utils/users/accounts.ts +++ b/shared/extra-utils/users/accounts.ts | |||
@@ -39,7 +39,7 @@ async function expectAccountFollows (url: string, nameWithDomain: string, follow | |||
39 | expect(account.followingCount).to.equal(followingCount, message) | 39 | expect(account.followingCount).to.equal(followingCount, message) |
40 | } | 40 | } |
41 | 41 | ||
42 | async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: number) { | 42 | async function checkActorFilesWereRemoved (filename: string, serverNumber: number) { |
43 | const testDirectory = 'test' + serverNumber | 43 | const testDirectory = 'test' + serverNumber |
44 | 44 | ||
45 | for (const directory of [ 'avatars' ]) { | 45 | for (const directory of [ 'avatars' ]) { |
@@ -50,7 +50,7 @@ async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: numb | |||
50 | 50 | ||
51 | const files = await readdir(directoryPath) | 51 | const files = await readdir(directoryPath) |
52 | for (const file of files) { | 52 | for (const file of files) { |
53 | expect(file).to.not.contain(actorUUID) | 53 | expect(file).to.not.contain(filename) |
54 | } | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
diff --git a/shared/extra-utils/users/user-notifications.ts b/shared/extra-utils/users/user-notifications.ts index 495ff80d9..f7de542bf 100644 --- a/shared/extra-utils/users/user-notifications.ts +++ b/shared/extra-utils/users/user-notifications.ts | |||
@@ -380,7 +380,7 @@ async function checkNewCommentOnMyVideo (base: CheckerBaseParams, uuid: string, | |||
380 | } | 380 | } |
381 | } | 381 | } |
382 | 382 | ||
383 | const commentUrl = `http://localhost:9001/videos/watch/${uuid};threadId=${threadId}` | 383 | const commentUrl = `http://localhost:${base.server.port}/videos/watch/${uuid};threadId=${threadId}` |
384 | function emailFinder (email: object) { | 384 | function emailFinder (email: object) { |
385 | return email[ 'text' ].indexOf(commentUrl) !== -1 | 385 | return email[ 'text' ].indexOf(commentUrl) !== -1 |
386 | } | 386 | } |
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts index 2bd37b8be..1c39881d6 100644 --- a/shared/extra-utils/users/users.ts +++ b/shared/extra-utils/users/users.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' | 2 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' |
3 | 3 | ||
4 | import { UserRole } from '../../index' | 4 | import { UserCreate, UserRole } from '../../index' |
5 | import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' | 5 | import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' |
6 | import { ServerInfo, userLogin } from '..' | 6 | import { ServerInfo, userLogin } from '..' |
7 | import { UserAdminFlag } from '../../models/users/user-flag.model' | 7 | import { UserAdminFlag } from '../../models/users/user-flag.model' |
8 | import { UserRegister } from '../../models/users/user-register.model' | ||
8 | 9 | ||
9 | type CreateUserArgs = { url: string, | 10 | type CreateUserArgs = { url: string, |
10 | accessToken: string, | 11 | accessToken: string, |
@@ -70,6 +71,31 @@ function registerUser (url: string, username: string, password: string, specialS | |||
70 | .expect(specialStatus) | 71 | .expect(specialStatus) |
71 | } | 72 | } |
72 | 73 | ||
74 | function registerUserWithChannel (options: { | ||
75 | url: string, | ||
76 | user: { username: string, password: string, displayName?: string }, | ||
77 | channel: { name: string, displayName: string } | ||
78 | }) { | ||
79 | const path = '/api/v1/users/register' | ||
80 | const body: UserRegister = { | ||
81 | username: options.user.username, | ||
82 | password: options.user.password, | ||
83 | email: options.user.username + '@example.com', | ||
84 | channel: options.channel | ||
85 | } | ||
86 | |||
87 | if (options.user.displayName) { | ||
88 | Object.assign(body, { displayName: options.user.displayName }) | ||
89 | } | ||
90 | |||
91 | return makePostBodyRequest({ | ||
92 | url: options.url, | ||
93 | path, | ||
94 | fields: body, | ||
95 | statusCodeExpected: 204 | ||
96 | }) | ||
97 | } | ||
98 | |||
73 | function getMyUserInformation (url: string, accessToken: string, specialStatus = 200) { | 99 | function getMyUserInformation (url: string, accessToken: string, specialStatus = 200) { |
74 | const path = '/api/v1/users/me' | 100 | const path = '/api/v1/users/me' |
75 | 101 | ||
@@ -138,12 +164,16 @@ function getUsersList (url: string, accessToken: string) { | |||
138 | function getUsersListPaginationAndSort (url: string, accessToken: string, start: number, count: number, sort: string, search?: string) { | 164 | function getUsersListPaginationAndSort (url: string, accessToken: string, start: number, count: number, sort: string, search?: string) { |
139 | const path = '/api/v1/users' | 165 | const path = '/api/v1/users' |
140 | 166 | ||
167 | const query = { | ||
168 | start, | ||
169 | count, | ||
170 | sort, | ||
171 | search | ||
172 | } | ||
173 | |||
141 | return request(url) | 174 | return request(url) |
142 | .get(path) | 175 | .get(path) |
143 | .query({ start }) | 176 | .query(query) |
144 | .query({ count }) | ||
145 | .query({ sort }) | ||
146 | .query({ search }) | ||
147 | .set('Accept', 'application/json') | 177 | .set('Accept', 'application/json') |
148 | .set('Authorization', 'Bearer ' + accessToken) | 178 | .set('Authorization', 'Bearer ' + accessToken) |
149 | .expect(200) | 179 | .expect(200) |
@@ -293,13 +323,16 @@ function askSendVerifyEmail (url: string, email: string) { | |||
293 | }) | 323 | }) |
294 | } | 324 | } |
295 | 325 | ||
296 | function verifyEmail (url: string, userId: number, verificationString: string, statusCodeExpected = 204) { | 326 | function verifyEmail (url: string, userId: number, verificationString: string, isPendingEmail = false, statusCodeExpected = 204) { |
297 | const path = '/api/v1/users/' + userId + '/verify-email' | 327 | const path = '/api/v1/users/' + userId + '/verify-email' |
298 | 328 | ||
299 | return makePostBodyRequest({ | 329 | return makePostBodyRequest({ |
300 | url, | 330 | url, |
301 | path, | 331 | path, |
302 | fields: { verificationString }, | 332 | fields: { |
333 | verificationString, | ||
334 | isPendingEmail | ||
335 | }, | ||
303 | statusCodeExpected | 336 | statusCodeExpected |
304 | }) | 337 | }) |
305 | } | 338 | } |
@@ -312,6 +345,7 @@ export { | |||
312 | getMyUserInformation, | 345 | getMyUserInformation, |
313 | getMyUserVideoRating, | 346 | getMyUserVideoRating, |
314 | deleteMe, | 347 | deleteMe, |
348 | registerUserWithChannel, | ||
315 | getMyUserVideoQuotaUsed, | 349 | getMyUserVideoQuotaUsed, |
316 | getUsersList, | 350 | getUsersList, |
317 | getUsersListPaginationAndSort, | 351 | getUsersListPaginationAndSort, |