@@ -65,49 +65,3 @@ def test_bridge_rejects_invalid_scope(self, mock_credential_class):
6565 credential = MsalTokenCredential (auth )
6666 with pytest .raises (ClientAuthenticationError ):
6767 credential .get_token ("https://evil.example.com/.default" )
68-
69-
70- class TestMsalBridgeNonAzureCli :
71- """Verify non-azure-cli identity types never invoke AzureCliCredential."""
72-
73- @patch ("fabric_cli.core.fab_auth.AzureCliCredential" )
74- def test_user_identity_does_not_invoke_azure_cli (self , mock_credential_class ):
75- """When identity_type is 'user', AzureCliCredential must not be instantiated."""
76- auth = FabAuth ()
77- auth .set_access_mode ("user" )
78-
79- # Simulate MSAL returning a cached token so no interactive prompt
80- mock_app = MagicMock ()
81- mock_app .get_accounts .return_value = [{"username" : "test@contoso.com" }]
82- mock_app .acquire_token_silent .return_value = {
83- "access_token" : "msal-user-token" ,
84- "expires_on" : str (int (time .time ()) + 3600 ),
85- }
86- auth .app = mock_app
87-
88- credential = MsalTokenCredential (auth )
89- result = credential .get_token (con .SCOPE_FABRIC_DEFAULT [0 ])
90-
91- assert result .token == "msal-user-token"
92- mock_credential_class .assert_not_called ()
93-
94- @patch ("fabric_cli.core.fab_auth.AzureCliCredential" )
95- def test_service_principal_does_not_invoke_azure_cli (
96- self , mock_credential_class
97- ):
98- """When identity_type is 'service_principal', AzureCliCredential must not be instantiated."""
99- auth = FabAuth ()
100- auth .set_access_mode ("service_principal" )
101-
102- mock_app = MagicMock ()
103- mock_app .acquire_token_for_client .return_value = {
104- "access_token" : "spn-token" ,
105- "expires_on" : str (int (time .time ()) + 3600 ),
106- }
107- auth .app = mock_app
108-
109- credential = MsalTokenCredential (auth )
110- result = credential .get_token (con .SCOPE_FABRIC_DEFAULT [0 ])
111-
112- assert result .token == "spn-token"
113- mock_credential_class .assert_not_called ()
0 commit comments