Skip to content

Commit

Permalink
Update urllib version
Browse files Browse the repository at this point in the history
The reason are the dependabot security vulnerability alerts. Anything
above 1.26.19 should fix them.

The code also had to be updated, to replace method_whitelist with
allowed_methods. See https://github.com/urllib3/urllib3/blob/main/CHANGES.rst#1260-2020-11-10

Signed-off-by: mkosiarc <[email protected]>
  • Loading branch information
mkosiarc committed Aug 8, 2024
1 parent c22c6ea commit dfeac86
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion osbs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
HTTP_RETRIES_STATUS_FORCELIST = [408, 500, 502, 503, 504]

# HTTP methods that we should retry on
HTTP_RETRIES_METHODS_WHITELIST = ['GET', 'PUT', 'POST', 'DELETE']
HTTP_RETRIES_ALLOWED_METHODS = ['GET', 'PUT', 'POST', 'DELETE']

# requests timeout in seconds
HTTP_REQUEST_TIMEOUT = 600
Expand Down
4 changes: 2 additions & 2 deletions osbs/osbs_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from osbs.exceptions import OsbsException, OsbsNetworkException, OsbsResponseException
from osbs.constants import (
HTTP_MAX_RETRIES, HTTP_BACKOFF_FACTOR, HTTP_RETRIES_STATUS_FORCELIST,
HTTP_RETRIES_METHODS_WHITELIST, HTTP_REQUEST_TIMEOUT)
HTTP_RETRIES_ALLOWED_METHODS, HTTP_REQUEST_TIMEOUT)

import requests
from requests.adapters import HTTPAdapter
Expand Down Expand Up @@ -111,7 +111,7 @@ def log_error_response_text_hook(resp, *args, **kwargs):
read=HTTP_MAX_RETRIES,
backoff_factor=HTTP_BACKOFF_FACTOR,
status_forcelist=HTTP_RETRIES_STATUS_FORCELIST,
method_whitelist=HTTP_RETRIES_METHODS_WHITELIST,
allowed_methods=HTTP_RETRIES_ALLOWED_METHODS,
raise_on_status=False,
)
self.session = requests.Session()
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
flexmock>=0.11.0
urllib3<1.26
urllib3>=1.26.19
pytest==7.0.1
pytest-cov
pytest-html
Expand Down
4 changes: 2 additions & 2 deletions tests/test_retries.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import requests
from urllib3.util import Retry
from osbs.exceptions import OsbsNetworkException, OsbsResponseException
from osbs.constants import HTTP_RETRIES_STATUS_FORCELIST, HTTP_RETRIES_METHODS_WHITELIST
from osbs.constants import HTTP_RETRIES_STATUS_FORCELIST, HTTP_RETRIES_ALLOWED_METHODS
from osbs.osbs_http import HttpSession, HttpStream
from osbs import osbs_http
logger = logging.getLogger(__file__)
Expand Down Expand Up @@ -49,7 +49,7 @@ def has_connection():
reason="requires internet connection")
class TestHttpRetries(object):
@pytest.mark.parametrize('status_code', HTTP_RETRIES_STATUS_FORCELIST)
@pytest.mark.parametrize('method', HTTP_RETRIES_METHODS_WHITELIST)
@pytest.mark.parametrize('method', HTTP_RETRIES_ALLOWED_METHODS)
def test_fail_after_retries(self, s, status_code, method):
flexmock(osbs_http).should_receive('Retry').and_return(fake_retry)
# latest python-requests throws OsbsResponseException, 2.6.x - OsbsNetworkException
Expand Down

0 comments on commit dfeac86

Please sign in to comment.