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
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ def to_msal_proxies(self, authority: str | None, proxies: dict | None) -> dict |
if authority.endswith(domain_name):
return None
return proxies
if proxies:
return proxies
return None

def _build_request_adapter(self, connection) -> tuple[str, RequestAdapter]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,46 @@ async def test_build_request_adapter_masks_secrets(self):
mock_redact.assert_any_call({"http": "http://user:pass@proxy:3128"}, name="proxies")
mock_redact.assert_any_call("my_secret_password", name="client_secret")

def test_msal_returns_none_when_authority_matches_no_proxy(self):
hook = KiotaRequestAdapterHook(conn_id="msgraph")

proxies = {"http": "http://proxy", "no": "*.example.com"}
authority = "api.example.com"

result = hook.to_msal_proxies(authority, proxies)

assert result is None

def test_msal_returns_proxies_when_authority_does_not_match_no_proxy(self):
hook = KiotaRequestAdapterHook(conn_id="msgraph")

proxies = {"http": "http://proxy", "no": "*.example.com"}
authority = "api.other.com"

result = hook.to_msal_proxies(authority, proxies)

assert result == proxies

def test_msal_returns_proxies_when_no_authority_no_proxy_key(self):
hook = KiotaRequestAdapterHook(conn_id="msgraph")

proxies = {"no": "*example.com"}
authority = None

result = hook.to_msal_proxies(authority, proxies)

assert result == proxies

def test_msal_returns_proxies_when_no_authority_with_proxy_key(self):
hook = KiotaRequestAdapterHook(conn_id="msgraph")

proxies = {"http": "http://proxy"}
authority = None

result = hook.to_msal_proxies(authority, proxies)

assert result == proxies


class TestResponseHandler:
def test_default_response_handler_when_json(self):
Expand Down