From b9e7c830ba013ca2203ff912f9f82602b0db7bcf Mon Sep 17 00:00:00 2001 From: Luis Presuel Date: Fri, 29 Nov 2024 15:46:43 -0600 Subject: [PATCH] makes sure proxies are forcefully set in requests for testing --- vcert/connection_cloud.py | 8 ++++++++ vcert/connection_tpp_token.py | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/vcert/connection_cloud.py b/vcert/connection_cloud.py index 84f3c5d..9dd8263 100644 --- a/vcert/connection_cloud.py +++ b/vcert/connection_cloud.py @@ -14,10 +14,17 @@ # limitations under the License. # import base64 +import os import re import time import requests + +proxies = { + "http": os.environ.get('HTTP_PROXY'), + "https": os.environ.get('HTTPS_PROXY'), +} + import six.moves.urllib.parse as urlparse from nacl.public import SealedBox from six import string_types @@ -153,6 +160,7 @@ def __init__(self, token, url=None, http_request_kwargs=None): http_request_kwargs = {'timeout': 180} elif 'timeout' not in http_request_kwargs: http_request_kwargs['timeout'] = 180 + http_request_kwargs['proxies'] = proxies self._http_request_kwargs = http_request_kwargs def __str__(self): diff --git a/vcert/connection_tpp_token.py b/vcert/connection_tpp_token.py index cdf940c..8fa8b1a 100644 --- a/vcert/connection_tpp_token.py +++ b/vcert/connection_tpp_token.py @@ -14,6 +14,7 @@ # limitations under the License. # import logging as log +import os import re import time @@ -30,6 +31,10 @@ KEY_REFRESH_TOKEN = 'refresh_token' # nosec KEY_EXPIRATION_DATE = 'expiration_date' +proxies = { + "http": os.environ.get('HTTP_PROXY'), + "https": os.environ.get('HTTPS_PROXY'), +} class TPPTokenConnection(AbstractTPPConnection): def __init__(self, url, user=None, password=None, access_token=None, refresh_token=None, http_request_kwargs=None): @@ -50,6 +55,7 @@ def __init__(self, url, user=None, password=None, access_token=None, refresh_tok http_request_kwargs = {'timeout': 180} elif 'timeout' not in http_request_kwargs: http_request_kwargs['timeout'] = 180 + http_request_kwargs['proxies'] = proxies self._http_request_kwargs = http_request_kwargs or {} def __setattr__(self, key, value):