aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/users.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/check-params/users.js')
-rw-r--r--server/tests/api/check-params/users.js39
1 files changed, 39 insertions, 0 deletions
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 () {
92 it('Should fail with a too small username', function (done) { 92 it('Should fail with a too small username', function (done) {
93 const data = { 93 const data = {
94 username: 'ji', 94 username: 'ji',
95 email: 'test@example.com',
95 password: 'mysuperpassword' 96 password: 'mysuperpassword'
96 } 97 }
97 98
@@ -101,6 +102,7 @@ describe('Test users API validators', function () {
101 it('Should fail with a too long username', function (done) { 102 it('Should fail with a too long username', function (done) {
102 const data = { 103 const data = {
103 username: 'mysuperusernamewhichisverylong', 104 username: 'mysuperusernamewhichisverylong',
105 email: 'test@example.com',
104 password: 'mysuperpassword' 106 password: 'mysuperpassword'
105 } 107 }
106 108
@@ -110,6 +112,26 @@ describe('Test users API validators', function () {
110 it('Should fail with an incorrect username', function (done) { 112 it('Should fail with an incorrect username', function (done) {
111 const data = { 113 const data = {
112 username: 'my username', 114 username: 'my username',
115 email: 'test@example.com',
116 password: 'mysuperpassword'
117 }
118
119 requestsUtils.makePostBodyRequest(server.url, path, server.accessToken, data, done)
120 })
121
122 it('Should fail with a missing email', function (done) {
123 const data = {
124 username: 'ji',
125 password: 'mysuperpassword'
126 }
127
128 requestsUtils.makePostBodyRequest(server.url, path, server.accessToken, data, done)
129 })
130
131 it('Should fail with an invalid email', function (done) {
132 const data = {
133 username: 'mysuperusernamewhichisverylong',
134 email: 'testexample.com',
113 password: 'mysuperpassword' 135 password: 'mysuperpassword'
114 } 136 }
115 137
@@ -119,6 +141,7 @@ describe('Test users API validators', function () {
119 it('Should fail with a too small password', function (done) { 141 it('Should fail with a too small password', function (done) {
120 const data = { 142 const data = {
121 username: 'myusername', 143 username: 'myusername',
144 email: 'test@example.com',
122 password: 'bla' 145 password: 'bla'
123 } 146 }
124 147
@@ -128,6 +151,7 @@ describe('Test users API validators', function () {
128 it('Should fail with a too long password', function (done) { 151 it('Should fail with a too long password', function (done) {
129 const data = { 152 const data = {
130 username: 'myusername', 153 username: 'myusername',
154 email: 'test@example.com',
131 password: 'my super long password which is very very very very very very very very very very very very very very' + 155 password: 'my super long password which is very very very very very very very very very very very very very very' +
132 'very very very very very very very very very very very very very very very veryv very very very very' + 156 'very very very very very very very very very very very very very very very veryv very very very very' +
133 'very very very very very very very very very very very very very very very very very very very very long' 157 '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 () {
139 it('Should fail with an non authenticated user', function (done) { 163 it('Should fail with an non authenticated user', function (done) {
140 const data = { 164 const data = {
141 username: 'myusername', 165 username: 'myusername',
166 email: 'test@example.com',
142 password: 'my super password' 167 password: 'my super password'
143 } 168 }
144 169
@@ -148,6 +173,17 @@ describe('Test users API validators', function () {
148 it('Should fail if we add a user with the same username', function (done) { 173 it('Should fail if we add a user with the same username', function (done) {
149 const data = { 174 const data = {
150 username: 'user1', 175 username: 'user1',
176 email: 'test@example.com',
177 password: 'my super password'
178 }
179
180 requestsUtils.makePostBodyRequest(server.url, path, server.accessToken, data, done, 409)
181 })
182
183 it('Should fail if we add a user with the same email', function (done) {
184 const data = {
185 username: 'myusername',
186 email: 'user1@example.com',
151 password: 'my super password' 187 password: 'my super password'
152 } 188 }
153 189
@@ -157,6 +193,7 @@ describe('Test users API validators', function () {
157 it('Should succeed with the correct params', function (done) { 193 it('Should succeed with the correct params', function (done) {
158 const data = { 194 const data = {
159 username: 'user2', 195 username: 'user2',
196 email: 'test@example.com',
160 password: 'my super password' 197 password: 'my super password'
161 } 198 }
162 199
@@ -166,6 +203,7 @@ describe('Test users API validators', function () {
166 it('Should fail with a non admin user', function (done) { 203 it('Should fail with a non admin user', function (done) {
167 server.user = { 204 server.user = {
168 username: 'user1', 205 username: 'user1',
206 email: 'test@example.com',
169 password: 'my super password' 207 password: 'my super password'
170 } 208 }
171 209
@@ -176,6 +214,7 @@ describe('Test users API validators', function () {
176 214
177 const data = { 215 const data = {
178 username: 'user3', 216 username: 'user3',
217 email: 'test@example.com',
179 password: 'my super password' 218 password: 'my super password'
180 } 219 }
181 220