def test_extended_handshake(self):
     mock = self.mox.CreateMockAnything()
     mock.__call__(IsA(SmtpSession)).AndReturn(mock)
     mock.handle_banner(IsA(Reply), ('127.0.0.1', 0))
     mock.handle_ehlo(IsA(Reply), 'there')
     mock.handle_tls()
     self.mox.ReplayAll()
     h = SmtpSession(('127.0.0.1', 0), mock, None)
     h.BANNER_(Reply('220'))
     h.EHLO(Reply('250'), 'there')
     h.TLSHANDSHAKE()
     h.AUTH(Reply('250'), 'testauth')
     assert_equal('there', h.ehlo_as)
     assert_true(h.extended_smtp)
     assert_equal('TLS', h.security)
     assert_equal('testauth', h.auth_result)
     assert_equal('ESMTPSA', h.protocol)
 def test_extended_handshake(self):
     creds = self.mox.CreateMockAnything()
     creds.authcid = 'testuser'
     creds.authzid = 'testzid'
     mock = self.mox.CreateMockAnything()
     mock.__call__(IsA(SmtpSession)).AndReturn(mock)
     mock.handle_banner(IsA(Reply), ('127.0.0.1', 0))
     mock.handle_ehlo(IsA(Reply), 'there')
     mock.handle_tls()
     mock.handle_auth(IsA(Reply), creds)
     self.mox.ReplayAll()
     h = SmtpSession(('127.0.0.1', 0), mock, None)
     h.BANNER_(Reply('220'))
     h.EHLO(Reply('250'), 'there')
     h.TLSHANDSHAKE()
     h.AUTH(Reply('235'), creds)
     self.assertEqual('there', h.ehlo_as)
     self.assertTrue(h.extended_smtp)
     self.assertEqual('TLS', h.security)
     self.assertEqual(('testuser', 'testzid'), h.auth)
     self.assertEqual('ESMTPSA', h.protocol)