MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestDomainViewInboundStatus

Function TestDomainViewInboundStatus

internal/httpapi/domainview_test.go:22–72  ·  view source on GitHub ↗

TestDomainViewInboundStatus: inbound records (ownership, inbound_mx) follow `verified`; with the sending feature off there are no mail_from records and the dkim record only appears when a key is stored.

(t *testing.T)

Source from the content-addressed store, hash-verified

20// `verified`; with the sending feature off there are no mail_from records and
21// the dkim record only appears when a key is stored.
22func TestDomainViewInboundStatus(t *testing.T) {
23 s := New(Deps{SMTPDomain: "mx.e2a.dev"}) // SESRegion empty ⇒ sending off
24
25 t.Run("verified, no key", func(t *testing.T) {
26 v := s.domainView(&identity.Domain{Domain: "acme.com", Verified: true, VerificationToken: "tok"})
27 m := byPurpose(v.DNSRecords)
28 if len(v.DNSRecords) != 2 {
29 t.Fatalf("want exactly ownership+inbound_mx, got %d: %+v", len(v.DNSRecords), v.DNSRecords)
30 }
31 own := m["ownership"]
32 if own.Type != "TXT" || own.Value != "tok" || own.Status != "verified" {
33 t.Fatalf("ownership record wrong: %+v", own)
34 }
35 mx := m["inbound_mx"]
36 if mx.Type != "MX" || mx.Value != "mx.e2a.dev" || mx.Priority == nil || *mx.Priority != 10 || mx.Status != "verified" {
37 t.Fatalf("inbound_mx record wrong: %+v", mx)
38 }
39 if _, ok := m["dkim"]; ok {
40 t.Fatalf("no stored key ⇒ no dkim record: %+v", v.DNSRecords)
41 }
42 if _, ok := m["mail_from_mx"]; ok {
43 t.Fatalf("feature off ⇒ no mail_from records: %+v", v.DNSRecords)
44 }
45 })
46
47 t.Run("unverified ⇒ inbound pending", func(t *testing.T) {
48 v := s.domainView(&identity.Domain{Domain: "pending.com", Verified: false, VerificationToken: "tok"})
49 m := byPurpose(v.DNSRecords)
50 if m["ownership"].Status != "pending" || m["inbound_mx"].Status != "pending" {
51 t.Fatalf("unverified domain inbound records must be pending: %+v", v.DNSRecords)
52 }
53 })
54
55 t.Run("dkim present but feature off ⇒ dkim pending", func(t *testing.T) {
56 v := s.domainView(&identity.Domain{
57 Domain: "acme.com", Verified: true, VerificationToken: "tok",
58 DKIMSelector: "e2a202606", DKIMPublicKey: "PUBKEY",
59 })
60 m := byPurpose(v.DNSRecords)
61 dk, ok := m["dkim"]
62 if !ok {
63 t.Fatalf("stored key ⇒ dkim record expected: %+v", v.DNSRecords)
64 }
65 if dk.Type != "TXT" || dk.Status != "pending" {
66 t.Fatalf("dkim status with feature off must be pending: %+v", dk)
67 }
68 if _, ok := m["mail_from_mx"]; ok {
69 t.Fatalf("feature off ⇒ still no mail_from records: %+v", v.DNSRecords)
70 }
71 })
72}
73
74// TestDomainViewSendingRecords: with the sending feature on (SESRegion set) the
75// mail_from_mx + mail_from_spf records are returned deterministically — even

Callers

nothing calls this directly

Calls 4

byPurposeFunction · 0.85
RunMethod · 0.80
domainViewMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected