Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert www.security test suite to pytest and remove residuals #18961

Merged
16 changes: 12 additions & 4 deletions tests/test_utils/api_connexion_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,23 @@ def create_role(app, name, permissions=None):
return role


def set_user_single_role(app, username, role_name):
role = create_role(app, role_name)
user = app.appbuilder.sm.find_user(username)
if role not in user.roles:
user.roles = [role]
app.appbuilder.sm.update_user(user)


def delete_role(app, name):
if app.appbuilder.sm.find_role(name):
app.appbuilder.sm.delete_role(name)
if name not in EXISTING_ROLES:
if app.appbuilder.sm.find_role(name):
app.appbuilder.sm.delete_role(name)


def delete_roles(app):
for role in app.appbuilder.sm.get_all_roles():
if role.name not in EXISTING_ROLES:
app.appbuilder.sm.delete_role(role.name)
delete_role(app, role.name)


def delete_user(app, username):
Expand Down
Loading