]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/utils/users/users.ts
Add ability to set video thumbnail/preview
[github/Chocobozzz/PeerTube.git] / server / tests / utils / users / users.ts
index 12945a805bb3404900eaadbd55991ccbd4f9085d..3c9d4624642b2154186b90183aa91d74a41285c9 100644 (file)
@@ -1,6 +1,6 @@
 import { isAbsolute, join } from 'path'
 import * as request from 'supertest'
-import { makePostUploadRequest, makePutBodyRequest } from '../'
+import { makePostBodyRequest, makeUploadRequest, makePutBodyRequest } from '../'
 
 import { UserRole } from '../../../../shared/index'
 
@@ -11,7 +11,7 @@ function createUser (
   password: string,
   videoQuota = 1000000,
   role: UserRole = UserRole.USER,
-  specialStatus = 204
+  specialStatus = 200
 ) {
   const path = '/api/v1/users'
   const body = {
@@ -162,7 +162,7 @@ function updateMyAvatar (options: {
     filePath = join(__dirname, '..', '..', 'api', 'fixtures', options.fixture)
   }
 
-  return makePostUploadRequest({
+  return makeUploadRequest({
     url: options.url,
     path,
     token: options.accessToken,
@@ -196,6 +196,28 @@ function updateUser (options: {
   })
 }
 
+function askResetPassword (url: string, email: string) {
+  const path = '/api/v1/users/ask-reset-password'
+
+  return makePostBodyRequest({
+    url,
+    path,
+    fields: { email },
+    statusCodeExpected: 204
+  })
+}
+
+function resetPassword (url: string, userId: number, verificationString: string, password: string, statusCodeExpected = 204) {
+  const path = '/api/v1/users/' + userId + '/reset-password'
+
+  return makePostBodyRequest({
+    url,
+    path,
+    fields: { password, verificationString },
+    statusCodeExpected
+  })
+}
+
 // ---------------------------------------------------------------------------
 
 export {
@@ -210,5 +232,7 @@ export {
   updateUser,
   updateMyUser,
   getUserInformation,
+  askResetPassword,
+  resetPassword,
   updateMyAvatar
 }