+ const fields = immutableAssign(baseCorrectParams, { password: 'bla' })
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should fail with a too long password', async function () {
+ const fields = immutableAssign(baseCorrectParams, { password: 'super'.repeat(61) })
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should fail with an non authenticated user', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ path,
+ token: 'super token',
+ fields: baseCorrectParams,
+ statusCodeExpected: 401
+ })
+ })
+
+ it('Should fail if we add a user with the same username', async function () {
+ const fields = immutableAssign(baseCorrectParams, { username: 'user1' })
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 })
+ })
+
+ it('Should fail if we add a user with the same email', async function () {
+ const fields = immutableAssign(baseCorrectParams, { email: 'user1@example.com' })
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields, statusCodeExpected: 409 })
+ })
+
+ it('Should fail without a videoQuota', async function () {
+ const fields = omit(baseCorrectParams, 'videoQuota')
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should fail with an invalid videoQuota', async function () {
+ const fields = immutableAssign(baseCorrectParams, { videoQuota: -5 })
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should fail without a user role', async function () {
+ const fields = omit(baseCorrectParams, 'role')
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should fail with an invalid user role', async function () {
+ const fields = immutableAssign(baseCorrectParams, { role: 88989 })
+
+ await makePostBodyRequest({ url: server.url, path, token: server.accessToken, fields })
+ })
+
+ it('Should fail with a "peertube" username', async function () {
+ const fields = immutableAssign(baseCorrectParams, { username: 'peertube' })
+
+ await makePostBodyRequest({
+ url: server.url,
+ path,
+ token: server.accessToken,
+ fields,
+ statusCodeExpected: 409
+ })
+ })
+
+ it('Should succeed with the correct params', async function () {
+ await makePostBodyRequest({
+ url: server.url,
+ path,
+ token: server.accessToken,
+ 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)
+