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 long username', async function () {
- const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(11) })
+ const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
})
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',
await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
})
+ it('Should fail with a too small password', async function () {
+ const fields = {
+ currentPassword: 'my super password',
+ password: 'bla'
+ }
+
+ await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields })
+ })
+
+ 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 + userId, token: server.accessToken, fields })
+ })
+
it('Should fail with an non authenticated user', async function () {
const fields = {
videoQuota: 42
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)
})
})
})
})
+ describe('When retrieving my global ratings', function () {
+ const path = '/api/v1/accounts/user1/ratings'
+
+ it('Should fail with a bad start pagination', async function () {
+ await checkBadStartPagination(server.url, path, userAccessToken)
+ })
+
+ it('Should fail with a bad count pagination', async function () {
+ await checkBadCountPagination(server.url, path, userAccessToken)
+ })
+
+ it('Should fail with an incorrect sort', async function () {
+ await checkBadSortPagination(server.url, path, userAccessToken)
+ })
+
+ it('Should fail with a unauthenticated user', async function () {
+ await makeGetRequest({ url: server.url, path, statusCodeExpected: 401 })
+ })
+
+ it('Should fail with a another user', async function () {
+ await makeGetRequest({ url: server.url, path, token: server.accessToken, statusCodeExpected: 403 })
+ })
+
+ it('Should fail with a bad type', async function () {
+ await makeGetRequest({ url: server.url, path, token: userAccessToken, query: { rating: 'toto ' }, statusCodeExpected: 400 })
+ })
+
+ it('Should succeed with the correct params', async function () {
+ await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 200 })
+ })
+ })
+
describe('When blocking/unblocking/removing user', function () {
it('Should fail with an incorrect id', async function () {
await removeUser(server.url, 'blabla', server.accessToken, 400)
})
it('Should fail with a too long username', async function () {
- const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(11) })
+ const fields = immutableAssign(baseCorrectParams, { username: 'super'.repeat(50) })
await makePostBodyRequest({ url: server.url, path: registrationPath, token: server.accessToken, fields })
})