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

Function TestDomainViewSendingPerAxis

internal/httpapi/domainview_test.go:151–228  ·  view source on GitHub ↗

TestDomainViewSendingPerAxis is the key regression for the per-axis fix: when SES reports the DKIM and custom MAIL FROM axes separately, each sending record must reflect its OWN axis instead of the all-or-nothing sending_status rollup, so the user can tell which record to fix. The rollup field itsel

(t *testing.T)

Source from the content-addressed store, hash-verified

149// must reflect its OWN axis instead of the all-or-nothing sending_status rollup,
150// so the user can tell which record to fix. The rollup field itself is unchanged.
151func TestDomainViewSendingPerAxis(t *testing.T) {
152 s := New(Deps{SMTPDomain: "mx.e2a.dev", SESRegion: "us-east-1"})
153
154 base := func() *identity.Domain {
155 return &identity.Domain{
156 Domain: "acme.com", Verified: true, VerificationToken: "tok",
157 DKIMSelector: "e2a202606", DKIMPublicKey: "PUBKEY",
158 }
159 }
160
161 // The headline case: good DKIM, broken MAIL FROM. The rollup is failed
162 // (all-or-nothing), but the dkim record must read verified while the
163 // mail_from_* records read failed.
164 t.Run("dkim verified + mail_from failed ⇒ records disagree", func(t *testing.T) {
165 d := base()
166 d.SendingStatus = "failed" // rollup stays all-or-nothing
167 d.SendingDkimStatus = "verified"
168 d.SendingMailFromStatus = "failed"
169 v := s.domainView(d)
170 m := byPurpose(v.DNSRecords)
171 if m["dkim"].Status != "verified" {
172 t.Fatalf("dkim should follow its OWN axis (verified): %+v", m["dkim"])
173 }
174 if m["mail_from_mx"].Status != "failed" || m["mail_from_spf"].Status != "failed" {
175 t.Fatalf("mail_from records should follow their OWN axis (failed): mx=%+v spf=%+v", m["mail_from_mx"], m["mail_from_spf"])
176 }
177 // The rollup field is the summary and must be untouched.
178 if v.SendingStatus != "failed" {
179 t.Fatalf("domain-level sending_status rollup must stay failed: %q", v.SendingStatus)
180 }
181 })
182
183 // Reverse mixed case: broken DKIM, good MAIL FROM.
184 t.Run("dkim failed + mail_from verified ⇒ records disagree", func(t *testing.T) {
185 d := base()
186 d.SendingStatus = "failed"
187 d.SendingDkimStatus = "failed"
188 d.SendingMailFromStatus = "verified"
189 m := byPurpose(s.domainView(d).DNSRecords)
190 if m["dkim"].Status != "failed" {
191 t.Fatalf("dkim should be failed: %+v", m["dkim"])
192 }
193 if m["mail_from_mx"].Status != "verified" || m["mail_from_spf"].Status != "verified" {
194 t.Fatalf("mail_from records should be verified: mx=%+v spf=%+v", m["mail_from_mx"], m["mail_from_spf"])
195 }
196 })
197
198 // Fallback: when the per-axis columns are empty (pre-migration-049 rows or
199 // pre-provision), every sending record falls back to the rollup — preserving
200 // the old behavior gracefully.
201 t.Run("empty axes ⇒ fall back to rollup", func(t *testing.T) {
202 d := base()
203 d.SendingStatus = "verified"
204 // SendingDkimStatus / SendingMailFromStatus left empty.
205 m := byPurpose(s.domainView(d).DNSRecords)
206 for _, p := range []string{"dkim", "mail_from_mx", "mail_from_spf"} {
207 if m[p].Status != "verified" {
208 t.Fatalf("%s should fall back to rollup (verified): %+v", p, m[p])

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