def testUnwrapSoapException(self): transport = SoapHttpTransport() transport.transport = MockTransport() str = """<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <context xmlns="urn:zimbra"/> </soap:Header> <soap:Body> <soap:Fault> <soap:faultcode>soap:CODE</soap:faultcode> <soap:faultstring>MESSAGE</soap:faultstring> <soap:detail> <Error xmlns="urn:zimbra"> <Code>CODE</Code> <Trace>TRACE</Trace> </Error> </soap:detail> </soap:Fault> </soap:Body> </soap:Envelope> """ def read(): return str exc = urllib2.HTTPError('url', '500', 'message', None, None) exc.read = read result = transport.init_soap_exception(exc) self.assertEqual('soap:CODE:MESSAGE', result.message) self.assertEqual('CODE', result.code) self.assertEqual('TRACE', result.trace)
def testZimbraClientNoAuth(self): zclient = ZimbraClient('') zclient.transport = MockTransport() zclient.authenticator = MockAuthenticator() self.assertRaises(AuthException, zclient.invoke, '', '', {})
def testZimbraClientAuth(self): zclient = ZimbraClient('') zclient.transport = MockTransport() zclient.authenticator = MockAuthenticator() zclient.authenticate(self.account_name, self.password)
def testAdminAuthInvalidCredentials(self): a = MockAuthenticator() transport = MockTransport() self.assertRaises(AuthException, a.authenticate, transport, "wrong", self.password) self.assertRaises(AuthException, a.authenticate, transport, self.account_name, "wrong")
def testZimbraClientWrongAuth(self): zclient = ZimbraClient('') zclient.transport = MockTransport() zclient.authenticator = MockAuthenticator() self.assertRaises(AuthException, zclient.authenticate, self.account_name, 'wrong')
def testAuthEmptyCredentials(self): a = MockAuthenticator() transport = MockTransport() self.assertRaises(AuthException, a.authenticate, transport, "", self.password) self.assertRaises(AuthException, a.authenticate, transport, self.username, "") self.assertRaises(AuthException, a.authenticate, transport, "", "")
def testZimbraClientNoRequest(self): zclient = ZimbraClient('') zclient.transport = MockTransport() zclient.authenticator = MockAuthenticator() zclient.authenticate(self.account_name, self.password) self.assertRaises(ZimbraClientException, zclient.invoke, '', '', {})
def testPreAuthValidCredentials(self): a = MockAuthenticator() transport = MockTransport() auth_token = a.authenticate(transport, self.account_name) self.assertTrue(auth_token != None) self.assertEquals(self.account_name, auth_token.account_name) self.assertEquals(self.token, auth_token.token) self.assertEquals(self.session_id, auth_token.session_id)
def testWorkingTransport(self): a = SoapAuthenticator() transport = MockTransport() auth_token = a.authenticate(transport, self.account_name, self.password) self.assertTrue(auth_token != None) self.assertEquals(self.token, auth_token.token) self.assertEquals(self.session_id, auth_token.session_id)
def testZimbraClientRequest(self): zclient = ZimbraClient('') zclient.transport = MockTransport() zclient.authenticator = MockAuthenticator() zclient.authenticate(self.account_name, self.password) params = {} res = zclient.invoke(zconstant.NS_ZIMBRA_ACC_URL, sconstant.GetInfoRequest, params) self.assertEqual(self.account_name, res.name)
def testPreAuthEmptyCredentials(self): a = MockAuthenticator() transport = MockTransport() self.assertRaises(AuthException, a.authenticate, transport, "")