mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-11 09:40:28 +03:00
Add timeout argument to requests.(get,post)
This commit is contained in:
parent
cf0100cf11
commit
c89a9f0e8b
11 changed files with 23 additions and 15 deletions
|
|
@ -14,7 +14,10 @@ checksums = None
|
|||
versions = dict()
|
||||
|
||||
while not checksums:
|
||||
r = requests.get('https://gitlab.com/fdroid/gradle-transparency-log/-/raw/master/checksums.json')
|
||||
r = requests.get(
|
||||
'https://gitlab.com/fdroid/gradle-transparency-log/-/raw/master/checksums.json',
|
||||
timeout=300,
|
||||
)
|
||||
if r.status_code == 200:
|
||||
checksums = r.json()
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class ImportTest(unittest.TestCase):
|
|||
fdroidserver.common.config = config
|
||||
|
||||
url = 'https://gitlab.com/fdroid/ci-test-app'
|
||||
r = requests.head(url)
|
||||
r = requests.head(url, timeout=300)
|
||||
if r.status_code != 200:
|
||||
print("ERROR", url, 'unreachable (', r.status_code, ')')
|
||||
print('Skipping ImportTest!')
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ versions = dict()
|
|||
|
||||
while not checksums:
|
||||
r = requests.get(
|
||||
'https://gitlab.com/fdroid/android-sdk-transparency-log/-/raw/master/checksums.json'
|
||||
'https://gitlab.com/fdroid/android-sdk-transparency-log/-/raw/master/checksums.json',
|
||||
timeout=300,
|
||||
)
|
||||
if r.status_code == 200:
|
||||
checksums = r.json()
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class NetTest(unittest.TestCase):
|
|||
|
||||
@patch('requests.get')
|
||||
def test_download_file_url_parsing(self, requests_get):
|
||||
def _get(url, stream, allow_redirects, headers): # pylint: disable=W0613
|
||||
def _get(url, stream, allow_redirects, headers, timeout): # pylint: disable=W0613
|
||||
return MagicMock()
|
||||
|
||||
requests_get.side_effect = _get
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class NightlyTest(unittest.TestCase):
|
|||
]:
|
||||
url = nightly.get_repo_base_url(clone_url, repo_git_base)
|
||||
self.assertEqual(result, url)
|
||||
r = requests.head(os.path.join(url, 'repo/index-v1.jar'))
|
||||
r = requests.head(os.path.join(url, 'repo/index-v1.jar'), timeout=300)
|
||||
# gitlab.com often returns 403 Forbidden from their cloudflare restrictions
|
||||
self.assertTrue(r.status_code in (200, 403), 'should not be a redirect')
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import requests
|
|||
versions = [
|
||||
]
|
||||
|
||||
r = requests.get('https://www.openssl.org/news/changelog.html')
|
||||
r = requests.get('https://www.openssl.org/news/changelog.html', timeout=300)
|
||||
|
||||
safe = set()
|
||||
bad = set()
|
||||
|
|
|
|||
|
|
@ -428,7 +428,9 @@ class Test_load_exodus_trackers_signatures(unittest.TestCase):
|
|||
"fdroidserver.scanner._exodus_compile_signatures", self.compilesig_func
|
||||
):
|
||||
result_sigs, result_regex = fdroidserver.scanner.load_exodus_trackers_signatures()
|
||||
self.requests_func.assert_called_once_with("https://reports.exodus-privacy.eu.org/api/trackers")
|
||||
self.requests_func.assert_called_once_with(
|
||||
"https://reports.exodus-privacy.eu.org/api/trackers", timeout=300
|
||||
)
|
||||
self.assertEqual(len(result_sigs), 2)
|
||||
self.assertListEqual([1, 2], sorted([x.id for x in result_sigs]))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue