dhirajkk91 commented on code in PR #75917:
URL: https://github.com/apache/airflow/pull/75917#discussion_r4459491048


##########
providers/git/tests/unit/git/hooks/test_git.py:
##########
@@ -781,6 +855,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, 
cert_file):
+            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_CAINFO": 
str(cert_file)})
+
+        assert set(received) == {f"token_user:{ACCESS_TOKEN}"}
+
+    @pytest.mark.parametrize(
+        ("version_info", "side_effect", "expected"),
+        [
+            pytest.param((2, 46, 0), None, True, id="2.46"),
+            pytest.param((2, 51, 2), None, True, id="2.51"),
+            pytest.param((2, 45, 4), None, False, id="2.45"),
+            pytest.param((), GitCommandNotFound("git", "not found"), False, 
id="unknown"),

Review Comment:
   Thanks for reproducing the revoked-token case. I’ve pushed a revision that 
makes proactive auth opt-in and defaults it to off. The HTTPS regression test 
now verifies that the same public endpoint accepts the anonymous request with 
the default settings and returns `401` when an opted-in connection sends a 
revoked token.
   
   I also removed the runtime Git version probe, derive `GIT_CONFIG_COUNT` once 
from the config entries, and documented the Git 2.46 requirement and recovery 
steps. All 183 Git provider unit tests passed locally on Git 2.52. Could you 
approve the workflow run when you have a chance?



-- 
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]

Reply via email to