Пример #1
0
 def test_admin_get_account_authToken2(self):
     """ From an account name """
     authToken, lifetime = self.zc.get_account_authToken(
         account_name=self.LAMBDA_USER
     )
     new_zc = ZimbraAccountClient(self.HOST)
     new_zc.login_with_authToken(authToken, lifetime)
     self.assertTrue(new_zc._session.is_logged_in())
     self.assertTrue(new_zc.is_session_valid())
Пример #2
0
    def test_account_delegated_login(self):
        admin_zc = ZimbraAdminClient(TEST_CONF['host'],
                                     TEST_CONF['admin_port'])
        admin_zc.login(TEST_CONF['admin_login'], TEST_CONF['admin_password'])

        new_zc = ZimbraAccountClient(TEST_CONF['host'])
        new_zc.delegated_login(TEST_CONF['lambda_user'], admin_zc)

        self.assertTrue(new_zc._session.is_logged_in())
        self.assertTrue(new_zc.is_session_valid())
Пример #3
0
    def test_create_get_update_rename_delete_account(self):
        name = 'test-{}@zimbratest.example.com'.format(
            random.randint(0, 10**9))
        password = '******'
        ac_req = Account(name=name)

        with self.assertRaises(ZimbraSoapServerError):
            self.zc.get_account(ac_req)

        # CREATE
        ac = self.zc.create_account(name, password)

        self.assertIsInstance(ac, Account)
        self.assertEqual(ac.name, name)

        # GET
        ac_got = self.zc.get_account(ac_req)
        self.assertIsInstance(ac_got, Account)
        self.assertEqual(ac_got.name, name)

        # UPDATE
        random_name_1 = 'test-{}'.format(random.randint(0, 10**9))
        self.zc.modify_account(ac_got, {'displayName': random_name_1})

        ac_got = self.zc.get_account(ac_req)
        self.assertEqual(ac_got['displayName'], random_name_1)

        # MODIFY PASSWORD
        new_password = '******'
        self.zc.set_password(ac, new_password)

        act_zc = ZimbraAccountClient(TEST_CONF['host'],
                                     TEST_CONF['https_port'])

        try:
            act_zc.login(ac.name, new_password)
        except ZimbraSoapServerError:
            self.fail('self.zc.set_password has failed to change password')

        # RENAME
        self.zc.rename_account(
            ac_got, '*****@*****.**')

        renamed_ac_got = self.zc.get_account(
            Account(name='*****@*****.**'))
        self.assertEqual(renamed_ac_got['mail'],
                         '*****@*****.**')

        # DELETE
        self.zc.delete_account(renamed_ac_got)

        with self.assertRaises(ZimbraSoapServerError):
            self.zc.get_account(ac)
Пример #4
0
 def is_session_valid(self):
     # zimbraMail does not have an Auth request, so create a
     # zimbraAccount client to check.
     zac = ZimbraAccountClient(self._server_host, self._server_port)
     zac._session.import_session(self._session.authToken)
     return zac.is_session_valid()