dhirajkk91 commented on code in PR #75917:
URL: https://github.com/apache/airflow/pull/75917#discussion_r4434120219
##########
providers/git/tests/unit/git/hooks/test_git.py:
##########
@@ -781,6 +847,76 @@ def
test_token_credential_env_skipped_for_ssh_transport(self, create_connection_
assert "GIT_CONFIG_COUNT" not in hook.env
assert "AIRFLOW_GIT_TOKEN" not in hook.env
+ @pytest.mark.parametrize(
+ ("url", "supported", "expected_count", "expected_key"),
+ [
+ pytest.param(AIRFLOW_HTTPS_URL, True, "3",
f"http.{AIRFLOW_HTTPS_URL}.proactiveAuth", id="https"),
+ pytest.param(AIRFLOW_HTTPS_URL, False, "2", None,
id="git-older-than-2.46"),
+ pytest.param(AIRFLOW_HTTP_URL, True, "2", None, id="plain-http"),
+ ],
+ )
+ def test_proactive_auth_config(
+ self,
+ url,
+ supported,
+ expected_count,
+ expected_key,
+ proactive_auth_supported,
+ create_connection_without_db,
+ ):
+ proactive_auth_supported.return_value = supported
+ create_connection_without_db(
+ Connection(conn_id="git_proactive_auth", host=url,
password=ACCESS_TOKEN, conn_type="git")
+ )
+ hook = GitHook(git_conn_id="git_proactive_auth")
+
+ with hook.configure_hook_env():
+ assert hook.env["GIT_CONFIG_COUNT"] == expected_count
+ assert hook.env.get("GIT_CONFIG_KEY_2") == expected_key
+ assert hook.env.get("GIT_CONFIG_VALUE_2") == ("basic" if
expected_key else None)
+
+ @pytest.mark.skipif(Git().version_info < (2, 46),
reason="http.proactiveAuth needs git 2.46+")
+ def test_token_reaches_a_public_repository_without_a_challenge(
+ self, proactive_auth_supported, create_connection_without_db, tmp_path
+ ):
+ proactive_auth_supported.return_value = True
+ with recording_public_https_git_server(tmp_path) as (port, received):
+ url = f"https://127.0.0.1:{port}/repo.git"
+ create_connection_without_db(
+ Connection(
+ conn_id="git_public_repo",
+ host=url,
+ login="token_user",
+ password=ACCESS_TOKEN,
+ conn_type="git",
+ )
+ )
+ hook = GitHook(git_conn_id="git_public_repo")
+
+ with hook.configure_hook_env():
+ git_ls_remote(url, {**hook.env, "GIT_SSL_NO_VERIFY": "true"})
Review Comment:
The connection doesn't have any TLS settings, so there wasn't a place for it
there, but turning verification off in the test wasn't great either. I changed
it to trust the test server's own certificate through GIT_SSL_CAINFO, so TLS is
actually verified now. Thanks for pointing it out
--
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]