fix(release): keep signed CI archive redirects on loopback
Gitea CI / Build Windows x64 app (pull_request) Successful in 5m56s
Gitea CI / Assemble and validate CI artifacts (pull_request) Successful in 53s
Gitea CI / Gitea CI passed (pull_request) Successful in 2s
Gitea CI / Check code and tests (pull_request) Successful in 5m49s
Gitea CI / Build Android APK (pull_request) Successful in 3m30s
Gitea CI / Audit and package Windows x64 (pull_request) Successful in 1m4s
Gitea CI / Build Windows x64 app (pull_request) Successful in 5m56s
Gitea CI / Assemble and validate CI artifacts (pull_request) Successful in 53s
Gitea CI / Gitea CI passed (pull_request) Successful in 2s
Gitea CI / Check code and tests (pull_request) Successful in 5m49s
Gitea CI / Build Android APK (pull_request) Successful in 3m30s
Gitea CI / Audit and package Windows x64 (pull_request) Successful in 1m4s
This commit is contained in:
1 parent
36b9fd9d21
commit
4346d9330a
3 files changed
+40
-1
No files matched your search
@@ -43,6 +43,36 @@ class TransferToolsTests(unittest.TestCase):
|
||||
self.assertEqual(result['sha256'], hashlib.sha256(b'app').hexdigest())
|
||||
self.assertEqual(asset['browser_download_url'], 'https://git.orangraph.com/attachments/example')
|
||||
|
||||
def test_local_ci_archive_request_keeps_local_host_for_signed_redirect(self):
|
||||
class Response(io.BytesIO):
|
||||
headers = {'Content-Type': 'application/zip'}
|
||||
|
||||
with patch.dict('os.environ', {'CUTDEX_GITEA_INTERNAL_URL': 'http://127.0.0.1:3000',
|
||||
'GITEA_TOKEN': 'test-token'}), \
|
||||
patch.object(transfers.urllib.request, 'urlopen', return_value=Response(b'archive')) as open_url:
|
||||
result = transfers.request(transfers.SERVER + '/api/v1/repos/owner/repo/actions/artifacts/40/zip')
|
||||
request = open_url.call_args.args[0]
|
||||
self.assertEqual(result, b'archive')
|
||||
self.assertEqual(request.full_url, 'http://127.0.0.1:3000/api/v1/repos/owner/repo/actions/artifacts/40/zip')
|
||||
self.assertIsNone(request.get_header('Host'))
|
||||
self.assertEqual(request.get_header('Authorization'), 'token test-token')
|
||||
|
||||
def test_local_host_exception_does_not_change_other_api_response_links(self):
|
||||
for path, method in [
|
||||
('/api/v1/repos/owner/repo/actions/artifacts/40/zip', 'POST'),
|
||||
('/api/v1/repos/owner/repo/actions/artifacts/not-a-number/zip', None),
|
||||
('/api/v1/repos/owner/repo/releases/40/zip', None),
|
||||
]:
|
||||
class Response(io.BytesIO):
|
||||
headers = {'Content-Type': 'application/json'}
|
||||
|
||||
with self.subTest(path=path, method=method), \
|
||||
patch.dict('os.environ', {'CUTDEX_GITEA_INTERNAL_URL': 'http://127.0.0.1:3000',
|
||||
'GITEA_TOKEN': 'test-token'}), \
|
||||
patch.object(transfers.urllib.request, 'urlopen', return_value=Response(b'{}')) as open_url:
|
||||
transfers.request(transfers.SERVER + path, method=method)
|
||||
self.assertEqual(open_url.call_args.args[0].get_header('Host'), 'git.orangraph.com')
|
||||
|
||||
def test_local_transport_rejects_unexpected_endpoint_or_origin_before_sending_credentials(self):
|
||||
for internal, url, message in [
|
||||
('http://example.com:3000', transfers.SERVER + '/api/v1/releases', 'internal Gitea endpoint'),
|
||||
|
||||
Reference in new issue
Block a user