- it('Should succeed with the correct params', async function () {
- const fields = {
- email: 'email@example.com',
- emailVerified: true,
- videoQuota: 42,
- role: UserRole.USER
- }
-
- await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 })
- })
- })
-
- describe('When getting my information', function () {
- it('Should fail with a non authenticated user', async function () {
- await getMyUserInformation(server.url, 'fake_token', 401)
- })
-
- it('Should success with the correct parameters', async function () {
- await getMyUserInformation(server.url, userAccessToken)
- })
- })
-
- describe('When getting my video rating', function () {
- it('Should fail with a non authenticated user', async function () {
- await getMyUserVideoRating(server.url, 'fake_token', videoId, 401)
- })
-
- it('Should fail with an incorrect video uuid', async function () {
- await getMyUserVideoRating(server.url, server.accessToken, 'blabla', 400)
- })
-
- it('Should fail with an unknown video', async function () {
- await getMyUserVideoRating(server.url, server.accessToken, '4da6fde3-88f7-4d16-b119-108df5630b06', 404)
- })
-
- it('Should succeed with the correct parameters', async function () {
- await getMyUserVideoRating(server.url, server.accessToken, videoId)
- })
- })
-
- 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)
- await blockUser(server.url, 'blabla', server.accessToken, 400)
- await unblockUser(server.url, 'blabla', server.accessToken, 400)
- })
-
- it('Should fail with the root user', async function () {
- await removeUser(server.url, rootId, server.accessToken, 400)
- await blockUser(server.url, rootId, server.accessToken, 400)
- await unblockUser(server.url, rootId, server.accessToken, 400)
- })
-
- it('Should return 404 with a non existing id', async function () {
- await removeUser(server.url, 4545454, server.accessToken, 404)
- await blockUser(server.url, 4545454, server.accessToken, 404)
- await unblockUser(server.url, 4545454, server.accessToken, 404)
- })
-
- it('Should fail with a non admin user', async function () {
- await removeUser(server.url, userId, userAccessToken, 403)
- await blockUser(server.url, userId, userAccessToken, 403)
- await unblockUser(server.url, userId, userAccessToken, 403)
- })
- })
-
- describe('When deleting our account', function () {
- it('Should fail with with the root account', async function () {
- await deleteMe(server.url, server.accessToken, 400)
- })
- })
-
- describe('When register a new user', function () {
- const registrationPath = path + '/register'
- const baseCorrectParams = {
- username: 'user3',
- email: 'test3@example.com',
- password: 'my super password'
- }
-
- it('Should fail with a too small username', async function () {
- const fields = immutableAssign(baseCorrectParams, { username: '' })