@@ -447,6 +447,71 @@ describe('AuthenticationOrchestrator', () => {
447447 ) ;
448448 } ) ;
449449
450+ it ( 'resetPassword should include organization when provided' , async ( ) => {
451+ mockHttpClientInstance . post . mockResolvedValueOnce ( {
452+ json : { } ,
453+ response : new Response ( null , { status : 200 } ) ,
454+ } ) ;
455+ await orchestrator . resetPassword ( {
456+ email : 'info@auth0.com' ,
457+ connection : 'Username-Password-Authentication' ,
458+ organization : 'org_123' ,
459+ } ) ;
460+
461+ expect ( mockHttpClientInstance . post ) . toHaveBeenCalledWith (
462+ '/dbconnections/change_password' ,
463+ {
464+ client_id : clientId ,
465+ email : 'info@auth0.com' ,
466+ connection : 'Username-Password-Authentication' ,
467+ organization : 'org_123' ,
468+ } ,
469+ undefined
470+ ) ;
471+ } ) ;
472+
473+ it ( 'resetPassword should handle custom headers' , async ( ) => {
474+ mockHttpClientInstance . post . mockResolvedValueOnce ( {
475+ json : { } ,
476+ response : new Response ( null , { status : 200 } ) ,
477+ } ) ;
478+ await orchestrator . resetPassword ( {
479+ email : 'info@auth0.com' ,
480+ connection : 'Username-Password-Authentication' ,
481+ organization : 'org_456' ,
482+ headers : { 'X-Custom-Header' : 'custom-value' } ,
483+ } ) ;
484+
485+ expect ( mockHttpClientInstance . post ) . toHaveBeenCalledWith (
486+ '/dbconnections/change_password' ,
487+ {
488+ client_id : clientId ,
489+ email : 'info@auth0.com' ,
490+ connection : 'Username-Password-Authentication' ,
491+ organization : 'org_456' ,
492+ } ,
493+ { 'X-Custom-Header' : 'custom-value' }
494+ ) ;
495+ } ) ;
496+
497+ it ( 'resetPassword should handle error response' , async ( ) => {
498+ const errorResponse = {
499+ error : 'invalid_request' ,
500+ error_description : 'Invalid connection' ,
501+ } ;
502+ mockHttpClientInstance . post . mockResolvedValueOnce ( {
503+ json : errorResponse ,
504+ response : new Response ( null , { status : 400 } ) ,
505+ } ) ;
506+
507+ await expect (
508+ orchestrator . resetPassword ( {
509+ email : 'info@auth0.com' ,
510+ connection : 'Invalid-Connection' ,
511+ } )
512+ ) . rejects . toThrow ( AuthError ) ;
513+ } ) ;
514+
450515 it ( 'createUser should send correct payload and return camelCased response' , async ( ) => {
451516 const userResponse = {
452517 id : 'user_id_123' ,
0 commit comments