Add Docker runtime helper and explicitly labelled service inventory

This commit is contained in:
Mikei386
2026-09-28 18:48:13 +02:00
parent a0941c0549
commit 5cc732f993
15 changed files with 399 additions and 13 deletions
+13
View File
@@ -70,6 +70,19 @@ class Tests(unittest.TestCase):
with self.assertRaises(urllib.error.HTTPError) as error:self.request('image-tests/image?id=../../auth.json')
self.assertEqual(error.exception.code,404);error.exception.close()
def test_docker_admin_auth_and_explicit_install_confirmation(self):
with patch.object(self.server.docker,'status',return_value={'installed':True,'services':[]}):
self.assertTrue(self.request('docker')['installed'])
with self.assertRaises(urllib.error.HTTPError) as error:
urllib.request.urlopen(urllib.request.Request(self.url+'/api/v1/docker',headers={'Authorization':'Bearer '+self.api_token}))
self.assertEqual(error.exception.code,401);error.exception.close()
with patch.object(self.server.docker,'install',return_value={'started':True}) as install:
for payload,expected in [({},400),({'confirm':True},200)]:
req=urllib.request.Request(self.url+'/api/v1/docker/install',data=json.dumps(payload).encode(),headers={'Cookie':self.cookie,'X-Athena-Deck':'1','Content-Type':'application/json'})
try:
with urllib.request.urlopen(req) as result:self.assertEqual(result.status,expected)
except urllib.error.HTTPError as error:self.assertEqual(error.code,expected);error.close()
install.assert_called_once()
def test_control_guard(self):
for headers in ({},{'X-Athena-Deck':'1','Origin':'http://evil.invalid'}):
with self.assertRaises(urllib.error.HTTPError) as e:self.request('demo/start','POST',headers)