def teardown_function(function): assert tmp_backup_directory_is_empty() reset_ssowat_conf() delete_all_backups() uninstall_test_apps_if_needed() markers = { m.name: { 'args': m.args, 'kwargs': m.kwargs } for m in function.__dict__.get("pytestmark", []) } if "clean_opt_dir" in markers: shutil.rmtree("/opt/test_backup_output_directory") if "alice" in user_list()["users"]: user_delete("alice") if "with_custom_domain" in markers: domain = markers['with_custom_domain']['args'][0] domain_remove(domain)
def teardown_function(function): clean_user_groups_permission() global other_domains for domain in other_domains: domain_remove(domain) other_domains = [] _clear_dummy_app_settings() try: app_remove("permissions_app") except: pass try: app_remove("legacy_app") except: pass
def clean(): assert os.system("pgrep slapd >/dev/null") == 0 assert os.system("pgrep nginx >/dev/null") == 0 if TEST_DOMAIN in domain_list()["domains"]: domain_remove(TEST_DOMAIN) assert not os.path.exists(TEST_DOMAIN_NGINX_CONFIG) os.system("rm -f %s" % TEST_DOMAIN_NGINX_CONFIG) assert os.system("nginx -t 2>/dev/null") == 0 assert not os.path.exists(TEST_DOMAIN_NGINX_CONFIG) assert TEST_DOMAIN_NGINX_CONFIG not in _get_conf_hashes("nginx") assert TEST_DOMAIN_NGINX_CONFIG not in manually_modified_files() regen_conf(["ssh"], force=True)
def test_stale_hashes_get_removed_if_empty(): """ This is intended to test that if a file gets removed and is indeed removed, we don't keep a useless empty hash corresponding to an old file. In this case, we test this using the dnsmasq conf file (we don't do this using the nginx conf file because it's already force-removed during domain_remove()) """ domain_add(TEST_DOMAIN) assert os.path.exists(TEST_DOMAIN_DNSMASQ_CONFIG) assert TEST_DOMAIN_DNSMASQ_CONFIG in _get_conf_hashes("dnsmasq") domain_remove(TEST_DOMAIN) assert not os.path.exists(TEST_DOMAIN_DNSMASQ_CONFIG) assert TEST_DOMAIN_DNSMASQ_CONFIG not in _get_conf_hashes("dnsmasq")
def test_stale_hashes_if_file_manually_deleted(): """ Same as other test, but manually delete the file in between and check behavior """ domain_add(TEST_DOMAIN) assert os.path.exists(TEST_DOMAIN_DNSMASQ_CONFIG) assert TEST_DOMAIN_DNSMASQ_CONFIG in _get_conf_hashes("dnsmasq") os.remove(TEST_DOMAIN_DNSMASQ_CONFIG) assert not os.path.exists(TEST_DOMAIN_DNSMASQ_CONFIG) regen_conf(names=["dnsmasq"]) assert not os.path.exists(TEST_DOMAIN_DNSMASQ_CONFIG) assert TEST_DOMAIN_DNSMASQ_CONFIG in _get_conf_hashes("dnsmasq") domain_remove(TEST_DOMAIN) assert not os.path.exists(TEST_DOMAIN_DNSMASQ_CONFIG) assert TEST_DOMAIN_DNSMASQ_CONFIG not in _get_conf_hashes("dnsmasq")
def teardown_module(module): global other_domains for domain in other_domains: domain_remove(domain)
def remove_example_domain(): domain_remove("example.test")