Пример #1
0
    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)
Пример #2
0
    def testZimbraClientNoAuth(self):

        zclient = ZimbraClient('')
        zclient.transport = MockTransport()
        zclient.authenticator = MockAuthenticator()

        self.assertRaises(AuthException, zclient.invoke, '', '', {})
Пример #3
0
    def testZimbraClientAuth(self):

        zclient = ZimbraClient('')
        zclient.transport = MockTransport()
        zclient.authenticator = MockAuthenticator()

        zclient.authenticate(self.account_name, self.password)
Пример #4
0
    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")
Пример #5
0
    def testZimbraClientWrongAuth(self):

        zclient = ZimbraClient('')
        zclient.transport = MockTransport()
        zclient.authenticator = MockAuthenticator()

        self.assertRaises(AuthException, zclient.authenticate,
                          self.account_name, 'wrong')
Пример #6
0
    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, "", "")
Пример #7
0
    def testZimbraClientNoRequest(self):

        zclient = ZimbraClient('')
        zclient.transport = MockTransport()
        zclient.authenticator = MockAuthenticator()

        zclient.authenticate(self.account_name, self.password)

        self.assertRaises(ZimbraClientException, zclient.invoke, '', '', {})
Пример #8
0
    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)
Пример #9
0
    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)
Пример #10
0
    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)
Пример #11
0
    def testPreAuthEmptyCredentials(self):
        a = MockAuthenticator()
        transport = MockTransport()

        self.assertRaises(AuthException, a.authenticate, transport, "")