From b93e610cb2f2966c5327c523dd39e52bec4687b7 Mon Sep 17 00:00:00 2001 From: morelgeorge <138018684+morelgeorge@users.noreply.github.com> Date: Thu, 29 Jan 2026 10:11:05 +0100 Subject: [PATCH 1/4] Update msgraph.py to_msal_proxies Updated the logic of function to_msal_proxies. Return proxies attribute even when the authority is not filled --- .../src/airflow/providers/microsoft/azure/hooks/msgraph.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py index 376292e1b3c6f..9f893b1f36a4a 100644 --- a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py +++ b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py @@ -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 + elif proxies: + return proxies return None def _build_request_adapter(self, connection) -> tuple[str, RequestAdapter]: From dfd2333f3dacc25eb286224c1053356f63f858fa Mon Sep 17 00:00:00 2001 From: morelgeorge <138018684+morelgeorge@users.noreply.github.com> Date: Fri, 30 Jan 2026 14:48:45 +0100 Subject: [PATCH 2/4] Added Unit tests for testing to_msal_proxies. --- .../microsoft/azure/hooks/test_msgraph.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_msgraph.py b/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_msgraph.py index 6f6216d8fa9d1..ddd0637c78ae7 100644 --- a/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_msgraph.py +++ b/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_msgraph.py @@ -431,6 +431,46 @@ async def test_build_request_adapter_masks_secrets(self): assert mock_redact.call_count >= 3 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: From d1347293b36523b17fa92151951518e5c6bafd52 Mon Sep 17 00:00:00 2001 From: morelgeorge <138018684+morelgeorge@users.noreply.github.com> Date: Sun, 1 Feb 2026 12:11:34 +0100 Subject: [PATCH 3/4] Changed elif to if based on Static Tests --- .../src/airflow/providers/microsoft/azure/hooks/msgraph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py index 9f893b1f36a4a..8216e9138149e 100644 --- a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py +++ b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py @@ -276,7 +276,7 @@ def to_msal_proxies(self, authority: str | None, proxies: dict | None) -> dict | if authority.endswith(domain_name): return None return proxies - elif proxies: + if proxies: return proxies return None From aa73d96fbbb1c78fc7d28b9dce95a72aedbc3622 Mon Sep 17 00:00:00 2001 From: morelgeorge <138018684+morelgeorge@users.noreply.github.com> Date: Sun, 1 Feb 2026 13:50:25 +0100 Subject: [PATCH 4/4] Removed trailing whitespaces based on Static Test output. --- .../azure/tests/unit/microsoft/azure/hooks/test_msgraph.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_msgraph.py b/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_msgraph.py index ddd0637c78ae7..4230bcd8ebec6 100644 --- a/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_msgraph.py +++ b/providers/microsoft/azure/tests/unit/microsoft/azure/hooks/test_msgraph.py @@ -431,7 +431,7 @@ async def test_build_request_adapter_masks_secrets(self): assert mock_redact.call_count >= 3 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") @@ -461,7 +461,7 @@ def test_msal_returns_proxies_when_no_authority_no_proxy_key(self): 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")