ultisuite-backend/internal/mail/imap/headers_meta_test.go
R3D347HR4Y cd0a80f5e8 huhu
2026-05-25 13:52:27 +02:00

34 lines
790 B
Go

package imap
import (
"bytes"
"net/mail"
"strings"
"testing"
)
func Test_mergeAuthFromHeaders_dkimAndTLS(t *testing.T) {
raw := strings.Join([]string{
"From: Sender <sender@example.com>",
"Authentication-Results: mx.example.com; dkim=pass header.d=mail.example.com",
"Received: from mail.example.com (mail.example.com [1.2.3.4]) by mx with ESMTPS",
"",
"Body",
}, "\r\n")
msg, err := mail.ReadMessage(bytes.NewReader([]byte(raw)))
if err != nil {
t.Fatal(err)
}
var auth MessageAuthInfo
mergeAuthFromHeaders(&auth, msg)
if auth.DKIMPass == nil || !*auth.DKIMPass {
t.Fatalf("dkim_pass = %v, want true", auth.DKIMPass)
}
if auth.SignedBy != "mail.example.com" {
t.Fatalf("signed_by = %q", auth.SignedBy)
}
if !auth.TLS {
t.Fatal("expected tls true")
}
}