-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add SIZE extension for mail from as it described in RFC 1870 Co-authored-by: Шипицын Анатолий <[email protected]>
- Loading branch information
Showing
3 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,6 +397,52 @@ QUIT | |
} | ||
}) | ||
|
||
t.Run("ehlo size", func(t *testing.T) { | ||
const ( | ||
basicServer = `250-mx.google.com at your service | ||
250-SIZE 35651584 | ||
250 [email protected] OK; can accommodate 500000 byte message | ||
250 Sender OK | ||
221 Goodbye | ||
` | ||
|
||
basicClient = `EHLO localhost | ||
MAIL FROM:<[email protected]> SIZE=50000 | ||
QUIT | ||
` | ||
) | ||
|
||
c, bcmdbuf, cmdbuf := faker(basicServer) | ||
cmdArgs := make(map[string]string) | ||
|
||
if err := c.hi("localhost"); err != nil { | ||
t.Fatalf("EHLO failed: %s", err) | ||
} | ||
if ok, _ := c.extension("SIZE"); !ok { | ||
t.Fatalf("Should support SIZE") | ||
} | ||
if ok, _ := c.extension("SMTPUTF8"); ok { | ||
t.Fatalf("Shouldn't support SMTPUTF8") | ||
} | ||
|
||
if ok, _ := c.extension("SIZE"); ok { | ||
cmdArgs["SIZE"] = "50000" | ||
} | ||
if err := c.mail("[email protected]", cmdArgs); err != nil { | ||
t.Fatalf("MAIL FROM failed: %s", err) | ||
} | ||
if err := c.quit(); err != nil { | ||
t.Fatalf("QUIT failed: %s", err) | ||
} | ||
|
||
bcmdbuf.Flush() | ||
actualcmds := cmdbuf.String() | ||
client := strings.Join(strings.Split(basicClient, "\n"), "\r\n") | ||
if client != actualcmds { | ||
t.Fatalf("Got:\n%s\nExpected:\n%s", actualcmds, client) | ||
} | ||
}) | ||
|
||
t.Run("ehlo 8bitmime", func(t *testing.T) { | ||
const ( | ||
basicServer = `250-mx.google.com at your service | ||
|