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

Function TestSignMessage_EmptyDomainSkipsLookup

internal/outbound/sender_test.go:130–149  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128}
129
130func TestSignMessage_EmptyDomainSkipsLookup(t *testing.T) {
131 // A pathological caller passing "" as the signing domain must
132 // short-circuit rather than calling GetDKIMKey(ctx, ""), which
133 // would scan all rows. Defensive guard at the entry point.
134 calls := 0
135 lookup := &fakeDKIMLookup{
136 get: func(_ context.Context, _ string) (string, []byte, error) {
137 calls++
138 return "sel", []byte("not-a-real-key"), nil
139 },
140 }
141 s := NewSenderWithDKIM(nil, "example.com", lookup)
142 _, ok := s.signMessage([]byte(validTestMessage), "")
143 if ok {
144 t.Errorf("ok = true, want false (empty domain)")
145 }
146 if calls != 0 {
147 t.Errorf("GetDKIMKey called %d times for empty domain, want 0", calls)
148 }
149}
150
151func TestSignMessage_LookupErrorFailsOpen(t *testing.T) {
152 // DB transient error → log + proceed unsigned. The caller treats

Callers

nothing calls this directly

Calls 2

NewSenderWithDKIMFunction · 0.85
signMessageMethod · 0.80

Tested by

no test coverage detected