mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2026-11-19 06:26:14 -05:00
fix(ci): identify the release feed publisher in HTTP requests
This commit is contained in:
2 files changed
+7
-2
No files matched your search
@@ -5,7 +5,7 @@ import json
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from urllib.request import urlopen
|
from urllib.request import Request, urlopen
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
FEEDS = ("appcast.xml", "latest.json", "windows/latest.json", "windows/stable/appcast.xml", "windows/snapshot/appcast.xml")
|
FEEDS = ("appcast.xml", "latest.json", "windows/latest.json", "windows/stable/appcast.xml", "windows/snapshot/appcast.xml")
|
||||||
@@ -18,7 +18,9 @@ def preserve(base_url: str, directory: Path, exclude: list[str]) -> None:
|
|||||||
if relative in exclude:
|
if relative in exclude:
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
with urlopen(base_url.rstrip("/") + "/" + relative, timeout=30) as response:
|
request = Request(base_url.rstrip("/") + "/" + relative,
|
||||||
|
headers={"User-Agent": "GPConnectReleasePublisher/1.0"})
|
||||||
|
with urlopen(request, timeout=30) as response:
|
||||||
data = response.read(1024 * 1024 + 1)
|
data = response.read(1024 * 1024 + 1)
|
||||||
except HTTPError as error:
|
except HTTPError as error:
|
||||||
if error.code == 404:
|
if error.code == 404:
|
||||||
|
|||||||
@@ -187,6 +187,9 @@ class WindowsFeedTests(unittest.TestCase):
|
|||||||
["appcast.xml", "latest.json", "windows/stable/appcast.xml", "windows/snapshot/appcast.xml"])
|
["appcast.xml", "latest.json", "windows/stable/appcast.xml", "windows/snapshot/appcast.xml"])
|
||||||
self.assertTrue((root / "windows/latest.json").exists())
|
self.assertTrue((root / "windows/latest.json").exists())
|
||||||
self.assertEqual(request.call_count, 1)
|
self.assertEqual(request.call_count, 1)
|
||||||
|
outgoing = request.call_args.args[0]
|
||||||
|
self.assertEqual(outgoing.full_url, "https://updates.gpgui.com/windows/latest.json")
|
||||||
|
self.assertEqual(outgoing.get_header("User-agent"), "GPConnectReleasePublisher/1.0")
|
||||||
with patch.object(preserver, "urlopen", side_effect=HTTPError("url", 500, "failure", {}, None)):
|
with patch.object(preserver, "urlopen", side_effect=HTTPError("url", 500, "failure", {}, None)):
|
||||||
with self.assertRaises(HTTPError):
|
with self.assertRaises(HTTPError):
|
||||||
preserver.preserve("https://updates.gpgui.com", root, [])
|
preserver.preserve("https://updates.gpgui.com", root, [])
|
||||||
|
|||||||
Reference in new issue
Block a user