fix: schemas for upload API (#29604)
This commit is contained in:
parent
ec508a70a6
commit
b66c0f8d30
|
|
@ -982,7 +982,7 @@ class Database(Model, AuditMixinNullable, ImportExportMixin): # pylint: disable
|
||||||
|
|
||||||
def get_schema_access_for_file_upload( # pylint: disable=invalid-name
|
def get_schema_access_for_file_upload( # pylint: disable=invalid-name
|
||||||
self,
|
self,
|
||||||
) -> list[str]:
|
) -> set[str]:
|
||||||
allowed_databases = self.get_extra().get("schemas_allowed_for_file_upload", [])
|
allowed_databases = self.get_extra().get("schemas_allowed_for_file_upload", [])
|
||||||
|
|
||||||
if isinstance(allowed_databases, str):
|
if isinstance(allowed_databases, str):
|
||||||
|
|
@ -993,7 +993,7 @@ class Database(Model, AuditMixinNullable, ImportExportMixin): # pylint: disable
|
||||||
self, g.user
|
self, g.user
|
||||||
)
|
)
|
||||||
allowed_databases += extra_allowed_databases
|
allowed_databases += extra_allowed_databases
|
||||||
return sorted(set(allowed_databases))
|
return set(allowed_databases)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sqlalchemy_uri_decrypted(self) -> str:
|
def sqlalchemy_uri_decrypted(self) -> str:
|
||||||
|
|
|
||||||
|
|
@ -2621,7 +2621,7 @@ class TestDashboardApi(ApiOwnersTestCaseMixin, InsertChartMixin, SupersetTestCas
|
||||||
|
|
||||||
# Clean up system tags
|
# Clean up system tags
|
||||||
tag_list = [tag.id for tag in model.tags if tag.type == TagType.custom]
|
tag_list = [tag.id for tag in model.tags if tag.type == TagType.custom]
|
||||||
self.assertEqual(tag_list, new_tags)
|
self.assertEqual(sorted(tag_list), sorted(new_tags))
|
||||||
|
|
||||||
@pytest.mark.usefixtures("create_dashboard_with_tag")
|
@pytest.mark.usefixtures("create_dashboard_with_tag")
|
||||||
def test_update_dashboard_remove_tags_can_write_on_tag(self):
|
def test_update_dashboard_remove_tags_can_write_on_tag(self):
|
||||||
|
|
|
||||||
|
|
@ -461,3 +461,23 @@ def test_raw_connection_oauth(mocker: MockerFixture) -> None:
|
||||||
with database.get_raw_connection() as conn:
|
with database.get_raw_connection() as conn:
|
||||||
conn.cursor()
|
conn.cursor()
|
||||||
assert str(excinfo.value) == "You don't have permission to access the data."
|
assert str(excinfo.value) == "You don't have permission to access the data."
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_schema_access_for_file_upload() -> None:
|
||||||
|
"""
|
||||||
|
Test the `get_schema_access_for_file_upload` method.
|
||||||
|
"""
|
||||||
|
database = Database(
|
||||||
|
database_name="first-database",
|
||||||
|
sqlalchemy_uri="gsheets://",
|
||||||
|
extra=json.dumps(
|
||||||
|
{
|
||||||
|
"metadata_params": {},
|
||||||
|
"engine_params": {},
|
||||||
|
"metadata_cache_timeout": {},
|
||||||
|
"schemas_allowed_for_file_upload": '["public"]',
|
||||||
|
}
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
assert database.get_schema_access_for_file_upload() == {"public"}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue