feat(SIP-95): permissions for catalogs (#28317)

This commit is contained in:
Beto Dealmeida
2024-05-06 11:41:58 -04:00
committed by GitHub
parent 9a339f08a7
commit e90246fd1f
50 changed files with 2381 additions and 316 deletions

View File

@@ -175,3 +175,33 @@ SELECT * FROM some_table;
str(excinfo.value)
== "Users are not allowed to set a search path for security reasons."
)
def test_adjust_engine_params() -> None:
"""
Test `adjust_engine_params`.
The method can be used to adjust the catalog (database) dynamically.
"""
from superset.db_engine_specs.postgres import PostgresEngineSpec
adjusted = PostgresEngineSpec.adjust_engine_params(
make_url("postgresql://user:password@host:5432/dev"),
{},
catalog="prod",
)
assert adjusted == (make_url("postgresql://user:password@host:5432/prod"), {})
def test_get_default_catalog() -> None:
"""
Test `get_default_catalog`.
"""
from superset.db_engine_specs.postgres import PostgresEngineSpec
from superset.models.core import Database
database = Database(
database_name="postgres",
sqlalchemy_uri="postgresql://user:password@host:5432/dev",
)
assert PostgresEngineSpec.get_default_catalog(database) == "dev"