diff --git a/subiquity/server/controllers/ssh.py b/subiquity/server/controllers/ssh.py index 3bd84a78..d37f07c9 100644 --- a/subiquity/server/controllers/ssh.py +++ b/subiquity/server/controllers/ssh.py @@ -70,7 +70,9 @@ class SSHController(SubiquityController): async def GET(self) -> SSHData: return SSHData( - install_server=self.model.install_server, allow_pw=self.model.pwauth + install_server=self.model.install_server, + allow_pw=self.model.pwauth, + authorized_keys=self.model.authorized_keys, ) async def POST(self, data: SSHData) -> None: diff --git a/subiquity/server/controllers/tests/test_ssh.py b/subiquity/server/controllers/tests/test_ssh.py index a141cfaf..ec50d2b7 100644 --- a/subiquity/server/controllers/tests/test_ssh.py +++ b/subiquity/server/controllers/tests/test_ssh.py @@ -29,6 +29,24 @@ class TestSSHController(unittest.IsolatedAsyncioTestCase): def setUp(self): self.controller = SSHController(make_app()) + async def test_GET(self): + model = self.controller.model + + model.pwauth = False + model.authorized_keys = [ + "ssh-rsa AAAAAAAAAAAAAAAAAAAAAAAAA # ssh-import-id lp:subiquity", + ] + model.install_server = True + + data = await self.controller.GET() + + self.assertFalse(data.allow_pw) + self.assertTrue(data.install_server) + self.assertIn( + "ssh-rsa AAAAAAAAAAAAAAAAAAAAAAAAA # ssh-import-id lp:subiquity", + data.authorized_keys, + ) + async def test_fetch_id_GET_ok(self): key = "ssh-rsa AAAAA[..] user@host # ssh-import-id lp:user" mock_fetch_keys = mock.patch.object(