chore: get embedded user with roles and permissions (#19813)

* feat: get user roles endpoint

* add tests

* fix test

* get user with permission and roles with full user

* frontend

* type juggling

* the hash slinging slasher

* user reducer and action

* make it happy

* result

* lint

Co-authored-by: Lily Kuang <lily@preset.io>
This commit is contained in:
David Aaron Suddjian
2022-05-03 12:58:06 -07:00
committed by GitHub
parent 7657e42cff
commit 7f8279b4b3
12 changed files with 143 additions and 20 deletions

View File

@@ -37,6 +37,21 @@ class TestCurrentUserApi(SupersetTestCase):
self.assertEqual(True, response["result"]["is_active"])
self.assertEqual(False, response["result"]["is_anonymous"])
def test_get_me_with_roles(self):
self.login(username="admin")
rv = self.client.get(meUri + "roles/")
self.assertEqual(200, rv.status_code)
response = json.loads(rv.data.decode("utf-8"))
roles = list(response["result"]["roles"].keys())
self.assertEqual("Admin", roles.pop())
@patch("superset.security.manager.g")
def test_get_my_roles_anonymous(self, mock_g):
mock_g.user = security_manager.get_anonymous_user
rv = self.client.get(meUri + "roles/")
self.assertEqual(401, rv.status_code)
def test_get_me_unauthorized(self):
self.logout()
rv = self.client.get(meUri)