Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
 def test_execute_root(self):
     device = ExecuteCmd('key', {'cmd': 'ls', 'user': '******'})
     device.execute(True)
     self.execute_mock_req.assert_called_once()
Ejemplo n.º 4
0
 def test_execute(self):
     device = ExecuteCmd('key', {'cmd': 'ls'})
     device.execute()
     self.execute_mock_req.assert_called_once()
Ejemplo n.º 5
0
 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()