本文整理汇总了Python中slimta.smtp.server.Server类的典型用法代码示例。如果您正苦于以下问题:Python Server类的具体用法?Python Server怎么用?Python Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_recv_command
def test_recv_command(self):
self.sock.recv(IsA(int)).AndReturn(b'cmd ARG\r\n')
self.mox.ReplayAll()
s = Server(self.sock, None)
cmd, arg = s._recv_command()
self.assertEqual(b'CMD', cmd)
self.assertEqual(b'ARG', arg)
示例2: test_gather_params
def test_gather_params(self):
s = Server(None, None)
self.assertEqual({b'ONE': b'1'}, s._gather_params(b' ONE=1'))
self.assertEqual({b'TWO': True}, s._gather_params(b'TWO'))
self.assertEqual({b'THREE': b'foo', b'FOUR': b'bar'},
s._gather_params(b' THREE=foo FOUR=bar'))
self.assertEqual({b'FIVE': True}, s._gather_params(b'five'))
示例3: test_banner_quit
def test_banner_quit(self):
self.sock.sendall(b'220 ESMTP server\r\n')
self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
self.sock.sendall(b'221 2.0.0 Bye\r\n')
self.mox.ReplayAll()
s = Server(self.sock, None)
s.handle()
示例4: test_tls_immediately
def test_tls_immediately(self):
self.context.wrap_socket(self.sock, server_side=True).AndReturn(self.sock)
self.sock.sendall(b'220 ESMTP server\r\n')
self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
self.sock.sendall(b'221 2.0.0 Bye\r\n')
self.mox.ReplayAll()
s = Server(self.sock, None, context=self.context, tls_immediately=True)
s.handle()
示例5: test_noop
def test_noop(self):
self.sock.sendall(b'220 ESMTP server\r\n')
self.sock.recv(IsA(int)).AndReturn(b'NOOP\r\n')
self.sock.sendall(b'250 2.0.0 Ok\r\n')
self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
self.sock.sendall(b'221 2.0.0 Bye\r\n')
self.mox.ReplayAll()
s = Server(self.sock, None)
s.handle()
示例6: test_quit_bad
def test_quit_bad(self):
self.sock.sendall(b'220 ESMTP server\r\n')
self.sock.recv(IsA(int)).AndReturn(b'QUIT arg\r\n')
self.sock.sendall(b'501 5.5.4 Syntax error in parameters or arguments\r\n')
self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
self.sock.sendall(b'221 2.0.0 Bye\r\n')
self.mox.ReplayAll()
s = Server(self.sock, None)
s.handle()
示例7: test_tls_immediately_sslerror
def test_tls_immediately_sslerror(self):
sock = self.mox.CreateMockAnything()
sock.fileno = lambda: -1
sock.tls_wrapper(sock, self.tls_args).AndRaise(SSLError())
sock.sendall(b'421 4.7.0 TLS negotiation failed\r\n')
self.mox.ReplayAll()
s = Server(sock, None, tls=self.tls_args, tls_immediately=True,
tls_wrapper=sock.tls_wrapper)
s.handle()
示例8: test_helo
def test_helo(self):
self.sock.sendall(b'220 ESMTP server\r\n')
self.sock.recv(IsA(int)).AndReturn(b'HELO there\r\n')
self.sock.sendall(b'250 Hello there\r\n')
self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
self.sock.sendall(b'221 2.0.0 Bye\r\n')
self.mox.ReplayAll()
s = Server(self.sock, None)
s.handle()
self.assertEqual('there', s.ehlo_as)
示例9: test_helo_empty
def test_helo_empty(self):
self.sock.sendall(b'220 ESMTP server\r\n')
self.sock.recv(IsA(int)).AndReturn(b'HELO\r\n')
self.sock.sendall(b'501 5.5.4 Syntax error in parameters or arguments\r\n')
self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
self.sock.sendall(b'221 2.0.0 Bye\r\n')
self.mox.ReplayAll()
s = Server(self.sock, None)
s.handle()
self.assertEqual(None, s.ehlo_as)
示例10: test_unhandled_error
def test_unhandled_error(self):
class TestHandler(object):
def BANNER_(self, reply):
raise Exception('test')
self.sock.sendall(b'421 4.3.0 Unhandled system error\r\n')
self.mox.ReplayAll()
s = Server(self.sock, TestHandler())
with self.assertRaises(Exception) as cm:
s.handle()
self.assertEqual(('test', ), cm.exception.args)
示例11: test_get_message_data
def test_get_message_data(self):
expected_reply = b'250 2.6.0 Message accepted for delivery\r\n'
self.sock.recv(IsA(int)).AndReturn(b'one\r\n')
self.sock.recv(IsA(int)).AndReturn(b'.\r\n')
self.sock.sendall(expected_reply)
self.mox.ReplayAll()
s = Server(self.sock, None)
s._get_message_data()
self.assertFalse(s.have_mailfrom)
self.assertFalse(s.have_rcptto)
示例12: test_data_connectionlost
def test_data_connectionlost(self):
self.sock.sendall(b'220 ESMTP server\r\n')
self.sock.recv(IsA(int)).AndReturn(b'DATA\r\n')
self.sock.sendall(b'354 Start mail input; end with <CRLF>.<CRLF>\r\n')
self.sock.recv(IsA(int)).AndReturn(b'')
self.mox.ReplayAll()
s = Server(self.sock, None)
s.ehlo_as = b'test'
s.have_mailfrom = True
s.have_rcptto = True
self.assertRaises(ConnectionLost, s.handle)
示例13: test_banner_command
def test_banner_command(self):
self.sock.sendall(b'220 ESMTP server\r\n')
self.sock.recv(IsA(int)).AndReturn(b'BANNER\r\n')
self.sock.sendall(b'500 5.5.2 Syntax error, command unrecognized\r\n')
self.sock.recv(IsA(int)).AndReturn(b'BANNER_\r\n')
self.sock.sendall(b'500 5.5.2 Syntax error, command unrecognized\r\n')
self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
self.sock.sendall(b'221 2.0.0 Bye\r\n')
self.mox.ReplayAll()
s = Server(self.sock, None)
s.handle()
示例14: test_tls_immediately
def test_tls_immediately(self):
sock = self.mox.CreateMockAnything()
sock.fileno = lambda: -1
sock.tls_wrapper(sock, self.tls_args).AndReturn(sock)
sock.sendall(b'220 ESMTP server\r\n')
sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
sock.sendall(b'221 2.0.0 Bye\r\n')
self.mox.ReplayAll()
s = Server(sock, None, tls=self.tls_args, tls_immediately=True,
tls_wrapper=sock.tls_wrapper)
s.handle()
示例15: test_ehlo
def test_ehlo(self):
self.sock.sendall(b'220 ESMTP server\r\n')
self.sock.recv(IsA(int)).AndReturn(b'EHLO there\r\n')
self.sock.sendall(b'250-Hello there\r\n250 TEST\r\n')
self.sock.recv(IsA(int)).AndReturn(b'QUIT\r\n')
self.sock.sendall(b'221 2.0.0 Bye\r\n')
self.mox.ReplayAll()
s = Server(self.sock, None)
s.extensions.reset()
s.extensions.add('TEST')
s.handle()
self.assertEqual('there', s.ehlo_as)