import { isAbsolute, join } from 'path'
import * as request from 'supertest'
-import { makePostUploadRequest, makePutBodyRequest } from '../'
+import { makePostBodyRequest, makeUploadRequest, makePutBodyRequest } from '../'
import { UserRole } from '../../../../shared/index'
password: string,
videoQuota = 1000000,
role: UserRole = UserRole.USER,
- specialStatus = 204
+ specialStatus = 200
) {
const path = '/api/v1/users'
const body = {
.expect('Content-Type', /json/)
}
+function getMyUserVideoQuotaUsed (url: string, accessToken: string, specialStatus = 200) {
+ const path = '/api/v1/users/me/video-quota-used'
+
+ return request(url)
+ .get(path)
+ .set('Accept', 'application/json')
+ .set('Authorization', 'Bearer ' + accessToken)
+ .expect(specialStatus)
+ .expect('Content-Type', /json/)
+}
+
function getUserInformation (url: string, accessToken: string, userId: number) {
const path = '/api/v1/users/' + userId
filePath = join(__dirname, '..', '..', 'api', 'fixtures', options.fixture)
}
- return makePostUploadRequest({
+ return makeUploadRequest({
url: options.url,
path,
token: options.accessToken,
})
}
+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 {
registerUser,
getMyUserInformation,
getMyUserVideoRating,
+ getMyUserVideoQuotaUsed,
getUsersList,
getUsersListPaginationAndSort,
removeUser,
updateUser,
updateMyUser,
getUserInformation,
+ askResetPassword,
+ resetPassword,
updateMyAvatar
}