bugraoz93 commented on code in PR #43102:
URL: https://github.com/apache/airflow/pull/43102#discussion_r1826398908
##########
tests/api_fastapi/core_api/routes/public/test_connections.py:
##########
@@ -376,10 +376,28 @@ def test_patch_should_respond_400(self, test_client,
payload):
],
)
def test_patch_should_respond_404(self, test_client, payload):
- payload = {"connection_id": TEST_CONN_ID, "conn_type": TEST_CONN_TYPE,
"port": 90}
- response = test_client.patch(f"/public/connections/{TEST_CONN_ID}",
json=payload)
+ response =
test_client.patch(f"/public/connections/{payload['connection_id']}",
json=payload)
assert response.status_code == 404
- print(response.json())
assert {
- "detail": f"The Connection with connection_id: `{TEST_CONN_ID}`
was not found",
+ "detail": f"The Connection with connection_id:
`{payload['connection_id']}` was not found",
} == response.json()
+
+ @pytest.mark.parametrize(
+ "body",
+ [
+ {"connection_id": TEST_CONN_ID, "conn_type": TEST_CONN_TYPE,
"password": "test-password"},
+ {"connection_id": TEST_CONN_ID, "conn_type": TEST_CONN_LOGIN_2,
"password": "?>@#+!_%()#"},
+ {
+ "connection_id": TEST_CONN_ID,
+ "conn_type": TEST_CONN_TYPE,
+ "password": "A!rF|0wi$aw3s0m3",
+ "extra": '{"password": "test-password"}',
+ },
+ ],
+ )
+ def test_patch_should_response_201_redacted_password(self, test_client,
body):
+ self.create_connection()
+ response =
test_client.patch(f"/public/connections/{body['connection_id']}", json=body)
+ assert response.status_code == 200
+ connection = response.json()
+ assert "password" not in connection
Review Comment:
@pierrejeambrun this is working fine though I didn't like the hacky `JSON`
parsing back and forth but I could only make `mypy airflow` happy otherwise. I
was surprised by how the first commit worked in `POST` #43396 after digging
deeper into the `redact()` method.
--
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]