Пример #1
0
 def delete_service(self, data, req_info, session, curs=None):
     f = ServiceFilter(session.environment_id, {'id': data.get('id')}, {}, None)
     s = f.filter_one_obj(curs)
     if s.type == Service.TYPE_AUTH:
         raise ServiceDeletionError(Service.TYPE_AUTH)
     mapping.delete(curs, s)
     return response_ok()
Пример #2
0
 def get_services(self, data, req_info, session, curs=None):
     f = ServiceFilter(session.environment_id, data['filter_params'],
         data['paging_params'], data.get('ordering_params'))
     ss, total = f.filter_counted(curs)
     def viewer(obj):
         result = obj.to_dict()
         result = mapping.objects.deserialize_field(result, 'serialized_properties', 'properties')
         result.pop('environment_id')
         return result
     return response_ok(services=self.objects_info(ss, viewer),
         total=total)
Пример #3
0
    def modify_service(self, data, req_info, session, curs=None):
        f = ServiceFilter(session.environment_id, data, {}, None)

        # checking service deactivation is possible
        srv = f.filter_one_obj(curs)
        if not data.get('new_is_active', True) and not srv.is_possible_deactiate:
            raise ServiceDeactivationError(srv.name)

        loader = partial(f.filter_one_obj, curs, for_update=True)
        try:
            d = mapping.objects.serialize_field(data, 'new_properties', 'new_serialized_properties')
            self.update_obj(curs, d, loader)
        except DataIntegrityError:
            raise HelixauthObjectAlreadyExists('Service %s already exists' %
                data.get('new_name'))
        return response_ok()
Пример #4
0
    def test_default_service_created(self, curs=None):
        env = self.get_environment_by_name(self.actor_env_name)
        f = ServiceFilter(env.id, {}, {}, None)
        srvs = f.filter_objs(curs)
        s_auth = srvs[0]
        s_billing = srvs[1]

        self.assertEqual('Auth', s_auth.name)
        self.assertEqual(env.id, s_auth.environment_id)
        self.assertEqual(True, s_auth.is_active)
        self.assertEqual(False, s_auth.is_possible_deactiate)

        resp = self.get_authorized_api_actions()
        self.check_response_ok(resp)
        auth_a = resp['actions']

        srv_props = json.loads(s_auth.serialized_properties)
        self.assertEqual(auth_a, srv_props)

        self.assertEqual('Billing', s_billing.name)
        self.assertEqual(env.id, s_billing.environment_id)
        self.assertEqual(True, s_billing.is_active)
        self.assertEqual(True, s_billing.is_possible_deactiate)
Пример #5
0
 def load_service(self, env_id, name, curs=None):
     f = ServiceFilter(env_id, {'name': name}, {}, None)
     return f.filter_one_obj(curs)
Пример #6
0
 def load_auth_service(self, env_id, curs=None):
     f = ServiceFilter(env_id, {}, {'limit': 1}, ['id'])
     return f.filter_one_obj(curs)
Пример #7
0
 def _get_services_id_type_idx(self, curs, env):
     f = ServiceFilter(env.id, {}, {}, None)
     srvs = f.filter_objs(curs)
     idx = dict([(s.id, s.type) for s in srvs])
     return idx
Пример #8
0
 def _get_session_data(self, curs, env, user):
     f = ServiceFilter(env.id, {'is_active': True}, {}, None)
     srvs = f.filter_objs(curs)
     srvs_id_type_idx = dict([(str(s.id), s.type) for s in srvs])
     return {'services_id_type_idx': srvs_id_type_idx, 'lang': user.lang,
         'rights': self._get_user_rights(curs, env, user, srvs)}