diff options
author | Georg Brandl <georg@python.org> | 2010-12-03 07:38:22 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-12-03 07:38:22 (GMT) |
commit | 1e5c5f8f7d507af580486529399f12f7e2bbf70a (patch) | |
tree | d55d91fc4b5e7a303756376fe19e7cc277bf9268 /Lib/test/test_smtpd.py | |
parent | 106a54d764f1f796a67c4dfef8c98b1a7f8bf183 (diff) | |
download | cpython-1e5c5f8f7d507af580486529399f12f7e2bbf70a.zip cpython-1e5c5f8f7d507af580486529399f12f7e2bbf70a.tar.gz cpython-1e5c5f8f7d507af580486529399f12f7e2bbf70a.tar.bz2 |
#1745035: add limits for command and data size to smtpd; patch by Savio Sena.
Diffstat (limited to 'Lib/test/test_smtpd.py')
-rw-r--r-- | Lib/test/test_smtpd.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_smtpd.py b/Lib/test/test_smtpd.py index 3d55bb2..a4cd670 100644 --- a/Lib/test/test_smtpd.py +++ b/Lib/test/test_smtpd.py @@ -121,6 +121,24 @@ class SMTPDChannelTest(TestCase): self.assertEqual(self.channel.socket.last, b'451 Internal confusion\r\n') + def test_command_too_long(self): + self.write_line(b'MAIL from ' + + b'a' * self.channel.command_size_limit + + b'@example') + self.assertEqual(self.channel.socket.last, + b'500 Error: line too long\r\n') + + def test_data_too_long(self): + # Small hack. Setting limit to 2K octets here will save us some time. + self.channel.data_size_limit = 2048 + self.write_line(b'MAIL From:eggs@example') + self.write_line(b'RCPT To:spam@example') + self.write_line(b'DATA') + self.write_line(b'A' * self.channel.data_size_limit + + b'A\r\n.') + self.assertEqual(self.channel.socket.last, + b'552 Error: Too much mail data\r\n') + def test_need_MAIL(self): self.write_line(b'RCPT to:spam@example') self.assertEqual(self.channel.socket.last, |