- fields: baseCorrectParams,
- statusCodeExpected: 200
- })
- })
-
- it('Should fail with a non admin user', async function () {
- const user = {
- username: 'user1',
- password: 'my super password'
- }
- userAccessToken = await userLogin(server, user)
-
- const fields = {
- username: 'user3',
- email: 'test@example.com',
- password: 'my super password',
- videoQuota: 42000000
- }
- await makePostBodyRequest({ url: server.url, path, token: userAccessToken, fields, statusCodeExpected: 403 })
- })
- })
-
- describe('When updating my account', function () {
- it('Should fail with an invalid email attribute', async function () {
- const fields = {
- email: 'blabla'
- }
-
- await makePutBodyRequest({ url: server.url, path: path + 'me', 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 + 'me', token: userAccessToken, 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 + '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 autoPlayVideo attribute', async function () {
- const fields = {
- autoPlayVideo: -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'
- }
-
- await makePutBodyRequest({ url: server.url, path: path + 'me', token: 'super token', fields, statusCodeExpected: 401 })
- })
-
- it('Should fail with a too long description', async function () {
- const fields = {
- description: 'super'.repeat(201)
- }
-
- await makePutBodyRequest({ url: server.url, path: path + 'me', token: userAccessToken, fields })
- })
-
- 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,
- email: 'super_email@example.com'
- }
-
- 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 () {
- it('Should fail without an incorrect input file', async function () {
- const fields = {}
- const attaches = {
- 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'video_short.mp4')
- }
- await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
- })
-
- it('Should fail with a big file', async function () {
- const fields = {}
- const attaches = {
- 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar-big.png')
- }
- await makeUploadRequest({ url: server.url, path: path + '/me/avatar/pick', token: server.accessToken, fields, attaches })
- })
-
- it('Should fail with an unauthenticated user', async function () {
- const fields = {}
- const attaches = {
- 'avatarfile': join(__dirname, '..', '..', 'fixtures', 'avatar.png')
- }
- await makeUploadRequest({
- url: server.url,
- path: path + '/me/avatar/pick',