baptistegh commented on code in PR #77368:
URL: https://github.com/apache/airflow/pull/77368#discussion_r4705455868
##########
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:
Could you add the case "http://airflow.example.com" with request port 8080,
expecting `http_host == "airflow.example.com"`? I think it fails with the
current code.
##########
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:
```suggestion
mock_request = Mock(spec=Request)
```
--
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]