@tiledesk/tiledesk-server 2.10.15 → 2.10.16
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +6 -0
- package/app.js +2 -1
- package/models/request.js +8 -0
- package/package.json +4 -3
- package/pubmodules/activities/test/activityRoute.js +6 -2
- package/pubmodules/events/test/eventRoute.js +7 -3
- package/pubmodules/pubModulesManager.js +24 -0
- package/pubmodules/voice-twilio/index.js +6 -0
- package/pubmodules/voice-twilio/listener.js +59 -0
- package/routes/campaigns.js +1 -1
- package/routes/files.js +6 -4
- package/routes/images.js +0 -2
- package/routes/kb.js +7 -1
- package/routes/users.js +2 -2
- package/services/fileGridFsService.js +12 -10
- package/services/requestService.js +2 -1
- package/test/app-test.js +36 -1
- package/test/authentication.js +662 -796
- package/test/authenticationJwt.js +213 -315
- package/test/authorization.js +53 -72
- package/test/campaignsRoute.js +42 -47
- package/test/cannedRoute.js +30 -16
- package/test/departmentService.js +222 -274
- package/test/example.json +31 -1
- package/test/faqRoute.js +713 -622
- package/test/faqService.js +124 -159
- package/test/faqkbRoute.js +128 -100
- package/test/fileRoute.js +50 -46
- package/test/imageRoute.js +263 -254
- package/test/jwtRoute.js +128 -153
- package/test/kbRoute.js +40 -17
- package/test/kbsettingsRoute.js +78 -54
- package/test/keysRoute.js +6 -7
- package/test/labelRoute.js +591 -696
- package/test/labelService.js +40 -47
- package/test/leadService.js +100 -115
- package/test/logsRoute.js +13 -7
- package/test/messageRootRoute.js +112 -102
- package/test/messageRoute.js +1171 -1419
- package/test/messageService.js +41 -43
- package/test/openaiRoute.js +5 -1
- package/test/projectRoute.js +23 -4
- package/test/projectService.js +3 -1
- package/test/quoteManager.js +36 -13
- package/test/requestRoute.js +103 -72
- package/test/requestService.js +51 -51
- package/test/userRoute.js +37 -8
- package/test/userService.js +34 -31
- package/utils/promiseUtil.js +1 -1
package/test/authentication.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
//During the test the env variable is set to test
|
2
2
|
process.env.NODE_ENV = 'test';
|
3
3
|
process.env.ADMIN_EMAIL = "admin@tiledesk.com";
|
4
|
+
process.env.LOG_LEVEL = 'critical';
|
4
5
|
//var User = require('../models/user');
|
5
6
|
var projectService = require('../services/projectService');
|
6
7
|
var requestService = require('../services/requestService');
|
@@ -21,6 +22,8 @@ var jwt = require('jsonwebtoken');
|
|
21
22
|
|
22
23
|
var config = require('../config/database');
|
23
24
|
|
25
|
+
let log = false;
|
26
|
+
|
24
27
|
var mongoose = require('mongoose');
|
25
28
|
mongoose.connect(config.databasetest);
|
26
29
|
|
@@ -29,1041 +32,904 @@ chai.use(chaiHttp);
|
|
29
32
|
|
30
33
|
describe('Authentication', () => {
|
31
34
|
|
32
|
-
|
35
|
+
// mocha test/authentication.js --grep 'signinOk'
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
describe('/signin', () => {
|
37
38
|
|
38
|
-
it('signinOk', (done) => {
|
39
39
|
|
40
|
-
|
41
|
-
// this.timeout();
|
40
|
+
it('signinOk', (done) => {
|
42
41
|
|
43
|
-
|
44
|
-
|
42
|
+
var email = "test-signin-" + Date.now() + "@email.com";
|
43
|
+
var pwd = "pwd";
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
45
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
46
|
+
|
47
|
+
chai.request(server)
|
48
|
+
.post('/auth/signin')
|
49
|
+
.send({ "email": email, "password": pwd })
|
50
|
+
.end((err, res) => {
|
51
|
+
|
52
|
+
if (err) { console.error("err: ", err); }
|
53
|
+
if (log) { console.log("res.body", res.body); }
|
54
|
+
|
55
|
+
res.should.have.status(200);
|
56
|
+
res.body.should.be.a('object');
|
57
|
+
expect(res.body.success).to.equal(true);
|
58
|
+
expect(res.body.token).to.not.equal(null);
|
59
|
+
expect(res.body.user.email).to.equal(email);
|
60
|
+
expect(res.body.user.password).to.equal(undefined);
|
61
|
+
|
62
|
+
done();
|
63
|
+
});
|
64
|
+
|
65
|
+
});
|
66
|
+
});
|
63
67
|
|
64
|
-
|
68
|
+
|
69
|
+
it('signinkO', (done) => {
|
70
|
+
|
71
|
+
var email = "test-signinko-" + Date.now() + "@email.com";
|
72
|
+
var pwd = "pwd";
|
73
|
+
|
74
|
+
chai.request(server)
|
75
|
+
.post('/auth/signin')
|
76
|
+
.send({ "email": email, "password": pwd })
|
77
|
+
.end((err, res) => {
|
78
|
+
|
79
|
+
if (err) { console.error("err: ", err); }
|
80
|
+
if (log) { console.log("res.body", res.body); }
|
81
|
+
|
82
|
+
res.should.have.status(401);
|
83
|
+
|
84
|
+
done();
|
65
85
|
});
|
66
|
-
});
|
67
86
|
|
87
|
+
});
|
68
88
|
|
69
89
|
|
70
|
-
|
90
|
+
it('signinValidation', (done) => {
|
71
91
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
var email = "test-signinko-" + Date.now() + "@email.com";
|
76
|
-
var pwd = "pwd";
|
77
|
-
|
78
|
-
|
79
|
-
chai.request(server)
|
80
|
-
.post('/auth/signin' )
|
81
|
-
.send({"email":email, "password":pwd})
|
82
|
-
.end((err, res) => {
|
83
|
-
//console.log("res", res);
|
84
|
-
console.log("res.body", res.body);
|
85
|
-
res.should.have.status(401);
|
86
|
-
|
87
|
-
|
88
|
-
done();
|
89
|
-
});
|
90
|
-
|
91
|
-
|
92
|
-
});
|
93
|
-
|
92
|
+
var email = "test-signinko-" + Date.now() + "@email.com";
|
93
|
+
var pwd = "pwd";
|
94
94
|
|
95
|
+
chai.request(server)
|
96
|
+
.post('/auth/signin')
|
97
|
+
.send()
|
98
|
+
.end((err, res) => {
|
95
99
|
|
100
|
+
if (err) { console.error("err: ", err); }
|
101
|
+
if (log) { console.log("res.body", res.body); }
|
96
102
|
|
103
|
+
res.should.have.status(422);
|
97
104
|
|
105
|
+
done();
|
106
|
+
});
|
98
107
|
|
99
|
-
|
108
|
+
});
|
100
109
|
|
101
|
-
|
102
|
-
// this.timeout();
|
103
|
-
|
104
|
-
var email = "test-signinko-" + Date.now() + "@email.com";
|
105
|
-
var pwd = "pwd";
|
106
|
-
|
107
|
-
|
108
|
-
chai.request(server)
|
109
|
-
.post('/auth/signin' )
|
110
|
-
.send()
|
111
|
-
.end((err, res) => {
|
112
|
-
//console.log("res", res);
|
113
|
-
console.log("res.body", res.body);
|
114
|
-
res.should.have.status(422);
|
115
|
-
|
116
|
-
|
117
|
-
done();
|
118
|
-
});
|
119
|
-
|
120
|
-
|
121
|
-
});
|
122
|
-
|
123
110
|
|
124
|
-
|
111
|
+
// mocha test/authentication.js --grep 'signinLowercase'
|
112
|
+
it('signinLowercase', (done) => {
|
113
|
+
|
114
|
+
var email = "Test-SigninKO-" + Date.now() + "@email.com";
|
115
|
+
var pwd = "pwd";
|
125
116
|
|
126
|
-
|
117
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
127
118
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
119
|
+
chai.request(server)
|
120
|
+
.post('/auth/signin')
|
121
|
+
.send({ "email": email, "password": pwd })
|
122
|
+
.end((err, res) => {
|
123
|
+
|
124
|
+
if (err) { console.error("err: ", err); }
|
125
|
+
if (log) { console.log("res.body", res.body); }
|
126
|
+
|
127
|
+
res.should.have.status(200);
|
128
|
+
res.body.should.be.a('object');
|
129
|
+
expect(res.body.success).to.equal(true);
|
130
|
+
expect(res.body.token).to.not.equal(null);
|
131
|
+
expect(res.body.user.email).to.equal(email.toLowerCase());
|
132
|
+
expect(res.body.user.password).to.equal(undefined);
|
135
133
|
|
136
134
|
chai.request(server)
|
137
|
-
.
|
138
|
-
.
|
135
|
+
.get('/users/')
|
136
|
+
.auth(email, pwd)
|
139
137
|
.end((err, res) => {
|
140
|
-
|
138
|
+
|
139
|
+
if (err) { console.error("err: ", err); }
|
140
|
+
if (log) { console.log("res.body", res.body); }
|
141
|
+
|
141
142
|
res.should.have.status(200);
|
142
143
|
res.body.should.be.a('object');
|
143
|
-
expect(res.body.success).to.equal(true);
|
144
|
-
expect(res.body.token).to.not.equal(null);
|
145
|
-
expect(res.body.user.email).to.equal(email.toLowerCase());
|
146
|
-
expect(res.body.user.password).to.equal(undefined);
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
chai.request(server)
|
151
|
-
.get('/users/' )
|
152
|
-
.auth(email, pwd)
|
153
|
-
.end((err, res) => {
|
154
|
-
console.log("res.body", res.body);
|
155
|
-
res.should.have.status(200);
|
156
|
-
res.body.should.be.a('object');
|
157
|
-
|
158
|
-
done();
|
159
|
-
});
|
160
|
-
|
161
|
-
});
|
162
144
|
|
145
|
+
done();
|
163
146
|
});
|
164
|
-
|
165
|
-
});
|
166
147
|
});
|
167
|
-
|
168
|
-
|
169
|
-
});
|
148
|
+
});
|
149
|
+
});
|
170
150
|
|
151
|
+
});
|
171
152
|
|
153
|
+
describe('/signup', () => {
|
172
154
|
|
173
155
|
|
156
|
+
it('signupOk', (done) => {
|
174
157
|
|
158
|
+
var email = "test-signuook-" + Date.now() + "@email.com";
|
159
|
+
var pwd = "Pwd1234!";
|
175
160
|
|
161
|
+
chai.request(server)
|
162
|
+
.post('/auth/signup')
|
163
|
+
.send({ email: email, password: pwd, lastname: "lastname", firstname: "firstname", disableEmail: true }) // whi disableEmail true?
|
164
|
+
.end((err, res) => {
|
176
165
|
|
166
|
+
if (err) { console.error("err: ", err); }
|
167
|
+
if (log) { console.log("res.body", res.body); }
|
177
168
|
|
169
|
+
res.should.have.status(200);
|
170
|
+
res.body.should.be.a('object');
|
171
|
+
expect(res.body.success).to.equal(true);
|
172
|
+
expect(res.body.user.email).to.equal(email);
|
173
|
+
expect(res.body.user.password).to.equal(undefined);
|
178
174
|
|
179
|
-
|
180
|
-
|
181
|
-
|
175
|
+
done();
|
176
|
+
});
|
177
|
+
});
|
182
178
|
|
183
|
-
it('signupOk', (done) => {
|
184
179
|
|
185
|
-
|
186
|
-
// this.timeout();
|
180
|
+
// it('verifyemail', (done) => {
|
187
181
|
|
188
|
-
|
189
|
-
|
182
|
+
// let user_id = "670e55c8187b430e793d644e";
|
183
|
+
// let code = "4fx6e1hfcm2admb4a";
|
184
|
+
// chai.request(server)
|
185
|
+
// .put('/auth/verifyemail/' + user_id + '/' + code)
|
186
|
+
// .send({ emailVerified: true })
|
187
|
+
// .end((err, res) => {
|
190
188
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
.end((err, res) => {
|
196
|
-
//console.log("res", res);
|
197
|
-
console.log("res.body", res.body);
|
198
|
-
res.should.have.status(200);
|
199
|
-
res.body.should.be.a('object');
|
200
|
-
expect(res.body.success).to.equal(true);
|
201
|
-
expect(res.body.user.email).to.equal(email);
|
202
|
-
expect(res.body.user.password).to.equal(undefined);
|
203
|
-
|
204
|
-
done();
|
205
|
-
});
|
189
|
+
// console.error("err: ", err)
|
190
|
+
// console.log("res.body: ", res.body)
|
191
|
+
// done();
|
192
|
+
// })
|
206
193
|
|
207
|
-
|
208
|
-
|
209
|
-
});
|
210
194
|
|
211
195
|
|
212
|
-
|
196
|
+
// });
|
213
197
|
|
214
|
-
// let user_id = "670e55c8187b430e793d644e";
|
215
|
-
// let code = "4fx6e1hfcm2admb4a";
|
216
|
-
// chai.request(server)
|
217
|
-
// .put('/auth/verifyemail/' + user_id + '/' + code)
|
218
|
-
// .send({ emailVerified: true })
|
219
|
-
// .end((err, res) => {
|
220
198
|
|
221
|
-
// console.error("err: ", err)
|
222
|
-
// console.log("res.body: ", res.body)
|
223
|
-
// done();
|
224
|
-
// })
|
225
199
|
|
226
200
|
|
201
|
+
// it('signUpAdminNoVerificationEmail', (done) => {
|
227
202
|
|
228
|
-
|
203
|
+
// var email = "test-signup-" + Date.now() + "@email.com";
|
204
|
+
// var pwd = "pwd";
|
229
205
|
|
206
|
+
// chai.request(server)
|
207
|
+
// .post("/auth/signin")
|
208
|
+
// .send({ email: "admin@tiledesk.com", password: "adminadmin" })
|
209
|
+
// .end((err, res) => {
|
230
210
|
|
231
|
-
|
211
|
+
// // console.log("login with superadmin res.body: ", res.body)
|
212
|
+
// let superadmin_token = res.body.token;
|
232
213
|
|
233
|
-
|
214
|
+
// chai.request(server)
|
215
|
+
// .post("/auth/signup")
|
216
|
+
// .set('Authorization', superadmin_token)
|
217
|
+
// .send({ email: email, password: pwd, lastname: "lastname", firstname: "firstname", disableEmail: true })
|
218
|
+
// .end((err, res) => {
|
234
219
|
|
235
|
-
|
236
|
-
|
220
|
+
// // console.log("res.body: ", res.body);
|
221
|
+
// done();
|
222
|
+
// })
|
223
|
+
// })
|
237
224
|
|
238
|
-
// chai.request(server)
|
239
|
-
// .post("/auth/signin")
|
240
|
-
// .send({ email: "admin@tiledesk.com", password: "adminadmin" })
|
241
|
-
// .end((err, res) => {
|
242
225
|
|
243
|
-
|
244
|
-
// let superadmin_token = res.body.token;
|
226
|
+
// })
|
245
227
|
|
246
|
-
|
247
|
-
// .post("/auth/signup")
|
248
|
-
// .set('Authorization', superadmin_token)
|
249
|
-
// .send({ email: email, password: pwd, lastname: "lastname", firstname: "firstname", disableEmail: true })
|
250
|
-
// .end((err, res) => {
|
228
|
+
// mocha test/authentication.js --grep 'signupUpperCaseEmail'
|
251
229
|
|
252
|
-
// // console.log("res.body: ", res.body);
|
253
|
-
// done();
|
254
|
-
// })
|
255
|
-
// })
|
256
230
|
|
231
|
+
it('signupUpperCaseEmail', (done) => {
|
257
232
|
|
258
|
-
|
233
|
+
var now = Date.now();
|
234
|
+
var email = "test-signupUpperCaseEmail-" + now + "@email.com";
|
235
|
+
var pwd = "Pwd1234!";
|
259
236
|
|
260
|
-
|
237
|
+
chai.request(server)
|
238
|
+
.post('/auth/signup')
|
239
|
+
.send({ email: email, password: pwd, lastname: "lastname", firstname: "firstname", disableEmail: true })
|
240
|
+
.end((err, res) => {
|
261
241
|
|
242
|
+
if (err) { console.error("err: ", err); }
|
243
|
+
if (log) { console.log("res.body", res.body); }
|
262
244
|
|
263
|
-
|
245
|
+
res.should.have.status(200);
|
246
|
+
res.body.should.be.a('object');
|
247
|
+
expect(res.body.success).to.equal(true);
|
248
|
+
expect(res.body.user.email).to.equal("test-signupuppercaseemail-" + now + "@email.com");
|
249
|
+
expect(res.body.user.password).to.equal(undefined);
|
264
250
|
|
265
|
-
|
266
|
-
|
267
|
-
var now = Date.now();
|
268
|
-
var email = "test-signupUpperCaseEmail-" + now + "@email.com";
|
269
|
-
var pwd = "Pwd1234!";
|
270
|
-
|
271
|
-
|
272
|
-
chai.request(server)
|
273
|
-
.post('/auth/signup' )
|
274
|
-
.send({email:email, password:pwd, lastname:"lastname", firstname: "firstname", disableEmail: true})
|
275
|
-
.end((err, res) => {
|
276
|
-
//console.log("res", res);
|
277
|
-
console.log("res.body", res.body);
|
278
|
-
res.should.have.status(200);
|
279
|
-
res.body.should.be.a('object');
|
280
|
-
expect(res.body.success).to.equal(true);
|
281
|
-
expect(res.body.user.email).to.equal("test-signupuppercaseemail-" + now + "@email.com");
|
282
|
-
expect(res.body.user.password).to.equal(undefined);
|
283
|
-
|
284
|
-
done();
|
285
|
-
});
|
286
|
-
|
251
|
+
done();
|
252
|
+
});
|
287
253
|
});
|
288
254
|
|
289
|
-
|
255
|
+
// mocha test/authentication.js --grep 'signupkOWrongEmail'
|
256
|
+
it('signupkOWrongEmail', (done) => {
|
290
257
|
|
291
|
-
|
258
|
+
var email = "test-signuoOk-" + Date.now() + "@email";
|
259
|
+
var pwd = "Pwd1234!";
|
292
260
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
console.log("res.body", res.body);
|
306
|
-
res.should.have.status(422);
|
307
|
-
|
308
|
-
done();
|
309
|
-
});
|
310
|
-
|
311
|
-
|
312
|
-
|
261
|
+
chai.request(server)
|
262
|
+
.post('/auth/signup')
|
263
|
+
.send({ email: email, password: pwd, lastname: "lastname", firstname: "firstname", disableEmail: true })
|
264
|
+
.end((err, res) => {
|
265
|
+
|
266
|
+
if (err) { console.error("err: ", err); }
|
267
|
+
if (log) { console.log("res.body", res.body); }
|
268
|
+
|
269
|
+
res.should.have.status(422);
|
270
|
+
|
271
|
+
done();
|
272
|
+
});
|
313
273
|
});
|
314
274
|
|
315
275
|
|
316
|
-
// });
|
276
|
+
// });
|
277
|
+
|
278
|
+
|
279
|
+
|
317
280
|
|
318
281
|
|
319
282
|
|
320
283
|
|
321
|
-
describe('/signInAnonymously', () => {
|
322
|
-
|
323
|
-
|
324
284
|
|
325
|
-
it('signInAnonymouslyOk', (done) => {
|
326
285
|
|
327
|
-
|
328
|
-
var email = "test-signInAnonymouslyOk-" + Date.now() + "@email.com";
|
329
|
-
var pwd = "pwd";
|
330
286
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
});
|
291
|
+
|
292
|
+
describe('/signInAnonymously', () => {
|
293
|
+
|
294
|
+
|
295
|
+
it('signInAnonymouslyOk', (done) => {
|
296
|
+
|
297
|
+
var email = "test-signInAnonymouslyOk-" + Date.now() + "@email.com";
|
298
|
+
var pwd = "pwd";
|
299
|
+
|
300
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
301
|
+
// create(name, createdBy, settings)
|
302
|
+
projectService.create("test-signInAnonymouslyOk", savedUser._id).then(function (savedProject) {
|
303
|
+
|
335
304
|
chai.request(server)
|
336
|
-
.post('/auth/signinAnonymously'
|
337
|
-
.send({ id_project: savedProject._id, email: "email@email.com"})
|
305
|
+
.post('/auth/signinAnonymously')
|
306
|
+
.send({ id_project: savedProject._id, email: "email@email.com" })
|
338
307
|
.end((err, res) => {
|
339
|
-
|
340
|
-
console.
|
308
|
+
|
309
|
+
if (err) { console.error("err: ", err); }
|
310
|
+
if (log) { console.log("res.body", res.body); }
|
311
|
+
|
341
312
|
res.should.have.status(200);
|
342
313
|
res.body.should.be.a('object');
|
343
|
-
expect(res.body.success).to.equal(true);
|
344
|
-
expect(res.body.user.email).to.equal("email@email.com");
|
345
|
-
expect(res.body.token).to.not.equal(undefined);
|
346
|
-
|
314
|
+
expect(res.body.success).to.equal(true);
|
315
|
+
expect(res.body.user.email).to.equal("email@email.com");
|
316
|
+
expect(res.body.token).to.not.equal(undefined);
|
317
|
+
|
347
318
|
done();
|
348
319
|
});
|
349
|
-
});
|
350
320
|
});
|
351
|
-
|
352
|
-
|
353
|
-
});
|
354
|
-
|
355
|
-
|
356
|
-
|
321
|
+
});
|
322
|
+
});
|
357
323
|
|
358
|
-
// it('signInAnonymouslyReLoginSameProject', (done) => {
|
359
|
-
|
360
|
-
|
361
|
-
// var email = "test-signInAnonymouslyReLogin-" + Date.now() + "@email.com";
|
362
|
-
// var pwd = "pwd";
|
363
|
-
|
364
|
-
// userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
365
|
-
// // create(name, createdBy, settings)
|
366
|
-
// projectService.create("test-signInAnonymouslyReLogin", savedUser._id).then(function(savedProject) {
|
367
|
-
|
368
|
-
// chai.request(server)
|
369
|
-
// .post('/auth/signinAnonymously' )
|
370
|
-
// .send({ id_project: savedProject._id, email: "email@email.com"})
|
371
|
-
// .end((err, res) => {
|
372
|
-
// //console.log("res", res);
|
373
|
-
// console.log("res.body", res.body);
|
374
|
-
// res.should.have.status(200);
|
375
|
-
// res.body.should.be.a('object');
|
376
|
-
// expect(res.body.success).to.equal(true);
|
377
|
-
// expect(res.body.user.email).to.equal("email@email.com");
|
378
|
-
// expect(res.body.token).to.not.equal(undefined);
|
379
|
-
// expect(res.body.user._id).to.not.equal(undefined);
|
380
324
|
|
381
|
-
|
382
|
-
// console.log("uuid", uuid);
|
325
|
+
// it('signInAnonymouslyReLoginSameProject', (done) => {
|
383
326
|
|
384
|
-
// var token = res.body.token;
|
385
|
-
// console.log("token", token);
|
386
327
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
// console.log("res.body", res.body);
|
394
|
-
// res.should.have.status(200);
|
395
|
-
// res.body.should.be.a('object');
|
396
|
-
// expect(res.body.success).to.equal(true);
|
397
|
-
// expect(res.body.user.email).to.equal("email@email.com");
|
398
|
-
// expect(res.body.token).to.not.equal(undefined);
|
399
|
-
// expect(res.body.user._id.toString()).to.equal(uuid.toString());
|
328
|
+
// var email = "test-signInAnonymouslyReLogin-" + Date.now() + "@email.com";
|
329
|
+
// var pwd = "pwd";
|
330
|
+
|
331
|
+
// userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
332
|
+
// // create(name, createdBy, settings)
|
333
|
+
// projectService.create("test-signInAnonymouslyReLogin", savedUser._id).then(function(savedProject) {
|
400
334
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
335
|
+
// chai.request(server)
|
336
|
+
// .post('/auth/signinAnonymously' )
|
337
|
+
// .send({ id_project: savedProject._id, email: "email@email.com"})
|
338
|
+
// .end((err, res) => {
|
339
|
+
// //console.log("res", res);
|
340
|
+
// console.log("res.body", res.body);
|
341
|
+
// res.should.have.status(200);
|
342
|
+
// res.body.should.be.a('object');
|
343
|
+
// expect(res.body.success).to.equal(true);
|
344
|
+
// expect(res.body.user.email).to.equal("email@email.com");
|
345
|
+
// expect(res.body.token).to.not.equal(undefined);
|
346
|
+
// expect(res.body.user._id).to.not.equal(undefined);
|
409
347
|
|
348
|
+
// var uuid = res.body.user._id.toString();
|
349
|
+
// console.log("uuid", uuid);
|
410
350
|
|
351
|
+
// var token = res.body.token;
|
352
|
+
// console.log("token", token);
|
411
353
|
|
354
|
+
// chai.request(server)
|
355
|
+
// .post('/auth/resigninAnonymously' )
|
356
|
+
// .set('Authorization', token)
|
357
|
+
// .send({ id_project: savedProject._id, email: "email@email.com"})
|
358
|
+
// .end((err, res) => {
|
359
|
+
// //console.log("res", res);
|
360
|
+
// console.log("res.body", res.body);
|
361
|
+
// res.should.have.status(200);
|
362
|
+
// res.body.should.be.a('object');
|
363
|
+
// expect(res.body.success).to.equal(true);
|
364
|
+
// expect(res.body.user.email).to.equal("email@email.com");
|
365
|
+
// expect(res.body.token).to.not.equal(undefined);
|
366
|
+
// expect(res.body.user._id.toString()).to.equal(uuid.toString());
|
412
367
|
|
368
|
+
// done();
|
369
|
+
// });
|
370
|
+
// });
|
371
|
+
// });
|
372
|
+
// });
|
413
373
|
|
414
|
-
// it('signInAnonymouslyReLoginDifferentProject', (done) => {
|
415
374
|
|
416
|
-
|
417
|
-
// var email = "test-signInAnonymouslyReLogin-" + Date.now() + "@email.com";
|
418
|
-
// var pwd = "pwd";
|
375
|
+
// });
|
419
376
|
|
420
|
-
// userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
421
|
-
// // create(name, createdBy, settings)
|
422
|
-
// projectService.create("test-signInAnonymouslyReLogin", savedUser._id).then(function(savedProject) {
|
423
377
|
|
424
|
-
// projectService.create("test-signInAnonymouslyReLoginDifferent", savedUser._id).then(function(savedProjectDifferent) {
|
425
|
-
|
426
|
-
// chai.request(server)
|
427
|
-
// .post('/auth/signinAnonymously' )
|
428
|
-
// .send({ id_project: savedProject._id, email: "email@email.com"})
|
429
|
-
// .end((err, res) => {
|
430
|
-
// //console.log("res", res);
|
431
|
-
// console.log("res.body", res.body);
|
432
|
-
// res.should.have.status(200);
|
433
|
-
// res.body.should.be.a('object');
|
434
|
-
// expect(res.body.success).to.equal(true);
|
435
|
-
// expect(res.body.user.email).to.equal("email@email.com");
|
436
|
-
// expect(res.body.token).to.not.equal(undefined);
|
437
|
-
// expect(res.body.user._id).to.not.equal(undefined);
|
438
378
|
|
439
|
-
// var uuid = res.body.user._id.toString();
|
440
|
-
// console.log("uuid", uuid);
|
441
379
|
|
442
|
-
// var token = res.body.token;
|
443
|
-
// console.log("token", token);
|
444
380
|
|
445
|
-
|
446
|
-
// .post('/auth/resigninAnonymously' )
|
447
|
-
// .set('Authorization', token)
|
448
|
-
// .send({ id_project: savedProjectDifferent._id, email: "email@email.com"})
|
449
|
-
// .end((err, res) => {
|
450
|
-
// //console.log("res", res);
|
451
|
-
// console.log("res.body", res.body);
|
452
|
-
// res.should.have.status(200);
|
453
|
-
// res.body.should.be.a('object');
|
454
|
-
// expect(res.body.success).to.equal(true);
|
455
|
-
// expect(res.body.user.email).to.equal("email@email.com");
|
456
|
-
// expect(res.body.token).to.not.equal(undefined);
|
457
|
-
// expect(res.body.user._id.toString()).to.equal(uuid.toString());
|
458
|
-
|
459
|
-
// done();
|
460
|
-
// });
|
461
|
-
// });
|
462
|
-
// });
|
463
|
-
// });
|
464
|
-
// });
|
465
|
-
|
466
|
-
// });
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
});
|
381
|
+
// it('signInAnonymouslyReLoginDifferentProject', (done) => {
|
472
382
|
|
473
383
|
|
384
|
+
// var email = "test-signInAnonymouslyReLogin-" + Date.now() + "@email.com";
|
385
|
+
// var pwd = "pwd";
|
474
386
|
|
387
|
+
// userService.signup( email ,pwd, "Test Firstname", "Test lastname").then(function(savedUser) {
|
388
|
+
// // create(name, createdBy, settings)
|
389
|
+
// projectService.create("test-signInAnonymouslyReLogin", savedUser._id).then(function(savedProject) {
|
475
390
|
|
391
|
+
// projectService.create("test-signInAnonymouslyReLoginDifferent", savedUser._id).then(function(savedProjectDifferent) {
|
476
392
|
|
393
|
+
// chai.request(server)
|
394
|
+
// .post('/auth/signinAnonymously' )
|
395
|
+
// .send({ id_project: savedProject._id, email: "email@email.com"})
|
396
|
+
// .end((err, res) => {
|
397
|
+
// //console.log("res", res);
|
398
|
+
// console.log("res.body", res.body);
|
399
|
+
// res.should.have.status(200);
|
400
|
+
// res.body.should.be.a('object');
|
401
|
+
// expect(res.body.success).to.equal(true);
|
402
|
+
// expect(res.body.user.email).to.equal("email@email.com");
|
403
|
+
// expect(res.body.token).to.not.equal(undefined);
|
404
|
+
// expect(res.body.user._id).to.not.equal(undefined);
|
477
405
|
|
478
|
-
|
479
|
-
|
406
|
+
// var uuid = res.body.user._id.toString();
|
407
|
+
// console.log("uuid", uuid);
|
480
408
|
|
481
|
-
|
409
|
+
// var token = res.body.token;
|
410
|
+
// console.log("token", token);
|
482
411
|
|
483
|
-
|
484
|
-
|
485
|
-
|
412
|
+
// chai.request(server)
|
413
|
+
// .post('/auth/resigninAnonymously' )
|
414
|
+
// .set('Authorization', token)
|
415
|
+
// .send({ id_project: savedProjectDifferent._id, email: "email@email.com"})
|
416
|
+
// .end((err, res) => {
|
417
|
+
// //console.log("res", res);
|
418
|
+
// console.log("res.body", res.body);
|
419
|
+
// res.should.have.status(200);
|
420
|
+
// res.body.should.be.a('object');
|
421
|
+
// expect(res.body.success).to.equal(true);
|
422
|
+
// expect(res.body.user.email).to.equal("email@email.com");
|
423
|
+
// expect(res.body.token).to.not.equal(undefined);
|
424
|
+
// expect(res.body.user._id.toString()).to.equal(uuid.toString());
|
425
|
+
|
426
|
+
// done();
|
427
|
+
// });
|
428
|
+
// });
|
429
|
+
// });
|
430
|
+
// });
|
431
|
+
// });
|
432
|
+
|
433
|
+
// });
|
486
434
|
|
487
|
-
|
488
|
-
// create(name, createdBy, settings)
|
489
|
-
projectService.create("test-signinWithCustomToken", savedUser._id).then(function(savedProject) {
|
490
|
-
|
491
|
-
chai.request(server)
|
492
|
-
.post('/'+ savedProject._id + '/keys/generate')
|
493
|
-
.auth(email, pwd)
|
494
|
-
.send()
|
495
|
-
.end((err, res) => {
|
496
|
-
//console.log("res", res);
|
497
|
-
console.log("res.body", res.body);
|
498
|
-
res.should.have.status(200);
|
499
|
-
res.body.should.be.a('object');
|
500
|
-
expect(res.body.jwtSecret).to.not.equal(null);
|
501
|
-
|
502
|
-
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
503
|
-
var externalUserObj = {_id: "123", firstname:"andrea", lastname:"leo", email: "email2@email.com", customAttr: "c1"};
|
504
|
-
|
505
|
-
console.log("externalUserObj", externalUserObj);
|
435
|
+
});
|
506
436
|
|
437
|
+
describe('/signinWithCustomToken', () => {
|
507
438
|
|
508
|
-
var signOptions = {
|
509
|
-
subject: 'userexternal',
|
510
|
-
audience: 'https://tiledesk.com/projects/'+savedProject._id ,
|
511
|
-
};
|
512
439
|
|
440
|
+
it('signinWithCustomTokenOk', (done) => {
|
513
441
|
|
514
|
-
|
515
|
-
|
516
|
-
console.log("jwtToken", jwtToken);
|
442
|
+
var email = "test-signinwithcustomtoken-" + Date.now() + "@email.com";
|
443
|
+
var pwd = "pwd";
|
517
444
|
|
445
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
446
|
+
// create(name, createdBy, settings)
|
447
|
+
projectService.create("test-signinWithCustomToken", savedUser._id).then(function (savedProject) {
|
518
448
|
|
519
449
|
chai.request(server)
|
520
|
-
.post('/
|
521
|
-
.
|
522
|
-
//.send({ id_project: savedProject._id})
|
450
|
+
.post('/' + savedProject._id + '/keys/generate')
|
451
|
+
.auth(email, pwd)
|
523
452
|
.send()
|
524
453
|
.end((err, res) => {
|
525
|
-
|
526
|
-
console.
|
454
|
+
|
455
|
+
if (err) { console.error("err: ", err); }
|
456
|
+
if (log) { console.log("res.body", res.body); }
|
457
|
+
|
527
458
|
res.should.have.status(200);
|
528
459
|
res.body.should.be.a('object');
|
529
|
-
expect(res.body.
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
460
|
+
expect(res.body.jwtSecret).to.not.equal(null);
|
461
|
+
|
462
|
+
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
463
|
+
var externalUserObj = { _id: "123", firstname: "andrea", lastname: "leo", email: "email2@email.com", customAttr: "c1" };
|
464
|
+
if (log) { console.log("externalUserObj", externalUserObj); }
|
465
|
+
|
466
|
+
var signOptions = {
|
467
|
+
subject: 'userexternal',
|
468
|
+
audience: 'https://tiledesk.com/projects/' + savedProject._id,
|
469
|
+
};
|
470
|
+
|
471
|
+
var jwtToken = jwt.sign(externalUserObj, res.body.jwtSecret, signOptions);
|
472
|
+
if (log) { console.log("jwtToken", jwtToken); }
|
473
|
+
|
474
|
+
chai.request(server)
|
475
|
+
.post('/auth/signinWithCustomToken')
|
476
|
+
.set('Authorization', 'JWT ' + jwtToken)
|
477
|
+
//.send({ id_project: savedProject._id})
|
478
|
+
.send()
|
479
|
+
.end((err, res) => {
|
480
|
+
|
481
|
+
if (err) { console.error("err: ", err); }
|
482
|
+
if (log) { console.log("res.body", res.body); }
|
483
|
+
|
484
|
+
res.should.have.status(200);
|
485
|
+
res.body.should.be.a('object');
|
486
|
+
expect(res.body.success).to.equal(true);
|
487
|
+
expect(res.body.user.email).to.equal("email2@email.com");
|
488
|
+
expect(res.body.user.firstname).to.equal("andrea");
|
489
|
+
expect(res.body.user.customAttr).to.equal("c1");
|
490
|
+
expect(res.body.token).to.not.equal(undefined);
|
491
|
+
expect(res.body.token).to.equal('JWT ' + jwtToken);
|
492
|
+
|
493
|
+
done();
|
494
|
+
});
|
540
495
|
});
|
541
|
-
});
|
542
496
|
});
|
543
497
|
});
|
544
|
-
|
545
|
-
});
|
498
|
+
});
|
546
499
|
|
547
|
-
|
548
500
|
|
501
|
+
it('signinWithCustomTokenKO', (done) => {
|
549
502
|
|
503
|
+
var email = "test-signinwithcustomtoken-" + Date.now() + "@email.com";
|
504
|
+
var pwd = "pwd";
|
550
505
|
|
506
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
507
|
+
// create(name, createdBy, settings)
|
508
|
+
projectService.create("test-signinWithCustomTokenKO", savedUser._id).then(function (savedProject) {
|
551
509
|
|
552
|
-
|
510
|
+
chai.request(server)
|
511
|
+
.post('/' + savedProject._id + '/keys/generate')
|
512
|
+
.auth(email, pwd)
|
513
|
+
.send()
|
514
|
+
.end((err, res) => {
|
553
515
|
|
554
|
-
|
555
|
-
|
556
|
-
var pwd = "pwd";
|
516
|
+
if (err) { console.error("err: ", err); }
|
517
|
+
if (log) { console.log("res.body", res.body); }
|
557
518
|
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
chai.request(server)
|
563
|
-
.post('/'+ savedProject._id + '/keys/generate')
|
564
|
-
.auth(email, pwd)
|
565
|
-
.send()
|
566
|
-
.end((err, res) => {
|
567
|
-
//console.log("res", res);
|
568
|
-
console.log("res.body", res.body);
|
569
|
-
res.should.have.status(200);
|
570
|
-
res.body.should.be.a('object');
|
571
|
-
expect(res.body.jwtSecret).to.not.equal(null);
|
572
|
-
|
519
|
+
res.should.have.status(200);
|
520
|
+
res.body.should.be.a('object');
|
521
|
+
expect(res.body.jwtSecret).to.not.equal(null);
|
573
522
|
|
574
|
-
|
575
|
-
|
576
|
-
console.log("externalUserObj", externalUserObj);
|
523
|
+
var externalUserObj = { _id: "123", name: "andrea", surname: "leo", customAttr: "c1" };
|
524
|
+
if (log) { console.log("externalUserObj", externalUserObj); }
|
577
525
|
|
526
|
+
var signOptions = {
|
527
|
+
subject: 'userexternal',
|
528
|
+
audience: 'https://tiledesk.com/projects/' + savedProject._id,
|
529
|
+
};
|
578
530
|
|
579
|
-
var signOptions = {
|
580
|
-
subject: 'userexternal',
|
581
|
-
audience: 'https://tiledesk.com/projects/'+savedProject._id ,
|
582
|
-
};
|
583
531
|
|
532
|
+
var jwtToken = jwt.sign(externalUserObj, res.body.jwtSecret + "1234567KOOOOOOO", signOptions);
|
533
|
+
if (log) { console.log("jwtToken", jwtToken); }
|
584
534
|
|
585
|
-
|
586
|
-
|
587
|
-
|
535
|
+
chai.request(server)
|
536
|
+
.post('/auth/signinWithCustomToken')
|
537
|
+
.set('Authorization', 'JWT ' + jwtToken)
|
538
|
+
.send({ id_project: savedProject._id })
|
539
|
+
.end((err, res) => {
|
588
540
|
|
541
|
+
if (err) { console.error("err: ", err); }
|
542
|
+
if (log) { console.log("res.body", res.body); }
|
589
543
|
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
.end((err, res) => {
|
595
|
-
//console.log("res", res);
|
596
|
-
// console.log("res.body", res.body);
|
597
|
-
res.should.have.status(401);
|
598
|
-
|
599
|
-
done();
|
544
|
+
res.should.have.status(401);
|
545
|
+
|
546
|
+
done();
|
547
|
+
});
|
600
548
|
});
|
601
|
-
});
|
602
549
|
});
|
603
550
|
});
|
604
|
-
|
605
|
-
});
|
551
|
+
});
|
606
552
|
|
607
|
-
});
|
608
553
|
|
554
|
+
it('signinWithCustomTokenKONoID', (done) => {
|
609
555
|
|
556
|
+
var email = "test-signinwithcustomtokenkonoid-" + Date.now() + "@email.com";
|
557
|
+
var pwd = "pwd";
|
610
558
|
|
559
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
560
|
+
// create(name, createdBy, settings)
|
561
|
+
projectService.create("test-signinWithCustomTokenKONoID", savedUser._id).then(function (savedProject) {
|
611
562
|
|
612
|
-
|
563
|
+
chai.request(server)
|
564
|
+
.post('/' + savedProject._id + '/keys/generate')
|
565
|
+
.auth(email, pwd)
|
566
|
+
.send()
|
567
|
+
.end((err, res) => {
|
613
568
|
|
614
|
-
|
615
|
-
|
616
|
-
var pwd = "pwd";
|
569
|
+
if (err) { console.error("err: ", err); }
|
570
|
+
if (log) { console.log("res.body", res.body); }
|
617
571
|
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
chai.request(server)
|
623
|
-
.post('/'+ savedProject._id + '/keys/generate')
|
624
|
-
.auth(email, pwd)
|
625
|
-
.send()
|
626
|
-
.end((err, res) => {
|
627
|
-
//console.log("res", res);
|
628
|
-
console.log("res.body", res.body);
|
629
|
-
res.should.have.status(200);
|
630
|
-
res.body.should.be.a('object');
|
631
|
-
expect(res.body.jwtSecret).to.not.equal(null);
|
632
|
-
|
633
|
-
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
634
|
-
var externalUserObj = {firstname:"andrea", lastname:"leo", email: "email2@email.com"};
|
635
|
-
|
636
|
-
console.log("externalUserObj", externalUserObj);
|
572
|
+
res.should.have.status(200);
|
573
|
+
res.body.should.be.a('object');
|
574
|
+
expect(res.body.jwtSecret).to.not.equal(null);
|
637
575
|
|
576
|
+
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
577
|
+
var externalUserObj = { firstname: "andrea", lastname: "leo", email: "email2@email.com" };
|
578
|
+
if (log) { console.log("externalUserObj", externalUserObj); }
|
638
579
|
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
580
|
+
var signOptions = {
|
581
|
+
subject: 'userexternal',
|
582
|
+
audience: 'https://tiledesk.com/projects/' + savedProject._id,
|
583
|
+
};
|
643
584
|
|
585
|
+
var jwtToken = jwt.sign(externalUserObj, res.body.jwtSecret, signOptions);
|
586
|
+
if (log) { console.log("jwtToken", jwtToken); }
|
644
587
|
|
645
|
-
|
646
|
-
|
647
|
-
|
588
|
+
chai.request(server)
|
589
|
+
.post('/auth/signinWithCustomToken')
|
590
|
+
.set('Authorization', 'JWT ' + jwtToken)
|
591
|
+
//.send({ id_project: savedProject._id})
|
592
|
+
.send()
|
593
|
+
.end((err, res) => {
|
648
594
|
|
595
|
+
if (err) { console.error("err: ", err); }
|
596
|
+
if (log) { console.log("res.body", res.body); }
|
649
597
|
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
.end((err, res) => {
|
656
|
-
//console.log("res", res);
|
657
|
-
console.log("res.body", res.body);
|
658
|
-
res.should.have.status(401);
|
659
|
-
|
660
|
-
done();
|
661
|
-
});
|
598
|
+
res.should.have.status(401);
|
599
|
+
|
600
|
+
done();
|
601
|
+
});
|
602
|
+
});
|
662
603
|
});
|
663
604
|
});
|
664
|
-
});
|
665
|
-
|
666
|
-
}).timeout(20000);
|
667
605
|
|
606
|
+
}).timeout(20000);
|
668
607
|
|
669
608
|
|
609
|
+
// mocha test/authentication.js --grep 'signinWithCustomTokenKONoAud'
|
610
|
+
it('signinWithCustomTokenKONoAud', (done) => {
|
670
611
|
|
671
|
-
|
612
|
+
var email = "test-signinwithcustomtokenkowrongaud-" + Date.now() + "@email.com";
|
613
|
+
var pwd = "pwd";
|
672
614
|
|
673
|
-
|
674
|
-
|
675
|
-
|
615
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
616
|
+
// create(name, createdBy, settings)
|
617
|
+
projectService.create("test-signinWithCustomTokenKOWrongAud", savedUser._id).then(function (savedProject) {
|
676
618
|
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
.post('/'+ savedProject._id + '/keys/generate')
|
683
|
-
.auth(email, pwd)
|
684
|
-
.send()
|
685
|
-
.end((err, res) => {
|
686
|
-
//console.log("res", res);
|
687
|
-
console.log("res.body", res.body);
|
688
|
-
res.should.have.status(200);
|
689
|
-
res.body.should.be.a('object');
|
690
|
-
expect(res.body.jwtSecret).to.not.equal(null);
|
691
|
-
|
692
|
-
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
693
|
-
var externalUserObj = {_id: 1234, firstname:"andrea", lastname:"leo", email: "email2@email.com"};
|
694
|
-
|
695
|
-
console.log("externalUserObj", externalUserObj);
|
619
|
+
chai.request(server)
|
620
|
+
.post('/' + savedProject._id + '/keys/generate')
|
621
|
+
.auth(email, pwd)
|
622
|
+
.send()
|
623
|
+
.end((err, res) => {
|
696
624
|
|
625
|
+
if (err) { console.error("err: ", err); }
|
626
|
+
if (log) { console.log("res.body", res.body); }
|
697
627
|
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
};
|
628
|
+
res.should.have.status(200);
|
629
|
+
res.body.should.be.a('object');
|
630
|
+
expect(res.body.jwtSecret).to.not.equal(null);
|
702
631
|
|
632
|
+
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
633
|
+
var externalUserObj = { _id: 1234, firstname: "andrea", lastname: "leo", email: "email2@email.com" };
|
634
|
+
if (log) { console.log("externalUserObj", externalUserObj); }
|
703
635
|
|
704
|
-
|
705
|
-
|
706
|
-
|
636
|
+
var signOptions = {
|
637
|
+
subject: 'userexternal',
|
638
|
+
//audience: 'https://tiledesk.com/projects/'+savedProject._id ,
|
639
|
+
};
|
707
640
|
|
641
|
+
var jwtToken = jwt.sign(externalUserObj, res.body.jwtSecret, signOptions);
|
642
|
+
if (log) { console.log("jwtToken", jwtToken); }
|
708
643
|
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
644
|
+
chai.request(server)
|
645
|
+
.post('/auth/signinWithCustomToken')
|
646
|
+
.set('Authorization', 'JWT ' + jwtToken)
|
647
|
+
//.send({ id_project: savedProject._id})
|
648
|
+
.send()
|
649
|
+
.end((err, res) => {
|
650
|
+
|
651
|
+
if (err) { console.error("err: ", err); }
|
652
|
+
if (log) { console.log("res.body", res.body); }
|
653
|
+
|
654
|
+
res.should.have.status(401);
|
655
|
+
|
656
|
+
done();
|
657
|
+
});
|
658
|
+
});
|
721
659
|
});
|
722
660
|
});
|
723
661
|
});
|
724
|
-
|
725
|
-
});
|
726
|
-
|
727
662
|
|
728
663
|
|
729
|
-
|
664
|
+
// mocha test/authentication.js --grep 'signinWithCustomTokenOkTwoSigninWithCT'
|
665
|
+
it('signinWithCustomTokenOkTwoSigninWithCT', (done) => {
|
730
666
|
|
731
|
-
|
667
|
+
var email = "test-signinwithcustomtokenoktwosigninwithct-" + Date.now() + "@email.com";
|
668
|
+
var pwd = "pwd";
|
732
669
|
|
733
|
-
|
734
|
-
|
735
|
-
|
670
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
671
|
+
// create(name, createdBy, settings)
|
672
|
+
projectService.create("test-signinWithCustomTokenOkTwoSigninWithCT", savedUser._id).then(function (savedProject) {
|
736
673
|
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
.post('/'+ savedProject._id + '/keys/generate')
|
743
|
-
.auth(email, pwd)
|
744
|
-
.send()
|
745
|
-
.end((err, res) => {
|
746
|
-
//console.log("res", res);
|
747
|
-
console.log("res.body", res.body);
|
748
|
-
res.should.have.status(200);
|
749
|
-
res.body.should.be.a('object');
|
750
|
-
expect(res.body.jwtSecret).to.not.equal(null);
|
751
|
-
|
752
|
-
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
753
|
-
var externalUserObj = {_id: "123", firstname:"andrea", lastname:"leo", email: "email2@email.com", customAttr: "c1"};
|
754
|
-
|
755
|
-
console.log("externalUserObj", externalUserObj);
|
674
|
+
chai.request(server)
|
675
|
+
.post('/' + savedProject._id + '/keys/generate')
|
676
|
+
.auth(email, pwd)
|
677
|
+
.send()
|
678
|
+
.end((err, res) => {
|
756
679
|
|
680
|
+
if (err) { console.error("err: ", err); }
|
681
|
+
if (log) { console.log("res.body", res.body); }
|
757
682
|
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
};
|
683
|
+
res.should.have.status(200);
|
684
|
+
res.body.should.be.a('object');
|
685
|
+
expect(res.body.jwtSecret).to.not.equal(null);
|
762
686
|
|
687
|
+
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
688
|
+
var externalUserObj = { _id: "123", firstname: "andrea", lastname: "leo", email: "email2@email.com", customAttr: "c1" };
|
689
|
+
if (log) { console.log("externalUserObj", externalUserObj); }
|
763
690
|
|
764
|
-
|
765
|
-
|
766
|
-
|
691
|
+
var signOptions = {
|
692
|
+
subject: 'userexternal',
|
693
|
+
audience: 'https://tiledesk.com/projects/' + savedProject._id,
|
694
|
+
};
|
767
695
|
|
696
|
+
var jwtToken = jwt.sign(externalUserObj, res.body.jwtSecret, signOptions);
|
697
|
+
if (log) { console.log("jwtToken", jwtToken); }
|
768
698
|
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
//.send({ id_project: savedProject._id})
|
773
|
-
.send()
|
774
|
-
.end((err, res) => {
|
775
|
-
//console.log("res", res);
|
776
|
-
console.log("res.body", res.body);
|
777
|
-
res.should.have.status(200);
|
778
|
-
res.body.should.be.a('object');
|
779
|
-
expect(res.body.success).to.equal(true);
|
780
|
-
expect(res.body.user.email).to.equal("email2@email.com");
|
781
|
-
expect(res.body.user.firstname).to.equal("andrea");
|
782
|
-
expect(res.body.user.customAttr).to.equal("c1");
|
783
|
-
|
784
|
-
|
785
|
-
expect(res.body.token).to.not.equal(undefined);
|
786
|
-
expect(res.body.token).to.equal('JWT '+jwtToken);
|
787
|
-
|
788
|
-
|
789
|
-
chai.request(server)
|
790
|
-
.post('/auth/signinWithCustomToken' )
|
791
|
-
.set('Authorization', 'JWT '+jwtToken)
|
699
|
+
chai.request(server)
|
700
|
+
.post('/auth/signinWithCustomToken')
|
701
|
+
.set('Authorization', 'JWT ' + jwtToken)
|
792
702
|
//.send({ id_project: savedProject._id})
|
793
703
|
.send()
|
794
704
|
.end((err, res) => {
|
795
|
-
|
796
|
-
console.
|
705
|
+
|
706
|
+
if (err) { console.error("err: ", err); }
|
707
|
+
if (log) { console.log("res.body", res.body); }
|
708
|
+
|
797
709
|
res.should.have.status(200);
|
798
710
|
res.body.should.be.a('object');
|
799
|
-
expect(res.body.success).to.equal(true);
|
800
|
-
expect(res.body.user.email).to.equal("email2@email.com");
|
801
|
-
expect(res.body.user.firstname).to.equal("andrea");
|
802
|
-
expect(res.body.user.customAttr).to.equal("c1");
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
711
|
+
expect(res.body.success).to.equal(true);
|
712
|
+
expect(res.body.user.email).to.equal("email2@email.com");
|
713
|
+
expect(res.body.user.firstname).to.equal("andrea");
|
714
|
+
expect(res.body.user.customAttr).to.equal("c1");
|
715
|
+
expect(res.body.token).to.not.equal(undefined);
|
716
|
+
expect(res.body.token).to.equal('JWT ' + jwtToken);
|
717
|
+
|
718
|
+
chai.request(server)
|
719
|
+
.post('/auth/signinWithCustomToken')
|
720
|
+
.set('Authorization', 'JWT ' + jwtToken)
|
721
|
+
//.send({ id_project: savedProject._id})
|
722
|
+
.send()
|
723
|
+
.end((err, res) => {
|
724
|
+
|
725
|
+
if (err) { console.error("err: ", err); }
|
726
|
+
if (log) { console.log("res.body", res.body); }
|
727
|
+
|
728
|
+
res.should.have.status(200);
|
729
|
+
res.body.should.be.a('object');
|
730
|
+
expect(res.body.success).to.equal(true);
|
731
|
+
expect(res.body.user.email).to.equal("email2@email.com");
|
732
|
+
expect(res.body.user.firstname).to.equal("andrea");
|
733
|
+
expect(res.body.user.customAttr).to.equal("c1");
|
734
|
+
expect(res.body.token).to.not.equal(undefined);
|
735
|
+
expect(res.body.token).to.equal('JWT ' + jwtToken);
|
736
|
+
|
737
|
+
done();
|
738
|
+
});
|
810
739
|
});
|
811
|
-
|
740
|
+
});
|
812
741
|
});
|
813
742
|
});
|
814
|
-
});
|
815
|
-
|
816
|
-
}).timeout(20000);
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
743
|
|
822
|
-
|
744
|
+
}).timeout(20000);
|
823
745
|
|
824
746
|
|
825
|
-
|
747
|
+
// mocha test/authentication.js --grep 'signinWithCustomTokenRoleNew'
|
748
|
+
it('signinWithCustomTokenRoleNew', (done) => {
|
826
749
|
|
827
|
-
|
828
|
-
|
829
|
-
|
750
|
+
var email = "test-signinWithCustomTokenRole-" + Date.now() + "@email.com";
|
751
|
+
var pwd = "pwd";
|
752
|
+
var emailToCheck = "emailrole" + Date.now() + "@email.com";
|
830
753
|
|
754
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
755
|
+
// create(name, createdBy, settings)
|
756
|
+
projectService.create("test-signinWithCustomTokenRole", savedUser._id).then(function (savedProject) {
|
831
757
|
|
832
|
-
|
758
|
+
chai.request(server)
|
759
|
+
.post('/' + savedProject._id + '/keys/generate')
|
760
|
+
.auth(email, pwd)
|
761
|
+
.send()
|
762
|
+
.end((err, res) => {
|
833
763
|
|
764
|
+
if (err) { console.error("err: ", err); }
|
765
|
+
if (log) { console.log("res.body", res.body); }
|
834
766
|
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
chai.request(server)
|
840
|
-
.post('/'+ savedProject._id + '/keys/generate')
|
841
|
-
.auth(email, pwd)
|
842
|
-
.send()
|
843
|
-
.end((err, res) => {
|
844
|
-
//console.log("res", res);
|
845
|
-
console.log("res.body", res.body);
|
846
|
-
res.should.have.status(200);
|
847
|
-
res.body.should.be.a('object');
|
848
|
-
expect(res.body.jwtSecret).to.not.equal(null);
|
849
|
-
|
850
|
-
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
851
|
-
var externalUserObj = {_id: "123", firstname:"andrea", lastname:"leo", email: emailToCheck, role:"admin"};
|
852
|
-
|
853
|
-
console.log("externalUserObj", externalUserObj);
|
767
|
+
res.should.have.status(200);
|
768
|
+
res.body.should.be.a('object');
|
769
|
+
expect(res.body.jwtSecret).to.not.equal(null);
|
854
770
|
|
771
|
+
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
772
|
+
var externalUserObj = { _id: "123", firstname: "andrea", lastname: "leo", email: emailToCheck, role: "admin" };
|
773
|
+
if (log) { console.log("externalUserObj", externalUserObj); }
|
855
774
|
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
775
|
+
var signOptions = {
|
776
|
+
subject: 'userexternal',
|
777
|
+
audience: 'https://tiledesk.com/projects/' + savedProject._id,
|
778
|
+
};
|
860
779
|
|
780
|
+
var jwtToken = jwt.sign(externalUserObj, res.body.jwtSecret, signOptions);
|
781
|
+
if (log) { console.log("jwtToken", jwtToken); }
|
861
782
|
|
862
|
-
|
863
|
-
|
864
|
-
|
783
|
+
chai.request(server)
|
784
|
+
.post('/auth/signinWithCustomToken')
|
785
|
+
.set('Authorization', 'JWT ' + jwtToken)
|
786
|
+
//.send({ id_project: savedProject._id})
|
787
|
+
.send()
|
788
|
+
.end((err, res) => {
|
865
789
|
|
790
|
+
if (err) { console.error("err: ", err); }
|
791
|
+
if (log) { console.log("res.body", res.body); }
|
866
792
|
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
console.log("1");
|
879
|
-
|
880
|
-
expect(res.body.user.email).to.equal(emailToCheck);
|
881
|
-
console.log("2");
|
882
|
-
expect(res.body.user.firstname).to.equal("andrea");
|
883
|
-
// expect(res.body.user._id).to.not.equal("123");
|
884
|
-
console.log("3");
|
885
|
-
|
886
|
-
|
887
|
-
expect(res.body.token).to.not.equal(undefined);
|
888
|
-
// expect(res.body.token).to.equal('JWT '+jwtToken);
|
889
|
-
|
890
|
-
console.log("4");
|
891
|
-
done();
|
892
|
-
});
|
793
|
+
res.should.have.status(200);
|
794
|
+
res.body.should.be.a('object');
|
795
|
+
expect(res.body.success).to.equal(true);
|
796
|
+
expect(res.body.user.email).to.equal(emailToCheck);
|
797
|
+
expect(res.body.user.firstname).to.equal("andrea");
|
798
|
+
// expect(res.body.user._id).to.not.equal("123");
|
799
|
+
expect(res.body.token).to.not.equal(undefined);
|
800
|
+
// expect(res.body.token).to.equal('JWT '+jwtToken);
|
801
|
+
done();
|
802
|
+
});
|
803
|
+
});
|
893
804
|
});
|
894
805
|
});
|
895
806
|
});
|
896
807
|
|
897
|
-
});
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
808
|
|
903
|
-
|
809
|
+
// mocha test/authentication.js --grep 'signinWithCustomTokenRole'
|
810
|
+
it('signinWithCustomTokenRoleEmailAlreadyUsed', (done) => {
|
904
811
|
|
812
|
+
var email = "test-signinWithCustomTokenRoleEmailAlreadyUsed-" + Date.now() + "@email.com";
|
813
|
+
var pwd = "pwd";
|
814
|
+
var emailToCheck = "emailrole" + Date.now() + "@email.com";
|
905
815
|
|
906
|
-
|
816
|
+
userService.signup(emailToCheck, pwd, "andrea", "leo").then(function (savedUserToCheck) {
|
817
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
818
|
+
projectService.create("test-signinWithCustomTokenRoleEmailAlreadyUsed", savedUser._id).then(function (savedProject) {
|
907
819
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
var emailToCheck = "emailrole"+ Date.now() +"@email.com";
|
820
|
+
chai.request(server)
|
821
|
+
.post('/' + savedProject._id + '/keys/generate')
|
822
|
+
.auth(email, pwd)
|
823
|
+
.send()
|
824
|
+
.end((err, res) => {
|
914
825
|
|
915
|
-
|
826
|
+
if (err) { console.error("err: ", err); }
|
827
|
+
if (log) { console.log("res.body", res.body); }
|
916
828
|
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
chai.request(server)
|
922
|
-
.post('/'+ savedProject._id + '/keys/generate')
|
923
|
-
.auth(email, pwd)
|
924
|
-
.send()
|
925
|
-
.end((err, res) => {
|
926
|
-
//console.log("res", res);
|
927
|
-
console.log("res.body", res.body);
|
928
|
-
res.should.have.status(200);
|
929
|
-
res.body.should.be.a('object');
|
930
|
-
expect(res.body.jwtSecret).to.not.equal(null);
|
931
|
-
|
932
|
-
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
933
|
-
var externalUserObj = {_id: "123", firstname:"andrea", lastname:"leo", email: emailToCheck, role:"admin"};
|
934
|
-
|
935
|
-
console.log("externalUserObj", externalUserObj);
|
829
|
+
res.should.have.status(200);
|
830
|
+
res.body.should.be.a('object');
|
831
|
+
expect(res.body.jwtSecret).to.not.equal(null);
|
936
832
|
|
833
|
+
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
834
|
+
var externalUserObj = { _id: "123", firstname: "andrea", lastname: "leo", email: emailToCheck, role: "admin" };
|
835
|
+
if (log) { console.log("externalUserObj", externalUserObj); }
|
937
836
|
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
837
|
+
var signOptions = {
|
838
|
+
subject: 'userexternal',
|
839
|
+
audience: 'https://tiledesk.com/projects/' + savedProject._id,
|
840
|
+
};
|
942
841
|
|
842
|
+
var jwtToken = jwt.sign(externalUserObj, res.body.jwtSecret, signOptions);
|
843
|
+
if (log) { console.log("jwtToken", jwtToken); }
|
943
844
|
|
944
|
-
|
945
|
-
|
946
|
-
|
845
|
+
chai.request(server)
|
846
|
+
.post('/auth/signinWithCustomToken')
|
847
|
+
.set('Authorization', 'JWT ' + jwtToken)
|
848
|
+
//.send({ id_project: savedProject._id})
|
849
|
+
.send()
|
850
|
+
.end((err, res) => {
|
947
851
|
|
852
|
+
if (err) { console.error("err: ", err); }
|
853
|
+
if (log) { console.log("res.body", res.body); }
|
948
854
|
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
// console.log("1");
|
961
|
-
|
962
|
-
expect(res.body.user.email).to.equal(emailToCheck);
|
963
|
-
// console.log("2");
|
964
|
-
expect(res.body.user.firstname).to.equal("andrea");
|
965
|
-
// expect(res.body.user._id).to.not.equal("123");
|
966
|
-
// console.log("3");
|
967
|
-
|
968
|
-
|
969
|
-
expect(res.body.token).to.not.equal(undefined);
|
970
|
-
// expect(res.body.token).to.equal('JWT '+jwtToken);
|
971
|
-
|
972
|
-
// console.log("4");
|
973
|
-
done();
|
855
|
+
res.should.have.status(200);
|
856
|
+
res.body.should.be.a('object');
|
857
|
+
expect(res.body.success).to.equal(true);
|
858
|
+
expect(res.body.user.email).to.equal(emailToCheck);
|
859
|
+
expect(res.body.user.firstname).to.equal("andrea");
|
860
|
+
// expect(res.body.user._id).to.not.equal("123");
|
861
|
+
expect(res.body.token).to.not.equal(undefined);
|
862
|
+
// expect(res.body.token).to.equal('JWT '+jwtToken);
|
863
|
+
done();
|
864
|
+
});
|
865
|
+
});
|
974
866
|
});
|
975
867
|
});
|
976
868
|
});
|
977
869
|
});
|
978
|
-
});
|
979
|
-
});
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
870
|
|
985
871
|
|
872
|
+
// mocha test/authentication.js --grep 'signinWithCustomTokenRoleSameOwnerEmail'
|
873
|
+
it('signinWithCustomTokenRoleSameOwnerEmail', (done) => {
|
986
874
|
|
987
|
-
|
875
|
+
var email = "test-sctrolesameowner-" + Date.now() + "@email.com";
|
876
|
+
var pwd = "pwd";
|
877
|
+
var emailToCheck = email;
|
988
878
|
|
879
|
+
userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
|
880
|
+
projectService.create("test-signinWithCustomTokenRoleEmailAlreadyUsed", savedUser._id).then(function (savedProject) {
|
989
881
|
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
var emailToCheck = email;
|
882
|
+
chai.request(server)
|
883
|
+
.post('/' + savedProject._id + '/keys/generate')
|
884
|
+
.auth(email, pwd)
|
885
|
+
.send()
|
886
|
+
.end((err, res) => {
|
998
887
|
|
888
|
+
if (err) { console.error("err: ", err); }
|
889
|
+
if (log) { console.log("res.body", res.body); }
|
999
890
|
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
chai.request(server)
|
1005
|
-
.post('/'+ savedProject._id + '/keys/generate')
|
1006
|
-
.auth(email, pwd)
|
1007
|
-
.send()
|
1008
|
-
.end((err, res) => {
|
1009
|
-
//console.log("res", res);
|
1010
|
-
console.log("res.body", res.body);
|
1011
|
-
res.should.have.status(200);
|
1012
|
-
res.body.should.be.a('object');
|
1013
|
-
expect(res.body.jwtSecret).to.not.equal(null);
|
1014
|
-
|
1015
|
-
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
1016
|
-
var externalUserObj = {_id: "123", firstname:"andrea", lastname:"leo", email: emailToCheck, role:"admin"};
|
1017
|
-
|
1018
|
-
console.log("externalUserObj", externalUserObj);
|
891
|
+
res.should.have.status(200);
|
892
|
+
res.body.should.be.a('object');
|
893
|
+
expect(res.body.jwtSecret).to.not.equal(null);
|
1019
894
|
|
895
|
+
// 'E11000 duplicate key error collection: tiledesk-test.users index: email_1 dup key: { email: "email@email.com" }' }
|
896
|
+
var externalUserObj = { _id: "123", firstname: "andrea", lastname: "leo", email: emailToCheck, role: "admin" };
|
897
|
+
if (log) { console.log("externalUserObj", externalUserObj); }
|
1020
898
|
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
899
|
+
var signOptions = {
|
900
|
+
subject: 'userexternal',
|
901
|
+
audience: 'https://tiledesk.com/projects/' + savedProject._id,
|
902
|
+
};
|
1025
903
|
|
904
|
+
var jwtToken = jwt.sign(externalUserObj, res.body.jwtSecret, signOptions);
|
905
|
+
if (log) { console.log("jwtToken", jwtToken); }
|
1026
906
|
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
907
|
+
chai.request(server)
|
908
|
+
.post('/auth/signinWithCustomToken')
|
909
|
+
.set('Authorization', 'JWT ' + jwtToken)
|
910
|
+
//.send({ id_project: savedProject._id})
|
911
|
+
.send()
|
912
|
+
.end((err, res) => {
|
1030
913
|
|
914
|
+
if (err) { console.error("err: ", err); }
|
915
|
+
if (log) { console.log("res.body", res.body); }
|
1031
916
|
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
console.log("1");
|
1044
|
-
|
1045
|
-
expect(res.body.user.email).to.equal(emailToCheck);
|
1046
|
-
console.log("2");
|
1047
|
-
expect(res.body.user.firstname).to.equal("Test Firstname");
|
1048
|
-
// expect(res.body.user._id).to.not.equal("123");
|
1049
|
-
console.log("3");
|
1050
|
-
|
1051
|
-
|
1052
|
-
expect(res.body.token).to.not.equal(undefined);
|
1053
|
-
// expect(res.body.token).to.equal('JWT '+jwtToken);
|
1054
|
-
|
1055
|
-
console.log("4");
|
1056
|
-
done();
|
1057
|
-
});
|
917
|
+
res.should.have.status(200);
|
918
|
+
res.body.should.be.a('object');
|
919
|
+
expect(res.body.success).to.equal(true);
|
920
|
+
expect(res.body.user.email).to.equal(emailToCheck);
|
921
|
+
expect(res.body.user.firstname).to.equal("Test Firstname");
|
922
|
+
// expect(res.body.user._id).to.not.equal("123");
|
923
|
+
expect(res.body.token).to.not.equal(undefined);
|
924
|
+
// expect(res.body.token).to.equal('JWT '+jwtToken);
|
925
|
+
done();
|
926
|
+
});
|
927
|
+
});
|
1058
928
|
});
|
1059
929
|
});
|
1060
930
|
});
|
1061
|
-
});
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
931
|
|
1067
|
-
}).timeout(20000);
|
1068
932
|
|
933
|
+
}).timeout(20000);
|
1069
934
|
|
935
|
+
});
|