diff --git a/src/domain.py b/src/domain.py index 0ead23a4d..598fd9e5f 100644 --- a/src/domain.py +++ b/src/domain.py @@ -274,6 +274,20 @@ def domains_regen(domains: List[str]): app_ssowatconf() _run_service_command("reload", "nginx") +# Used in tests to delete many domains at once. +# The permissions/configuration are synchronized at the end of the entire operation. +@is_unit_operation() +def domains_remove(operation_logger, domains: List[str]): + for domain in domains: + domain_remove(domain, do_regen_conf=False) + + domains_regen(domains) + + from yunohost.hook import hook_callback + for domain in domains: + hook_callback("post_domain_remove", args=[domain]) + logger.success(m18n.n("domain_deleted")) + # Used in tests to create many domains at once. # The permissions/configuration are synchronized at the end of the entire operation. @is_unit_operation() @@ -419,6 +433,7 @@ def domain_remove( force=False, dyndns_recovery_password=None, ignore_dyndns=False, + do_regen_conf=True, ): """ Delete domains @@ -541,6 +556,10 @@ def domain_remove( rm(key_file, force=True) rm(f"{DOMAIN_SETTINGS_DIR}/{domain}.yml", force=True) + # We are in a bulk domains_remove so don't regen_conf immediately + if not do_regen_conf: + return + # Sometime we have weird issues with the regenconf where some files # appears as manually modified even though they weren't touched ... # There are a few ideas why this happens (like backup/restore nginx diff --git a/src/tests/test_sso_and_portalapi.py b/src/tests/test_sso_and_portalapi.py index 0049e9857..78e1cb278 100644 --- a/src/tests/test_sso_and_portalapi.py +++ b/src/tests/test_sso_and_portalapi.py @@ -6,7 +6,7 @@ import os from .conftest import message, raiseYunohostError, get_test_apps_dir -from yunohost.domain import _get_maindomain, domain_add, domain_remove, domain_list, domains_add +from yunohost.domain import _get_maindomain, domain_add, domain_remove, domain_list, domains_add, domains_remove from yunohost.user import user_create, user_list, user_delete, User, users_add from yunohost.authenticators.ldap_ynhuser import Authenticator, SESSION_FOLDER, short_hash from yunohost.app import app_install, app_remove, app_setting, app_ssowatconf, app_change_url @@ -70,8 +70,7 @@ def teardown_module(module): domainlist = domain_list()["domains"] domains = [ domain for domain in [ subdomain, secondarydomain ] if domain in domainlist ] - for domain in domains: - domain_remove(domain) + domains_remove(domains) def login(session, logged_as, logged_on=None):