aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils/users
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils/users')
-rw-r--r--shared/extra-utils/users/accounts.ts4
-rw-r--r--shared/extra-utils/users/user-notifications.ts2
-rw-r--r--shared/extra-utils/users/users.ts39
3 files changed, 36 insertions, 9 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
42async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: number) { 42async 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..0f2f0ae15 100644
--- a/shared/extra-utils/users/users.ts
+++ b/shared/extra-utils/users/users.ts
@@ -1,10 +1,11 @@
1import * as request from 'supertest' 1import * as request from 'supertest'
2import { makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests' 2import { makeGetRequest, makePostBodyRequest, makePutBodyRequest, updateAvatarRequest } from '../requests/requests'
3 3
4import { UserRole } from '../../index' 4import { UserCreate, UserRole } from '../../index'
5import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type' 5import { NSFWPolicyType } from '../../models/videos/nsfw-policy.type'
6import { ServerInfo, userLogin } from '..' 6import { ServerInfo, userLogin } from '..'
7import { UserAdminFlag } from '../../models/users/user-flag.model' 7import { UserAdminFlag } from '../../models/users/user-flag.model'
8import { UserRegister } from '../../models/users/user-register.model'
8 9
9type CreateUserArgs = { url: string, 10type CreateUserArgs = { url: string,
10 accessToken: string, 11 accessToken: string,
@@ -70,6 +71,27 @@ function registerUser (url: string, username: string, password: string, specialS
70 .expect(specialStatus) 71 .expect(specialStatus)
71} 72}
72 73
74function registerUserWithChannel (options: {
75 url: string,
76 user: { username: string, password: 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 return makePostBodyRequest({
88 url: options.url,
89 path,
90 fields: body,
91 statusCodeExpected: 204
92 })
93}
94
73function getMyUserInformation (url: string, accessToken: string, specialStatus = 200) { 95function getMyUserInformation (url: string, accessToken: string, specialStatus = 200) {
74 const path = '/api/v1/users/me' 96 const path = '/api/v1/users/me'
75 97
@@ -138,12 +160,16 @@ function getUsersList (url: string, accessToken: string) {
138function getUsersListPaginationAndSort (url: string, accessToken: string, start: number, count: number, sort: string, search?: string) { 160function getUsersListPaginationAndSort (url: string, accessToken: string, start: number, count: number, sort: string, search?: string) {
139 const path = '/api/v1/users' 161 const path = '/api/v1/users'
140 162
163 const query = {
164 start,
165 count,
166 sort,
167 search
168 }
169
141 return request(url) 170 return request(url)
142 .get(path) 171 .get(path)
143 .query({ start }) 172 .query(query)
144 .query({ count })
145 .query({ sort })
146 .query({ search })
147 .set('Accept', 'application/json') 173 .set('Accept', 'application/json')
148 .set('Authorization', 'Bearer ' + accessToken) 174 .set('Authorization', 'Bearer ' + accessToken)
149 .expect(200) 175 .expect(200)
@@ -312,6 +338,7 @@ export {
312 getMyUserInformation, 338 getMyUserInformation,
313 getMyUserVideoRating, 339 getMyUserVideoRating,
314 deleteMe, 340 deleteMe,
341 registerUserWithChannel,
315 getMyUserVideoQuotaUsed, 342 getMyUserVideoQuotaUsed,
316 getUsersList, 343 getUsersList,
317 getUsersListPaginationAndSort, 344 getUsersListPaginationAndSort,