aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-02-18 09:29:59 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-02-18 09:29:59 +0100
commitad4a8a1cca1049f600ebcdce9260c1021cd821a5 (patch)
treeca8ffba899b024d56d1bd7846f61aecae0821c82 /server/tests/api/check-params
parent5d67f289df4a68e35ad7e0af3c601c7db0dc7586 (diff)
downloadPeerTube-ad4a8a1cca1049f600ebcdce9260c1021cd821a5.tar.gz
PeerTube-ad4a8a1cca1049f600ebcdce9260c1021cd821a5.tar.zst
PeerTube-ad4a8a1cca1049f600ebcdce9260c1021cd821a5.zip
Add email to users
Diffstat (limited to 'server/tests/api/check-params')
-rw-r--r--server/tests/api/check-params/pods.js24
-rw-r--r--server/tests/api/check-params/users.js39
2 files changed, 62 insertions, 1 deletions
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 () {
39 ], done) 39 ], done)
40 }) 40 })
41 41
42 describe('When making friends', function () { 42 describe('When managing friends', function () {
43 let userAccessToken = null 43 let userAccessToken = null
44 44
45 before(function (done) { 45 before(function (done) {
@@ -156,13 +156,32 @@ describe('Test pods API validators', function () {
156 156
157 it('Should fail without public key', function (done) { 157 it('Should fail without public key', function (done) {
158 const data = { 158 const data = {
159 email: 'testexample.com',
159 host: 'coucou.com' 160 host: 'coucou.com'
160 } 161 }
161 requestsUtils.makePostBodyRequest(server.url, path, null, data, done) 162 requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
162 }) 163 })
163 164
165 it('Should fail without an email', function (done) {
166 const data = {
167 host: 'coucou.com',
168 publicKey: 'mysuperpublickey'
169 }
170 requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
171 })
172
173 it('Should fail without an invalid email', function (done) {
174 const data = {
175 host: 'coucou.com',
176 email: 'testexample.com',
177 publicKey: 'mysuperpublickey'
178 }
179 requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
180 })
181
164 it('Should fail without an host', function (done) { 182 it('Should fail without an host', function (done) {
165 const data = { 183 const data = {
184 email: 'testexample.com',
166 publicKey: 'mysuperpublickey' 185 publicKey: 'mysuperpublickey'
167 } 186 }
168 requestsUtils.makePostBodyRequest(server.url, path, null, data, done) 187 requestsUtils.makePostBodyRequest(server.url, path, null, data, done)
@@ -171,6 +190,7 @@ describe('Test pods API validators', function () {
171 it('Should fail with an incorrect host', function (done) { 190 it('Should fail with an incorrect host', function (done) {
172 const data = { 191 const data = {
173 host: 'http://coucou.com', 192 host: 'http://coucou.com',
193 email: 'testexample.com',
174 publicKey: 'mysuperpublickey' 194 publicKey: 'mysuperpublickey'
175 } 195 }
176 requestsUtils.makePostBodyRequest(server.url, path, null, data, function () { 196 requestsUtils.makePostBodyRequest(server.url, path, null, data, function () {
@@ -185,6 +205,7 @@ describe('Test pods API validators', function () {
185 it('Should succeed with the correct parameters', function (done) { 205 it('Should succeed with the correct parameters', function (done) {
186 const data = { 206 const data = {
187 host: 'coucou.com', 207 host: 'coucou.com',
208 email: 'test@example.com',
188 publicKey: 'mysuperpublickey' 209 publicKey: 'mysuperpublickey'
189 } 210 }
190 requestsUtils.makePostBodyRequest(server.url, path, null, data, done, 200) 211 requestsUtils.makePostBodyRequest(server.url, path, null, data, done, 200)
@@ -193,6 +214,7 @@ describe('Test pods API validators', function () {
193 it('Should fail with a host that already exists', function (done) { 214 it('Should fail with a host that already exists', function (done) {
194 const data = { 215 const data = {
195 host: 'coucou.com', 216 host: 'coucou.com',
217 email: 'test@example.com',
196 publicKey: 'mysuperpublickey' 218 publicKey: 'mysuperpublickey'
197 } 219 }
198 requestsUtils.makePostBodyRequest(server.url, path, null, data, done, 409) 220 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 () {
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