Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4180,6 +4180,8 @@ def process_form(self, form, is_created):
# value isn't an empty string.
if value != "":
extra[field_name] = value
elif field_name in extra:
del extra[field_name]
if extra.keys():
sensitive_unchanged_keys = set()
for key, value in extra.items():
Expand Down
26 changes: 26 additions & 0 deletions tests/www/views/test_views_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,32 @@ def test_process_form_extras_updates_sensitive_placeholder_unchanged(
}


@mock.patch("airflow.utils.module_loading.import_string")
@mock.patch("airflow.providers_manager.ProvidersManager.hooks", new_callable=PropertyMock)
def test_process_form_extras_remove(mock_pm_hooks, mock_import_str):
"""
Test the remove value from field.
"""
# Testing parameters set in both extra and custom fields (connection updates).
mock_form = mock.Mock()
mock_form.data = {
"conn_type": "test4",
"conn_id": "extras_test4",
"extra": '{"extra__test4__remove_field": "remove_field_val3"}',
"extra__test4__remove_field": "",
}

cmv = ConnectionModelView()
cmv._iter_extra_field_names_and_sensitivity = mock.Mock(
return_value=[("extra__test4__remove_field", "remove_field", False)]
)
cmv.process_form(form=mock_form, is_created=True)

assert json.loads(mock_form.extra.data) == {
"extra__test4__remove_field": "remove_field_val3",
}


def test_duplicate_connection(admin_client):
"""Test Duplicate multiple connection with suffix"""
conn1 = Connection(
Expand Down