Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion msal/token_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ def _get(self, credential_type, key, default=None): # O(1)

@staticmethod
def _is_matching(entry: dict, query: dict, target_set: set = None) -> bool:
return is_subdict_of(query or {}, entry) and (
query_with_lowercase_environment = {
# __add() canonicalized entry's environment value to lower case,
# so we do the same here.
k: v.lower() if k == "environment" and isinstance(v, str) else v
for k, v in query.items()
} if query else {}
return is_subdict_of(query_with_lowercase_environment, entry) and (
target_set <= set(entry.get("target", "").split())
if target_set else True)

Expand Down
4 changes: 4 additions & 0 deletions tests/test_mi.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ def test_happy_path_of_vm(self):
headers={'Metadata': 'true'},
)

@patch("msal.managed_identity.socket.getfqdn", new=lambda: "MixedCaseHostName")
def test_happy_path_of_windows_vm(self):
self.test_happy_path_of_vm()

@patch.dict(os.environ, {"AZURE_POD_IDENTITY_AUTHORITY_HOST": "http://localhost:1234//"})
def test_happy_path_of_pod_identity(self):
self._test_happy_path().assert_called_with(
Expand Down
Loading