mirror of
https://github.com/chatmail/relay.git
synced 2026-05-15 19:14:44 +00:00
Compare commits
3 Commits
docs-inter
...
ci-improve
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
134d533aa0 | ||
|
|
8110a3f3a9 | ||
|
|
5c1d7763d0 |
@@ -73,9 +73,7 @@ def query_dns(typ, domain):
|
|||||||
|
|
||||||
# Query authoritative nameserver directly to bypass DNS cache.
|
# Query authoritative nameserver directly to bypass DNS cache.
|
||||||
res = shell(f"dig @{ns} -r -q {domain} -t {typ} +short", print=log_progress)
|
res = shell(f"dig @{ns} -r -q {domain} -t {typ} +short", print=log_progress)
|
||||||
if res:
|
return next((line for line in res.split("\n") if not line.startswith(';')), '')
|
||||||
return res.split("\n")[0]
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
def check_zonefile(zonefile, verbose=True):
|
def check_zonefile(zonefile, verbose=True):
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class TestDC:
|
|||||||
|
|
||||||
def test_ping_pong(self, benchmark, cmfactory):
|
def test_ping_pong(self, benchmark, cmfactory):
|
||||||
ac1, ac2 = cmfactory.get_online_accounts(2)
|
ac1, ac2 = cmfactory.get_online_accounts(2)
|
||||||
chat = cmfactory.get_protected_chat(ac1, ac2)
|
chat = cmfactory.get_accepted_chat(ac1, ac2)
|
||||||
|
|
||||||
def dc_ping_pong():
|
def dc_ping_pong():
|
||||||
chat.send_text("ping")
|
chat.send_text("ping")
|
||||||
@@ -49,7 +49,7 @@ class TestDC:
|
|||||||
|
|
||||||
def test_send_10_receive_10(self, benchmark, cmfactory, lp):
|
def test_send_10_receive_10(self, benchmark, cmfactory, lp):
|
||||||
ac1, ac2 = cmfactory.get_online_accounts(2)
|
ac1, ac2 = cmfactory.get_online_accounts(2)
|
||||||
chat = cmfactory.get_protected_chat(ac1, ac2)
|
chat = cmfactory.get_accepted_chat(ac1, ac2)
|
||||||
|
|
||||||
def dc_send_10_receive_10():
|
def dc_send_10_receive_10():
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class TestEndToEndDeltaChat:
|
|||||||
"""Test that a DC account can send a message to a second DC account
|
"""Test that a DC account can send a message to a second DC account
|
||||||
on the same chat-mail instance."""
|
on the same chat-mail instance."""
|
||||||
ac1, ac2 = cmfactory.get_online_accounts(2)
|
ac1, ac2 = cmfactory.get_online_accounts(2)
|
||||||
chat = cmfactory.get_protected_chat(ac1, ac2)
|
chat = cmfactory.get_accepted_chat(ac1, ac2)
|
||||||
chat.send_text("message0")
|
chat.send_text("message0")
|
||||||
|
|
||||||
lp.sec("wait for ac2 to receive message")
|
lp.sec("wait for ac2 to receive message")
|
||||||
@@ -70,7 +70,7 @@ class TestEndToEndDeltaChat:
|
|||||||
before quota is exceeded, and thus depends on the speed of the upload.
|
before quota is exceeded, and thus depends on the speed of the upload.
|
||||||
"""
|
"""
|
||||||
ac1, ac2 = cmfactory.get_online_accounts(2)
|
ac1, ac2 = cmfactory.get_online_accounts(2)
|
||||||
chat = cmfactory.get_protected_chat(ac1, ac2)
|
chat = cmfactory.get_accepted_chat(ac1, ac2)
|
||||||
|
|
||||||
user = ac2.get_config("configured_addr")
|
user = ac2.get_config("configured_addr")
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ def test_hide_senders_ip_address(cmfactory):
|
|||||||
assert ipaddress.ip_address(public_ip)
|
assert ipaddress.ip_address(public_ip)
|
||||||
|
|
||||||
user1, user2 = cmfactory.get_online_accounts(2)
|
user1, user2 = cmfactory.get_online_accounts(2)
|
||||||
chat = cmfactory.get_protected_chat(user1, user2)
|
chat = cmfactory.get_accepted_chat(user1, user2)
|
||||||
|
|
||||||
chat.send_text("testing submission header cleanup")
|
chat.send_text("testing submission header cleanup")
|
||||||
user2._evtracker.wait_next_incoming_message()
|
user2._evtracker.wait_next_incoming_message()
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from copy import deepcopy
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from cmdeploy import remote
|
from cmdeploy import remote
|
||||||
@@ -8,38 +10,63 @@ from cmdeploy.dns import check_full_zone, check_initial_remote_data
|
|||||||
def mockdns_base(monkeypatch):
|
def mockdns_base(monkeypatch):
|
||||||
qdict = {}
|
qdict = {}
|
||||||
|
|
||||||
def query_dns(typ, domain):
|
def shell(command, fail_ok=False, print=print):
|
||||||
try:
|
if command.startswith("dig"):
|
||||||
return qdict[typ][domain]
|
if command == "dig":
|
||||||
except KeyError:
|
return "."
|
||||||
return ""
|
if "SOA" in command:
|
||||||
|
return (
|
||||||
|
"delta.chat. 21600 IN SOA ns1.first-ns.de. dns.hetzner.com."
|
||||||
|
" 2025102800 14400 1800 604800 3600"
|
||||||
|
)
|
||||||
|
command_chunks = command.split()
|
||||||
|
domain, typ = command_chunks[4], command_chunks[6]
|
||||||
|
try:
|
||||||
|
return qdict[typ][domain]
|
||||||
|
except KeyError:
|
||||||
|
return ""
|
||||||
|
return remote.rshell.shell(command=command, fail_ok=fail_ok, print=print)
|
||||||
|
|
||||||
monkeypatch.setattr(remote.rdns, query_dns.__name__, query_dns)
|
monkeypatch.setattr(remote.rdns, shell.__name__, shell)
|
||||||
return qdict
|
return qdict
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mockdns(mockdns_base):
|
def mockdns_expected():
|
||||||
mockdns_base.update(
|
return {
|
||||||
{
|
"A": {"some.domain": "1.1.1.1"},
|
||||||
"A": {"some.domain": "1.1.1.1"},
|
"AAAA": {"some.domain": "fde5:cd7a:9e1c:3240:5a99:936f:cdac:53ae"},
|
||||||
"AAAA": {"some.domain": "fde5:cd7a:9e1c:3240:5a99:936f:cdac:53ae"},
|
"CNAME": {
|
||||||
"CNAME": {
|
"mta-sts.some.domain": "some.domain.",
|
||||||
"mta-sts.some.domain": "some.domain.",
|
"www.some.domain": "some.domain.",
|
||||||
"www.some.domain": "some.domain.",
|
},
|
||||||
},
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
|
@pytest.fixture(params=["plain", "with-dns-comments"])
|
||||||
|
def mockdns(request, mockdns_base, mockdns_expected):
|
||||||
|
mockdns_base.update(deepcopy(mockdns_expected))
|
||||||
|
match request.param:
|
||||||
|
case "plain":
|
||||||
|
pass
|
||||||
|
case "with-dns-comments":
|
||||||
|
for typ, data in mockdns_base.items():
|
||||||
|
for host, result in data.items():
|
||||||
|
mockdns_base[typ][host] = (
|
||||||
|
";; some unsuccessful attempt result\n"
|
||||||
|
"; and another with a single semicolon\n"
|
||||||
|
f"{result}"
|
||||||
|
)
|
||||||
return mockdns_base
|
return mockdns_base
|
||||||
|
|
||||||
|
|
||||||
class TestPerformInitialChecks:
|
class TestPerformInitialChecks:
|
||||||
def test_perform_initial_checks_ok1(self, mockdns):
|
def test_perform_initial_checks_ok1(self, mockdns, mockdns_expected):
|
||||||
remote_data = remote.rdns.perform_initial_checks("some.domain")
|
remote_data = remote.rdns.perform_initial_checks("some.domain")
|
||||||
assert remote_data["A"] == mockdns["A"]["some.domain"]
|
assert remote_data["A"] == mockdns_expected["A"]["some.domain"]
|
||||||
assert remote_data["AAAA"] == mockdns["AAAA"]["some.domain"]
|
assert remote_data["AAAA"] == mockdns_expected["AAAA"]["some.domain"]
|
||||||
assert remote_data["MTA_STS"] == mockdns["CNAME"]["mta-sts.some.domain"]
|
assert remote_data["MTA_STS"] == mockdns_expected["CNAME"]["mta-sts.some.domain"]
|
||||||
assert remote_data["WWW"] == mockdns["CNAME"]["www.some.domain"]
|
assert remote_data["WWW"] == mockdns_expected["CNAME"]["www.some.domain"]
|
||||||
|
|
||||||
@pytest.mark.parametrize("drop", ["A", "AAAA"])
|
@pytest.mark.parametrize("drop", ["A", "AAAA"])
|
||||||
def test_perform_initial_checks_with_one_of_A_AAAA(self, mockdns, drop):
|
def test_perform_initial_checks_with_one_of_A_AAAA(self, mockdns, drop):
|
||||||
|
|||||||
Reference in New Issue
Block a user