• Home
  • Raw
  • Download

Lines Matching +full:localhost +full:- +full:test

20 from test import support, mock_socket
21 from test.support import hashlib_helper
22 from test.support import socket_helper
23 from test.support import threading_helper
24 from test.support import warnings_helper
59 n -= 1
76 # so test to make sure it still works.
174 @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), "test requires Unix domain socket")
191 # Test server thread using the specified SMTP server class
211 n -= 1
223 MSG_BEGIN = '---------- MESSAGE FOLLOWS ----------\n'
224 MSG_END = '------------ END MESSAGE ------------\n'
226 # NOTE: Some SMTP objects in the tests below are created with a non-default
229 # test server times out, causing the test to fail.
231 # Test behavior of smtpd.DebuggingServer
251 self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1),
281 return re.sub(r'(.*?)^X-Peer:\s*\S+\n(.*)', r'\1\2',
286 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
294 smtp = smtplib.SMTP(self.host, self.port, local_hostname='localhost',
299 self.assertEqual(smtp.local_hostname, 'localhost')
307 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
315 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
324 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
333 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
343 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
347 smtp.putcmd('helo\nX-INJECTED')
352 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
364 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
373 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
382 m = 'A test message'
383 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
387 # XXX(nnorwitz): this test is flaky and dies with a bad file descriptor
400 m = b'A test message'
401 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
417 m = '.A test\n.mes.sage.'
418 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
436 smtp = smtplib.SMTP(HOST, self.port, local_hostname='hi\nX-INJECTED',
442 "prohibited newline characters: ehlo hi\\nX-INJECTED",
450 self.assertNotIn("X-INJECTED", debugout)
457 HOST, self.port, local_hostname='localhost',
463 smtp.mail("hi@me.com", ["X-OPTION\nX-INJECTED-1", "X-OPTION2\nX-INJECTED-2"])
466 self.assertIn("X-OPTION\\nX-INJECTED-1 X-OPTION2\\nX-INJECTED-2", msg)
472 self.assertNotIn("X-OPTION", debugout)
473 self.assertNotIn("X-OPTION2", debugout)
474 self.assertNotIn("X-INJECTED-1", debugout)
475 self.assertNotIn("X-INJECTED-2", debugout)
478 m = 'A test message'
479 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
497 m = email.mime.text.MIMEText('A test message')
498 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
509 # Remove the X-Peer header that DebuggingServer adds as figuring out
511 # irrelevant to our test). Typically 127.0.0.1 or ::1, but it is
514 del m['X-Peer']
519 m = email.mime.text.MIMEText('A test message')
523 m['Bcc'] = 'John Root <root@localhost>, "Dinsdale" <warped@silly.walks.com>'
524 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
532 self.assertEqual(m['Bcc'], 'John Root <root@localhost>, "Dinsdale" '
538 # Remove the X-Peer header that DebuggingServer adds.
540 del m['X-Peer']
548 for addr in ('John', 'Sally', 'Fred', 'root@localhost',
556 m = email.mime.text.MIMEText('A test message')
559 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
570 # Remove the X-Peer header that DebuggingServer adds.
572 del m['X-Peer']
585 m = email.mime.text.MIMEText('A test message')
588 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
599 # Remove the X-Peer header that DebuggingServer adds.
601 del m['X-Peer']
616 m = email.mime.text.MIMEText('A test message')
618 m['Sender'] = 'the_rescuers@Rescue-Aid-Society.com'
620 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
631 # Remove the X-Peer header that DebuggingServer adds.
633 del m['X-Peer']
637 sender = re.compile("^sender: the_rescuers@Rescue-Aid-Society.com$", re.MULTILINE)
645 m = email.mime.text.MIMEText('A test message')
649 m['Bcc'] = 'John Root <root@localhost>, "Dinsdale" <warped@silly.walks.com>'
650 m['Resent-Date'] = 'Thu, 1 Jan 1970 17:42:00 +0000'
651 m['Resent-From'] = 'holy@grail.net'
652 m['Resent-To'] = 'Martha <my_mom@great.cooker.com>, Jeff'
653 m['Resent-Bcc'] = 'doe@losthope.net'
654 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
665 # The Resent-Bcc headers are deleted before serialization.
667 del m['Resent-Bcc']
668 # Remove the X-Peer header that DebuggingServer adds.
670 del m['X-Peer']
682 m = email.mime.text.MIMEText('A test message')
686 m['Bcc'] = 'John Root <root@localhost>, "Dinsdale" <warped@silly.walks.com>'
687 m['Resent-Date'] = 'Thu, 1 Jan 1970 17:42:00 +0000'
688 m['Resent-From'] = 'holy@grail.net'
689 m['Resent-To'] = 'Martha <my_mom@great.cooker.com>, Jeff'
690 m['Resent-Bcc'] = 'doe@losthope.net'
691 m['Resent-Date'] = 'Thu, 2 Jan 1970 17:42:00 +0000'
692 m['Resent-To'] = 'holy@grail.net'
693 m['Resent-From'] = 'Martha <my_mom@great.cooker.com>, Jeff'
694 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
704 # Test various operations on an unconnected SMTP object that
711 smtp.send, 'test msg')
714 # check that non-numeric port raises OSError
716 "localhost", "bogus")
718 "localhost:bogus")
722 # (regression test, the previous behavior raised an
755 # test response of client to a non-successful HELO message
772 HOST, self.port, 'localhost', 3)
804 HOST, self.port, 'localhost', 3)
808 'Ms.B@xn--fo-fka.com':'Sally B',
815 sim_lists = {'list-1':['Mr.A@somewhere.com','Mrs.C@somewhereesle.com'],
816 'list-2':['Ms.B@xn--fo-fka.com',],
835 [ "250-{0}\r\n".format(x) for x in extra_features ])
866 self.push('501 Syntax: AUTH <mechanism> [initial-response]')
868 auth_object_name = '_auth_%s' % args[0].lower().replace('-', '_')
887 return base64.decodebytes(string.encode('ascii')).decode('utf-8')
939 resp = ('250-testhost\r\n'
940 '250-EXPN\r\n'
941 '250-SIZE 20000000\r\n'
942 '250-STARTTLS\r\n'
943 '250-DELIVERBY\r\n')
962 if n < len(user_list) - 1:
963 self.push('250-%s %s' % (sim_users[user_email], quoted_addr))
989 self.push(self.rcpt_response[self.rcpt_count-1])
1030 # Test various SMTP & ESMTP commands/behaviors that require a simulated server
1041 self.serv = SimSMTPServer((HOST, 0), ('nowhere', -1), decode_data=True)
1064 # smoke test
1065 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1070 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1076 # features expected from the test server
1088 self.assertFalse(smtp.has_extn('unsupported-feature'))
1092 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1107 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1117 u = 'PSU-Members-List'
1124 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1132 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1140 with smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1149 with smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1164 HOST, self.port, local_hostname='localhost',
1178 self.serv.add_feature("AUTH CRAM-MD5")
1179 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1187 # Test that multiple authentication methods are tried.
1188 self.serv.add_feature("AUTH BOGUS PLAIN LOGIN CRAM-MD5")
1189 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1202 supported.add('CRAM-MD5')
1208 local_hostname='localhost',
1212 method = 'auth_' + mechanism.lower().replace('-', '_')
1219 local_hostname='localhost',
1250 #test infrastructure can support it.
1254 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1260 smtp.sendmail('John', 'Sally', 'test message')
1265 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1270 smtp.sendmail('John', 'Sally', 'test message')
1275 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1280 smtp.sendmail('John', ['Sally', 'Frank', 'George'], 'test message')
1293 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1297 smtp.sendmail('John@foo.org', ['Sally@foo.org'], 'test message')
1303 HOST, self.port, local_hostname='localhost',
1319 HOST, self.port, local_hostname='localhost',
1326 # This test is located here and not in the SMTPUTF8SimTests
1333 HOST, self.port, local_hostname='localhost',
1341 HOST, self.port, local_hostname='localhost',
1358 # The base SMTP server turns these on automatically, but our test
1392 self.serv = SimSMTPUTF8Server((HOST, 0), ('nowhere', -1),
1418 HOST, self.port, local_hostname='localhost',
1426 m = '¡a test message containing unicode!'.encode('utf-8')
1428 HOST, self.port, local_hostname='localhost',
1441 m = '¡a test message containing unicode!'.encode('utf-8')
1443 HOST, self.port, local_hostname='localhost',
1467 # XXX smtpd converts received /r/n to /n, so we can't easily test that
1473 Content-Type: text/plain; charset="utf-8"
1474 Content-Transfer-Encoding: 8bit
1475 MIME-Version: 1.0
1480 HOST, self.port, local_hostname='localhost',
1496 # RFC 4954's AUTH command allows for an optional initial-response.
1498 # PLAIN does those, so test that here. See issue #15014.
1502 # AUTH PLAIN <initial-response> with the response base 64
1503 # encoded. Hard code the expected response for the test.
1522 (HOST, 0), ('nowhere', -1), decode_data=True)
1546 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
1553 smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',