github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/syz-cluster/pkg/emailclient/smtp_sender_test.go (about) 1 // Copyright 2025 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package emailclient 5 6 import ( 7 "fmt" 8 "testing" 9 10 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestRawEmail(t *testing.T) { 14 tests := []struct { 15 item *Email 16 id string 17 result string 18 }{ 19 { 20 item: &Email{ 21 To: []string{"1@to.com", "2@to.com"}, 22 Cc: []string{"1@cc.com", "2@cc.com"}, 23 InReplyTo: "<reply-to@domain>", 24 Subject: "subject", 25 Body: []byte("Email body"), 26 }, 27 id: "<id@domain>", 28 result: "From: name <a@b.com>\r\n" + 29 "To: 1@to.com, 2@to.com\r\n" + 30 "Cc: 1@cc.com, 2@cc.com\r\n" + 31 "Subject: subject\r\n" + 32 "In-Reply-To: <reply-to@domain>\r\n" + 33 "Message-ID: <id@domain>\r\n" + 34 "MIME-Version: 1.0\r\n" + 35 "Content-Type: text/plain; charset=UTF-8\r\n" + 36 "Content-Transfer-Encoding: 8bit\r\n\r\n" + 37 "Email body", 38 }, 39 } 40 41 for i, test := range tests { 42 t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { 43 ret := rawEmail(TestEmailConfig(), test.item, test.id) 44 assert.Equal(t, test.result, string(ret)) 45 }) 46 } 47 }