Skip to content

Commit 1e26ed3

Browse files
committed
#894: updates to 'update-settings' endpoint
1 parent 5310812 commit 1e26ed3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

dtale/views.py

+7
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,13 @@ def update_settings(data_id):
16251625
"""
16261626

16271627
updated_settings = get_json_arg(request, "settings", {})
1628+
1629+
# block users from manually updating 'enable_custom_filters'
1630+
if "enable_custom_filters" in updated_settings:
1631+
raise ValueError(
1632+
"Cannot alter the property 'enable_custom_filters' from this endpoint"
1633+
)
1634+
16281635
if not global_state.load_flag(data_id, "enable_custom_filters", False):
16291636
updated_settings.pop("query", None)
16301637

tests/dtale/test_views.py

+15
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,21 @@ def test_update_settings(test_data, unittest):
585585
response_data = response.get_json()
586586
assert "error" in response_data
587587

588+
settings = json.dumps(dict(enable_custom_filters=True))
589+
with app.test_client() as c:
590+
with ExitStack() as stack:
591+
global_state.set_data(c.port, None)
592+
response = c.get(
593+
"/dtale/update-settings/{}".format(c.port),
594+
query_string=dict(settings=settings),
595+
)
596+
assert response.status_code == 200, "should return 200 response"
597+
response_data = response.get_json()
598+
assert (
599+
response_data["error"]
600+
== "Cannot alter the property 'enable_custom_filters' from this endpoint"
601+
)
602+
588603

589604
@pytest.mark.unit
590605
def test_update_formats():

0 commit comments

Comments
 (0)