createUser, flushTests, getMyUserInformation, getMyUserVideoRating, getUsersList, immutableAssign, killallServers, makeGetRequest,
makePostBodyRequest, makeUploadRequest, makePutBodyRequest, registerUser, removeUser, runServer, ServerInfo, setAccessTokensToServers,
updateUser, uploadVideo, userLogin, deleteMe, unblockUser, blockUser
-} from '../../utils'
-import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params'
-import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../utils/videos/video-imports'
+} from '../../../../shared/utils'
+import {
+ checkBadCountPagination,
+ checkBadSortPagination,
+ checkBadStartPagination
+} from '../../../../shared/utils/requests/check-api-params'
+import { getMagnetURI, getMyVideoImports, getYoutubeVideoUrl, importVideo } from '../../../../shared/utils/videos/video-imports'
import { VideoPrivacy } from '../../../../shared/models/videos'
-import { waitJobs } from '../../utils/server/jobs'
+import { waitJobs } from '../../../../shared/utils/server/jobs'
import { expect } from 'chai'
describe('Test users API validators', function () {
}
it('Should fail with a too small username', async function () {
- const fields = immutableAssign(baseCorrectParams, { username: 'fi' })
+ const fields = immutableAssign(baseCorrectParams, { username: '' })
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
})
it('Should fail with a too long username', async function () {
- const fields = immutableAssign(baseCorrectParams, { username: 'my_super_username_which_is_very_long' })
+ const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
})
it('Should fail with a too small password', async function () {
const fields = {
+ currentPassword: 'my super password',
password: 'bla'
}
it('Should fail with a too long password', async function () {
const fields = {
+ currentPassword: 'my super password',
+ password: 'super'.repeat(61)
+ }
+
+ await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
+ })
+
+ it('Should fail without the current password', async function () {
+ const fields = {
+ currentPassword: 'my super password',
password: 'super'.repeat(61)
}
await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
})
+ it('Should fail with an invalid current password', async function () {
+ const fields = {
+ currentPassword: 'my super password fail',
+ password: 'super'.repeat(61)
+ }
+
+ await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 401 })
+ })
+
it('Should fail with an invalid NSFW policy attribute', async function () {
const fields = {
nsfwPolicy: 'hello'
await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
})
+ it('Should fail with an invalid videosHistoryEnabled attribute', async function () {
+ const fields = {
+ videosHistoryEnabled: -1
+ }
+
+ await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
+ })
+
it('Should fail with an non authenticated user', async function () {
const fields = {
+ currentPassword: 'my super password',
password: 'my super password'
}
it('Should fail with a too long description', async function () {
const fields = {
- description: 'super'.repeat(60)
+ description: 'super'.repeat(201)
}
await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
})
- it('Should succeed with the correct params', async function () {
+ it('Should succeed to change password with the correct params', async function () {
const fields = {
+ currentPassword: 'my super password',
password: 'my super password',
nsfwPolicy: 'blur',
autoPlayVideo: false,
await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 })
})
+
+ it('Should succeed without password change with the correct params', async function () {
+ const fields = {
+ nsfwPolicy: 'blur',
+ autoPlayVideo: false,
+ email: 'super_email@example.com'
+ }
+
+ await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields, statusCodeExpected: 204 })
+ })
})
describe('When updating my avatar', function () {
await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
})
+ it('Should fail with an invalid emailVerified attribute', async function () {
+ const fields = {
+ emailVerified: 'yes'
+ }
+
+ await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
+ })
+
it('Should fail with an invalid videoQuota attribute', async function () {
const fields = {
videoQuota: -90
it('Should succeed with the correct params', async function () {
const fields = {
email: 'email@example.com',
+ emailVerified: true,
videoQuota: 42,
- role: UserRole.MODERATOR
+ role: UserRole.USER
}
await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 })
- userAccessToken = await userLogin(server, user)
})
})
}
it('Should fail with a too small username', async function () {
- const fields = immutableAssign(baseCorrectParams, { username: 'ji' })
+ const fields = immutableAssign(baseCorrectParams, { username: '' })
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
})
it('Should fail with a too long username', async function () {
- const fields = immutableAssign(baseCorrectParams, { username: 'my_super_username_which_is_very_long' })
+ const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
})