Keep source, config, and deploy files. Leave runtime data, uploads, and logs out of git. Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
727 B
Python
27 lines
727 B
Python
import pytest
|
|
|
|
from kamidso.contracts.errors import KamidsoError, KamidsoErrorCode
|
|
from kamidso.integrations.sql_guard import ensure_read_only_sql
|
|
|
|
|
|
def test_allows_select_and_with():
|
|
ensure_read_only_sql("SELECT id FROM customers LIMIT 10")
|
|
ensure_read_only_sql("WITH x AS (SELECT 1 AS n) SELECT * FROM x")
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"sql",
|
|
[
|
|
"DELETE FROM customers",
|
|
"UPDATE t SET a=1",
|
|
"DROP TABLE t",
|
|
"INSERT INTO t VALUES (1)",
|
|
"ALTER TABLE t ADD COLUMN a int",
|
|
"TRUNCATE t",
|
|
],
|
|
)
|
|
def test_rejects_writes(sql):
|
|
with pytest.raises(KamidsoError) as exc:
|
|
ensure_read_only_sql(sql)
|
|
assert exc.value.code == KamidsoErrorCode.SQL_WRITE_DENIED
|