mirror of
https://github.com/apache/superset.git
synced 2026-05-10 18:35:40 +00:00
fix: permission checks on import (#23200)
This commit is contained in:
committed by
Elizabeth Thompson
parent
831978f0f7
commit
cfc2ca672e
@@ -327,10 +327,11 @@ class TestImportDatasetsCommand(SupersetTestCase):
|
||||
db.session.commit()
|
||||
|
||||
@patch("superset.datasets.commands.importers.v1.utils.g")
|
||||
@patch("superset.security.manager.g")
|
||||
@pytest.mark.usefixtures("load_energy_table_with_slice")
|
||||
def test_import_v1_dataset(self, mock_g):
|
||||
def test_import_v1_dataset(self, sm_g, utils_g):
|
||||
"""Test that we can import a dataset"""
|
||||
mock_g.user = security_manager.find_user("admin")
|
||||
admin = sm_g.user = utils_g.user = security_manager.find_user("admin")
|
||||
contents = {
|
||||
"metadata.yaml": yaml.safe_dump(dataset_metadata_config),
|
||||
"databases/imported_database.yaml": yaml.safe_dump(database_config),
|
||||
@@ -360,7 +361,7 @@ class TestImportDatasetsCommand(SupersetTestCase):
|
||||
)
|
||||
|
||||
# user should be included as one of the owners
|
||||
assert dataset.owners == [mock_g.user]
|
||||
assert dataset.owners == [admin]
|
||||
|
||||
# database is also imported
|
||||
assert str(dataset.database.uuid) == "b8a1ccd3-779d-4ab7-8ad8-9ab119d7fe89"
|
||||
@@ -395,8 +396,11 @@ class TestImportDatasetsCommand(SupersetTestCase):
|
||||
db.session.delete(dataset.database)
|
||||
db.session.commit()
|
||||
|
||||
def test_import_v1_dataset_multiple(self):
|
||||
@patch("superset.security.manager.g")
|
||||
def test_import_v1_dataset_multiple(self, mock_g):
|
||||
"""Test that a dataset can be imported multiple times"""
|
||||
mock_g.user = security_manager.find_user("admin")
|
||||
|
||||
contents = {
|
||||
"metadata.yaml": yaml.safe_dump(dataset_metadata_config),
|
||||
"databases/imported_database.yaml": yaml.safe_dump(database_config),
|
||||
@@ -483,8 +487,11 @@ class TestImportDatasetsCommand(SupersetTestCase):
|
||||
}
|
||||
}
|
||||
|
||||
def test_import_v1_dataset_existing_database(self):
|
||||
@patch("superset.security.manager.g")
|
||||
def test_import_v1_dataset_existing_database(self, mock_g):
|
||||
"""Test that a dataset can be imported when the database already exists"""
|
||||
mock_g.user = security_manager.find_user("admin")
|
||||
|
||||
# first import database...
|
||||
contents = {
|
||||
"metadata.yaml": yaml.safe_dump(database_metadata_config),
|
||||
|
||||
Reference in New Issue
Block a user