Skip to content

Commit

Permalink
Fix mocking in kerberos integration test (#40042)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
potiuk authored and ephraimbuddy committed Jun 5, 2024
1 parent b2efa5e commit f76b3cc
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ def _set_attrs(self, app_for_kerberos, dagbag_to_db):
def test_trigger_dag(self):
with self.app.test_client() as client:
url_template = "/api/experimental/dags/{}/dag_runs"
url_path = url_template.format("example_bash_operator")
response = client.post(
url_template.format("example_bash_operator"),
url_path,
data=json.dumps(dict(run_id="my_run" + datetime.now().isoformat())),
content_type="application/json",
)
Expand All @@ -79,6 +80,8 @@ class Request:
response.raw = mock.MagicMock()
response.connection = mock.MagicMock()
response.connection.send = mock.MagicMock()
response.connection.send.return_value = mock.MagicMock()
response.connection.send.return_value.url = url_path

# disable mutual authentication for testing
CLIENT_AUTH.mutual_authentication = 3
Expand Down

0 comments on commit f76b3cc

Please sign in to comment.