def test_permission_delete_doesnt_existing(mocker): with raiseYunohostError(mocker, "permission_not_found"): permission_delete("doesnt.exist", force=True) res = user_permission_list()['permissions'] assert "wiki.main" in res assert "blog.main" in res assert "mail.main" in res assert "xmpp.main" in res
def test_permission_delete(mocker): with message(mocker, "permission_deleted", permission="wiki.main"): permission_delete("wiki.main", force=True) res = user_permission_list()['permissions'] assert "wiki.main" not in res with message(mocker, "permission_deleted", permission="blog.api"): permission_delete("blog.api", force=False) res = user_permission_list()['permissions'] assert "blog.api" not in res
def clean_user_groups_permission(): for u in user_list()['users']: user_delete(u) for g in user_group_list()['groups']: if g not in ["all_users", "visitors"]: user_group_delete(g) for p in user_permission_list()['permissions']: if any( p.startswith(name) for name in ["wiki", "blog", "site", "web", "permissions_app"]): permission_delete(p, force=True, sync_perm=False) socket.getaddrinfo = prv_getaddrinfo
def clean(): # Make sure we have a ssowat os.system("mkdir -p /etc/ssowat/") app_ssowatconf() test_apps = ["break_yo_system", "legacy_app", "legacy_app__2", "full_domain_app"] for test_app in test_apps: if _is_installed(test_app): app_remove(test_app) for filepath in glob.glob("/etc/nginx/conf.d/*.d/*%s*" % test_app): os.remove(filepath) for folderpath in glob.glob("/etc/yunohost/apps/*%s*" % test_app): shutil.rmtree(folderpath, ignore_errors=True) for folderpath in glob.glob("/var/www/*%s*" % test_app): shutil.rmtree(folderpath, ignore_errors=True) os.system( "bash -c \"mysql -u root --password=$(cat /etc/yunohost/mysql) 2>/dev/null <<< 'DROP DATABASE %s' \"" % test_app ) os.system( "bash -c \"mysql -u root --password=$(cat /etc/yunohost/mysql) 2>/dev/null <<< 'DROP USER %s@localhost'\"" % test_app ) os.system( "systemctl reset-failed nginx" ) # Reset failed quota for service to avoid running into start-limit rate ? os.system("systemctl start nginx") # Clean permissions for permission_name in user_permission_list(short=True)["permissions"]: if any(test_app in permission_name for test_app in test_apps): permission_delete(permission_name, force=True)
def test_permission_delete_main_without_force(mocker): with raiseYunohostError(mocker, "permission_cannot_remove_main"): permission_delete("blog.main") res = user_permission_list()['permissions'] assert "blog.main" in res