From ad4a8a1cca1049f600ebcdce9260c1021cd821a5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 18 Feb 2017 09:29:59 +0100 Subject: Add email to users --- server/tests/api/check-params/pods.js | 24 ++++++++++++++++++++- server/tests/api/check-params/users.js | 39 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) (limited to 'server/tests/api/check-params') diff --git a/server/tests/api/check-params/pods.js b/server/tests/api/check-params/pods.js index 8d52b69b1..22cbdb30f 100644 --- a/server/tests/api/check-params/pods.js +++ b/server/tests/api/check-params/pods.js @@ -39,7 +39,7 @@ describe('Test pods API validators', function () { ], done) }) - describe('When making friends', function () { + describe('When managing friends', function () { let userAccessToken = null before(function (done) { @@ -156,13 +156,32 @@ describe('Test pods API validators', function () { it('Should fail without public key', function (done) { const data = { + email: 'testexample.com', host: 'coucou.com' } requestsUtils.makePostBodyRequest(server.url, path, null, data, done) }) + it('Should fail without an email', function (done) { + const data = { + host: 'coucou.com', + publicKey: 'mysuperpublickey' + } + requestsUtils.makePostBodyRequest(server.url, path, null, data, done) + }) + + it('Should fail without an invalid email', function (done) { + const data = { + host: 'coucou.com', + email: 'testexample.com', + publicKey: 'mysuperpublickey' + } + requestsUtils.makePostBodyRequest(server.url, path, null, data, done) + }) + it('Should fail without an host', function (done) { const data = { + email: 'testexample.com', publicKey: 'mysuperpublickey' } requestsUtils.makePostBodyRequest(server.url, path, null, data, done) @@ -171,6 +190,7 @@ describe('Test pods API validators', function () { it('Should fail with an incorrect host', function (done) { const data = { host: 'http://coucou.com', + email: 'testexample.com', publicKey: 'mysuperpublickey' } requestsUtils.makePostBodyRequest(server.url, path, null, data, function () { @@ -185,6 +205,7 @@ describe('Test pods API validators', function () { it('Should succeed with the correct parameters', function (done) { const data = { host: 'coucou.com', + email: 'test@example.com', publicKey: 'mysuperpublickey' } requestsUtils.makePostBodyRequest(server.url, path, null, data, done, 200) @@ -193,6 +214,7 @@ describe('Test pods API validators', function () { it('Should fail with a host that already exists', function (done) { const data = { host: 'coucou.com', + email: 'test@example.com', publicKey: 'mysuperpublickey' } requestsUtils.makePostBodyRequest(server.url, path, null, data, done, 409) diff --git a/server/tests/api/check-params/users.js b/server/tests/api/check-params/users.js index c1fcf34a4..debf63cf6 100644 --- a/server/tests/api/check-params/users.js +++ b/server/tests/api/check-params/users.js @@ -92,6 +92,7 @@ describe('Test users API validators', function () { it('Should fail with a too small username', function (done) { const data = { username: 'ji', + email: 'test@example.com', password: 'mysuperpassword' } @@ -101,6 +102,7 @@ describe('Test users API validators', function () { it('Should fail with a too long username', function (done) { const data = { username: 'mysuperusernamewhichisverylong', + email: 'test@example.com', password: 'mysuperpassword' } @@ -110,6 +112,26 @@ describe('Test users API validators', function () { it('Should fail with an incorrect username', function (done) { const data = { username: 'my username', + email: 'test@example.com', + password: 'mysuperpassword' + } + + requestsUtils.makePostBodyRequest(server.url, path, server.accessToken, data, done) + }) + + it('Should fail with a missing email', function (done) { + const data = { + username: 'ji', + password: 'mysuperpassword' + } + + requestsUtils.makePostBodyRequest(server.url, path, server.accessToken, data, done) + }) + + it('Should fail with an invalid email', function (done) { + const data = { + username: 'mysuperusernamewhichisverylong', + email: 'testexample.com', password: 'mysuperpassword' } @@ -119,6 +141,7 @@ describe('Test users API validators', function () { it('Should fail with a too small password', function (done) { const data = { username: 'myusername', + email: 'test@example.com', password: 'bla' } @@ -128,6 +151,7 @@ describe('Test users API validators', function () { it('Should fail with a too long password', function (done) { const data = { username: 'myusername', + email: 'test@example.com', password: 'my super long password which is very very very very very very very very very very very very very very' + 'very very very very very very very very very very very very very very very veryv very very very very' + 'very very very very very very very very very very very very very very very very very very very very long' @@ -139,6 +163,7 @@ describe('Test users API validators', function () { it('Should fail with an non authenticated user', function (done) { const data = { username: 'myusername', + email: 'test@example.com', password: 'my super password' } @@ -148,6 +173,17 @@ describe('Test users API validators', function () { it('Should fail if we add a user with the same username', function (done) { const data = { username: 'user1', + email: 'test@example.com', + password: 'my super password' + } + + requestsUtils.makePostBodyRequest(server.url, path, server.accessToken, data, done, 409) + }) + + it('Should fail if we add a user with the same email', function (done) { + const data = { + username: 'myusername', + email: 'user1@example.com', password: 'my super password' } @@ -157,6 +193,7 @@ describe('Test users API validators', function () { it('Should succeed with the correct params', function (done) { const data = { username: 'user2', + email: 'test@example.com', password: 'my super password' } @@ -166,6 +203,7 @@ describe('Test users API validators', function () { it('Should fail with a non admin user', function (done) { server.user = { username: 'user1', + email: 'test@example.com', password: 'my super password' } @@ -176,6 +214,7 @@ describe('Test users API validators', function () { const data = { username: 'user3', + email: 'test@example.com', password: 'my super password' } -- cgit v1.2.3