Exemplo n.º 1
0
    def _on_auth_success(self, token_data):
        if not token_data:
            return

        self._user_uuid = token_data['xivo_user_uuid']
        try:
            user_config = dao.user.get_by_uuid(self._user_uuid)
        except NoSuchUserException:
            return self._fatal('login_pass', 'user_not_found')

        self._cti_profile_id = user_config.get('cti_profile_id')
        if not self._cti_profile_id:
            logger.info('%s failed to login, profile %s', self._username,
                        self._cti_profile_id)
            return self._fatal('login_pass', 'login_password')

        self._authenticated = True
        self._auth_token = token_data['token']
        self._user_id = str(user_config['id'])
        msg = CTIMessageFormatter.login_pass(self._cti_profile_id)
        LoginCapas.register_callback_params(
            self._on_login_capas, ['capaid', 'state', 'cti_connection'])
        self._send_msg(msg)
        self._on_auth_complete()
    def test_login_pass(self):
        expected = {'class': 'login_pass', 'capalist': [s.cti_profile_id]}

        result = CTIMessageFormatter.login_pass(s.cti_profile_id)

        assert_that(result, equal_to(expected))