Skip to content

Commit

Permalink
fix: css template permissions for gamma role (#23083)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgaspar authored Feb 15, 2023
1 parent e5a4c78 commit c39cf36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions superset/security/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ class SupersetSecurityManager( # pylint: disable=too-many-public-methods
GAMMA_READ_ONLY_MODEL_VIEWS = {
"Dataset",
"Datasource",
"CssTemplate",
} | READ_ONLY_MODEL_VIEWS

ADMIN_ONLY_VIEW_MENUS = {
Expand Down
16 changes: 15 additions & 1 deletion tests/integration_tests/security_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1328,13 +1328,26 @@ def assert_can_all(self, view_menu, permissions_set):
def assert_can_menu(self, view_menu, permissions_set):
self.assertIn(("menu_access", view_menu), permissions_set)

def assert_cannot_menu(self, view_menu, permissions_set):
self.assertNotIn(("menu_access", view_menu), permissions_set)

def assert_cannot_gamma(self, perm_set):
self.assert_cannot_write("CssTemplate", perm_set)
self.assert_cannot_menu("CSS Templates", perm_set)
self.assert_cannot_menu("Manage", perm_set)
self.assert_cannot_menu("Queries", perm_set)
self.assert_cannot_menu("Import dashboards", perm_set)
self.assert_cannot_menu("Upload a CSV", perm_set)
self.assert_cannot_menu("ReportSchedule", perm_set)
self.assert_cannot_menu("Alerts & Report", perm_set)

def assert_can_gamma(self, perm_set):
self.assert_can_read("CssTemplate", perm_set)
self.assert_can_read("Dataset", perm_set)

# make sure that user can create slices and dashboards
self.assert_can_all("Dashboard", perm_set)
self.assert_can_all("Chart", perm_set)

self.assertIn(("can_add_slices", "Superset"), perm_set)
self.assertIn(("can_copy_dash", "Superset"), perm_set)
self.assertIn(("can_created_dashboards", "Superset"), perm_set)
Expand Down Expand Up @@ -1477,6 +1490,7 @@ def test_is_gamma_pvm(self):
def test_gamma_permissions_basic(self):
self.assert_can_gamma(get_perm_tuples("Gamma"))
self.assert_cannot_alpha(get_perm_tuples("Gamma"))
self.assert_cannot_gamma(get_perm_tuples("Gamma"))

@pytest.mark.usefixtures("public_role_like_gamma")
def test_public_permissions_basic(self):
Expand Down

0 comments on commit c39cf36

Please sign in to comment.