DKIM
- {{ dns_snapshot.dkim_records | length }} selectors
+ {{ dns_snapshot.dkim_found | length }} found{% if dns_snapshot.dkim_missing %}, {{ dns_snapshot.dkim_missing | length }} missing{% endif %}
- {% for item in dns_snapshot.dkim_records %}
+ {% for item in dns_snapshot.dkim_found %}
- {{ item.selector }}
- {{ item.record or item.error or "No DKIM record found." }}
+ {{ item.selector }}._domainkey.{{ item.domain or domain }}
+ {{ item.record }}
{% else %}
-
No observed DKIM selectors yet.
+
No currently resolvable observed DKIM selectors.
{% endfor %}
+ {% if dns_snapshot.dkim_missing %}
+
+ {{ dns_snapshot.dkim_missing | length }} observed selector lookups did not resolve
+
+ {% for item in dns_snapshot.dkim_missing %}
+ {{ item.query_name }}{% if item.error %}: {{ item.error }}{% endif %}
+ {% endfor %}
+
+
+ {% endif %}
diff --git a/tests/test_dns_policy.py b/tests/test_dns_policy.py
index 08fdf6d..a635800 100644
--- a/tests/test_dns_policy.py
+++ b/tests/test_dns_policy.py
@@ -24,7 +24,7 @@ def test_collect_domain_dns_policy_uses_observed_dkim_selectors():
txt_records = {
"_dmarc.example.com": ["v=DMARC1; p=reject; pct=100"],
"example.com": ["v=spf1 include:_spf.example.net -all"],
- "s1._domainkey.example.com": ["v=DKIM1; k=rsa; p=abc"],
+ "s1._domainkey.mail.example.net": ["v=DKIM1; k=rsa; p=abc"],
}
def txt_lookup(name: str) -> list[str]:
@@ -34,7 +34,7 @@ def test_collect_domain_dns_policy_uses_observed_dkim_selectors():
policy = collect_domain_dns_policy(
"example.com",
- selectors=["s1"],
+ selectors=[("s1", "mail.example.net")],
txt_lookup=txt_lookup,
mx_lookup=lambda name: ["10 mail.example.com"],
)
@@ -43,5 +43,7 @@ def test_collect_domain_dns_policy_uses_observed_dkim_selectors():
assert policy.spf.all_mechanism == "-all"
assert policy.mx_records == ["10 mail.example.com"]
assert policy.dkim[0].selector == "s1"
+ assert policy.dkim[0].domain == "mail.example.net"
+ assert policy.dkim[0].query_name == "s1._domainkey.mail.example.net"
assert policy.dkim[0].record == "v=DKIM1; k=rsa; p=abc"
assert policy.errors == []