fix: permission checks on import (#23200)

This commit is contained in:
Beto Dealmeida
2023-03-15 08:31:09 -07:00
committed by Elizabeth Thompson
parent 831978f0f7
commit cfc2ca672e
17 changed files with 621 additions and 99 deletions

View File

@@ -485,9 +485,10 @@ class TestImportDashboardsCommand(SupersetTestCase):
db.session.commit()
@patch("superset.dashboards.commands.importers.v1.utils.g")
def test_import_v1_dashboard(self, mock_g):
@patch("superset.security.manager.g")
def test_import_v1_dashboard(self, sm_g, utils_g):
"""Test that we can import a dashboard"""
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(dashboard_metadata_config),
"databases/imported_database.yaml": yaml.safe_dump(database_config),
@@ -570,7 +571,7 @@ class TestImportDashboardsCommand(SupersetTestCase):
database = dataset.database
assert str(database.uuid) == database_config["uuid"]
assert dashboard.owners == [mock_g.user]
assert dashboard.owners == [admin]
dashboard.owners = []
chart.owners = []
@@ -582,8 +583,11 @@ class TestImportDashboardsCommand(SupersetTestCase):
db.session.delete(database)
db.session.commit()
def test_import_v1_dashboard_multiple(self):
@patch("superset.security.manager.g")
def test_import_v1_dashboard_multiple(self, mock_g):
"""Test that a dashboard can be imported multiple times"""
mock_g.user = security_manager.find_user("admin")
num_dashboards = db.session.query(Dashboard).count()
contents = {