예제 #1
0
 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('*****@*****.**', 'asdf', 'jkl', 'PLAIN')
     self.assertEqual('235', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
 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('*****@*****.**', 'asdf', None, 'LOGIN')
     self.assertEqual('535', reply.code)
     self.assertEqual('5.0.0 Nope!', reply.message)
예제 #3
0
 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('*****@*****.**', 'asdf', None, 'XOAUTH2')
     self.assertEqual('235', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
예제 #4
0
 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('*****@*****.**', 'asdf', None, 'LOGIN')
     self.assertEqual('535', reply.code)
     self.assertEqual('5.0.0 Nope!', reply.message)
 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('*****@*****.**', 'asdf', 'jkl', 'PLAIN')
     self.assertEqual('235', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
예제 #6
0
 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([b'XOAUTH2']), self.io)
     reply = auth.client_attempt(u'*****@*****.**', u'asdf',
                                 None, b'XOAUTH2')
     self.assertEqual('235', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
 def test_client_login_bad_username(self):
     self.sock.sendall(b'AUTH LOGIN\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'334 VXNlcm5hbWU6\r\n')
     self.sock.sendall(b'dGVzdEBleGFtcGxlLmNvbQ==\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('*****@*****.**', 'asdf', None, 'LOGIN')
     self.assertEqual('535', reply.code)
     self.assertEqual('5.0.0 Nope!', reply.message)
예제 #8
0
 def test_client_xoauth2_error(self):
     self.sock.sendall(b'AUTH XOAUTH2 dXNlcj10ZXN0QGV4YW1wbGUuY29tAWF1dGg9QmVhcmVyYXNkZgEB\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'334 eyJzdGF0dXMiOiI0MDEiLCJzY2hlbWVzIjoiYmVhcmVyIG1hYyIsInNjb3BlIjoiaHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vIn0K\r\n')
     self.sock.sendall(b'\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('*****@*****.**', 'asdf', None, 'XOAUTH2')
     self.assertEqual('535', reply.code)
     self.assertEqual('5.0.0 Nope!', reply.message)
예제 #9
0
 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('*****@*****.**', 'asdf', None, 'CRAM-MD5')
     self.assertEqual('235', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
예제 #10
0
 def test_client_login_bad_username(self):
     self.sock.sendall(b'AUTH LOGIN\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'334 VXNlcm5hbWU6\r\n')
     self.sock.sendall(b'dGVzdEBleGFtcGxlLmNvbQ==\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('*****@*****.**', 'asdf', None, 'LOGIN')
     self.assertEqual('535', reply.code)
     self.assertEqual('5.0.0 Nope!', reply.message)
예제 #11
0
 def test_client_xoauth2_error(self):
     self.sock.sendall(b'AUTH XOAUTH2 dXNlcj10ZXN0QGV4YW1wbGUuY29tAWF1dGg9QmVhcmVyYXNkZgEB\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'334 eyJzdGF0dXMiOiI0MDEiLCJzY2hlbWVzIjoiYmVhcmVyIG1hYyIsInNjb3BlIjoiaHR0cHM6Ly9tYWlsLmdvb2dsZS5jb20vIn0K\r\n')
     self.sock.sendall(b'\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'535 Nope!\r\n')
     self.mox.ReplayAll()
     auth = AuthSession(SASLAuth([b'XOAUTH2']), self.io)
     reply = auth.client_attempt(u'*****@*****.**', u'asdf',
                                 None, b'XOAUTH2')
     self.assertEqual('535', reply.code)
     self.assertEqual('5.0.0 Nope!', reply.message)
예제 #12
0
 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(u'*****@*****.**', u'asdf',
                                 None, b'CRAM-MD5')
     self.assertEqual('235', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
 def test_client_login(self):
     self.sock.sendall(b'AUTH LOGIN\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'334 VXNlcm5hbWU6\r\n')
     self.sock.sendall(b'dGVzdEBleGFtcGxlLmNvbQ==\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'334 UGFzc3dvcmQ6\r\n')
     self.sock.sendall(b'YXNkZg==\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('*****@*****.**', 'asdf', None, 'LOGIN')
     self.assertEqual('235', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)
예제 #14
0
 def test_client_login(self):
     self.sock.sendall(b'AUTH LOGIN\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'334 VXNlcm5hbWU6\r\n')
     self.sock.sendall(b'dGVzdEBleGFtcGxlLmNvbQ==\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'334 UGFzc3dvcmQ6\r\n')
     self.sock.sendall(b'YXNkZg==\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('*****@*****.**', 'asdf', None, 'LOGIN')
     self.assertEqual('235', reply.code)
     self.assertEqual('2.0.0 Ok', reply.message)