diff --git a/cmdeploy/src/cmdeploy/cmdeploy.py b/cmdeploy/src/cmdeploy/cmdeploy.py index 3b1195b8..711e4024 100644 --- a/cmdeploy/src/cmdeploy/cmdeploy.py +++ b/cmdeploy/src/cmdeploy/cmdeploy.py @@ -144,6 +144,9 @@ def dns_cmd_options(parser): def dns_cmd(args, out): """Check DNS entries and optionally generate dns zone file.""" + if is_valid_ipv4(args.config.mail_domain): + print(f"[WARNING] {args.config.mail_domain} is not a domain, skipping DNS checks.") + return 0 ssh_host = args.ssh_host if args.ssh_host else args.config.mail_domain sshexec = get_sshexec(ssh_host, verbose=args.verbose) tls_cert_mode = args.config.tls_cert_mode diff --git a/cmdeploy/src/cmdeploy/tests/test_cmdeploy.py b/cmdeploy/src/cmdeploy/tests/test_cmdeploy.py index b7f7b873..c4513bc1 100644 --- a/cmdeploy/src/cmdeploy/tests/test_cmdeploy.py +++ b/cmdeploy/src/cmdeploy/tests/test_cmdeploy.py @@ -39,6 +39,14 @@ class TestCmdline: out, err = capsys.readouterr() assert "deleting config file" in out.lower() + def test_dns_skip_on_ip(self, capsys, tmp_path, monkeypatch): + monkeypatch.delenv("CHATMAIL_INI", raising=False) + inipath = tmp_path / "chatmail.ini" + assert main(["init", "--config", str(inipath), "1.3.3.7"]) == 0 + assert main(["dns", "--config", str(inipath)]) == 0 + out, err = capsys.readouterr() + assert out == "[WARNING] 1.3.3.7 is not a domain, skipping DNS checks.\n" + def test_www_folder(example_config, tmp_path): reporoot = importlib.resources.files(__package__).joinpath("../../../../").resolve()