From a331dd416b1e40290e5ac905d9882c3905843f0c Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 10 Sep 2024 14:32:48 +1000 Subject: [PATCH] Adds option to bypass strict HTTPS checks (#243) * Adds option to bypass strict HTTPS checks * Fix CI pipeline --- .github/workflows/ci.yaml | 4 ++-- inventree/api.py | 5 +++++ inventree/base.py | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c1ba419c..ebc4ddbb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,8 +43,8 @@ jobs: cd inventree_server invoke install invoke migrate - invoke import-fixtures - invoke server -a 127.0.0.1:12345 & + invoke dev.import-fixtures + invoke dev.server -a 127.0.0.1:12345 & invoke wait - name: Run Tests run: | diff --git a/inventree/api.py b/inventree/api.py index 99a24dea..38fe6c00 100644 --- a/inventree/api.py +++ b/inventree/api.py @@ -46,6 +46,7 @@ def __init__(self, host=None, **kwargs): token-name - Name of the token to use (default = 'inventree-python-client') use_token_auth - Use token authentication? (default = True) verbose - Print extra debug messages (default = False) + strict - Enforce strict HTTPS certificate checking (default = True) timeout - Set timeout to use (in seconds). Default: 10 proxies - Definition of proxies as a dict (defaults to an empty dict) @@ -66,6 +67,7 @@ def __init__(self, host=None, **kwargs): self.token_name = kwargs.get('token_name', os.environ.get('INVENTREE_API_TOKEN_NAME', 'inventree-python-client')) self.timeout = kwargs.get('timeout', os.environ.get('INVENTREE_API_TIMEOUT', 10)) self.proxies = kwargs.get('proxies', dict()) + self.strict = bool(kwargs.get('strict', True)) self.use_token_auth = kwargs.get('use_token_auth', True) self.verbose = kwargs.get('verbose', False) @@ -326,6 +328,9 @@ def request(self, api_url, **kwargs): else: payload['json'] = data + # Enforce strict HTTPS certificate checking? + payload['verify'] = self.strict + # Debug request information logger.debug("Sending Request:") logger.debug(f" - URL: {method} {api_url}") diff --git a/inventree/base.py b/inventree/base.py index ab6d0a61..e166a6a5 100644 --- a/inventree/base.py +++ b/inventree/base.py @@ -6,7 +6,7 @@ from . import api as inventree_api -INVENTREE_PYTHON_VERSION = "0.16.1" +INVENTREE_PYTHON_VERSION = "0.17.0" logger = logging.getLogger('inventree')