feat: add Postfix/pneumatube container rig with live recipient rejection
This commit is contained in:
parent
722394a7bf
commit
a0950fab52
9 changed files with 306 additions and 2 deletions
54
tests/test_lookup_server.py
Normal file
54
tests/test_lookup_server.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import asyncio
|
||||
from types import SimpleNamespace
|
||||
from urllib.parse import unquote
|
||||
|
||||
import pytest
|
||||
|
||||
from pneumatube.lookup_server import _lookup
|
||||
|
||||
|
||||
class _StubBridge:
|
||||
def __init__(self, known):
|
||||
self.known = known
|
||||
|
||||
def user_exists(self, username):
|
||||
if username == "broken":
|
||||
return None
|
||||
return username in self.known
|
||||
|
||||
|
||||
class _InlineWorker:
|
||||
async def run(self, fn, *args):
|
||||
return fn(*args)
|
||||
|
||||
|
||||
def _config():
|
||||
return SimpleNamespace(email_domain="gateway.example")
|
||||
|
||||
|
||||
def test_lookup_known_user_returns_ok():
|
||||
bridge = _StubBridge({"alice"})
|
||||
reply = asyncio.run(_lookup(bridge, _InlineWorker(), _config(), "alice@gateway.example"))
|
||||
code, _, text = reply.partition(" ")
|
||||
assert code == "200"
|
||||
assert unquote(text) == "OK"
|
||||
|
||||
|
||||
def test_lookup_unknown_user_returns_reject_action():
|
||||
bridge = _StubBridge({"alice"})
|
||||
reply = asyncio.run(_lookup(bridge, _InlineWorker(), _config(), "nobody@gateway.example"))
|
||||
code, _, text = reply.partition(" ")
|
||||
assert code == "200"
|
||||
assert unquote(text) == "550 5.1.1 no such user"
|
||||
|
||||
|
||||
def test_lookup_resolve_failure_is_temporary():
|
||||
bridge = _StubBridge({"alice"})
|
||||
reply = asyncio.run(_lookup(bridge, _InlineWorker(), _config(), "broken@gateway.example"))
|
||||
assert reply.startswith("400 ")
|
||||
|
||||
|
||||
def test_lookup_other_domain_has_no_opinion():
|
||||
bridge = _StubBridge({"alice"})
|
||||
reply = asyncio.run(_lookup(bridge, _InlineWorker(), _config(), "alice@other.example"))
|
||||
assert reply == "500 not found"
|
||||
Loading…
Add table
Add a link
Reference in a new issue