Skip to content

Commit

Permalink
Adds option to bypass strict HTTPS checks (#243)
Browse files Browse the repository at this point in the history
* Adds option to bypass strict HTTPS checks

* Fix CI pipeline
  • Loading branch information
SchrodingersGat authored Sep 10, 2024
1 parent faf0e16 commit a331dd4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
5 changes: 5 additions & 0 deletions inventree/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion inventree/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit a331dd4

Please sign in to comment.