diff --git a/python-sync-actions/src/configuration.py b/python-sync-actions/src/configuration.py index 5984f37..d49bea3 100644 --- a/python-sync-actions/src/configuration.py +++ b/python-sync-actions/src/configuration.py @@ -158,10 +158,10 @@ def search_dict(d): return results -def _remove_auth_from_dict(dictionary: dict, to_remove: list) -> dict: +def _remove_auth_from_dict(dictionary: dict, to_remove: list, auth_method: str) -> dict: filtered_dict = {} for key, value in dictionary.items(): - if isinstance(value, dict): + if isinstance(value, dict) and auth_method == 'bearer': if key != 'Authorization': filtered_value = _remove_auth_from_dict(value, to_remove) if filtered_value: @@ -189,8 +189,11 @@ def convert_to_v2(configuration: dict) -> list[Configuration]: default_headers_org = api_json.get('http', {}).get('headers', {}) default_query_parameters_org = api_json.get('http', {}).get('defaultOptions', {}).get('params', {}) - default_headers = _remove_auth_from_dict(default_headers_org, _return_ui_params(configuration)) - default_query_parameters = _remove_auth_from_dict(default_query_parameters_org, _return_ui_params(configuration)) + auth_method = configuration.get('config').get('__AUTH_METHOD') + + default_headers = _remove_auth_from_dict(default_headers_org, _return_ui_params(configuration), auth_method) + default_query_parameters = _remove_auth_from_dict(default_query_parameters_org, _return_ui_params(configuration), + auth_method) pagination = {} if api_json.get('pagination', {}).get('scrollers'): @@ -380,7 +383,7 @@ def convert(cls, config_parameters: dict) -> Authentication | None: auth_method = config_parameters.get('config', {}).get('__AUTH_METHOD', None) # or take it form the authentication section auth_method = auth_method or config_parameters.get('api', {}).get('authentication', {}).get('type') - if not auth_method: + if not auth_method or auth_method == 'custom': return None methods = { diff --git a/python-sync-actions/tests/calls/010-default-header/config.json b/python-sync-actions/tests/calls/010-default-header/config.json new file mode 100644 index 0000000..9b5af2e --- /dev/null +++ b/python-sync-actions/tests/calls/010-default-header/config.json @@ -0,0 +1,57 @@ +{ + "storage": {}, + "parameters": { + "__SELECTED_JOB": "0", + + "config": { + "jobs": [ + { + "__NAME": "orders", + "endpoint": "010-default-header/orders", + "method": "GET", + "dataType": "", + "dataField": "nested.orders" + } + ], + "test": "test-value", + "concat": { + "function": "concat", + "args": [ + "hello", + "-world" + ] + }, + "debug": false, + "outputBucket": "in.c-", + "incrementalOutput": false, + "#BEARER_TOKEN": "token" + }, + "api": { + "baseUrl": "http://mock-server:80/", + "http": { + "headers": { + "Authorization": { + "attr": "#BEARER_TOKEN" + } + } + } + }, + "http": { + "maxRetries": 10, + "codes": [ + 500, + 502, + 503, + 504, + 408, + 420, + 429 + ] + } +}, + "action": "test_request", + "image_parameters": { + }, + "authorization": { + } +} diff --git a/python-sync-actions/tests/calls/010-default-header/orders.request b/python-sync-actions/tests/calls/010-default-header/orders.request new file mode 100644 index 0000000..340f045 --- /dev/null +++ b/python-sync-actions/tests/calls/010-default-header/orders.request @@ -0,0 +1 @@ +GET /010-default-header/orders \ No newline at end of file diff --git a/python-sync-actions/tests/calls/010-default-header/orders.requestHeaders b/python-sync-actions/tests/calls/010-default-header/orders.requestHeaders new file mode 100644 index 0000000..2726203 --- /dev/null +++ b/python-sync-actions/tests/calls/010-default-header/orders.requestHeaders @@ -0,0 +1,2 @@ +accept: */* +authorization: Bearer token diff --git a/python-sync-actions/tests/calls/010-default-header/orders.response b/python-sync-actions/tests/calls/010-default-header/orders.response new file mode 100644 index 0000000..71d78ff --- /dev/null +++ b/python-sync-actions/tests/calls/010-default-header/orders.response @@ -0,0 +1,82 @@ +{ + "nested": { + "orders": [ + { + "id": 1, + "customer": "John Doe", + "address": "123 Main St", + "items": [ + { + "id": 1, + "name": "Widget", + "price": 9.99, + "quantity": 2 + }, + { + "id": 2, + "name": "Thing", + "price": 5.99, + "quantity": 5 + } + ] + }, + { + "id": 2, + "customer": "Jan Novak", + "address": "123 Main St", + "items": [ + { + "id": 1, + "name": "Widget", + "price": 9.99, + "quantity": 2 + }, + { + "id": 2, + "name": "Thing", + "price": 5.99, + "quantity": 5 + } + ] + }, + { + "id": 3, + "customer": "Jana Novakova", + "address": "123 Main St", + "items": [ + { + "id": 1, + "name": "Widget", + "price": 9.99, + "quantity": 2 + }, + { + "id": 2, + "name": "Thing", + "price": 5.99, + "quantity": 5 + } + ] + }, + { + "id": 4, + "customer": "Bob Smith", + "address": "123 Main St", + "items": [ + { + "id": 1, + "name": "Widget", + "price": 9.99, + "quantity": 2 + }, + { + "id": 2, + "name": "Thing", + "price": 5.99, + "quantity": 5 + } + ] + } + ] + } +} \ No newline at end of file