Accept matching HTTPS origins through trusted Deck GUI proxy

This commit is contained in:
Mikei386 committed 2026-10-07 21:03:41 +02:00
1 parent 0966abf1b5
commit 4072cfd46c
3 files changed
+24 -1

No files matched your search

+10
View File
@@ -162,6 +162,16 @@ class Tests(unittest.TestCase):
with self.assertRaises(urllib.error.HTTPError) as e:self.request('models/start','POST',{'X-Athena-Deck':'1'})
self.assertEqual(e.exception.code,404)
e.exception.close()
def test_https_origin_requires_authenticated_proxy_and_matching_host(self):
with patch.dict('os.environ', {'DECK_PROXY_TOKEN':'test-proxy-secret'}):
base={'Host':'athena.example.org','X-Athena-Deck':'1','X-Deck-Proxy':'test-proxy-secret','X-Deck-Ingress':'tunnel'}
for origin,expected in [('https://athena.example.org',404),('http://athena.example.org',404),('https://evil.invalid',403),('https://athena.example.org:8443',403),('null',403)]:
with self.assertRaises(urllib.error.HTTPError) as error:
self.request('models/start','POST',{**base,'Origin':origin})
self.assertEqual(error.exception.code,expected);error.exception.close()
with self.assertRaises(urllib.error.HTTPError) as error:
self.request('models/start','POST',{**base,'Origin':'https://athena.example.org','X-Deck-Proxy':'wrong','X-Forwarded-Proto':'https'})
self.assertEqual(error.exception.code,403);error.exception.close()
def test_unavailable_hardware(self):
with patch.dict('os.environ', {'DECK_LOCAL_HARDWARE':'0'}), patch('server.subprocess.run',side_effect=OSError()):
result=HardwareProvider().snapshot()