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('CRAM-MD5')
 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
0
 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==')
예제 #4
0
 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=')
예제 #5
0
 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=')
 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 self.assertRaises(ServerAuthError):
         auth.server_attempt(io, 'CRAM-MD5 dGVzdHVzZXI=')
 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 self.assertRaises(CredentialsInvalidError):
         auth.server_attempt(io, 'CRAM-MD5 dGVzdHVzZXI=')
 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('PLAIN')
     with self.assertRaises(AuthenticationCanceled):
         auth.server_attempt('PLAIN *')
 def test_plain_badcreds(self):
     self.mox.ReplayAll()
     io = IO(self.sock)
     auth = AuthSession(FakeAuth(), FakeSession(True))
     with self.assertRaises(CredentialsInvalidError):
         auth.server_attempt(
             io, 'PLAIN dGVzdHppZAB0ZXN0dXNlcgBiYWRwYXNzd29yZA==')
     with self.assertRaises(ServerAuthError):
         auth.server_attempt(io, 'PLAIN dGVzdGluZw==')
예제 #10
0
 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 *')
예제 #11
0
 def test_plain_canceled(self):
     self.sock.sendall('334 \r\n')
     self.sock.recv(IsA(int)).AndReturn('*\r\n')
     self.mox.ReplayAll()
     io = IO(self.sock)
     auth = AuthSession(FakeAuth(), FakeSession(True))
     with assert_raises(AuthenticationCanceled):
         auth.server_attempt(io, 'PLAIN')
     with assert_raises(AuthenticationCanceled):
         auth.server_attempt(io, 'PLAIN *')
 def test_plain_canceled(self):
     self.sock.sendall('334 \r\n')
     self.sock.recv(IsA(int)).AndReturn('*\r\n')
     self.mox.ReplayAll()
     io = IO(self.sock)
     auth = AuthSession(FakeAuth(), FakeSession(True))
     with self.assertRaises(AuthenticationCanceled):
         auth.server_attempt(io, 'PLAIN')
     with self.assertRaises(AuthenticationCanceled):
         auth.server_attempt(io, 'PLAIN *')
예제 #13
0
 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)
 def test_plain(self):
     self.mox.ReplayAll()
     io = IO(self.sock)
     auth = AuthSession(FakeAuth(), FakeSession(True))
     identity = auth.server_attempt(
         io, 'PLAIN dGVzdHppZAB0ZXN0dXNlcgB0ZXN0cGFzc3dvcmQ=')
     self.assertEqual('testidentity', identity)
예제 #15
0
 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)
 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=')
     self.assertEqual('testidentity', identity)
예제 #17
0
 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)
예제 #18
0
 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)
예제 #19
0
 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)
예제 #20
0
 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)
예제 #21
0
 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)
 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=')
     self.assertEqual('testidentity', identity)
예제 #23
0
 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)
 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')
     self.assertEqual('testidentity', identity)
 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('LOGIN dGVzdHVzZXI=')
     self.assertEqual(u'testuser', result.authcid)
     self.assertEqual(u'testpassword', result.secret)
     self.assertEqual(None, result.authzid)
예제 #26
0
 def test_crammd5(self):
     self.sock.sendall(b'334 PHRlc3RAZXhhbXBsZS5jb20+\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'dGVzdHVzZXIgNDkzMzA1OGU2ZjgyOTRkZTE0NDJkMTYxOTI3ZGI5NDQ=\r\n')
     self.mox.ReplayAll()
     auth = AuthSession(SASLAuth(), self.io)
     result = auth.server_attempt(b'CRAM-MD5')
     self.assertEqual(u'testuser', result.authcid)
     self.assertTrue(result.check_secret(u'testpassword'))
     self.assertFalse(result.check_secret(u'testwrong'))
     self.assertEqual(None, result.authzid)
예제 #27
0
 def test_crammd5(self):
     self.sock.sendall(b'334 PHRlc3RAZXhhbXBsZS5jb20+\r\n')
     self.sock.recv(IsA(int)).AndReturn(b'dGVzdHVzZXIgNDkzMzA1OGU2ZjgyOTRkZTE0NDJkMTYxOTI3ZGI5NDQ=\r\n')
     self.mox.ReplayAll()
     auth = AuthSession(SASLAuth(), self.io)
     result = auth.server_attempt(b'CRAM-MD5')
     self.assertEqual(u'testuser', result.authcid)
     self.assertTrue(result.check_secret(u'testpassword'))
     self.assertFalse(result.check_secret(u'testwrong'))
     self.assertEqual(None, result.authzid)
예제 #28
0
 def test_invalid_mechanism(self):
     auth = AuthSession(SASLAuth(), self.io)
     with self.assertRaises(InvalidMechanismError):
         auth.server_attempt(b'TEST')
     with self.assertRaises(InvalidMechanismError):
         auth.server_attempt(b'B@D')
예제 #29
0
 def test_invalid_mechanism(self):
     auth = AuthSession(FakeAuth(), FakeSession(True))
     with assert_raises(InvalidMechanismError):
         auth.server_attempt(None, 'TEST')
     with assert_raises(InvalidMechanismError):
         auth.server_attempt(None, 'B@D')
 def test_invalid_mechanism(self):
     auth = AuthSession(FakeAuth(), FakeSession(True))
     with self.assertRaises(InvalidMechanismError):
         auth.server_attempt(None, 'TEST')
     with self.assertRaises(InvalidMechanismError):
         auth.server_attempt(None, 'B@D')
 def test_invalid_mechanism(self):
     auth = AuthSession(SASLAuth(), self.io)
     with self.assertRaises(InvalidMechanismError):
         auth.server_attempt('TEST')
     with self.assertRaises(InvalidMechanismError):
         auth.server_attempt('B@D')
예제 #32
0
 def test_plain(self):
     self.mox.ReplayAll()
     io = IO(self.sock)
     auth = AuthSession(FakeAuth(), FakeSession(True))
     identity = auth.server_attempt(io, 'PLAIN dGVzdHppZAB0ZXN0dXNlcgB0ZXN0cGFzc3dvcmQ=')
     assert_equal('testidentity', identity)