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.
[API] Deprecate /update_role/ API endpoint (apache#4041)
- Loading branch information
1 parent
b7be963
commit 9937465
Showing
3 changed files
with
0 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -520,79 +520,6 @@ 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() | ||
data = json.dumps({ | ||
'users': [{ | ||
'username': 'gamma', | ||
'first_name': 'Gamma', | ||
'last_name': 'Gamma', | ||
'email': '[email protected]', | ||
}], | ||
'role_name': update_role_str}) | ||
r = self.client.post('/superset/update_role/', data=data, | ||
follow_redirects=True) | ||
self.assertEquals(500, r.status_code) | ||
|
||
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({ | ||
'users': [{ | ||
'username': 'gamma', | ||
'first_name': 'Gamma', | ||
'last_name': 'Gamma', | ||
'email': '[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(username='gamma')]) | ||
self.assertEquals(resp.status_code, 201) | ||
|
||
resp = self.client.post( | ||
'/superset/update_role/', | ||
data=json.dumps({ | ||
'users': [{ | ||
'username': 'alpha', | ||
'first_name': 'Alpha', | ||
'last_name': 'Alpha', | ||
'email': '[email protected]', | ||
}, { | ||
'username': 'unknown', | ||
'first_name': 'Unknown1', | ||
'last_name': 'Unknown2', | ||
'email': '[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(username='alpha'), | ||
sm.find_user(username='unknown'), | ||
]) | ||
unknown = sm.find_user(username='unknown') | ||
self.assertEquals('Unknown2', unknown.last_name) | ||
self.assertEquals('Unknown1', unknown.first_name) | ||
self.assertEquals('[email protected]', unknown.email) | ||
db.session.delete(update_role) | ||
db.session.delete(unknown) | ||
db.session.commit() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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