package imap import ( "bytes" "net/mail" "strings" "testing" ) func Test_mergeAuthFromHeaders_dkimAndTLS(t *testing.T) { raw := strings.Join([]string{ "From: Sender ", "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") } }