first commit
This commit is contained in:
commit
cce9a8c9ba
73 changed files with 8665 additions and 0 deletions
76
backend/tests/test_dns_setup.py
Normal file
76
backend/tests/test_dns_setup.py
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
"""Tests for deployment DNS record generation."""
|
||||
|
||||
from app.services.domain_provisioning import (
|
||||
build_deployment_dns_records,
|
||||
build_dns_records,
|
||||
build_spf_value,
|
||||
namecheap_host,
|
||||
)
|
||||
|
||||
|
||||
def test_namecheap_host_strips_zone_suffix():
|
||||
assert namecheap_host("mail.getall.help", "getall.help") == "mail"
|
||||
assert namecheap_host("@", "getall.help") == "@"
|
||||
assert (
|
||||
namecheap_host("agmail._domainkey.getall.help", "getall.help")
|
||||
== "agmail._domainkey"
|
||||
)
|
||||
|
||||
|
||||
def test_build_dns_records_uses_namecheap_hosts_and_ip():
|
||||
records = build_dns_records(
|
||||
"getall.help",
|
||||
"mail.getall.help",
|
||||
"agmail",
|
||||
"abc123",
|
||||
mail_server_ip="203.0.113.10",
|
||||
)
|
||||
mx = next(record for record in records if record["purpose"] == "mx")
|
||||
a_record = next(record for record in records if record["purpose"] == "mail_host")
|
||||
spf = next(record for record in records if record["purpose"] == "spf")
|
||||
|
||||
assert mx["host"] == "@"
|
||||
assert mx["value"] == "mail.getall.help"
|
||||
assert mx["priority"] == 10
|
||||
assert a_record["host"] == "mail"
|
||||
assert a_record["value"] == "203.0.113.10"
|
||||
assert spf["value"] == "v=spf1 mx a ip4:203.0.113.10 ~all"
|
||||
assert "amazonses" not in spf["value"]
|
||||
|
||||
|
||||
def test_build_spf_value_supports_ipv6():
|
||||
assert build_spf_value("2001:db8::1") == "v=spf1 mx a ip6:2001:db8::1 ~all"
|
||||
|
||||
|
||||
def test_deployment_sections_split_inbound_and_outbound():
|
||||
sections = build_deployment_dns_records(
|
||||
domain_name="getall.help",
|
||||
mail_server_ip="203.0.113.10",
|
||||
dkim_selector="agmail",
|
||||
dkim_public_key="test-public-key",
|
||||
app_public_host="email.getall.help",
|
||||
)
|
||||
|
||||
inbound_purposes = [record["purpose"] for record in sections["inbound"]]
|
||||
outbound_purposes = [record["purpose"] for record in sections["outbound"]]
|
||||
|
||||
assert inbound_purposes == ["mx", "mail_host", "app_host"]
|
||||
assert outbound_purposes == ["platform_spf", "spf", "dkim", "dmarc"]
|
||||
assert "ses_outbound" not in sections
|
||||
|
||||
app_host = next(
|
||||
record for record in sections["inbound"] if record["purpose"] == "app_host"
|
||||
)
|
||||
assert app_host["host"] == "email"
|
||||
assert app_host["value"] == "203.0.113.10"
|
||||
|
||||
dmarc = next(
|
||||
record for record in sections["outbound"] if record["purpose"] == "dmarc"
|
||||
)
|
||||
assert dmarc["value"] == "v=DMARC1; p=quarantine; rua=mailto:dmarc@getall.help"
|
||||
|
||||
dkim = next(
|
||||
record for record in sections["outbound"] if record["purpose"] == "dkim"
|
||||
)
|
||||
assert dkim["host"] == "agmail._domainkey"
|
||||
assert "test-public-key" in dkim["value"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue