@@ -751,7 +751,8 @@ def test_broker_should_be_disabled_by_default(self):
751751 @patch ("msal.application._init_broker" , new = Mock (side_effect = ImportError (
752752 "PyMsalRuntime not installed"
753753 )))
754- def test_should_error_out_when_opted_in_yet_pymsalruntime_not_installed (self ):
754+ def test_opt_in_should_error_out_when_pymsalruntime_not_installed (self ):
755+ """Because it is actionable to app developer to add dependency declaration"""
755756 with self .assertRaises (ImportError ):
756757 app = msal .PublicClientApplication (
757758 "client_id" ,
@@ -830,3 +831,28 @@ def test_should_fallback_to_non_broker_when_using_oidc_authority(self):
830831 )
831832 self .assertFalse (app ._enable_broker )
832833
834+ def test_app_did_not_register_redirect_uri_should_error_out (self ):
835+ """Because it is actionable to app developer to add redirect URI"""
836+ app = msal .PublicClientApplication (
837+ "client_id" ,
838+ authority = "https://login.microsoftonline.com/common" ,
839+ enable_broker_on_mac = True ,
840+ )
841+ self .assertTrue (app ._enable_broker )
842+ with patch .object (
843+ # Note: We tried @patch("msal.broker.foo", ...) but it ended up with
844+ # "module msal does not have attribute broker"
845+ app , "_acquire_token_interactive_via_broker" , return_value = {
846+ "error" : "broker_error" ,
847+ "error_description" :
848+ "(pii). " # pymsalruntime no longer surfaces AADSTS error,
849+ # So MSAL Python can't raise RedirectUriError.
850+ "Status: Response_Status.Status_ApiContractViolation, "
851+ "Error code: 3399614473, Tag 557973642" ,
852+ }):
853+ result = app .acquire_token_interactive (
854+ ["scope" ],
855+ parent_window_handle = app .CONSOLE_WINDOW_HANDLE ,
856+ )
857+ self .assertEqual (result .get ("error" ), "broker_error" )
858+
0 commit comments