Plan device actions exclusively as approved scripts and provide reboot library revisions
This commit is contained in:
@@ -157,6 +157,20 @@ class ScriptHelperInstallation(unittest.TestCase):
|
||||
self.assertIn(b'lifecycle.py run-helper',files[self.unit])
|
||||
self.assertIn(str(self.previous).encode(),self.unit.read_bytes())
|
||||
|
||||
def test_service_environment_cannot_replace_restrictive_operator_pin_or_claim_a_release(self):
|
||||
lifecycle.save(self.root / 'config.json', {'gateway':'https://127.0.0.1','tenant':self.previous})
|
||||
lifecycle.save(self.folder / 'script-pin.json',self.pin)
|
||||
self.state.return_value = 'enabled'
|
||||
environment = {'RMM_FULL_MAINTENANCE_POLICY_FILE':'/etc/site/restricted.json',
|
||||
'RMM_SCRIPT_HELPER_RELEASE':self.previous}
|
||||
with patch.dict(lifecycle.os.environ,environment,clear=True), patch.object(lifecycle.os,'execv'):
|
||||
lifecycle.run_agent()
|
||||
self.assertEqual(lifecycle.os.environ['RMM_FULL_MAINTENANCE_POLICY_FILE'],'/etc/site/restricted.json')
|
||||
self.assertNotIn('RMM_SCRIPT_HELPER_RELEASE',lifecycle.os.environ)
|
||||
with patch.dict(lifecycle.os.environ,{},clear=True), patch.object(lifecycle.os,'execv'):
|
||||
lifecycle.run_agent()
|
||||
self.assertEqual(lifecycle.os.environ['RMM_SCRIPT_HELPER_RELEASE'],self.release)
|
||||
|
||||
def test_rejected_pair_does_not_run_candidate_and_altered_policy_stays_intact(self):
|
||||
with patch.object(lifecycle.subprocess,'check_output',side_effect=subprocess.CalledProcessError(1,'verify')) as run:
|
||||
with self.assertRaises(subprocess.CalledProcessError):
|
||||
|
||||
Reference in New Issue
Block a user