default_allow_sql setting, closes #1409

Refs #1410
This commit is contained in:
Simon Willison 2023-01-04 16:51:11 -08:00
commit c41278b46f
8 changed files with 61 additions and 4 deletions

View file

@ -821,6 +821,7 @@ async def test_settings_json(ds_client):
assert response.json() == {
"default_page_size": 50,
"default_facet_size": 30,
"default_allow_sql": True,
"facet_suggest_time_limit_ms": 50,
"facet_time_limit_ms": 200,
"max_returned_rows": 100,

View file

@ -216,6 +216,28 @@ def test_setting_type_validation():
assert '"default_page_size" should be an integer' in result.stderr
@pytest.mark.parametrize("default_allow_sql", (True, False))
def test_setting_default_allow_sql(default_allow_sql):
runner = CliRunner()
result = runner.invoke(
cli,
[
"--setting",
"default_allow_sql",
"on" if default_allow_sql else "off",
"--get",
"/_memory.json?sql=select+21&_shape=objects",
],
)
if default_allow_sql:
assert result.exit_code == 0, result.output
assert json.loads(result.output)["rows"][0] == {"21": 21}
else:
assert result.exit_code == 1, result.output
# This isn't JSON at the moment, maybe it should be though
assert "Forbidden" in result.output
def test_config_deprecated():
# The --config option should show a deprecation message
runner = CliRunner(mix_stderr=False)