ssh: pass the autorized_keys in GET /ssh
Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
parent
5a301bcdd6
commit
b1cdd74775
|
@ -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:
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue