@@ -393,6 +393,94 @@ describe("Custom Pages, Email Verification, Password Reset", () => {
393
393
} ) ;
394
394
} ) ;
395
395
396
+ it_exclude_dbs ( [ 'postgres' ] ) ( 'fails if you include an emailAdapter, have an appName, but have no publicServerURL and send a password reset email' , done => {
397
+ reconfigureServer ( {
398
+ appName : undefined ,
399
+ emailAdapter : MockEmailAdapterWithOptions ( {
400
+
401
+ apiKey : 'k' ,
402
+ domain : 'd' ,
403
+ } ) ,
404
+ } )
405
+ . then ( ( ) => {
406
+ let user = new Parse . User ( ) ;
407
+ user . setPassword ( "asdf" ) ;
408
+ user . setUsername ( "zxcv" ) ;
409
+ user . set ( "email" , "[email protected] " ) ;
410
+ user . signUp ( null )
411
+ . then ( user => Parse . User . requestPasswordReset ( "[email protected] " ) )
412
+ . then ( result => {
413
+ console . log ( result ) ;
414
+ fail ( 'sending password reset email should not have succeeded' ) ;
415
+ done ( ) ;
416
+ } , error => {
417
+ expect ( error . message ) . toEqual ( 'An appName, publicServerURL, and emailAdapter are required for password reset functionality.' )
418
+ done ( ) ;
419
+ } ) ;
420
+ } )
421
+ . catch ( error => {
422
+ fail ( JSON . stringify ( error ) ) ;
423
+ done ( ) ;
424
+ } ) ;
425
+ } ) ;
426
+
427
+ it_exclude_dbs ( [ 'postgres' ] ) ( 'fails if you set a publicServerURL, have an appName, but no emailAdapter and send a password reset email' , done => {
428
+ reconfigureServer ( {
429
+ appName : 'unused' ,
430
+ publicServerURL : 'http://localhost:1337/1' ,
431
+ emailAdapter : undefined ,
432
+ } )
433
+ . then ( ( ) => {
434
+ let user = new Parse . User ( ) ;
435
+ user . setPassword ( "asdf" ) ;
436
+ user . setUsername ( "zxcv" ) ;
437
+ user . set ( "email" , "[email protected] " ) ;
438
+ user . signUp ( null )
439
+ . then ( user => Parse . User . requestPasswordReset ( "[email protected] " ) )
440
+ . then ( result => {
441
+ console . log ( result ) ;
442
+ fail ( 'sending password reset email should not have succeeded' ) ;
443
+ done ( ) ;
444
+ } , error => {
445
+ expect ( error . message ) . toEqual ( 'An appName, publicServerURL, and emailAdapter are required for password reset functionality.' )
446
+ done ( ) ;
447
+ } ) ;
448
+ } )
449
+ . catch ( error => {
450
+ fail ( JSON . stringify ( error ) ) ;
451
+ done ( ) ;
452
+ } ) ;
453
+ } ) ;
454
+
455
+ it_exclude_dbs ( [ 'postgres' ] ) ( 'succeeds sending a password reset email if appName, publicServerURL, and email adapter are prodvided' , done => {
456
+ reconfigureServer ( {
457
+ appName : 'coolapp' ,
458
+ publicServerURL : 'http://localhost:1337/1' ,
459
+ emailAdapter : MockEmailAdapterWithOptions ( {
460
+
461
+ apiKey : 'k' ,
462
+ domain : 'd' ,
463
+ } ) ,
464
+ } )
465
+ . then ( ( ) => {
466
+ let user = new Parse . User ( ) ;
467
+ user . setPassword ( "asdf" ) ;
468
+ user . setUsername ( "zxcv" ) ;
469
+ user . set ( "email" , "[email protected] " ) ;
470
+ user . signUp ( null )
471
+ . then ( user => Parse . User . requestPasswordReset ( "[email protected] " ) )
472
+ . then ( result => {
473
+ done ( ) ;
474
+ } , error => {
475
+ done ( error ) ;
476
+ } ) ;
477
+ } )
478
+ . catch ( error => {
479
+ fail ( JSON . stringify ( error ) ) ;
480
+ done ( ) ;
481
+ } ) ;
482
+ } ) ;
483
+
396
484
it ( 'does not send verification email if email verification is disabled' , done => {
397
485
var emailAdapter = {
398
486
sendVerificationEmail : ( ) => Promise . resolve ( ) ,
0 commit comments