@@ -42,26 +42,22 @@ def test_get_azure_credential_with_website_site_name(self, monkeypatch):
4242 assert credential == mock_instance
4343
4444 def test_get_azure_credential_cli_failure_fallback (self , monkeypatch ):
45- """Test fallback to DefaultAzureCredential when CLI credentials fail"""
45+ """Test RuntimeError when all credential options fail"""
4646 # Clear all Azure environment indicators
4747 for key in ["WEBSITE_SITE_NAME" , "AZURE_CLIENT_ID" , "MSI_ENDPOINT" ,
4848 "IDENTITY_ENDPOINT" , "KUBERNETES_SERVICE_HOST" , "CONTAINER_REGISTRY_LOGIN" ]:
4949 monkeypatch .delenv (key , raising = False )
5050
5151 with patch ('libs.utils.azure_credential_utils.AzureCliCredential' ) as mock_cli_cred , \
52- patch ('libs.utils.azure_credential_utils.AzureDeveloperCliCredential' ) as mock_azd_cred , \
53- patch ('libs.utils.azure_credential_utils.DefaultAzureCredential' ) as mock_default :
52+ patch ('libs.utils.azure_credential_utils.AzureDeveloperCliCredential' ) as mock_azd_cred :
5453
55- # Make both CLI credentials raise exceptions
5654 mock_cli_cred .side_effect = Exception ("CLI credential failed" )
5755 mock_azd_cred .side_effect = Exception ("AZD credential failed" )
58- mock_default_instance = Mock ()
59- mock_default .return_value = mock_default_instance
6056
61- credential = get_azure_credential ()
57+ with pytest .raises (RuntimeError ) as exc :
58+ get_azure_credential ()
6259
63- assert credential == mock_default_instance
64- mock_default .assert_called_once ()
60+ assert "No Azure authentication available" in str (exc .value )
6561
6662 def test_get_azure_credential_azd_success (self , monkeypatch ):
6763 """Test successful Azure Developer CLI credential"""
0 commit comments