Skip to content

Commit 0ae4e9f

Browse files
authored
Merge pull request #239 from AzureAD/fix-leaky-authority-memorization-test-case
Ensure no side effect leaks outside
2 parents 646cd60 + 2e1176b commit 0ae4e9f

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

tests/test_authority.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,17 @@ def test_memorize(self):
8686
self.assertNotIn(authority, Authority._domains_without_user_realm_discovery)
8787
a = Authority(authority, MinimalHttpClient(), validate_authority=False)
8888

89-
# We now pretend this authority supports no User Realm Discovery
90-
class MockResponse(object):
91-
status_code = 404
92-
a.user_realm_discovery("[email protected]", response=MockResponse())
93-
self.assertIn(
94-
"login.microsoftonline.com",
95-
Authority._domains_without_user_realm_discovery,
96-
"user_realm_discovery() should memorize domains not supporting URD")
97-
a.user_realm_discovery("[email protected]",
98-
response="This would cause exception if memorization did not work")
89+
try:
90+
# We now pretend this authority supports no User Realm Discovery
91+
class MockResponse(object):
92+
status_code = 404
93+
a.user_realm_discovery("[email protected]", response=MockResponse())
94+
self.assertIn(
95+
"login.microsoftonline.com",
96+
Authority._domains_without_user_realm_discovery,
97+
"user_realm_discovery() should memorize domains not supporting URD")
98+
a.user_realm_discovery("[email protected]",
99+
response="This would cause exception if memorization did not work")
100+
finally: # MUST NOT let the previous test changes affect other test cases
101+
Authority._domains_without_user_realm_discovery = set([])
102+

0 commit comments

Comments
 (0)