Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 1 | from unittest import TestCase |
Richard Jones | 64b02de | 2010-08-03 06:39:33 +0000 | [diff] [blame] | 2 | from test import support, mock_socket |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 3 | import socket |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 4 | import io |
| 5 | import smtpd |
Richard Jones | 64b02de | 2010-08-03 06:39:33 +0000 | [diff] [blame] | 6 | import asyncore |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 7 | |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 8 | |
| 9 | class DummyServer(smtpd.SMTPServer): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 10 | def __init__(self, localaddr, remoteaddr): |
| 11 | smtpd.SMTPServer.__init__(self, localaddr, remoteaddr) |
Georg Brandl | 6d23c44 | 2010-07-29 13:19:42 +0000 | [diff] [blame] | 12 | self.messages = [] |
Richard Jones | 64b02de | 2010-08-03 06:39:33 +0000 | [diff] [blame] | 13 | |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 14 | def process_message(self, peer, mailfrom, rcpttos, data): |
| 15 | self.messages.append((peer, mailfrom, rcpttos, data)) |
| 16 | if data == 'return status': |
| 17 | return '250 Okish' |
| 18 | |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 19 | |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 20 | class DummyDispatcherBroken(Exception): |
| 21 | pass |
| 22 | |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 23 | |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 24 | class BrokenDummyServer(DummyServer): |
| 25 | def listen(self, num): |
| 26 | raise DummyDispatcherBroken() |
| 27 | |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 28 | |
| 29 | class SMTPDServerTest(TestCase): |
| 30 | def setUp(self): |
| 31 | smtpd.socket = asyncore.socket = mock_socket |
| 32 | |
| 33 | def test_process_message_unimplemented(self): |
| 34 | server = smtpd.SMTPServer('a', 'b') |
| 35 | conn, addr = server.accept() |
| 36 | channel = smtpd.SMTPChannel(server, conn, addr) |
| 37 | |
| 38 | def write_line(line): |
| 39 | channel.socket.queue_recv(line) |
| 40 | channel.handle_read() |
| 41 | |
| 42 | write_line(b'MAIL From:eggs@example') |
| 43 | write_line(b'RCPT To:spam@example') |
| 44 | write_line(b'DATA') |
| 45 | self.assertRaises(NotImplementedError, write_line, b'spam\r\n.\r\n') |
| 46 | |
| 47 | def tearDown(self): |
Richard Jones | daf2350 | 2010-08-16 01:48:14 +0000 | [diff] [blame] | 48 | asyncore.close_all() |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 49 | asyncore.socket = smtpd.socket = socket |
| 50 | |
| 51 | |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 52 | class SMTPDChannelTest(TestCase): |
| 53 | def setUp(self): |
Richard Jones | 64b02de | 2010-08-03 06:39:33 +0000 | [diff] [blame] | 54 | smtpd.socket = asyncore.socket = mock_socket |
Antoine Pitrou | e0815e2 | 2011-11-12 20:36:29 +0100 | [diff] [blame] | 55 | self.old_debugstream = smtpd.DEBUGSTREAM |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 56 | self.debug = smtpd.DEBUGSTREAM = io.StringIO() |
| 57 | self.server = DummyServer('a', 'b') |
| 58 | conn, addr = self.server.accept() |
| 59 | self.channel = smtpd.SMTPChannel(self.server, conn, addr) |
| 60 | |
Richard Jones | 64b02de | 2010-08-03 06:39:33 +0000 | [diff] [blame] | 61 | def tearDown(self): |
Richard Jones | daf2350 | 2010-08-16 01:48:14 +0000 | [diff] [blame] | 62 | asyncore.close_all() |
Richard Jones | 64b02de | 2010-08-03 06:39:33 +0000 | [diff] [blame] | 63 | asyncore.socket = smtpd.socket = socket |
Antoine Pitrou | e0815e2 | 2011-11-12 20:36:29 +0100 | [diff] [blame] | 64 | smtpd.DEBUGSTREAM = self.old_debugstream |
Richard Jones | 64b02de | 2010-08-03 06:39:33 +0000 | [diff] [blame] | 65 | |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 66 | def write_line(self, line): |
| 67 | self.channel.socket.queue_recv(line) |
| 68 | self.channel.handle_read() |
| 69 | |
| 70 | def test_broken_connect(self): |
| 71 | self.assertRaises(DummyDispatcherBroken, BrokenDummyServer, 'a', 'b') |
| 72 | |
| 73 | def test_server_accept(self): |
| 74 | self.server.handle_accept() |
| 75 | |
| 76 | def test_missing_data(self): |
| 77 | self.write_line(b'') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 78 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 79 | b'500 Error: bad syntax\r\n') |
| 80 | |
| 81 | def test_EHLO_not_implemented(self): |
| 82 | self.write_line(b'EHLO test.example') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 83 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 84 | b'502 Error: command "EHLO" not implemented\r\n') |
| 85 | |
| 86 | def test_HELO(self): |
Richard Jones | 64b02de | 2010-08-03 06:39:33 +0000 | [diff] [blame] | 87 | name = smtpd.socket.getfqdn() |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 88 | self.write_line(b'HELO test.example') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 89 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 90 | '250 {}\r\n'.format(name).encode('ascii')) |
| 91 | |
| 92 | def test_HELO_bad_syntax(self): |
| 93 | self.write_line(b'HELO') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 94 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 95 | b'501 Syntax: HELO hostname\r\n') |
| 96 | |
| 97 | def test_HELO_duplicate(self): |
| 98 | self.write_line(b'HELO test.example') |
| 99 | self.write_line(b'HELO test.example') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 100 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 101 | b'503 Duplicate HELO/EHLO\r\n') |
| 102 | |
| 103 | def test_NOOP(self): |
| 104 | self.write_line(b'NOOP') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 105 | self.assertEqual(self.channel.socket.last, b'250 Ok\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 106 | |
| 107 | def test_NOOP_bad_syntax(self): |
| 108 | self.write_line(b'NOOP hi') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 109 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 110 | b'501 Syntax: NOOP\r\n') |
| 111 | |
| 112 | def test_QUIT(self): |
| 113 | self.write_line(b'QUIT') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 114 | self.assertEqual(self.channel.socket.last, b'221 Bye\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 115 | |
| 116 | def test_QUIT_arg_ignored(self): |
| 117 | self.write_line(b'QUIT bye bye') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 118 | self.assertEqual(self.channel.socket.last, b'221 Bye\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 119 | |
| 120 | def test_bad_state(self): |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 121 | self.channel.smtp_state = 'BAD STATE' |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 122 | self.write_line(b'HELO') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 123 | self.assertEqual(self.channel.socket.last, |
| 124 | b'451 Internal confusion\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 125 | |
Georg Brandl | 1e5c5f8 | 2010-12-03 07:38:22 +0000 | [diff] [blame] | 126 | def test_command_too_long(self): |
| 127 | self.write_line(b'MAIL from ' + |
| 128 | b'a' * self.channel.command_size_limit + |
| 129 | b'@example') |
| 130 | self.assertEqual(self.channel.socket.last, |
| 131 | b'500 Error: line too long\r\n') |
| 132 | |
| 133 | def test_data_too_long(self): |
| 134 | # Small hack. Setting limit to 2K octets here will save us some time. |
| 135 | self.channel.data_size_limit = 2048 |
| 136 | self.write_line(b'MAIL From:eggs@example') |
| 137 | self.write_line(b'RCPT To:spam@example') |
| 138 | self.write_line(b'DATA') |
| 139 | self.write_line(b'A' * self.channel.data_size_limit + |
| 140 | b'A\r\n.') |
| 141 | self.assertEqual(self.channel.socket.last, |
| 142 | b'552 Error: Too much mail data\r\n') |
| 143 | |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 144 | def test_need_MAIL(self): |
| 145 | self.write_line(b'RCPT to:spam@example') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 146 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 147 | b'503 Error: need MAIL command\r\n') |
| 148 | |
| 149 | def test_MAIL_syntax(self): |
| 150 | self.write_line(b'MAIL from eggs@example') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 151 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 152 | b'501 Syntax: MAIL FROM:<address>\r\n') |
| 153 | |
| 154 | def test_MAIL_missing_from(self): |
| 155 | self.write_line(b'MAIL from:') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 156 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 157 | b'501 Syntax: MAIL FROM:<address>\r\n') |
| 158 | |
| 159 | def test_MAIL_chevrons(self): |
| 160 | self.write_line(b'MAIL from:<eggs@example>') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 161 | self.assertEqual(self.channel.socket.last, b'250 Ok\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 162 | |
| 163 | def test_nested_MAIL(self): |
| 164 | self.write_line(b'MAIL from:eggs@example') |
| 165 | self.write_line(b'MAIL from:spam@example') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 166 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 167 | b'503 Error: nested MAIL command\r\n') |
| 168 | |
| 169 | def test_need_RCPT(self): |
| 170 | self.write_line(b'MAIL From:eggs@example') |
| 171 | self.write_line(b'DATA') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 172 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 173 | b'503 Error: need RCPT command\r\n') |
| 174 | |
| 175 | def test_RCPT_syntax(self): |
| 176 | self.write_line(b'MAIL From:eggs@example') |
| 177 | self.write_line(b'RCPT to eggs@example') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 178 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 179 | b'501 Syntax: RCPT TO: <address>\r\n') |
| 180 | |
| 181 | def test_data_dialog(self): |
| 182 | self.write_line(b'MAIL From:eggs@example') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 183 | self.assertEqual(self.channel.socket.last, b'250 Ok\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 184 | self.write_line(b'RCPT To:spam@example') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 185 | self.assertEqual(self.channel.socket.last, b'250 Ok\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 186 | |
| 187 | self.write_line(b'DATA') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 188 | self.assertEqual(self.channel.socket.last, |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 189 | b'354 End data with <CR><LF>.<CR><LF>\r\n') |
| 190 | self.write_line(b'data\r\nmore\r\n.') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 191 | self.assertEqual(self.channel.socket.last, b'250 Ok\r\n') |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 192 | self.assertEqual(self.server.messages, |
| 193 | [('peer', 'eggs@example', ['spam@example'], 'data\nmore')]) |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 194 | |
| 195 | def test_DATA_syntax(self): |
| 196 | self.write_line(b'MAIL From:eggs@example') |
| 197 | self.write_line(b'RCPT To:spam@example') |
| 198 | self.write_line(b'DATA spam') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 199 | self.assertEqual(self.channel.socket.last, b'501 Syntax: DATA\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 200 | |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 201 | def test_data_transparency_section_4_5_2(self): |
| 202 | self.write_line(b'MAIL From:eggs@example') |
| 203 | self.write_line(b'RCPT To:spam@example') |
| 204 | self.write_line(b'DATA') |
| 205 | self.write_line(b'..\r\n.\r\n') |
| 206 | self.assertEqual(self.channel.received_data, '.') |
| 207 | |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 208 | def test_multiple_RCPT(self): |
| 209 | self.write_line(b'MAIL From:eggs@example') |
| 210 | self.write_line(b'RCPT To:spam@example') |
| 211 | self.write_line(b'RCPT To:ham@example') |
| 212 | self.write_line(b'DATA') |
| 213 | self.write_line(b'data\r\n.') |
Richard Jones | 6a9e6bb | 2010-08-04 12:27:36 +0000 | [diff] [blame] | 214 | self.assertEqual(self.server.messages, |
| 215 | [('peer', 'eggs@example', ['spam@example','ham@example'], 'data')]) |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 216 | |
| 217 | def test_manual_status(self): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 218 | # checks that the Channel is able to return a custom status message |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 219 | self.write_line(b'MAIL From:eggs@example') |
| 220 | self.write_line(b'RCPT To:spam@example') |
| 221 | self.write_line(b'DATA') |
| 222 | self.write_line(b'return status\r\n.') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 223 | self.assertEqual(self.channel.socket.last, b'250 Okish\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 224 | |
| 225 | def test_RSET(self): |
| 226 | self.write_line(b'MAIL From:eggs@example') |
| 227 | self.write_line(b'RCPT To:spam@example') |
| 228 | self.write_line(b'RSET') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 229 | self.assertEqual(self.channel.socket.last, b'250 Ok\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 230 | self.write_line(b'MAIL From:foo@example') |
| 231 | self.write_line(b'RCPT To:eggs@example') |
| 232 | self.write_line(b'DATA') |
| 233 | self.write_line(b'data\r\n.') |
Richard Jones | 6a9e6bb | 2010-08-04 12:27:36 +0000 | [diff] [blame] | 234 | self.assertEqual(self.server.messages, |
| 235 | [('peer', 'foo@example', ['eggs@example'], 'data')]) |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 236 | |
| 237 | def test_RSET_syntax(self): |
| 238 | self.write_line(b'RSET hi') |
Georg Brandl | 17e3d69 | 2010-07-31 10:08:09 +0000 | [diff] [blame] | 239 | self.assertEqual(self.channel.socket.last, b'501 Syntax: RSET\r\n') |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 240 | |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 241 | def test_attribute_deprecations(self): |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 242 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 243 | spam = self.channel._SMTPChannel__server |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 244 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 245 | self.channel._SMTPChannel__server = 'spam' |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 246 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 247 | spam = self.channel._SMTPChannel__line |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 248 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 249 | self.channel._SMTPChannel__line = 'spam' |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 250 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 251 | spam = self.channel._SMTPChannel__state |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 252 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 253 | self.channel._SMTPChannel__state = 'spam' |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 254 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 255 | spam = self.channel._SMTPChannel__greeting |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 256 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 257 | self.channel._SMTPChannel__greeting = 'spam' |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 258 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 259 | spam = self.channel._SMTPChannel__mailfrom |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 260 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 261 | self.channel._SMTPChannel__mailfrom = 'spam' |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 262 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 263 | spam = self.channel._SMTPChannel__rcpttos |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 264 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 265 | self.channel._SMTPChannel__rcpttos = 'spam' |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 266 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 267 | spam = self.channel._SMTPChannel__data |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 268 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 269 | self.channel._SMTPChannel__data = 'spam' |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 270 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 271 | spam = self.channel._SMTPChannel__fqdn |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 272 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 273 | self.channel._SMTPChannel__fqdn = 'spam' |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 274 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 275 | spam = self.channel._SMTPChannel__peer |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 276 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 277 | self.channel._SMTPChannel__peer = 'spam' |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 278 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 279 | spam = self.channel._SMTPChannel__conn |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 280 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 281 | self.channel._SMTPChannel__conn = 'spam' |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 282 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 283 | spam = self.channel._SMTPChannel__addr |
Florent Xicluna | 6731775 | 2011-12-10 11:07:42 +0100 | [diff] [blame] | 284 | with support.check_warnings(('', DeprecationWarning)): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 285 | self.channel._SMTPChannel__addr = 'spam' |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 286 | |
| 287 | def test_main(): |
Richard Jones | 4aa0d4d | 2010-08-04 01:20:14 +0000 | [diff] [blame] | 288 | support.run_unittest(SMTPDServerTest, SMTPDChannelTest) |
Richard Jones | 8cb3619 | 2010-07-23 16:20:40 +0000 | [diff] [blame] | 289 | |
| 290 | if __name__ == "__main__": |
| 291 | test_main() |