Fix Windows task and certificate collector reliability

This commit is contained in:
2026-10-30 13:06:14 -07:00
parent 57e716b710
commit 7fed3b9ab9
11 changed files with 283 additions and 19 deletions

View File

@@ -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=[]