Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Apr 24, 2024
1 parent 86a556f commit 0d093e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
16 changes: 8 additions & 8 deletions superset/security/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,6 @@ def can_access_all_queries(self) -> bool:

return self.can_access("all_query_access", "all_query_access")

def can_access_all_databases(self) -> bool:
"""
Return True if the user can access all the databases, False otherwise.
:returns: Whether the user can access all the databases
"""
return self.can_access("all_database_access", "all_database_access")

def can_access_all_datasources(self) -> bool:
"""
Return True if the user can access all the datasources, False otherwise.
Expand All @@ -421,6 +413,14 @@ def can_access_all_datasources(self) -> bool:
"all_datasource_access", "all_datasource_access"
)

def can_access_all_databases(self) -> bool:
"""
Return True if the user can access all the databases, False otherwise.
:returns: Whether the user can access all the databases
"""
return self.can_access("all_database_access", "all_database_access")

def can_access_database(self, database: "Database") -> bool:
"""
Return True if the user can access the specified database, False otherwise.
Expand Down
15 changes: 4 additions & 11 deletions tests/integration_tests/charts/api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,26 +1301,19 @@ def test_user_gets_all_charts(self):
def count_charts():
uri = "api/v1/chart/"
rv = self.client.get(uri, "get_list")
print(rv.data)
self.assertEqual(rv.status_code, 200)
data = rv.get_json()
return data["count"]

with self.temporary_user(gamma_user, login=True) as user:
self.assertEqual(count_charts(), 0)

all_db_pvm = ("all_database_access", "all_database_access")
with self.temporary_user(
gamma_user, extra_pvms=[all_db_pvm], login=True
) as user:
self.login(username=user.username)
perm = ("all_database_access", "all_database_access")
with self.temporary_user(gamma_user, extra_pvms=[perm], login=True) as user:
assert count_charts() > 0

all_db_pvm = ("all_datasource_access", "all_datasource_access")
with self.temporary_user(
gamma_user, extra_pvms=[all_db_pvm], login=True
) as user:
self.login(username=user.username)
perm = ("all_datasource_access", "all_datasource_access")
with self.temporary_user(gamma_user, extra_pvms=[perm], login=True) as user:
assert count_charts() > 0

# Back to normal
Expand Down

0 comments on commit 0d093e0

Please sign in to comment.