mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix: add disallowed query params for engines specs (#23217)
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
42db7e562d
commit
b479e93b49
@@ -33,6 +33,7 @@ from sqlalchemy.dialects.mysql import (
|
||||
TINYINT,
|
||||
TINYTEXT,
|
||||
)
|
||||
from sqlalchemy.engine.url import make_url
|
||||
|
||||
from superset.utils.core import GenericDataType
|
||||
from tests.unit_tests.db_engine_specs.utils import (
|
||||
@@ -99,6 +100,25 @@ def test_convert_dttm(
|
||||
assert_convert_dttm(spec, target_type, expected_result, dttm)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sqlalchemy_uri,error",
|
||||
[
|
||||
("mysql://user:password@host/db1?local_infile=1", True),
|
||||
("mysql://user:password@host/db1?local_infile=0", True),
|
||||
("mysql://user:password@host/db1", False),
|
||||
],
|
||||
)
|
||||
def test_validate_database_uri(sqlalchemy_uri: str, error: bool) -> None:
|
||||
from superset.db_engine_specs.mysql import MySQLEngineSpec
|
||||
|
||||
url = make_url(sqlalchemy_uri)
|
||||
if error:
|
||||
with pytest.raises(ValueError):
|
||||
MySQLEngineSpec.validate_database_uri(url)
|
||||
return
|
||||
MySQLEngineSpec.validate_database_uri(url)
|
||||
|
||||
|
||||
@patch("sqlalchemy.engine.Engine.connect")
|
||||
def test_get_cancel_query_id(engine_mock: Mock) -> None:
|
||||
from superset.db_engine_specs.mysql import MySQLEngineSpec
|
||||
|
||||
Reference in New Issue
Block a user