Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ def connect(self):
key_stream = StringIO(self.target_host.access_key)
key_obj = RSAKey.from_private_key(key_stream)
self.session.connect(self.target_host.ip, username=self.target_host.username, pkey=key_obj)
else:
elif self.target_host.username:
raise Exception('Both password and access key are empty.')
else:
raise Exception('Machine credentials are empty.')
except NoValidConnectionsError as e:
error_code = next(e.errors.itervalues(), type('e', (object,), {'errno': 0})).errno
raise ExcutorConnectionError(error_code, e)
Expand Down
6 changes: 6 additions & 0 deletions package/tests/test_linux_script_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def test_no_password_nor_pen_file(self):
executor.connect()
self.assertEqual('Both password and access key are empty.', e.exception.inner_error.message)

def test_no_password_no_pen_file_no_username(self):
executor = LinuxScriptExecutor(self.logger, self.host, self.cancel_sampler)
with self.assertRaises(Exception) as e:
executor.connect()
self.assertEqual('Machine credentials are empty.', e.exception.inner_error.message)

def test_create_temp_folder_success(self):
self._mock_session_answer(0,'tmp123','')
result = self.executor.create_temp_folder()
Expand Down