Esempio n. 1
0
 def test_ssh_key(self, fake_open):
     mock_key_file = mock.MagicMock(spec=file)
     mock_key_file.read.return_value = 'fake-key'
     mock_key_file.__enter__.return_value = mock_key_file
     fake_open.return_value = mock_key_file
     result = nova._ssh_key()
     self.assertEqual(result, 'fake-key')
Esempio n. 2
0
 def test_ssh_key(self, fake_open):
     mock_key_file = mock.MagicMock(spec=file)
     mock_key_file.read.return_value = 'fake-key'
     mock_key_file.__enter__.return_value = mock_key_file
     fake_open.return_value = mock_key_file
     result = nova._ssh_key()
     self.assertEqual(result, 'fake-key')
Esempio n. 3
0
    def test_ssh_key_sanitize(self, fake_open):
        mock_key_file = mock.MagicMock(spec=file)
        mock_key_file.read.return_value = ('''

            fake-key with some newlines

        ''')
        mock_key_file.__enter__.return_value = mock_key_file
        fake_open.return_value = mock_key_file
        result = nova._ssh_key()
        self.assertEqual(result, 'fake-key with some newlines')
Esempio n. 4
0
 def test_ssh_key_not_found(self, fake_open, fake_log):
     fake_open.side_effect = IOError
     result = nova._ssh_key()
     self.assertEqual(result, '')
     self.assertTrue(fake_log.warning.called)
Esempio n. 5
0
 def test_ssh_key_not_found(self, fake_open, fake_log):
     fake_open.side_effect = IOError
     result = nova._ssh_key()
     self.assertEqual(result, '')
     self.assertTrue(fake_log.warning.called)