SachinyadavAug20 commented on code in PR #77368:
URL: https://github.com/apache/airflow/pull/77368#discussion_r4705698581
##########
providers/amazon/tests/unit/amazon/aws/auth_manager/routes/test_login.py:
##########
@@ -533,3 +534,55 @@ def
test_login_callback_still_binds_a_solicited_response_when_unsolicited_allowe
def test_login_callback_unsuccessful(self):
response = get_login_callback_response(RELAY_REDIRECT,
is_authenticated=False)
assert response.status_code == 500
+
+ @pytest.mark.parametrize(
+ ("base_url", "req_scheme", "req_port", "expected_https",
"expected_host", "expected_port"),
+ [
+ pytest.param(
+ "http://localhost:8080", "http", 8080, "off",
"localhost:8080", 8080, id="http-local"
+ ),
+ pytest.param(
+ "https://airflow.example.com",
+ "http",
+ 8000,
+ "on",
+ "airflow.example.com",
+ 443,
+ id="tls-reverse-proxy",
+ ),
+ pytest.param(
+ "https://airflow.example.com:8443",
+ "http",
+ 8000,
+ "on",
+ "airflow.example.com:8443",
+ 8443,
+ id="https-custom-port",
+ ),
+ pytest.param(
+ "http://airflow.example.com",
+ "http",
+ 80,
+ "off",
+ "airflow.example.com",
+ 80,
+ id="http-default-port",
Review Comment:
Good catch! When `base_url` is an HTTP scheme without an explicit port
(default port 80) and the request arrives from an internal reverse-proxy port
like 8080, `server_port` previously defaulted to `request.url.port`, which
caused python3-saml to append `:8080` to the callback URL. Added `elif
parsed.scheme == "http": server_port = 80` to align with standard HTTP reverse
proxies, and added the test case. Passes cleanly!
##########
providers/amazon/tests/unit/amazon/aws/auth_manager/routes/test_login.py:
##########
@@ -533,3 +534,55 @@ def
test_login_callback_still_binds_a_solicited_response_when_unsolicited_allowe
def test_login_callback_unsuccessful(self):
response = get_login_callback_response(RELAY_REDIRECT,
is_authenticated=False)
assert response.status_code == 500
+
+ @pytest.mark.parametrize(
+ ("base_url", "req_scheme", "req_port", "expected_https",
"expected_host", "expected_port"),
+ [
+ pytest.param(
+ "http://localhost:8080", "http", 8080, "off",
"localhost:8080", 8080, id="http-local"
+ ),
+ pytest.param(
+ "https://airflow.example.com",
+ "http",
+ 8000,
+ "on",
+ "airflow.example.com",
+ 443,
+ id="tls-reverse-proxy",
+ ),
+ pytest.param(
+ "https://airflow.example.com:8443",
+ "http",
+ 8000,
+ "on",
+ "airflow.example.com:8443",
+ 8443,
+ id="https-custom-port",
+ ),
+ pytest.param(
+ "http://airflow.example.com",
+ "http",
+ 80,
+ "off",
+ "airflow.example.com",
+ 80,
+ id="http-default-port",
+ ),
+ ],
+ )
+ def test_prepare_request_scheme_and_port(
+ self, base_url, req_scheme, req_port, expected_https, expected_host,
expected_port
+ ):
+ mock_request = Mock()
Review Comment:
Applied! Updated to `Mock(spec=Request)`. Thanks for the suggestion!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]