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

Function TestDomainViewSendingRecords

internal/httpapi/domainview_test.go:78–145  ·  view source on GitHub ↗

TestDomainViewSendingRecords: with the sending feature on (SESRegion set) the mail_from_mx + mail_from_spf records are returned deterministically — even before SES provisioning (sending_status none) — and the dkim + mail_from statuses track the sending_status rollup.

(t *testing.T)

Source from the content-addressed store, hash-verified

76// before SES provisioning (sending_status none) — and the dkim + mail_from
77// statuses track the sending_status rollup.
78func TestDomainViewSendingRecords(t *testing.T) {
79 s := New(Deps{SMTPDomain: "mx.e2a.dev", SESRegion: "us-east-1"})
80
81 base := func(sendingStatus string) *identity.Domain {
82 return &identity.Domain{
83 Domain: "acme.com", Verified: true, VerificationToken: "tok",
84 DKIMSelector: "e2a202606", DKIMPublicKey: "PUBKEY",
85 SendingStatus: sendingStatus,
86 }
87 }
88
89 // Pre-provision (none): records present + deterministic, status pending.
90 t.Run("pre-provision none ⇒ records present, pending", func(t *testing.T) {
91 v := s.domainView(base("none"))
92 m := byPurpose(v.DNSRecords)
93 mfmx, ok := m["mail_from_mx"]
94 if !ok {
95 t.Fatalf("feature on ⇒ mail_from_mx must be present even pre-provision: %+v", v.DNSRecords)
96 }
97 if mfmx.Type != "MX" || mfmx.Name != "bounce.acme.com" ||
98 mfmx.Value != "feedback-smtp.us-east-1.amazonses.com" ||
99 mfmx.Priority == nil || *mfmx.Priority != 10 || mfmx.Status != "pending" {
100 t.Fatalf("mail_from_mx shape/status wrong: %+v", mfmx)
101 }
102 mfspf, ok := m["mail_from_spf"]
103 if !ok || mfspf.Type != "TXT" || mfspf.Name != "bounce.acme.com" ||
104 mfspf.Value != "v=spf1 include:amazonses.com ~all" || mfspf.Status != "pending" {
105 t.Fatalf("mail_from_spf shape/status wrong: %+v", mfspf)
106 }
107 if mfspf.Priority != nil {
108 t.Fatalf("TXT mail_from_spf must have null priority: %+v", mfspf)
109 }
110 if m["dkim"].Status != "pending" {
111 t.Fatalf("dkim follows sending_status (none⇒pending): %+v", m["dkim"])
112 }
113 // Inbound still follows `verified`, independent of sending.
114 if m["ownership"].Status != "verified" {
115 t.Fatalf("inbound status must remain independent of sending: %+v", m["ownership"])
116 }
117 })
118
119 t.Run("sending verified ⇒ sending records verified", func(t *testing.T) {
120 m := byPurpose(s.domainView(base("verified")).DNSRecords)
121 for _, p := range []string{"dkim", "mail_from_mx", "mail_from_spf"} {
122 if m[p].Status != "verified" {
123 t.Fatalf("%s should be verified: %+v", p, m[p])
124 }
125 }
126 })
127
128 t.Run("sending failed ⇒ sending records failed", func(t *testing.T) {
129 m := byPurpose(s.domainView(base("failed")).DNSRecords)
130 for _, p := range []string{"dkim", "mail_from_mx", "mail_from_spf"} {
131 if m[p].Status != "failed" {
132 t.Fatalf("%s should be failed: %+v", p, m[p])
133 }
134 }
135 })

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