mirror of
https://github.com/chatmail/relay.git
synced 2026-05-20 04:48:06 +00:00
various fixes
This commit is contained in:
@@ -1,21 +1,55 @@
|
||||
from chatmaild.config import read_config
|
||||
import chatmaild.config
|
||||
|
||||
|
||||
def test_read_config_no_privacy_policy(tmp_path, create_ini):
|
||||
def test_read_config_without_mailname(tmp_path, create_ini, monkeypatch):
|
||||
mailname_path = tmp_path.joinpath("mailname")
|
||||
mailname_path.write_text("something.example.org")
|
||||
monkeypatch.setattr(chatmaild.config, "system_mailname_path", mailname_path)
|
||||
|
||||
inipath = create_ini(
|
||||
"""
|
||||
[params]
|
||||
max_user_send_per_minute = 40
|
||||
filtermail_smtp_port = 9875
|
||||
postfix_reinject_port = 9999
|
||||
"""
|
||||
)
|
||||
config = read_config(inipath)
|
||||
assert config.mailname == "something.example.org"
|
||||
|
||||
|
||||
def test_read_config_without_privacy_policy(tmp_path, create_ini):
|
||||
inipath = create_ini(
|
||||
"""
|
||||
[params]
|
||||
max_user_send_per_minute = 40
|
||||
filtermail_smtp_port = 9875
|
||||
postfix_reinject_port = 9999
|
||||
|
||||
[privacy:testrun]
|
||||
domain = *.example.org
|
||||
"""
|
||||
)
|
||||
config = read_config(inipath, "something.example.org")
|
||||
assert config.mailname == "something.example.org"
|
||||
assert not config.has_privacy_policy
|
||||
assert config.max_user_send_per_minute == 40
|
||||
assert config.filtermail_smtp_port == 9875
|
||||
assert config.postfix_reinject_port == 9999
|
||||
assert not config.privacy_postal
|
||||
assert not config.privacy_mail
|
||||
assert not config.privacy_pdo
|
||||
assert not config.privacy_supervisor
|
||||
|
||||
|
||||
def test_read_config(create_ini):
|
||||
inipath = create_ini(
|
||||
"""
|
||||
[params]
|
||||
max_user_send_per_minute = 40
|
||||
filtermail_smtp_port = 10080
|
||||
postfix_reinject_port = 10025
|
||||
|
||||
[privacy:testrun]
|
||||
domain = *.testrun.org
|
||||
|
||||
@@ -35,9 +69,10 @@ def test_read_config(create_ini):
|
||||
)
|
||||
|
||||
config = read_config(inipath, "something.testrun.org")
|
||||
assert config.has_privacy_policy
|
||||
|
||||
assert config.mailname == "something.testrun.org"
|
||||
assert config.filtermail_smtp_port == 10080
|
||||
assert config.postfix_reinject_port == 10025
|
||||
assert config.privacy_postal == "Postal Ltd"
|
||||
assert config.privacy_mail == "privacy@merlinux.eu"
|
||||
lines = config.privacy_pdo.split("\n")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import json
|
||||
import sys
|
||||
import pytest
|
||||
import threading
|
||||
import queue
|
||||
@@ -7,7 +6,7 @@ import traceback
|
||||
|
||||
import chatmaild.doveauth
|
||||
from chatmaild.doveauth import get_user_data, lookup_passdb, handle_dovecot_request
|
||||
from chatmaild.database import Database, DBError
|
||||
from chatmaild.database import DBError
|
||||
|
||||
|
||||
def test_basic(db):
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
from chatmaild.filtermail import check_encrypted, check_DATA, SendRateLimiter, check_mdn, is_passthrough_recipient
|
||||
from chatmaild.filtermail import (
|
||||
check_encrypted,
|
||||
check_DATA,
|
||||
SendRateLimiter,
|
||||
check_mdn,
|
||||
is_passthrough_recipient,
|
||||
)
|
||||
import pytest
|
||||
|
||||
|
||||
@@ -73,12 +79,12 @@ def test_filtermail_to_multiple_recipients_no_mdn(maildata, gencreds):
|
||||
def test_send_rate_limiter():
|
||||
limiter = SendRateLimiter()
|
||||
for i in range(100):
|
||||
if limiter.is_sending_allowed("some@example.org"):
|
||||
if i <= SendRateLimiter.MAX_USER_SEND_PER_MINUTE:
|
||||
if limiter.is_sending_allowed("some@example.org", 10):
|
||||
if i <= 10:
|
||||
continue
|
||||
pytest.fail("limiter didn't work")
|
||||
else:
|
||||
assert i == SendRateLimiter.MAX_USER_SEND_PER_MINUTE + 1
|
||||
assert i == 11
|
||||
break
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user