Skip to content

Commit 2f5774c

Browse files
authored
Merge pull request #225 from AzureAD/arlington-test-case
Adding test case for acquire_token_silent in Arlington
2 parents 0ced4cb + 0c5c807 commit 2f5774c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

msal/application.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,12 @@ def acquire_token_silent_with_error(
552552
return result
553553
final_result = result
554554
for alias in self._get_authority_aliases(self.authority.instance):
555+
if not self.token_cache.find(
556+
self.token_cache.CredentialType.REFRESH_TOKEN,
557+
target=scopes,
558+
query={"environment": alias}):
559+
# Skip heavy weight logic when RT for this alias doesn't exist
560+
continue
555561
the_authority = Authority(
556562
"https://" + alias + "/" + self.authority.tenant,
557563
self.http_client,

tests/test_e2e.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,17 @@ def test_acquire_token_device_flow(self):
590590
config["scope"] = ["user.read"]
591591
self._test_device_flow(**config)
592592

593+
def test_acquire_token_silent_with_an_empty_cache_should_return_none(self):
594+
config = self.get_lab_user(
595+
usertype="cloud", azureenvironment=self.environment, publicClient="no")
596+
app = msal.ConfidentialClientApplication(
597+
config['client_id'], authority=config['authority'],
598+
http_client=MinimalHttpClient())
599+
result = app.acquire_token_silent(scopes=config['scope'], account=None)
600+
self.assertEqual(result, None)
601+
# Note: An alias in this region is no longer accepting HTTPS traffic.
602+
# If this test case passes without exception,
603+
# it means MSAL Python is not affected by that.
593604

594605
if __name__ == "__main__":
595606
unittest.main()

0 commit comments

Comments
 (0)