From 33423459fe679a3cd4bdb58b6a1da400db98517c Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 11 Dec 2023 00:18:45 +0100 Subject: [PATCH] make tests depend on chatmail.ini, not env var --- chatmaild/src/chatmaild/ini/chatmail.ini.f | 1 - plan.txt | 65 ---------------------- tests/conftest.py | 18 +++--- tests/test_cmdeploy.py | 3 - tests/test_helpers.py | 5 +- 5 files changed, 12 insertions(+), 80 deletions(-) delete mode 100644 plan.txt diff --git a/chatmaild/src/chatmaild/ini/chatmail.ini.f b/chatmaild/src/chatmaild/ini/chatmail.ini.f index c9a90755..3b95f854 100644 --- a/chatmaild/src/chatmaild/ini/chatmail.ini.f +++ b/chatmaild/src/chatmaild/ini/chatmail.ini.f @@ -1,4 +1,3 @@ - [params] # mail domain (MUST be set to fully qualified chat mail domain) diff --git a/plan.txt b/plan.txt deleted file mode 100644 index 66e8d20c..00000000 --- a/plan.txt +++ /dev/null @@ -1,65 +0,0 @@ -# Chat-mail server development (up until Oct 18th) - -## Dovecot goals/steps - -- automatic expiry of messages older than M days - - also expunge unread messages - -- limit: configure max-connections per account - - -## nami: send out rate limit / rspamd - -- basic outgoing send rate/limits (depending on "account-rating") - use rspamd in a minimal way, check support dkim-signing - (including an online test exceeding rate limit) - - -## doveauth questions/futures - -- bcrypt-password scheme is slow: require long passwords, use faster hashing - -- define user-name and password policies, and implement them - (be very restrictive at the beginning, we can relax later) - -- password is part of the dictproxy-lookup key, is it safe to use auth-caching? - - -## How to limit creation of accounts? - -attack: a 3-line bash script to fill the chatmail db with millions of unused accouts - -- make it computationally expensive (somehow try to except our tests from it) - 1st pass instant onboarding: create userid + cheap password -- if it fails then - 2nd pass instant onboarding: create userdid + comput. expensive password - -- probably also do firewall: limit number of new tcp-connections per IP address per duration - - -## Open/deferred questions - -- automatic expiry of users that haven't logged in for N days - Is it neccessary? If all messages are gone, does the existence of - an e-mail address bother anybody? - - -## web page for chat-mail servers? - -- documentation for users, privacy policy etc. - (probably also with provider-messages ...) - - -## online tests (first with plain python/pytest) - -- write tests for dovecot login (exists) -- write tests for postfix logins (exists) -- write A<>B send/receive tests (exists) - - -## Delta Chat - -1. qr code that defines access to a chatmail instance (like mailadm but without http etc.) - -2. support for creating username/password and verifying login works - - diff --git a/tests/conftest.py b/tests/conftest.py index eea5d6e3..74c8d9dd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,10 +3,8 @@ import io import time import random import subprocess -import textwrap import imaplib import smtplib -import importlib.resources import itertools from email.parser import BytesParser from email import policy @@ -14,6 +12,7 @@ from pathlib import Path import pytest from chatmaild.database import Database +from chatmaild.config import read_config conftestdir = Path(__file__).parent @@ -39,13 +38,17 @@ def pytest_runtest_setup(item): pytest.skip("skipping slow test, use --slow to run") +@pytest.fixture +def chatmail_config(pytestconfig): + path = Path("chatmail.ini").resolve() + if path.exists(): + return read_config(path) + pytest.skip(f"no chatmail.ini file found in {path}") + @pytest.fixture -def maildomain(): - domain = os.environ.get("CHATMAIL_DOMAIN") - if not domain: - pytest.skip("set CHATMAIL_DOMAIN to a ssh-reachable chatmail instance") - return domain +def maildomain(chatmail_config): + return chatmail_config.mailname @pytest.fixture @@ -410,6 +413,7 @@ class CMUser: @pytest.fixture def make_config(tmp_path): from chatmaild.config import read_config, write_initial_config + inipath = tmp_path.joinpath("chatmail.ini") def make_conf(mailname): diff --git a/tests/test_cmdeploy.py b/tests/test_cmdeploy.py index 3a253c36..a57933af 100644 --- a/tests/test_cmdeploy.py +++ b/tests/test_cmdeploy.py @@ -1,6 +1,3 @@ - -import os -import sys import pytest from deploy_chatmail.cmdeploy import get_parser, main from chatmaild.config import read_config diff --git a/tests/test_helpers.py b/tests/test_helpers.py index c25c2a1b..ff5d679d 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -1,9 +1,6 @@ -import textwrap import importlib.resources from deploy_chatmail.www import build_webpages -from chatmaild.config import read_config - def test_build_webpages(tmp_path, make_config): @@ -13,4 +10,4 @@ def test_build_webpages(tmp_path, make_config): config = make_config("chat.example.org") build_dir = tmp_path.joinpath("build") build_webpages(src_dir, build_dir, config) - assert len([x for x in build_dir.iterdir() if x.suffix == '.html']) >= 3 + assert len([x for x in build_dir.iterdir() if x.suffix == ".html"]) >= 3