2
2
3
3
const Config = require ( '../lib/Config' ) ;
4
4
5
- const loginWithWrongCredentialsShouldFail = function ( username , password ) {
5
+ const loginWithWrongCredentialsShouldFail = function ( username , password ) {
6
6
return new Promise ( ( resolve , reject ) => {
7
7
Parse . User . logIn ( username , password )
8
8
. then ( ( ) => reject ( 'login should have failed' ) )
@@ -16,7 +16,7 @@ const loginWithWrongCredentialsShouldFail = function(username, password) {
16
16
} ) ;
17
17
} ;
18
18
19
- const isAccountLockoutError = function ( username , password , duration , waitTime ) {
19
+ const isAccountLockoutError = function ( username , password , duration , waitTime ) {
20
20
return new Promise ( ( resolve , reject ) => {
21
21
setTimeout ( ( ) => {
22
22
Parse . User . logIn ( username , password )
@@ -50,28 +50,17 @@ describe('Account Lockout Policy: ', () => {
50
50
return user . signUp ( null ) ;
51
51
} )
52
52
. then ( ( ) => {
53
- return loginWithWrongCredentialsShouldFail (
54
- 'username1' ,
55
- 'incorrect password 1'
56
- ) ;
53
+ return loginWithWrongCredentialsShouldFail ( 'username1' , 'incorrect password 1' ) ;
57
54
} )
58
55
. then ( ( ) => {
59
- return loginWithWrongCredentialsShouldFail (
60
- 'username1' ,
61
- 'incorrect password 2'
62
- ) ;
56
+ return loginWithWrongCredentialsShouldFail ( 'username1' , 'incorrect password 2' ) ;
63
57
} )
64
58
. then ( ( ) => {
65
- return loginWithWrongCredentialsShouldFail (
66
- 'username1' ,
67
- 'incorrect password 3'
68
- ) ;
59
+ return loginWithWrongCredentialsShouldFail ( 'username1' , 'incorrect password 3' ) ;
69
60
} )
70
61
. then ( ( ) => done ( ) )
71
62
. catch ( err => {
72
- fail (
73
- 'allow unlimited failed login attempts failed: ' + JSON . stringify ( err )
74
- ) ;
63
+ fail ( 'allow unlimited failed login attempts failed: ' + JSON . stringify ( err ) ) ;
75
64
done ( ) ;
76
65
} ) ;
77
66
} ) ;
@@ -93,15 +82,11 @@ describe('Account Lockout Policy: ', () => {
93
82
. catch ( err => {
94
83
if (
95
84
err &&
96
- err ===
97
- 'Account lockout duration should be greater than 0 and less than 100000'
85
+ err === 'Account lockout duration should be greater than 0 and less than 100000'
98
86
) {
99
87
done ( ) ;
100
88
} else {
101
- fail (
102
- 'set duration to an invalid number test failed: ' +
103
- JSON . stringify ( err )
104
- ) ;
89
+ fail ( 'set duration to an invalid number test failed: ' + JSON . stringify ( err ) ) ;
105
90
done ( ) ;
106
91
}
107
92
} ) ;
@@ -124,15 +109,11 @@ describe('Account Lockout Policy: ', () => {
124
109
. catch ( err => {
125
110
if (
126
111
err &&
127
- err ===
128
- 'Account lockout threshold should be an integer greater than 0 and less than 1000'
112
+ err === 'Account lockout threshold should be an integer greater than 0 and less than 1000'
129
113
) {
130
114
done ( ) ;
131
115
} else {
132
- fail (
133
- 'set threshold to an invalid number test failed: ' +
134
- JSON . stringify ( err )
135
- ) ;
116
+ fail ( 'set threshold to an invalid number test failed: ' + JSON . stringify ( err ) ) ;
136
117
done ( ) ;
137
118
}
138
119
} ) ;
@@ -155,14 +136,11 @@ describe('Account Lockout Policy: ', () => {
155
136
. catch ( err => {
156
137
if (
157
138
err &&
158
- err ===
159
- 'Account lockout threshold should be an integer greater than 0 and less than 1000'
139
+ err === 'Account lockout threshold should be an integer greater than 0 and less than 1000'
160
140
) {
161
141
done ( ) ;
162
142
} else {
163
- fail (
164
- 'threshold value < 1 is invalid test failed: ' + JSON . stringify ( err )
165
- ) ;
143
+ fail ( 'threshold value < 1 is invalid test failed: ' + JSON . stringify ( err ) ) ;
166
144
done ( ) ;
167
145
}
168
146
} ) ;
@@ -185,15 +163,11 @@ describe('Account Lockout Policy: ', () => {
185
163
. catch ( err => {
186
164
if (
187
165
err &&
188
- err ===
189
- 'Account lockout threshold should be an integer greater than 0 and less than 1000'
166
+ err === 'Account lockout threshold should be an integer greater than 0 and less than 1000'
190
167
) {
191
168
done ( ) ;
192
169
} else {
193
- fail (
194
- 'threshold value > 999 is invalid test failed: ' +
195
- JSON . stringify ( err )
196
- ) ;
170
+ fail ( 'threshold value > 999 is invalid test failed: ' + JSON . stringify ( err ) ) ;
197
171
done ( ) ;
198
172
}
199
173
} ) ;
@@ -216,14 +190,11 @@ describe('Account Lockout Policy: ', () => {
216
190
. catch ( err => {
217
191
if (
218
192
err &&
219
- err ===
220
- 'Account lockout duration should be greater than 0 and less than 100000'
193
+ err === 'Account lockout duration should be greater than 0 and less than 100000'
221
194
) {
222
195
done ( ) ;
223
196
} else {
224
- fail (
225
- 'duration value < 1 is invalid test failed: ' + JSON . stringify ( err )
226
- ) ;
197
+ fail ( 'duration value < 1 is invalid test failed: ' + JSON . stringify ( err ) ) ;
227
198
done ( ) ;
228
199
}
229
200
} ) ;
@@ -246,15 +217,11 @@ describe('Account Lockout Policy: ', () => {
246
217
. catch ( err => {
247
218
if (
248
219
err &&
249
- err ===
250
- 'Account lockout duration should be greater than 0 and less than 100000'
220
+ err === 'Account lockout duration should be greater than 0 and less than 100000'
251
221
) {
252
222
done ( ) ;
253
223
} else {
254
- fail (
255
- 'duration value > 99999 is invalid test failed: ' +
256
- JSON . stringify ( err )
257
- ) ;
224
+ fail ( 'duration value > 99999 is invalid test failed: ' + JSON . stringify ( err ) ) ;
258
225
done ( ) ;
259
226
}
260
227
} ) ;
@@ -276,16 +243,10 @@ describe('Account Lockout Policy: ', () => {
276
243
return user . signUp ( ) ;
277
244
} )
278
245
. then ( ( ) => {
279
- return loginWithWrongCredentialsShouldFail (
280
- 'username2' ,
281
- 'wrong password'
282
- ) ;
246
+ return loginWithWrongCredentialsShouldFail ( 'username2' , 'wrong password' ) ;
283
247
} )
284
248
. then ( ( ) => {
285
- return loginWithWrongCredentialsShouldFail (
286
- 'username2' ,
287
- 'wrong password'
288
- ) ;
249
+ return loginWithWrongCredentialsShouldFail ( 'username2' , 'wrong password' ) ;
289
250
} )
290
251
. then ( ( ) => {
291
252
return isAccountLockoutError ( 'username2' , 'wrong password' , 1 , 1 ) ;
@@ -294,10 +255,7 @@ describe('Account Lockout Policy: ', () => {
294
255
done ( ) ;
295
256
} )
296
257
. catch ( err => {
297
- fail (
298
- 'lock account after failed login attempts test failed: ' +
299
- JSON . stringify ( err )
300
- ) ;
258
+ fail ( 'lock account after failed login attempts test failed: ' + JSON . stringify ( err ) ) ;
301
259
done ( ) ;
302
260
} ) ;
303
261
} ) ;
@@ -318,16 +276,10 @@ describe('Account Lockout Policy: ', () => {
318
276
return user . signUp ( ) ;
319
277
} )
320
278
. then ( ( ) => {
321
- return loginWithWrongCredentialsShouldFail (
322
- 'username3' ,
323
- 'wrong password'
324
- ) ;
279
+ return loginWithWrongCredentialsShouldFail ( 'username3' , 'wrong password' ) ;
325
280
} )
326
281
. then ( ( ) => {
327
- return loginWithWrongCredentialsShouldFail (
328
- 'username3' ,
329
- 'wrong password'
330
- ) ;
282
+ return loginWithWrongCredentialsShouldFail ( 'username3' , 'wrong password' ) ;
331
283
} )
332
284
. then ( ( ) => {
333
285
return isAccountLockoutError ( 'username3' , 'wrong password' , 0.05 , 1 ) ;
@@ -340,10 +292,7 @@ describe('Account Lockout Policy: ', () => {
340
292
done ( ) ;
341
293
} )
342
294
. catch ( err => {
343
- fail (
344
- 'account should be locked for duration mins test failed: ' +
345
- JSON . stringify ( err )
346
- ) ;
295
+ fail ( 'account should be locked for duration mins test failed: ' + JSON . stringify ( err ) ) ;
347
296
done ( ) ;
348
297
} ) ;
349
298
} ) ;
@@ -364,16 +313,10 @@ describe('Account Lockout Policy: ', () => {
364
313
return user . signUp ( ) ;
365
314
} )
366
315
. then ( ( ) => {
367
- return loginWithWrongCredentialsShouldFail (
368
- 'username4' ,
369
- 'wrong password'
370
- ) ;
316
+ return loginWithWrongCredentialsShouldFail ( 'username4' , 'wrong password' ) ;
371
317
} )
372
318
. then ( ( ) => {
373
- return loginWithWrongCredentialsShouldFail (
374
- 'username4' ,
375
- 'wrong password'
376
- ) ;
319
+ return loginWithWrongCredentialsShouldFail ( 'username4' , 'wrong password' ) ;
377
320
} )
378
321
. then ( ( ) => {
379
322
// allow locked user to login after 3 seconds with a valid userid and password
0 commit comments