本文整理汇总了Python中slimta.smtp.auth.AuthSession类的典型用法代码示例。如果您正苦于以下问题:Python AuthSession类的具体用法?Python AuthSession怎么用?Python AuthSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AuthSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_plain
def test_plain(self):
self.mox.ReplayAll()
auth = AuthSession(SASLAuth(), self.io)
result = auth.server_attempt(b'PLAIN dGVzdHppZAB0ZXN0dXNlcgB0ZXN0cGFzc3dvcmQ=')
self.assertEqual(u'testuser', result.authcid)
self.assertEqual(u'testpassword', result.secret)
self.assertEqual(u'testzid', result.authzid)
示例2: test_crammd5_malformed
def test_crammd5_malformed(self):
self.sock.sendall(b'334 PHRlc3RAZXhhbXBsZS5jb20+\r\n')
self.sock.recv(IsA(int)).AndReturn(b'bWFsZm9ybWVk\r\n')
self.mox.ReplayAll()
auth = AuthSession(SASLAuth(), self.io)
with self.assertRaises(ServerAuthError):
auth.server_attempt(b'CRAM-MD5')
示例3: test_login
def test_login(self):
self.sock.sendall('334 UGFzc3dvcmQ6\r\n')
self.sock.recv(IsA(int)).AndReturn('dGVzdHBhc3N3b3Jk\r\n')
self.mox.ReplayAll()
io = IO(self.sock)
auth = AuthSession(FakeAuth(), FakeSession(True))
identity = auth.server_attempt(io, 'LOGIN dGVzdHVzZXI=')
assert_equal('testidentity', identity)
示例4: test_client_xoauth2
def test_client_xoauth2(self):
self.sock.sendall(b'AUTH XOAUTH2 dXNlcj10ZXN0QGV4YW1wbGUuY29tAWF1dGg9QmVhcmVyYXNkZgEB\r\n')
self.sock.recv(IsA(int)).AndReturn(b'235 Ok\r\n')
self.mox.ReplayAll()
auth = AuthSession(SASLAuth(), self.io)
reply = auth.client_attempt('[email protected]', 'asdf', None, 'XOAUTH2')
self.assertEqual('235', reply.code)
self.assertEqual('2.0.0 Ok', reply.message)
示例5: test_crammd5_badcreds
def test_crammd5_badcreds(self):
self.sock.sendall('334 PHRlc3RAZXhhbXBsZS5jb20+\r\n')
self.sock.recv(IsA(int)).AndReturn('dGVzdHVzZXIgMTIzNDU2Nzg5MA==\r\n')
self.mox.ReplayAll()
io = IO(self.sock)
auth = AuthSession(FakeAuth(), FakeSession(True))
with assert_raises(CredentialsInvalidError):
auth.server_attempt(io, 'CRAM-MD5 dGVzdHVzZXI=')
示例6: test_client_bad_mech
def test_client_bad_mech(self):
self.sock.sendall(b'AUTH LOGIN\r\n')
self.sock.recv(IsA(int)).AndReturn(b'535 Nope!\r\n')
self.mox.ReplayAll()
auth = AuthSession(SASLAuth(), self.io)
reply = auth.client_attempt('[email protected]', 'asdf', None, 'LOGIN')
self.assertEqual('535', reply.code)
self.assertEqual('5.0.0 Nope!', reply.message)
示例7: test_client_plain
def test_client_plain(self):
self.sock.sendall(b'AUTH PLAIN amtsAHRlc3RAZXhhbXBsZS5jb20AYXNkZg==\r\n')
self.sock.recv(IsA(int)).AndReturn(b'235 Ok\r\n')
self.mox.ReplayAll()
auth = AuthSession(SASLAuth(), self.io)
reply = auth.client_attempt('[email protected]', 'asdf', 'jkl', 'PLAIN')
self.assertEqual('235', reply.code)
self.assertEqual('2.0.0 Ok', reply.message)
示例8: test_plain_noarg
def test_plain_noarg(self):
self.sock.sendall('334 \r\n')
self.sock.recv(IsA(int)).AndReturn('dGVzdHppZAB0ZXN0dXNlcgB0ZXN0cGFzc3dvcmQ=\r\n')
self.mox.ReplayAll()
io = IO(self.sock)
auth = AuthSession(FakeAuth(), FakeSession(True))
identity = auth.server_attempt(io, 'PLAIN')
assert_equal('testidentity', identity)
示例9: test_crammd5
def test_crammd5(self):
self.sock.sendall('334 PHRlc3RAZXhhbXBsZS5jb20+\r\n')
self.sock.recv(IsA(int)).AndReturn('dGVzdHVzZXIgNDkzMzA1OGU2ZjgyOTRkZTE0NDJkMTYxOTI3ZGI5NDQ=\r\n')
self.mox.ReplayAll()
io = IO(self.sock)
auth = AuthSession(FakeAuth(), FakeSession(True))
identity = auth.server_attempt(io, 'CRAM-MD5 dGVzdHVzZXI=')
assert_equal('testidentity', identity)
示例10: test_plain_badcreds
def test_plain_badcreds(self):
self.mox.ReplayAll()
io = IO(self.sock)
auth = AuthSession(FakeAuth(), FakeSession(True))
with assert_raises(CredentialsInvalidError):
auth.server_attempt(io, 'PLAIN dGVzdHppZAB0ZXN0dXNlcgBiYWRwYXNzd29yZA==')
with assert_raises(ServerAuthError):
auth.server_attempt(io, 'PLAIN dGVzdGluZw==')
示例11: test_crammd5_malformed
def test_crammd5_malformed(self):
self.sock.sendall('334 PHRlc3RAZXhhbXBsZS5jb20+\r\n')
self.sock.recv(IsA(int)).AndReturn('bWFsZm9ybWVk\r\n')
self.mox.ReplayAll()
io = IO(self.sock)
auth = AuthSession(FakeAuth(), FakeSession(True))
with assert_raises(ServerAuthError):
auth.server_attempt(io, 'CRAM-MD5 dGVzdHVzZXI=')
示例12: test_plain_canceled
def test_plain_canceled(self):
self.sock.sendall(b'334 \r\n')
self.sock.recv(IsA(int)).AndReturn(b'*\r\n')
self.mox.ReplayAll()
auth = AuthSession(SASLAuth(), self.io)
with self.assertRaises(AuthenticationCanceled):
auth.server_attempt(b'PLAIN')
with self.assertRaises(AuthenticationCanceled):
auth.server_attempt(b'PLAIN *')
示例13: test_login
def test_login(self):
self.sock.sendall(b'334 UGFzc3dvcmQ6\r\n')
self.sock.recv(IsA(int)).AndReturn(b'dGVzdHBhc3N3b3Jk\r\n')
self.mox.ReplayAll()
auth = AuthSession(SASLAuth(), self.io)
result = auth.server_attempt(b'LOGIN dGVzdHVzZXI=')
self.assertEqual(u'testuser', result.authcid)
self.assertEqual(u'testpassword', result.secret)
self.assertEqual(None, result.authzid)
示例14: test_plain_noarg
def test_plain_noarg(self):
self.sock.sendall(b'334 \r\n')
self.sock.recv(IsA(int)).AndReturn(b'dGVzdHppZAB0ZXN0dXNlcgB0ZXN0cGFzc3dvcmQ=\r\n')
self.mox.ReplayAll()
auth = AuthSession(SASLAuth(), self.io)
result = auth.server_attempt(b'PLAIN')
self.assertEqual(u'testuser', result.authcid)
self.assertEqual(u'testpassword', result.secret)
self.assertEqual(u'testzid', result.authzid)
示例15: test_client_crammd5
def test_client_crammd5(self):
self.sock.sendall(b'AUTH CRAM-MD5\r\n')
self.sock.recv(IsA(int)).AndReturn(b'334 dGVzdCBjaGFsbGVuZ2U=\r\n')
self.sock.sendall(b'dGVzdEBleGFtcGxlLmNvbSA1Yzk1OTBjZGE3ZTgxMDY5Mzk2ZjhiYjlkMzU1MzE1Yg==\r\n')
self.sock.recv(IsA(int)).AndReturn(b'235 Ok\r\n')
self.mox.ReplayAll()
auth = AuthSession(SASLAuth(), self.io)
reply = auth.client_attempt('[email protected]', 'asdf', None, 'CRAM-MD5')
self.assertEqual('235', reply.code)
self.assertEqual('2.0.0 Ok', reply.message)