From: David Mulder Date: Tue, 25 Jul 2023 18:52:11 +0000 (-0600) Subject: gp: Test modifying Messages policy enforces changes X-Git-Tag: tevent-0.16.0~1322 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae752b8c0b3fb5abc292bd9f040dea1b187510f1;p=thirdparty%2Fsamba.git gp: Test modifying Messages policy enforces changes Signed-off-by: David Mulder Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/gpo.py b/python/samba/tests/gpo.py index d971b5dfb5c..d7882f86fa8 100644 --- a/python/samba/tests/gpo.py +++ b/python/samba/tests/gpo.py @@ -6306,8 +6306,11 @@ class GPOTests(tests.TestCase): def test_vgp_motd(self): local_path = self.lp.cache_path('gpo_cache') - guid = '{31B2F340-016D-11D2-945F-00C04FB984F9}' - manifest = os.path.join(local_path, policies, guid, 'MACHINE', + guids = ['{31B2F340-016D-11D2-945F-00C04FB984F9}', + '{6AC1786C-016F-11D2-945F-00C04FB984F9}'] + manifest = os.path.join(local_path, policies, guids[0], 'MACHINE', + 'VGP/VTLA/UNIX/MOTD/MANIFEST.XML') + manifest2 = os.path.join(local_path, policies, guids[1], 'MACHINE', 'VGP/VTLA/UNIX/MOTD/MANIFEST.XML') cache_dir = self.lp.get('cache directory') store = GPOStorage(os.path.join(cache_dir, 'gpo.tdb')) @@ -6336,9 +6339,33 @@ class GPOTests(tests.TestCase): ret = stage_file(manifest, etree.tostring(stage)) self.assertTrue(ret, 'Could not create the target %s' % manifest) + # Stage the other manifest.xml + stage = etree.Element('vgppolicy') + policysetting = etree.SubElement(stage, 'policysetting') + version = etree.SubElement(policysetting, 'version') + version.text = '1' + data = etree.SubElement(policysetting, 'data') + filename = etree.SubElement(data, 'filename') + filename.text = 'motd' + text2 = etree.SubElement(data, 'text') + text2.text = 'This should overwrite the first policy' + ret = stage_file(manifest2, etree.tostring(stage)) + self.assertTrue(ret, 'Could not create the target %s' % manifest2) + # Process all gpos, with temp output directory with NamedTemporaryFile() as f: ext.process_group_policy([], gpos, f.name) + self.assertTrue(os.path.exists(f.name), + 'Message of the day file not created') + data = open(f.name, 'r').read() + self.assertEquals(data, text2.text, 'Message of the day not applied') + + # Force apply with removal of second GPO + gp_db = store.get_gplog(machine_creds.get_username()) + del_gpos = gp_db.get_applied_settings([guids[1]]) + gpos = [gpo for gpo in gpos if gpo.name != guids[1]] + ext.process_group_policy(del_gpos, gpos, f.name) + self.assertEquals(open(f.name, 'r').read(), text.text, 'The motd was not applied') @@ -6347,14 +6374,14 @@ class GPOTests(tests.TestCase): self.assertEquals(ret, 0, 'gpupdate --rsop failed!') # Remove policy - gp_db = store.get_gplog(machine_creds.get_username()) del_gpos = get_deleted_gpos_list(gp_db, []) ext.process_group_policy(del_gpos, [], f.name) self.assertNotEqual(open(f.name, 'r').read(), text.text, 'The motd was not unapplied') - # Unstage the Registry.pol file + # Unstage the manifest files unstage_file(manifest) + unstage_file(manifest2) def test_vgp_issue(self): local_path = self.lp.cache_path('gpo_cache') diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo index 7a7d6c53075..3edd150be39 100644 --- a/selftest/knownfail.d/gpo +++ b/selftest/knownfail.d/gpo @@ -1,3 +1,4 @@ ^samba.tests.gpo.samba.tests.gpo.GPOTests.test_gp_firewalld_ext ^samba.tests.gpo.samba.tests.gpo.GPOTests.test_gp_firefox_ext ^samba.tests.gpo.samba.tests.gpo.GPOTests.test_gp_motd +^samba.tests.gpo.samba.tests.gpo.GPOTests.test_vgp_motd