From b55e139ecb811a6f28ec5942ec92e95e8bc7cbc1 Mon Sep 17 00:00:00 2001 From: gberger Date: Wed, 18 Mar 2020 18:23:17 +0200 Subject: [PATCH 1/4] remove slash if exists in demisto_base_url --- demisto_client/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/demisto_client/__init__.py b/demisto_client/__init__.py index 50e1bfd..5970164 100644 --- a/demisto_client/__init__.py +++ b/demisto_client/__init__.py @@ -60,6 +60,8 @@ def configure(base_url=None, api_key=None, verify_ssl=None, proxy=None, username configuration = Configuration() configuration.api_key['Authorization'] = api_key configuration.host = base_url or os.getenv('DEMISTO_BASE_URL', None) + if isinstance(configuration.host, str): + configuration.host = configuration.host.rstrip('/') configuration.verify_ssl = verify_ssl configuration.proxy = proxy configuration.debug = debug @@ -87,6 +89,8 @@ def configure(base_url=None, api_key=None, verify_ssl=None, proxy=None, username def login(base_url=None, username=None, password=None, verify_ssl=True, proxy=None, debug=False): configuration_orig = Configuration() configuration_orig.host = base_url or os.getenv('DEMISTO_BASE_URL', None) + if isinstance(configuration_orig.host, str): + configuration_orig.host = configuration_orig.host.rstrip('/') configuration_orig.verify_ssl = verify_ssl configuration_orig.proxy = proxy configuration_orig.debug = debug @@ -105,6 +109,8 @@ def login(base_url=None, username=None, password=None, verify_ssl=True, proxy=No xsrf_token = xsrf_token_raw.replace('XSRF-TOKEN=', '') configuration = Configuration() configuration.host = base_url or os.getenv('DEMISTO_BASE_URL', None) + if isinstance(configuration.host, str): + configuration.host = configuration.host.rstrip('/') configuration.verify_ssl = verify_ssl configuration.proxy = proxy configuration.debug = debug @@ -177,6 +183,8 @@ def generic_request_func(self, path, method, body=None, **kwargs): :return: tuple of (response_data, response_code, headers). """ + if not path.startswith('/'): + path = '/' + path all_params = [''] # noqa: E501 all_params.append('async_req') From 58df21cfd7dabaa7f074ef89e81a1b9dcdbc050e Mon Sep 17 00:00:00 2001 From: gberger Date: Thu, 19 Mar 2020 15:31:44 +0200 Subject: [PATCH 2/4] add change log --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16f48d2..46eb13a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ [1]: https://pypi.org/project/demisto-py/#history ## 2.0.9 -Improved error message when missing authentication parameters. +* Improved error message when missing authentication parameters. +* fix base_url slash inconsistency ## 2.0.8 * Added `ssl_ca_cert` configuration option to specify an alternate certificate bundle. From 8acc6ea64ec416dbc71a067257cf8120519ce8d8 Mon Sep 17 00:00:00 2001 From: gberger Date: Sun, 22 Mar 2020 10:40:40 +0200 Subject: [PATCH 3/4] fix changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46eb13a..ca61cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,11 @@ [PyPI History][1] [1]: https://pypi.org/project/demisto-py/#history +## 2.0.10 +* fix configuration.host slash inconsistency + ## 2.0.9 * Improved error message when missing authentication parameters. -* fix base_url slash inconsistency ## 2.0.8 * Added `ssl_ca_cert` configuration option to specify an alternate certificate bundle. From 199fb88b157970773fb11d734dbcb9020e9bebe9 Mon Sep 17 00:00:00 2001 From: gberger Date: Sun, 22 Mar 2020 12:23:41 +0200 Subject: [PATCH 4/4] change change log message --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca61cff..952014e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ [1]: https://pypi.org/project/demisto-py/#history ## 2.0.10 -* fix configuration.host slash inconsistency +* Enabled host and path parameters to function with trailing or leading slashes. ## 2.0.9 * Improved error message when missing authentication parameters.