Verify HTTPS proxy login and authenticated control end to end
This commit is contained in:
1 parent
4072cfd46c
commit
42b79f5065
1 file changed
+9
@@ -172,6 +172,15 @@ class Tests(unittest.TestCase):
|
||||
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()
|
||||
headers={**base,'Origin':'https://athena.example.org','Content-Type':'application/json'}
|
||||
req=urllib.request.Request(self.url+'/api/v1/login',data=json.dumps({'password':self.password}).encode(),headers=headers)
|
||||
with urllib.request.urlopen(req) as response:
|
||||
self.assertTrue(json.load(response)['authenticated'])
|
||||
cookie=response.headers['Set-Cookie'].split(';',1)[0]
|
||||
with patch.object(self.server.endpoint,'configure',return_value={'port':8120}) as configure:
|
||||
req=urllib.request.Request(self.url+'/api/v1/endpoint/config',data=b'{"port":8120}',headers={**headers,'Cookie':cookie})
|
||||
with urllib.request.urlopen(req) as response:self.assertEqual(json.load(response)['port'],8120)
|
||||
configure.assert_called_once_with({'port':8120})
|
||||
def test_unavailable_hardware(self):
|
||||
with patch.dict('os.environ', {'DECK_LOCAL_HARDWARE':'0'}), patch('server.subprocess.run',side_effect=OSError()):
|
||||
result=HardwareProvider().snapshot()
|
||||
|
||||
Reference in new issue
Block a user