def test_ssh(self): device = ExecuteCmd('key', {'cmd': 'ls', 'ssh': 'machine'}) with mock_patch('amazon_dash.execute.execute_over_ssh' ) as execute_over_ssh_mock: device.execute() execute_over_ssh_mock.assert_called_once() self.execute_mock_req.assert_called_once()
def test_user_on_ssh(self): device = ExecuteCmd('key', { 'cmd': 'ls', 'user': '******', 'ssh': 'machine' }) with self.assertRaises(InvalidConfig): device.execute() self.execute_mock_req.assert_not_called()
def test_execute_root(self): device = ExecuteCmd('key', {'cmd': 'ls', 'user': '******'}) device.execute(True) self.execute_mock_req.assert_called_once()
def test_execute(self): device = ExecuteCmd('key', {'cmd': 'ls'}) device.execute() self.execute_mock_req.assert_called_once()
def test_execute_root_error(self): device = ExecuteCmd('key', {'cmd': 'ls', 'user': '******'}) with self.assertRaises(SecurityException): device.execute(False) self.execute_mock_req.assert_not_called()