ktmud commented on a change in pull request #12680:
URL: https://github.com/apache/superset/pull/12680#discussion_r566368837
##########
File path: tests/base_tests.py
##########
@@ -149,7 +150,11 @@ def create_user_with_roles(username: str, roles:
List[str]):
db.session.commit()
user_to_create = security_manager.find_user(username)
assert user_to_create
- user_to_create.roles = [security_manager.find_role(r) for r in roles]
+ user_to_create.roles = []
+ for chosen_user_role in roles:
+ if copy_roles:
+ security_manager.copy_role("Gamma", chosen_user_role, False)
Review comment:
The name `copy_roles` is a little confusing considering you are just
copying `Gamma` permissions over to the new roles. Since a user can have
multiple roles, what you wanted is probably something like this:
```python
def create_user_with_roles(
username: str, roles: List[str], include_gamma_role: bool = True
):
...
user_to_create.roles = (
[security_manager.find_role("Gamma")]
if include_gamma_role else []
) + [security_manager.find_role(r) for r in roles]
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]