1919 id_token_claims ,
2020 mock_response ,
2121 msal_validating_transport ,
22+ new_msal_validating_transport ,
2223 Request ,
2324)
24-
25- try :
26- from unittest .mock import Mock , patch
27- except ImportError : # python < 3.3
28- from mock import Mock , patch # type: ignore
25+ from unittest .mock import Mock , patch
2926
3027
3128def test_tenant_id_validation ():
@@ -52,7 +49,7 @@ def test_no_scopes():
5249def test_policies_configurable ():
5350 policy = Mock (spec_set = SansIOHTTPPolicy , on_request = Mock ())
5451
55- transport = msal_validating_transport (
52+ transport = new_msal_validating_transport (
5653 requests = [Request ()], responses = [mock_response (json_payload = build_aad_response (access_token = "**" ))]
5754 )
5855
@@ -66,7 +63,7 @@ def test_policies_configurable():
6663
6764
6865def test_user_agent ():
69- transport = msal_validating_transport (
66+ transport = new_msal_validating_transport (
7067 requests = [Request (required_headers = {"User-Agent" : USER_AGENT })],
7168 responses = [mock_response (json_payload = build_aad_response (access_token = "**" ))],
7269 )
@@ -82,7 +79,7 @@ def test_client_secret_credential():
8279 tenant_id = "fake-tenant-id"
8380 access_token = "***"
8481
85- transport = msal_validating_transport (
82+ transport = new_msal_validating_transport (
8683 endpoint = "https://localhost/" + tenant_id ,
8784 requests = [Request (url_substring = tenant_id , required_data = {"client_id" : client_id , "client_secret" : secret })],
8885 responses = [mock_response (json_payload = build_aad_response (access_token = access_token ))],
@@ -170,10 +167,10 @@ def test_cache_multiple_clients():
170167
171168 access_token_a = "token a"
172169 access_token_b = "not " + access_token_a
173- transport_a = msal_validating_transport (
170+ transport_a = new_msal_validating_transport (
174171 requests = [Request ()], responses = [mock_response (json_payload = build_aad_response (access_token = access_token_a ))]
175172 )
176- transport_b = msal_validating_transport (
173+ transport_b = new_msal_validating_transport (
177174 requests = [Request ()], responses = [mock_response (json_payload = build_aad_response (access_token = access_token_b ))]
178175 )
179176
@@ -202,12 +199,12 @@ def test_cache_multiple_clients():
202199 scope = "scope"
203200 token_a = credential_a .get_token (scope )
204201 assert token_a .token == access_token_a
205- assert transport_a .send .call_count == 3 # two MSAL discovery requests, one token request
202+ assert transport_a .send .call_count == 2 # two MSAL discovery requests, one token request
206203
207204 # B should get a different token for the same scope
208205 token_b = credential_b .get_token (scope )
209206 assert token_b .token == access_token_b
210- assert transport_b .send .call_count == 3
207+ assert transport_b .send .call_count == 2
211208
212209 assert len (cache .find (TokenCache .CredentialType .ACCESS_TOKEN )) == 2
213210
0 commit comments