forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Programatically sync the role with user list. (apache#1619)
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -348,6 +348,54 @@ def test_request_access(self): | |
gamma_user.roles.remove(sm.find_role('dummy_role')) | ||
session.commit() | ||
|
||
def test_update_role_do_not_exist(self): | ||
update_role_str = 'update_me' | ||
update_role = sm.find_role(update_role_str) | ||
if update_role: | ||
db.session.delete(update_role) | ||
db.session.commit() | ||
with self.assertRaises(AttributeError): | ||
self.get_resp( | ||
'/superset/update_role/', | ||
data=json.dumps({ | ||
'user_emails': ['[email protected]'], | ||
'role_name': update_role_str, | ||
}) | ||
) | ||
|
||
def test_update_role(self): | ||
update_role_str = 'update_me' | ||
sm.add_role(update_role_str) | ||
db.session.commit() | ||
resp = self.client.post( | ||
'/superset/update_role/', | ||
data=json.dumps({ | ||
'user_emails': ['[email protected]'], | ||
'role_name': update_role_str | ||
}), | ||
follow_redirects=True | ||
) | ||
update_role = sm.find_role(update_role_str) | ||
self.assertEquals( | ||
update_role.user, [sm.find_user(email='[email protected]')]) | ||
self.assertEquals(resp.status_code, 201) | ||
|
||
resp = self.client.post( | ||
'/superset/update_role/', | ||
data=json.dumps({ | ||
'user_emails': ['[email protected]', '[email protected]'], | ||
'role_name': update_role_str | ||
}), | ||
follow_redirects=True | ||
) | ||
self.assertEquals(resp.status_code, 201) | ||
update_role = sm.find_role(update_role_str) | ||
self.assertEquals( | ||
update_role.user, [sm.find_user(email='[email protected]')]) | ||
|
||
db.session.delete(update_role) | ||
db.session.commit() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |