1
1
"use strict" ;
2
2
3
- var request = require ( 'request' ) ;
4
- var Config = require ( "../src/Config" ) ;
3
+ let MockEmailAdapterWithOptions = require ( './MockEmailAdapterWithOptions' ) ;
4
+ let request = require ( 'request' ) ;
5
+ let Config = require ( "../src/Config" ) ;
6
+
5
7
describe ( "Custom Pages Configuration" , ( ) => {
6
8
it ( "should set the custom pages" , ( done ) => {
7
9
setServerConfiguration ( {
@@ -62,7 +64,7 @@ describe("Email Verification", () => {
62
64
var user = new Parse . User ( ) ;
63
65
user . setPassword ( "asdf" ) ;
64
66
user . setUsername ( "zxcv" ) ;
65
- user . setEmail ( 'cool_guy @parse.com' ) ;
67
+ user . setEmail ( 'testIfEnabled @parse.com' ) ;
66
68
user . signUp ( null , {
67
69
success : function ( user ) {
68
70
expect ( emailAdapter . sendVerificationEmail ) . toHaveBeenCalled ( ) ;
@@ -150,7 +152,7 @@ describe("Email Verification", () => {
150
152
expect ( emailAdapter . sendVerificationEmail ) . not . toHaveBeenCalled ( ) ;
151
153
user . fetch ( )
152
154
. then ( ( user ) => {
153
- user . set ( "email" , "cool_guy @parse.com" ) ;
155
+ user . set ( "email" , "testWhenUpdating @parse.com" ) ;
154
156
return user . save ( ) ;
155
157
} ) . then ( ( user ) => {
156
158
return user . fetch ( ) ;
@@ -204,7 +206,7 @@ describe("Email Verification", () => {
204
206
expect ( emailAdapter . sendVerificationEmail ) . not . toHaveBeenCalled ( ) ;
205
207
user . fetch ( )
206
208
. then ( ( user ) => {
207
- user . set ( "email" , "cool_guy @parse.com" ) ;
209
+ user . set ( "email" , "testValidLinkWhenUpdating @parse.com" ) ;
208
210
return user . save ( ) ;
209
211
} ) . then ( ( user ) => {
210
212
return user . fetch ( ) ;
@@ -228,7 +230,7 @@ describe("Email Verification", () => {
228
230
var calls = 0 ;
229
231
var emailAdapter = {
230
232
sendMail : function ( options ) {
231
- expect ( options . to ) . toBe ( 'cool_guy @parse.com' ) ;
233
+ expect ( options . to ) . toBe ( 'testSendSimpleAdapter @parse.com' ) ;
232
234
if ( calls == 0 ) {
233
235
expect ( options . subject ) . toEqual ( 'Please verify your e-mail for My Cool App' ) ;
234
236
expect ( options . text . match ( / v e r i f y _ e m a i l / ) ) . not . toBe ( null ) ;
@@ -258,15 +260,15 @@ describe("Email Verification", () => {
258
260
var user = new Parse . User ( ) ;
259
261
user . setPassword ( "asdf" ) ;
260
262
user . setUsername ( "zxcv" ) ;
261
- user . set ( "email" , "cool_guy @parse.com" ) ;
263
+ user . set ( "email" , "testSendSimpleAdapter @parse.com" ) ;
262
264
user . signUp ( null , {
263
265
success : function ( user ) {
264
266
expect ( calls ) . toBe ( 1 ) ;
265
267
user . fetch ( )
266
268
. then ( ( user ) => {
267
269
return user . save ( ) ;
268
270
} ) . then ( ( user ) => {
269
- return Parse . User . requestPasswordReset ( "cool_guy @parse.com" ) . catch ( ( err ) => {
271
+ return Parse . User . requestPasswordReset ( "testSendSimpleAdapter @parse.com" ) . catch ( ( err ) => {
270
272
fail ( 'Should not fail requesting a password' ) ;
271
273
done ( ) ;
272
274
} )
@@ -282,6 +284,42 @@ describe("Email Verification", () => {
282
284
} ) ;
283
285
} ) ;
284
286
287
+ it ( 'fails if you include an emailAdapter, set verifyUserEmails to false, dont set a publicServerURL, and try to send a password reset email (regression test for #1649)' , done => {
288
+ setServerConfiguration ( {
289
+ serverURL : 'http://localhost:8378/1' ,
290
+ appId : 'test' ,
291
+ appName : 'unused' ,
292
+ javascriptKey : 'test' ,
293
+ dotNetKey : 'windows' ,
294
+ clientKey : 'client' ,
295
+ restAPIKey : 'rest' ,
296
+ masterKey : 'test' ,
297
+ collectionPrefix : 'test_' ,
298
+ fileKey : 'test' ,
299
+ verifyUserEmails : false ,
300
+ emailAdapter : MockEmailAdapterWithOptions ( {
301
+
302
+ apiKey : 'k' ,
303
+ domain : 'd' ,
304
+ } ) ,
305
+ } )
306
+
307
+ let user = new Parse . User ( ) ;
308
+ user . setPassword ( "asdf" ) ;
309
+ user . setUsername ( "zxcv" ) ;
310
+ user . set ( "email" , "[email protected] " ) ;
311
+ user . signUp ( null )
312
+ . then ( user => Parse . User . requestPasswordReset ( "[email protected] " ) )
313
+ . then ( result => {
314
+ console . log ( result ) ;
315
+ fail ( 'sending password reset email should not have succeeded' ) ;
316
+ done ( ) ;
317
+ } , error => {
318
+ expect ( error . message ) . toEqual ( 'An appName, publicServerURL, and emailAdapter are required for password reset functionality.' )
319
+ done ( ) ;
320
+ } ) ;
321
+ } ) ;
322
+
285
323
it ( 'does not send verification email if email verification is disabled' , done => {
286
324
var emailAdapter = {
287
325
sendVerificationEmail : ( ) => Promise . resolve ( ) ,
0 commit comments