Groups every flat test_*.py under the module it exercises, matching the
existing tests/{profiler,sniffer,prober,collector,correlation,cli,web,
topology,swarm,bus,updater,api,docker,geoip,...} layout. New folders:
services/, fleet/, config/, logging/, db/ (+ db/mysql/), telemetry/,
mutator/, core/.
Path-dependent __file__ references bumped an extra .parent in three
files that moved one level deeper:
- tests/sniffer/test_sniffer_ja3.py (template path)
- tests/services/test_ssh_capture_emit.py (template path)
- tests/cli/test_mode_gating.py (REPO root)
- tests/web/test_env_lazy_jwt.py (repo var)
Also drops two SQLite runtime artifacts (test_decnet.db-{shm,wal}) that
were leaking into the repo from a previous test run.
Fixes two test_service_isolation cases that patched asyncio.sleep (no
longer on the profiler main-loop hot path — same pre-existing bug I
fixed earlier in test_attacker_worker.py) by patching asyncio.wait_for
and passing interval=0.
43 lines
1.5 KiB
Python
43 lines
1.5 KiB
Python
"""
|
|
Tests for SMTP Relay service.
|
|
"""
|
|
|
|
from decnet.services.smtp_relay import SMTPRelayService
|
|
|
|
def test_smtp_relay_compose_fragment():
|
|
svc = SMTPRelayService()
|
|
fragment = svc.compose_fragment("test-decky", log_target="log-server")
|
|
|
|
assert fragment["container_name"] == "test-decky-smtp_relay"
|
|
assert fragment["environment"]["SMTP_OPEN_RELAY"] == "1"
|
|
assert fragment["environment"]["LOG_TARGET"] == "log-server"
|
|
|
|
def test_smtp_relay_custom_cfg():
|
|
svc = SMTPRelayService()
|
|
fragment = svc.compose_fragment(
|
|
"test-decky",
|
|
service_cfg={"banner": "Welcome", "mta": "Postfix"}
|
|
)
|
|
assert fragment["environment"]["SMTP_BANNER"] == "Welcome"
|
|
assert fragment["environment"]["SMTP_MTA"] == "Postfix"
|
|
|
|
def test_smtp_relay_dockerfile_context():
|
|
svc = SMTPRelayService()
|
|
ctx = svc.dockerfile_context()
|
|
assert ctx.name == "smtp"
|
|
assert ctx.is_dir()
|
|
|
|
|
|
def test_smtp_relay_quarantine_bind_mount():
|
|
"""Full-message capture: each decky gets its own host quarantine dir
|
|
bind-mounted into the container, and the in-container path is exposed
|
|
via SMTP_QUARANTINE_DIR so the server can write .eml files."""
|
|
svc = SMTPRelayService()
|
|
fragment = svc.compose_fragment("test-decky")
|
|
volumes = fragment["volumes"]
|
|
assert len(volumes) == 1
|
|
host, container, mode = volumes[0].split(":")
|
|
assert host.endswith("/test-decky/smtp")
|
|
assert container == fragment["environment"]["SMTP_QUARANTINE_DIR"]
|
|
assert mode == "rw"
|