Parser liest oberstes Return-Path, Index-Spalte env_from, Absender-Filter matcht from_addr oder env_from. Keine Zugriffswirkung. Reindex für Bestand nötig. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
29 lines
927 B
Go
29 lines
927 B
Go
package mailparser_test
|
|
|
|
import "testing"
|
|
|
|
func TestReturnPath(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
headers string
|
|
want string
|
|
}{
|
|
{"none", "", ""},
|
|
{"simple", "Return-Path: <Forwarder@Example.COM>\r\n", "forwarder@example.com"},
|
|
{"without brackets", "Return-Path: fwd@example.com\r\n", "fwd@example.com"},
|
|
{"topmost only", "Return-Path: <fwd@example.com>\r\nReceived: from x\r\nReturn-Path: <orig@example.net>\r\n", "fwd@example.com"},
|
|
{"null sender", "Return-Path: <>\r\n", ""},
|
|
{"null sender topmost hides lower", "Return-Path: <>\r\nReturn-Path: <orig@example.net>\r\n", ""},
|
|
{"garbage", "Return-Path: not an address\r\n", ""},
|
|
{"empty", "Return-Path: \r\n", ""},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
pm := parseHeaders(t, tt.headers)
|
|
if pm.ReturnPath != tt.want {
|
|
t.Errorf("ReturnPath = %q, want %q", pm.ReturnPath, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|