Skip to content

Commit

Permalink
test: XOORG
Browse files Browse the repository at this point in the history
  • Loading branch information
ml1nk authored and Marcel Link committed Aug 26, 2024
1 parent 04dd565 commit 3638f87
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1514,3 +1514,47 @@ func TestServerDSNwithSMTPUTF8(t *testing.T) {
t.Fatal("Invalid ORCPT address:", val)
}
}

func TestServerXOORG(t *testing.T) {
be, s, c, scanner, caps := testServerEhlo(t,
func(s *smtp.Server) {
s.EnableXOORG = true
})
defer s.Close()
defer c.Close()

for _, cap := range []string{"XOORG"} {
if _, ok := caps[cap]; !ok {
t.Fatal("Missing capability:", cap)
}
}

io.WriteString(c, "MAIL FROM:<e=mc2@example.com> XOORG=test.com\r\n")
scanner.Scan()
if !strings.HasPrefix(scanner.Text(), "250 ") {
t.Fatal("Invalid MAIL response:", scanner.Text())
}

io.WriteString(c, "RCPT TO:<e=mc2@example.com>\r\n")
scanner.Scan()
if !strings.HasPrefix(scanner.Text(), "250 ") {
t.Fatal("Invalid RCPT response:", scanner.Text())
}

// go on as usual
io.WriteString(c, "DATA\r\n")
scanner.Scan()
io.WriteString(c, "Hey <3\r\n")
io.WriteString(c, ".\r\n")
scanner.Scan()
if !strings.HasPrefix(scanner.Text(), "250 ") {
t.Fatal("Invalid DATA response:", scanner.Text())
}
if len(be.messages) != 0 || len(be.anonmsgs) != 1 {
t.Fatal("Invalid number of sent messages:", be.messages, be.anonmsgs)
}

if val := be.anonmsgs[0].Opts.XOORG; val != "test.com" {
t.Fatal("Invalid XOORG parameter value:", val)
}
}

0 comments on commit 3638f87

Please sign in to comment.