misc: always set a timeout on requests (#68471)
This commit is contained in:
parent
8edd406c88
commit
9e7d2f1640
|
@ -68,7 +68,7 @@ def cut_exists(request, cut_uuid):
|
|||
url = urlparse.urljoin(authentic_url, 'api/users/synchronization/')
|
||||
try:
|
||||
response = requests.post(
|
||||
url, json={"known_uuids": [cut_uuid]}, auth=request.user.credentials, verify=False
|
||||
url, json={"known_uuids": [cut_uuid]}, auth=request.user.credentials, verify=False, timeout=28
|
||||
)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
|
|
|
@ -45,7 +45,11 @@ class PetalAuthentication(BasicAuthentication):
|
|||
url = urlparse.urljoin(authentic_url, 'api/check-password/')
|
||||
try:
|
||||
response = requests.post(
|
||||
url, json={'username': userid, 'password': password}, auth=authentic_auth, verify=False
|
||||
url,
|
||||
json={'username': userid, 'password': password},
|
||||
auth=authentic_auth,
|
||||
verify=False,
|
||||
timeout=28,
|
||||
)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
|
|
|
@ -33,7 +33,7 @@ def check_unknown_cuts(uuids, creds):
|
|||
raise ValueError('PETALE_AUTHENTIC SETTINGS improperly defined')
|
||||
|
||||
url = urljoin(authentic_url, 'api/users/synchronization/')
|
||||
response = requests.post(url, json={"known_uuids": list(uuids)}, auth=creds)
|
||||
response = requests.post(url, json={"known_uuids": list(uuids)}, auth=creds, timeout=28)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
return data.get("unknown_uuids") or []
|
||||
|
|
|
@ -24,6 +24,7 @@ def test_check_unknown_cuts(requests_post):
|
|||
assert requests_post.call_args[1] == {
|
||||
'auth': ('admin', 'admin'),
|
||||
'json': {'known_uuids': ['1']},
|
||||
'timeout': 28,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue