+ 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 succeed with the correct params', async function () {
+ const fields = {}
+ const attaches = {
+ 'avatarfile': join(__dirname, '..', 'fixtures', 'avatar.png')
+ }
+ await makeUploadRequest({
+ url: server.url,
+ path: path + '/me/avatar/pick',
+ token: server.accessToken,
+ fields,
+ attaches,
+ statusCodeExpected: 200
+ })
+ })
+ })
+
+ describe('When getting a user', function () {
+ before(async function () {
+ const res = await getUsersList(server.url, server.accessToken)
+
+ userId = res.body.data[1].id
+ })
+
+ it('Should fail with an non authenticated user', async function () {
+ await makeGetRequest({ url: server.url, path: path + userId, token: 'super token', statusCodeExpected: 401 })
+ })
+
+ it('Should fail with a non admin user', async function () {
+ await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 403 })
+ })
+
+ it('Should succeed with the correct params', async function () {
+ await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: 200 })
+ })
+ })
+