Skip to content

Commit

Permalink
Merge branch 'dsuch-f-gh755-enmasse-sec-def'
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuch committed Aug 12, 2023
2 parents 2ad7aab + ad75a8e commit 321eba3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion code/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ configparser==3.7.1
convertdate==2.0.3.1
coverage==3.7.1
crontab==0.22.9
cryptography==41.0.2
cryptography==41.0.3
dacite==1.6.0
dataclasses-jsonschema==2.15.0
dateparser==0.7.6
Expand Down
16 changes: 13 additions & 3 deletions code/zato-cli/src/zato/cli/enmasse.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

"""
Copyright (C) 2022, Zato Source s.r.o. https://zato.io
Copyright (C) 2023, Zato Source s.r.o. https://zato.io
Licensed under LGPLv3, see LICENSE.txt for terms and conditions.
"""
Expand Down Expand Up @@ -93,7 +93,7 @@ def populate_services_from_apispec(client, logger):
})

if not response.ok:
logger.error('could not fetch service list')
logger.error('Could not fetch service list -> %s', response.inner.text)
return

by_prefix = {} # { "zato.apispec": {"get-api-spec": { .. } } }
Expand Down Expand Up @@ -549,16 +549,22 @@ def scan_item(self, item_type, item, results):
if item.get('security_id') == 'ZATO_SEC_USE_RBAC':
continue

if dep_key == 'sec_def':
if 'sec_def' not in item:
dep_key = 'security_name'

if dep_key not in item:
results.add_error(
(dep_key, dep_info), ERROR_MISSING_DEP, '{} lacks required {} field: {}', item_type, dep_key, item)

value = item.get(dep_key)

if value != dep_info.get('empty_value'):

dep = self.find(dep_info['dependent_type'], {dep_info['dependent_field']: value})
if dep is None:
key = (dep_info['dependent_type'], item[dep_key])

key = (dep_info['dependent_type'], value)
names = self.missing.setdefault(key, [])
names.append(item.name)

Expand Down Expand Up @@ -974,6 +980,10 @@ def _import_object(self, def_type, item, is_edit):
if item.get('security_id') == 'ZATO_SEC_USE_RBAC':
continue

if field_name == 'sec_def':
if 'sec_def' not in item:
field_name = 'security_name'

if item.get(field_name) != info.get('empty_value') and 'id_field' in info:
dep_obj = self.object_mgr.find(info['dependent_type'], {
info['dependent_field']: item[field_name]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ def _handle(self, initial:'stranydict') -> 'None':
if self._uses_name:
_orig_name = request['name']
_name = _orig_name
_wrapper_type = request['wrapper_type']
request['name'] = f'{_wrapper_type }.{_name}'
_wrapper_type = request.get('wrapper_type')
if _wrapper_type:
name = f'{_wrapper_type }.{_name}'
else:
name = _name
request['name'] = name

# .. and send it to the service.
response = self.invoke(service_name, request, skip_response_elem=True)
Expand Down

0 comments on commit 321eba3

Please sign in to comment.