Skip to content

Commit ec3c500

Browse files
committed
Merge branch 'release-1.31.1' into dev
2 parents 7826ea8 + 69a96fe commit ec3c500

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

msal/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
# The __init__.py will import this. Not the other way around.
25-
__version__ = "1.31.0" # When releasing, also check and bump our dependencies's versions if needed
25+
__version__ = "1.31.1" # When releasing, also check and bump our dependencies's versions if needed
2626

2727
logger = logging.getLogger(__name__)
2828
_AUTHORITY_TYPE_CLOUDSHELL = "CLOUDSHELL"

msal/managed_identity.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,12 @@ def _scope_to_resource(scope): # This is an experimental reasonable-effort appr
346346
def _get_arc_endpoint():
347347
if "IDENTITY_ENDPOINT" in os.environ and "IMDS_ENDPOINT" in os.environ:
348348
return os.environ["IDENTITY_ENDPOINT"]
349-
if ( # Defined in https://msazure.visualstudio.com/One/_wiki/wikis/One.wiki/233012/VM-Extension-Authoring-for-Arc?anchor=determining-which-endpoint-to-use
350-
sys.platform == "linux" and os.path.exists("/var/opt/azcmagent/bin/himds")
349+
if ( # Defined in https://eng.ms/docs/cloud-ai-platform/azure-core/azure-management-and-platforms/control-plane-bburns/hybrid-resource-provider/azure-arc-for-servers/specs/extension_authoring
350+
sys.platform == "linux" and os.path.exists("/opt/azcmagent/bin/himds")
351351
or sys.platform == "win32" and os.path.exists(os.path.expandvars(
352-
r"%ProgramFiles%\AzureConnectedMachineAgent\himds.exe"))
352+
# Avoid Windows-only "%EnvVar%" syntax so that tests can be run on Linux
353+
r"${ProgramFiles}\AzureConnectedMachineAgent\himds.exe"
354+
))
353355
):
354356
return "http://localhost:40342/metadata/identity/oauth2/token"
355357

tests/test_mi.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,23 @@ def test_machine_learning(self):
347347
"IDENTITY_ENDPOINT": "http://localhost",
348348
"IMDS_ENDPOINT": "http://localhost",
349349
})
350-
def test_arc(self):
350+
def test_arc_by_env_var(self):
351351
self.assertEqual(get_managed_identity_source(), AZURE_ARC)
352352

353+
@patch("msal.managed_identity.os.path.exists", return_value=True)
354+
@patch("msal.managed_identity.sys.platform", new="linux")
355+
def test_arc_by_file_existence_on_linux(self, mocked_exists):
356+
self.assertEqual(get_managed_identity_source(), AZURE_ARC)
357+
mocked_exists.assert_called_with("/opt/azcmagent/bin/himds")
358+
359+
@patch("msal.managed_identity.os.path.exists", return_value=True)
360+
@patch("msal.managed_identity.sys.platform", new="win32")
361+
@patch.dict(os.environ, {"ProgramFiles": "C:\Program Files"})
362+
def test_arc_by_file_existence_on_windows(self, mocked_exists):
363+
self.assertEqual(get_managed_identity_source(), AZURE_ARC)
364+
mocked_exists.assert_called_with(
365+
r"C:\Program Files\AzureConnectedMachineAgent\himds.exe")
366+
353367
@patch.dict(os.environ, {
354368
"AZUREPS_HOST_ENVIRONMENT": "cloud-shell-foo",
355369
})

0 commit comments

Comments
 (0)