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)
| 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. |
| 22 | func 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 |
nothing calls this directly
no test coverage detected