Skip to content

Commit f76b3cc

Browse files
potiukephraimbuddy
authored andcommitted
Fix mocking in kerberos integration test (#40042)
The new requests-kerberos has a slightly different approach for parsing urls and extracting hostname from url causes a problem with "mock cannot be compared to int" when mock is returned as URL. This PR fixes it by hard-coding returned URL in the mock that is being returned in this case. (cherry picked from commit 32fd29d)
1 parent b2efa5e commit f76b3cc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/integration/api_experimental/auth/backend/test_kerberos_auth.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ def _set_attrs(self, app_for_kerberos, dagbag_to_db):
6262
def test_trigger_dag(self):
6363
with self.app.test_client() as client:
6464
url_template = "/api/experimental/dags/{}/dag_runs"
65+
url_path = url_template.format("example_bash_operator")
6566
response = client.post(
66-
url_template.format("example_bash_operator"),
67+
url_path,
6768
data=json.dumps(dict(run_id="my_run" + datetime.now().isoformat())),
6869
content_type="application/json",
6970
)
@@ -79,6 +80,8 @@ class Request:
7980
response.raw = mock.MagicMock()
8081
response.connection = mock.MagicMock()
8182
response.connection.send = mock.MagicMock()
83+
response.connection.send.return_value = mock.MagicMock()
84+
response.connection.send.return_value.url = url_path
8285

8386
# disable mutual authentication for testing
8487
CLIENT_AUTH.mutual_authentication = 3

0 commit comments

Comments
 (0)