mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Better PRAGMA error message, closes #1185
This commit is contained in:
parent
8e8fc5cee5
commit
640ac7071b
3 changed files with 19 additions and 5 deletions
|
|
@ -1,4 +1,5 @@
|
|||
from bs4 import BeautifulSoup as Soup
|
||||
from datasette.utils import allowed_pragmas
|
||||
from .fixtures import ( # noqa
|
||||
app_client,
|
||||
app_client_base_url_prefix,
|
||||
|
|
@ -124,6 +125,20 @@ def test_invalid_custom_sql(app_client):
|
|||
assert "Statement must be a SELECT" in response.text
|
||||
|
||||
|
||||
def test_disallowed_custom_sql_pragma(app_client):
|
||||
response = app_client.get(
|
||||
"/fixtures?sql=SELECT+*+FROM+pragma_not_on_allow_list('idx52')"
|
||||
)
|
||||
assert response.status == 400
|
||||
pragmas = ", ".join("pragma_{}()".format(pragma) for pragma in allowed_pragmas)
|
||||
assert (
|
||||
"Statement contained a disallowed PRAGMA. Allowed pragma functions are {}".format(
|
||||
pragmas
|
||||
)
|
||||
in response.text
|
||||
)
|
||||
|
||||
|
||||
def test_sql_time_limit(app_client_shorter_time_limit):
|
||||
response = app_client_shorter_time_limit.get("/fixtures?sql=select+sleep(0.5)")
|
||||
assert 400 == response.status
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue