From bb92292c47e553accd9dd9cdb0690acf133d6b07 Mon Sep 17 00:00:00 2001 From: Ray Luo Date: Thu, 20 Jun 2024 18:27:10 -0700 Subject: [PATCH] Switch to MSAL 1.29+'s TokenCache.search() --- msal_extensions/__init__.py | 2 +- msal_extensions/token_cache.py | 4 ++-- setup.py | 2 +- tests/test_agnostic_backend.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/msal_extensions/__init__.py b/msal_extensions/__init__.py index 9bdc214..99ad4c7 100644 --- a/msal_extensions/__init__.py +++ b/msal_extensions/__init__.py @@ -1,5 +1,5 @@ """Provides auxiliary functionality to the `msal` package.""" -__version__ = "1.2.0b1" # Note: During/after release, copy this number to Dockerfile +__version__ = "1.2.0a2" # Note: During/after release, copy this number to Dockerfile from .persistence import ( FilePersistence, diff --git a/msal_extensions/token_cache.py b/msal_extensions/token_cache.py index 99fd4b2..93e8565 100644 --- a/msal_extensions/token_cache.py +++ b/msal_extensions/token_cache.py @@ -69,7 +69,7 @@ def modify(self, credential_type, old_entry, new_key_value_pairs=None): self._persistence.save(self.serialize()) self._last_sync = time.time() - def _find(self, credential_type, **kwargs): # pylint: disable=arguments-differ + def search(self, credential_type, **kwargs): # pylint: disable=arguments-differ # Use optimistic locking rather than CrossPlatLock(self._lock_location) retry = 3 for attempt in range(1, retry + 1): @@ -83,6 +83,6 @@ def _find(self, credential_type, **kwargs): # pylint: disable=arguments-differ else: raise # End of retry. Re-raise the exception as-is. else: # If reload encountered no error, the data is considered intact - return super(PersistedTokenCache, self)._find(credential_type, **kwargs) + return super(PersistedTokenCache, self).search(credential_type, **kwargs) return [] # Not really reachable here. Just to keep pylint happy. diff --git a/setup.py b/setup.py index 6b2e73c..8af3d63 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ package_data={'': ['LICENSE']}, python_requires=">=3.7", install_requires=[ - 'msal>=1.27,<1.29', # MSAL Python 1.29+ may not have TokenCache._find() + 'msal>=1.29,<2', # Use TokenCache.search() from MSAL Python 1.29+ 'portalocker<3,>=1.4', ## We choose to NOT define a hard dependency on this. diff --git a/tests/test_agnostic_backend.py b/tests/test_agnostic_backend.py index 9f6eca9..565de36 100644 --- a/tests/test_agnostic_backend.py +++ b/tests/test_agnostic_backend.py @@ -32,7 +32,7 @@ def _test_token_cache_roundtrip(persistence): assert token2["token_source"] == "cache", "App2 should hit cache written by app1" assert token1['access_token'] == token2['access_token'], "Cache should hit" -def test_token_cache_roundtrip_with_persistence_biulder(temp_location): +def test_token_cache_roundtrip_with_persistence_builder(temp_location): _test_token_cache_roundtrip(build_encrypted_persistence(temp_location)) def test_token_cache_roundtrip_with_file_persistence(temp_location):