mirror of
https://github.com/chatmail/relay.git
synced 2026-09-27 17:50:10 +00:00
* dovecot: enable login names with square brackets * config: make IPv4-only relays use self-signed TLS certs * postfix: make delivery for IP-only relays work * cmdeploy: skip DNS checks for IPv4 only relays * www: generate dclogin codes for IPv4-only relays * opendkim: disable DKIM signing on ipv4-only relays * get delivery working * get tests working on IPv4 only machine * doc: document IPv4-only relays * dns: warn if mail_domain is an IP, instead of checking DNS * config: validate domains when formatting them * ci: add cmlxc testing for no-DNS relays * ci: run no-dns and normal CI in parallel * retain "config.mail_domain" as the domain part of @ email addresses, so for ipv4 relays "[1.2.3.4]" and introduce config.ipv4_relay and config.mail_domain_bare helpers. * ci: migrate from --no-dns to --type ipv4 for cmlxc compatibility * cleanup dead code, fix docs, fixate cmlxc version --------- Co-authored-by: missytake <missytake@systemli.org>
74 lines
2.5 KiB
Python
74 lines
2.5 KiB
Python
import importlib
|
|
import os
|
|
|
|
import pytest
|
|
|
|
from cmdeploy.cmdeploy import get_parser, main
|
|
from cmdeploy.www import get_paths
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _chdir(tmp_path):
|
|
old = os.getcwd()
|
|
os.chdir(tmp_path)
|
|
yield
|
|
os.chdir(old)
|
|
|
|
|
|
class TestCmdline:
|
|
def test_parser(self, capsys):
|
|
parser = get_parser()
|
|
parser.parse_args([])
|
|
init = parser.parse_args(["init", "chat.example.org"])
|
|
run = parser.parse_args(["run"])
|
|
assert init and run
|
|
|
|
def test_init_not_overwrite(self, capsys, tmp_path, monkeypatch):
|
|
monkeypatch.delenv("CHATMAIL_INI", raising=False)
|
|
inipath = tmp_path / "chatmail.ini"
|
|
args = ["init", "--config", str(inipath), "chat.example.org"]
|
|
assert main(args) == 0
|
|
capsys.readouterr()
|
|
|
|
assert main(args) == 1
|
|
out, err = capsys.readouterr()
|
|
assert "path exists" in out.lower()
|
|
|
|
args.insert(1, "--force")
|
|
assert main(args) == 0
|
|
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()
|
|
assert not example_config.www_folder
|
|
www_path, src_dir, build_dir = get_paths(example_config)
|
|
assert www_path.absolute() == reporoot.joinpath("www").absolute()
|
|
assert src_dir == reporoot.joinpath("www").joinpath("src")
|
|
assert build_dir == reporoot.joinpath("www").joinpath("build")
|
|
example_config.www_folder = "disabled"
|
|
www_path, _, _ = get_paths(example_config)
|
|
assert not www_path.is_dir()
|
|
example_config.www_folder = str(tmp_path)
|
|
www_path, src_dir, build_dir = get_paths(example_config)
|
|
assert www_path == tmp_path
|
|
assert not src_dir.exists()
|
|
assert not build_dir
|
|
src_path = tmp_path.joinpath("src")
|
|
os.mkdir(src_path)
|
|
with open(src_path / "index.md", "w") as f:
|
|
f.write("# Test")
|
|
www_path, src_dir, build_dir = get_paths(example_config)
|
|
assert www_path == tmp_path
|
|
assert src_dir == src_path
|
|
assert build_dir == tmp_path.joinpath("build")
|