(t *testing.T)
| 188 | } |
| 189 | |
| 190 | func TestSignMessage_SignErrorFailsOpen(t *testing.T) { |
| 191 | // Store returned a selector + bytes, but the bytes aren't a |
| 192 | // valid PKCS#1 RSA private key (corruption, partial-write, etc). |
| 193 | // dkim.Sign returns an error; we log and proceed unsigned. A |
| 194 | // panic here would crash the outbound goroutine for every send. |
| 195 | lookup := &fakeDKIMLookup{ |
| 196 | get: func(_ context.Context, _ string) (string, []byte, error) { |
| 197 | return "e2a202605", []byte("definitely-not-a-key"), nil |
| 198 | }, |
| 199 | } |
| 200 | s := NewSenderWithDKIM(nil, "example.com", lookup) |
| 201 | signed, ok := s.signMessage([]byte(validTestMessage), "example.com") |
| 202 | if ok { |
| 203 | t.Errorf("ok = true, want false (sign should fail on garbage key)") |
| 204 | } |
| 205 | if signed != nil { |
| 206 | t.Errorf("signed != nil on sign error") |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | func TestSignMessage_HappyPathPrependsSignatureHeader(t *testing.T) { |
| 211 | // Generate a real keypair, hand it to the fake lookup, sign the |
nothing calls this directly
no test coverage detected