Example #1
0
 def test_add_authorized_key(self):
     self.setup_mocks_add_known_host()
     with patch_open() as (mock_open, mock_file):
         ssh_migrations.add_authorized_key(UNIT1_PUBKEY_1,
                                           'nova-compute-lxd')
         mock_file.write.assert_called_with(UNIT1_PUBKEY_1 + '\n')
         mock_open.assert_called_with('/somedir/authorized_keys', 'a')
Example #2
0
 def test_ssh_compute_remove(self):
     self.setup_mocks_ssh_compute_remove(isfile=True,
                                         authorized_keys_lines=PUB_KEYS)
     with patch_open() as (mock_open, mock_file):
         ssh_migrations.ssh_compute_remove(UNIT1_PUBKEY_1,
                                           'nova-compute-lxd')
         mock_file.write.assert_called_with(UNIT2_PUBKEY_1 + '\n')
         mock_open.assert_called_with('/somedir/authorized_keys', 'w')
Example #3
0
 def test_add_known_host(self):
     self.setup_mocks_add_known_host()
     self.check_output.return_value = UNIT1_HOST_KEY_1
     self.ssh_known_host_key.return_value = ''
     with patch_open() as (mock_open, mock_file):
         ssh_migrations.add_known_host('juju-4665be-20180716142533-8',
                                       'nova-compute-lxd')
         mock_file.write.assert_called_with(UNIT1_HOST_KEY_1 + '\n')
         mock_open.assert_called_with('/somedir/known_hosts', 'a')
     self.assertFalse(self.remove_known_host.called)