Skip to content

Commit 0a8def4

Browse files
author
Aviat Cohen
committed
mock acquire_token
1 parent b7bdfde commit 0a8def4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

tests/test_commands/conftest.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -898,18 +898,25 @@ def mock_get_access_token(vcr_mode):
898898
if vcr_mode == "none":
899899
fab_auth_instance = FabAuth() # Singleton
900900

901-
# Mock MSAL token result for acquire_token (used by MSAL bridge)
901+
# Mock JWT token in proper format for fabric-cicd library validation
902+
# This is a minimal valid JWT structure: header.payload.signature
903+
mock_jwt_token = (
904+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9."
905+
"eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Im1vY2tfdXNlciIsImV4cCI6OTk5OTk5OTk5OX0."
906+
"mock_signature"
907+
)
908+
909+
# Mock acquire_token since both get_access_token() and MSAL bridge use it
902910
mock_msal_result = {
903-
"access_token": "mocked_access_token",
911+
"access_token": mock_jwt_token,
912+
"expires_on": "9999999999", # Far future timestamp
904913
"expires_in": 3600
905914
}
906915

907916
with patch.object(
908-
fab_auth_instance, "get_access_token", return_value="mocked_access_token"
909-
) as mock_get_token, patch.object(
910917
fab_auth_instance, "acquire_token", return_value=mock_msal_result
911-
) as mock_acquire_token:
912-
yield {"get_access_token": mock_get_token, "acquire_token": mock_acquire_token}
918+
) as mock:
919+
yield mock
913920
else:
914921
yield
915922

0 commit comments

Comments
 (0)