Compare commits

..

40 Commits

Author SHA1 Message Date
holger krekel
805d743e9e show PATH env 2023-12-11 15:29:21 +01:00
holger krekel
b0d5ee084e fix cmdeploy test command 2023-12-11 15:22:12 +01:00
holger krekel
56c7853e5b remove tox run from deploy-chatmail and use 'cmdeploy fmt' and 'pytest' directly 2023-12-11 13:51:45 +01:00
holger krekel
071d708a89 move tests/chatmaild to chatmaild package, streamline tests and fixtures accordingly 2023-12-11 13:04:11 +01:00
holger krekel
c7c7ed8ff2 fix tests and run all tests on "cmdeploy test" 2023-12-11 12:18:10 +01:00
holger krekel
0aa0ef8a74 discover chatmail.ini in tests from CWD and all parent dirs (tox runs change dirs) 2023-12-11 02:27:05 +01:00
holger krekel
0662e3a8b1 "cmdeploy test" now installs deltachat if it's not there 2023-12-11 02:13:46 +01:00
holger krekel
6c453f93a1 consistently use shell helper 2023-12-11 01:58:31 +01:00
holger krekel
54f29f6bae consistently show ssh/shell output 2023-12-11 01:50:56 +01:00
holger krekel
ad8fee76cd add "build" dependency 2023-12-11 01:45:32 +01:00
holger krekel
528cd3da25 always show which ssh-commands execute 2023-12-11 01:43:09 +01:00
holger krekel
5734e00625 some more shifting around 2023-12-11 01:36:11 +01:00
holger krekel
947e1d6f89 shift functions around, discover sub commands automatically 2023-12-11 01:18:57 +01:00
holger krekel
33423459fe make tests depend on chatmail.ini, not env var 2023-12-11 00:49:32 +01:00
holger krekel
c70b72a21a tweak for making CI happy 2023-12-11 00:05:25 +01:00
holger krekel
33352f4694 try to fix workflow 2023-12-10 18:28:40 +01:00
holger krekel
59083ad16a don't print a traceback but do a proper return code for "cmdeploy test" 2023-12-10 18:24:08 +01:00
holger krekel
11518c2ef4 add chatmail.ini to ignore 2023-12-10 18:05:11 +01:00
holger krekel
a0cdfe6126 add manifest so that ini files get included 2023-12-10 18:02:00 +01:00
holger krekel
c25eefccc4 address nami comment 2023-12-10 17:56:26 +01:00
holger krekel
8b878e38cf fix readme 2023-12-10 14:41:20 +01:00
holger krekel
9e1e6d3c69 add test command 2023-12-10 14:38:57 +01:00
holger krekel
a1c817d758 fix README 2023-12-10 12:52:35 +01:00
holger krekel
ccc552f852 add status command and delete last script 2023-12-10 12:45:23 +01:00
holger krekel
73768256f6 some more housekeeping 2023-12-10 12:17:05 +01:00
holger krekel
34f7b3c0d3 introduce "cmdeploy bench" 2023-12-10 12:10:36 +01:00
holger krekel
e2828f4103 cleanup 2023-12-10 12:00:03 +01:00
holger krekel
df515bea41 generate dns zone file via cmdeploy 2023-12-10 11:56:41 +01:00
holger krekel
5614f03611 add dns command beginning 2023-12-09 18:07:44 +01:00
holger krekel
70443545d7 make cmdeploy test work 2023-12-09 17:55:08 +01:00
holger krekel
10ef842061 snap 2023-12-09 17:45:26 +01:00
holger krekel
98f92cd9b6 fix various test setups 2023-12-09 16:54:05 +01:00
holger krekel
fe99b97386 add webdev sub command 2023-12-09 16:42:03 +01:00
holger krekel
542decf798 making it work 2023-12-09 15:15:57 +01:00
holger krekel
2e7f8483b3 rework UI for chatmail setup 2023-12-09 13:43:56 +01:00
holger krekel
5c58e625f0 draft init flow 2023-12-09 02:07:09 +01:00
holger krekel
009f549619 document some attributes in chatmail.ini 2023-12-09 01:20:17 +01:00
holger krekel
99d36235fe get passthrough_recipients list from config 2023-12-09 01:07:37 +01:00
holger krekel
b52a8c969f various fixes 2023-12-09 00:22:58 +01:00
holger krekel
8520a9d8f2 introduce basic config file 2023-12-08 21:56:15 +01:00
47 changed files with 58 additions and 58 deletions

View File

@@ -31,7 +31,7 @@ jobs:
run: cmdeploy fmt -v
- name: run deploy-chatmail offline tests
run: pytest --pyargs cmdeploy
run: pytest tests
- name: initialize with chatmail domain
run: cmdeploy init chat.example.org

View File

@@ -9,7 +9,7 @@ def read_config(inipath):
class Config:
def __init__(self, inipath, params):
self._inipath = inipath
self.mail_domain = params["mail_domain"]
self.mailname = self.mail_domain = params["mailname"]
self.max_user_send_per_minute = int(params["max_user_send_per_minute"])
self.filtermail_smtp_port = int(params["filtermail_smtp_port"])
self.postfix_reinject_port = int(params["postfix_reinject_port"])
@@ -23,14 +23,12 @@ class Config:
return open(self._inipath, "rb")
def write_initial_config(inipath, mail_domain):
def write_initial_config(inipath, mailname):
from importlib.resources import files
inidir = files(__package__).joinpath("ini")
content = (
inidir.joinpath("chatmail.ini.f").read_text().format(mail_domain=mail_domain)
)
if mail_domain.endswith(".testrun.org"):
content = inidir.joinpath("chatmail.ini.f").read_text().format(mailname=mailname)
if mailname.endswith(".testrun.org"):
override_inipath = inidir.joinpath("override-testrun.ini")
privacy = iniconfig.IniConfig(override_inipath)["privacy"]
lines = []

View File

@@ -1,7 +1,7 @@
[params]
# mail domain (MUST be set to fully qualified chat mail domain)
mail_domain = {mail_domain}
mailname = {mailname}
#
# If you only do private test deploys, you don't need to modify any settings below

View File

@@ -5,7 +5,7 @@
import json
import random
mail_domain_path = "/etc/mailname"
mailname_path = "/etc/mailname"
def create_newemail_dict(domain):
@@ -16,7 +16,7 @@ def create_newemail_dict(domain):
def print_new_account():
domain = open(mail_domain_path).read().strip()
domain = open(mailname_path).read().strip()
creds = create_newemail_dict(domain=domain)
print("Content-Type: application/json")

View File

@@ -13,8 +13,8 @@ from chatmaild.config import read_config, write_initial_config
def make_config(tmp_path):
inipath = tmp_path.joinpath("chatmail.ini")
def make_conf(mail_domain):
write_initial_config(inipath, mail_domain=mail_domain)
def make_conf(mailname):
write_initial_config(inipath, mailname=mailname)
return read_config(inipath)
return make_conf
@@ -27,7 +27,7 @@ def example_config(make_config):
@pytest.fixture
def maildomain(example_config):
return example_config.mail_domain
return example_config.mailname
@pytest.fixture

View File

@@ -3,7 +3,7 @@ from chatmaild.config import read_config
def test_read_config_basic(make_config):
config = make_config("chat.example.org")
assert config.mail_domain == "chat.example.org"
assert config.mailname == "chat.example.org"
assert not config.privacy_supervisor and not config.privacy_mail
assert not config.privacy_pdo and not config.privacy_postal
@@ -11,12 +11,12 @@ def test_read_config_basic(make_config):
inipath.write_text(inipath.read_text().replace("60", "37"))
config = read_config(inipath)
assert config.max_user_send_per_minute == 37
assert config.mail_domain == "chat.example.org"
assert config.mailname == "chat.example.org"
def test_read_config_testrun(make_config):
config = make_config("something.testrun.org")
assert config.mail_domain == "something.testrun.org"
assert config.mailname == "something.testrun.org"
assert len(config.privacy_postal.split("\n")) > 1
assert len(config.privacy_supervisor.split("\n")) > 1
assert len(config.privacy_pdo.split("\n")) > 1

View File

@@ -18,7 +18,7 @@ def test_create_newemail_dict():
def test_print_new_account(capsys, monkeypatch, maildomain, tmpdir):
p = tmpdir.join("mailname")
p.write(maildomain)
monkeypatch.setattr(chatmaild.newemail, "mail_domain_path", str(p))
monkeypatch.setattr(chatmaild.newemail, "mailname_path", str(p))
print_new_account()
out, err = capsys.readouterr()
lines = out.split("\n")

View File

@@ -3,8 +3,8 @@ requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta"
[project]
name = "cmdeploy"
version = "0.2"
name = "deploy-chatmail"
version = "0.1"
dependencies = [
"pyinfra",
"pillow",
@@ -22,11 +22,10 @@ dependencies = [
]
[project.scripts]
cmdeploy = "cmdeploy.cmdeploy:main"
cmdeploy = "deploy_chatmail.cmdeploy:main"
[project.entry-points.pytest11]
"chatmaild.testplugin" = "chatmaild.tests.plugin"
"cmdeploy.testplugin" = "cmdeploy.tests.plugin"
[tool.pytest.ini_options]
addopts = "-v -ra --strict-markers"

View File

@@ -195,7 +195,7 @@ def _install_mta_sts_daemon() -> bool:
server.shell(
name="install postfix-mta-sts-resolver with pip",
commands=[
"python3 -m virtualenv /usr/local/lib/postfix-mta-sts-resolver",
"python3 -m venv /usr/local/lib/postfix-mta-sts-resolver",
"/usr/local/lib/postfix-mta-sts-resolver/bin/pip install postfix-mta-sts-resolver",
],
)
@@ -347,8 +347,8 @@ def _configure_nginx(domain: str, debug: bool = False) -> bool:
def check_config(config):
mail_domain = config.mail_domain
if mail_domain != "testrun.org" and not mail_domain.endswith(".testrun.org"):
mailname = config.mailname
if mailname != "testrun.org" and not mailname.endswith(".testrun.org"):
blocked_words = "merlinux schmieder testrun.org".split()
for value in config.__dict__.values():
if any(x in value for x in blocked_words):

View File

@@ -52,17 +52,17 @@ def run_cmd(args, out):
"""Deploy chatmail services on the remote server."""
env = os.environ.copy()
env["CHATMAIL_DOMAIN"] = args.config.mail_domain
deploy_path = "cmdeploy/src/cmdeploy/deploy.py"
env["CHATMAIL_DOMAIN"] = args.config.mailname
deploypy = "deploy-chatmail/src/deploy_chatmail/deploy.py"
pyinf = "pyinfra --dry" if args.dry_run else "pyinfra"
cmd = f"{pyinf} --ssh-user root {args.config.mail_domain} {deploy_path}"
cmd = f"{pyinf} --ssh-user root {args.config.mailname} {deploypy}"
out.check_call(cmd, env=env)
def dns_cmd(args, out):
"""Generate dns zone file."""
template = importlib.resources.files(__package__).joinpath("chatmail.zone.f")
ssh = f"ssh root@{args.config.mail_domain}"
ssh = f"ssh root@{args.config.mailname}"
def read_dkim_entries(entry):
lines = []
@@ -77,16 +77,16 @@ def dns_cmd(args, out):
dkim_entry = read_dkim_entries(out.shell_output(f"{ssh} -- opendkim-genzone -F"))
out(
f"[writing {args.config.mail_domain} zone data (using space as separator) to stdout output]",
f"[writing {args.config.mailname} zone data (using space as separator) to stdout output]",
green=True,
)
print(
template.read_text()
.format(
acme_account_url=acme_account_url,
email=f"root@{args.config.mail_domain}",
email=f"root@{args.config.mailname}",
sts_id=datetime.datetime.now().strftime("%Y%m%d%H%M"),
chatmail_domain=args.config.mail_domain,
chatmail_domain=args.config.mailname,
dkim_entry=dkim_entry,
)
.strip()
@@ -96,9 +96,9 @@ def dns_cmd(args, out):
def status_cmd(args, out):
"""Display status for online chatmail instance."""
ssh = f"ssh root@{args.config.mail_domain}"
ssh = f"ssh root@{args.config.mailname}"
out.green(f"chatmail domain: {args.config.mail_domain}")
out.green(f"chatmail domain: {args.config.mailname}")
if args.config.privacy_mail:
out.green("privacy settings: present")
else:
@@ -122,7 +122,7 @@ def test_cmd(args, out):
pytest_path = shutil.which("pytest")
ret = out.run_ret(
[pytest_path, "cmdeploy/src/", "-n4", "-rs", "-x", "-vrx", "--durations=5"]
[pytest_path, "tests/", "-n4", "-rs", "-x", "-vrx", "--durations=5"]
)
return ret
@@ -147,7 +147,11 @@ def fmt_cmd_options(parser):
def fmt_cmd(args, out):
"""Run formattting fixes (fuff and black) on all chatmail source code."""
sources = [str(importlib.resources.files(x)) for x in ("chatmaild", "cmdeploy")]
chatmaild = importlib.resources.files("chatmaild")
deploy_chatmail = importlib.resources.files("deploy_chatmail")
tests = deploy_chatmail.joinpath("../../../tests")
sources = list(str(x) for x in [chatmaild, deploy_chatmail, tests])
black_args = [shutil.which("black")]
ruff_args = [shutil.which("ruff")]
@@ -170,10 +174,9 @@ def fmt_cmd(args, out):
def bench_cmd(args, out):
"""Run benchmarks against an online chatmail instance."""
args = ["pytest", "--pyargs", "cmdeploy.tests.online.benchmark", "-vrx"]
cmdstring = " ".join(args)
out.green(f"[$ {cmdstring}]")
subprocess.check_call(args)
pytest_path = shutil.which("pytest")
benchmark = "tests/online/benchmark.py"
subprocess.check_call([pytest_path, benchmark, "-vrx"])
def webdev_cmd(args, out):

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,6 +1,6 @@
import os
import pyinfra
from cmdeploy import deploy_chatmail
from deploy_chatmail import deploy_chatmail
def main():

View File

@@ -1,4 +1,4 @@
myorigin = {{ config.mail_domain }}
myorigin = {{ config.mailname }}
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
@@ -16,8 +16,8 @@ readme_directory = no
compatibility_level = 2
# TLS parameters
smtpd_tls_cert_file=/var/lib/acme/live/{{ config.mail_domain }}/fullchain
smtpd_tls_key_file=/var/lib/acme/live/{{ config.mail_domain }}/privkey
smtpd_tls_cert_file=/var/lib/acme/live/{{ config.mailname }}/fullchain
smtpd_tls_key_file=/var/lib/acme/live/{{ config.mailname }}/privkey
smtpd_tls_security_level=may
smtp_tls_CApath=/etc/ssl/certs
@@ -26,7 +26,7 @@ smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_tls_policy_maps = socketmap:inet:127.0.0.1:8461:postfix
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = {{ config.mail_domain }}
myhostname = {{ config.mailname }}
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
@@ -45,7 +45,7 @@ inet_interfaces = all
inet_protocols = all
virtual_transport = lmtp:unix:private/dovecot-lmtp
virtual_mailbox_domains = {{ config.mail_domain }}
virtual_mailbox_domains = {{ config.mailname }}
smtpd_milters = unix:opendkim/opendkim.sock
non_smtpd_milters = $smtpd_milters

View File

@@ -37,7 +37,7 @@ def build_webpages(src_dir, build_dir, config):
def _build_webpages(src_dir, build_dir, config):
mail_domain = config.mail_domain
mail_domain = config.mailname
assert src_dir.exists(), src_dir
if not build_dir.exists():
build_dir.mkdir()
@@ -71,7 +71,7 @@ def main():
inipath = reporoot.joinpath("chatmail.ini")
config = read_config(inipath)
config.webdev = True
assert config.mail_domain
assert config.mailname
www_path = reporoot.joinpath("www")
src_path = www_path.joinpath("src")
stats = None

View File

@@ -2,8 +2,8 @@
set -e
python3 -m venv venv
venv/bin/pip install -e deploy-chatmail
venv/bin/pip install -e chatmaild
venv/bin/pip install -e cmdeploy
source venv/bin/activate
echo activated 'venv' python virtualenv environment containing "cmdeploy" tool

View File

@@ -38,7 +38,7 @@ def pytest_runtest_setup(item):
@pytest.fixture
def chatmail_config(pytestconfig):
current = basedir = Path().resolve()
current = basedir = Path()
while 1:
path = current.joinpath("chatmail.ini").resolve()
if path.exists():
@@ -52,7 +52,7 @@ def chatmail_config(pytestconfig):
@pytest.fixture
def maildomain(chatmail_config):
return chatmail_config.mail_domain
return chatmail_config.mailname
@pytest.fixture

View File

@@ -1,4 +1,4 @@
from cmdeploy.genqr import gen_qr_png_data
from deploy_chatmail.genqr import gen_qr_png_data
def test_gen_qr_png_data(maildomain):

View File

@@ -91,9 +91,9 @@ class TestEndToEndDeltaChat:
lp.sec("setup encrypted comms between ac1 and ac2 on different instances")
qr = ac1.get_setup_contact_qr()
ch = ac2.qr_setup_contact(qr)
assert ch.id >= 10
ac1._evtracker.wait_securejoin_inviter_progress(1000)
ac2.qr_setup_contact(qr)
msg = ac2.wait_next_incoming_message()
assert "verified" in msg.text
lp.sec("ac1 sends a message and ac2 marks it as seen")
chat = ac1.create_chat(ac2)

View File

@@ -1,7 +1,7 @@
import os
import pytest
from cmdeploy.cmdeploy import get_parser, main
from deploy_chatmail.cmdeploy import get_parser, main
from chatmaild.config import read_config
@@ -25,7 +25,7 @@ class TestCmdline:
main(["init", "chat.example.org"])
inipath = tmp_path.joinpath("chatmail.ini")
config = read_config(inipath)
assert config.mail_domain == "chat.example.org"
assert config.mailname == "chat.example.org"
def test_init_not_overwrite(self):
main(["init", "chat.example.org"])

View File

@@ -1,10 +1,10 @@
import importlib.resources
from cmdeploy.www import build_webpages
from deploy_chatmail.www import build_webpages
def test_build_webpages(tmp_path, make_config):
pkgroot = importlib.resources.files("cmdeploy")
pkgroot = importlib.resources.files("deploy_chatmail")
src_dir = pkgroot.joinpath("../../../www/src").resolve()
assert src_dir.exists(), src_dir
config = make_config("chat.example.org")