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