Fix Windows task and certificate collector reliability
This commit is contained in:
@@ -155,6 +155,19 @@ class FakeProcess:
|
||||
|
||||
|
||||
class ProcessTests(unittest.TestCase):
|
||||
def test_serialization_exit_and_diagnostic_switch(self):
|
||||
def create(args, **kwargs):
|
||||
self.assertIn('-Diagnostic', args)
|
||||
process = FakeProcess(args, **kwargs)
|
||||
process.returncode = 3
|
||||
kwargs['stdout'].write(b'SECRET')
|
||||
return process
|
||||
with patch('samsara.collectors.windows.subprocess.Popen', side_effect=create):
|
||||
with self.assertRaises(WindowsCollectionError) as error:
|
||||
run_section('tasks', 'powershell.exe', diagnostic=True)
|
||||
self.assertEqual(error.exception.code, 'serialization_failed')
|
||||
self.assertNotIn('SECRET', str(error.exception))
|
||||
|
||||
def test_timeout_and_cancel_kill_and_reap_without_shell(self):
|
||||
for cancel in [False,True]:
|
||||
processes=[]
|
||||
|
||||
Reference in New Issue
Block a user