]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
gp: Test that files are re-created if manually removed
authorDavid Mulder <dmulder@samba.org>
Wed, 7 Dec 2022 16:49:53 +0000 (09:49 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 21 Dec 2022 02:04:37 +0000 (02:04 +0000)
Currently applied files which are manually
removed do not get re-applied.

Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
python/samba/tests/gpo.py
selftest/knownfail.d/gpo [new file with mode: 0644]

index d0ee55182129db1933e39964251d39b0c6a27da4..1ae273f871929c7f9b8aa19833d273ea97314939 100644 (file)
@@ -7221,10 +7221,20 @@ class GPOTests(tests.TestCase):
             ext.process_group_policy([], gpos, dname)
             sudoers = os.listdir(dname)
             self.assertEquals(len(sudoers), 1, 'The sudoer file was not created')
-            self.assertIn(e2.data,
-                    open(os.path.join(dname, sudoers[0]), 'r').read(),
+            sudoers_file = os.path.join(dname, sudoers[0])
+            self.assertIn(e2.data, open(sudoers_file, 'r').read(),
                     'The sudoers entry was not applied')
 
+            # Remove the sudoers file, and make sure a re-apply puts it back
+            os.unlink(sudoers_file)
+            ext.process_group_policy([], gpos, dname)
+            sudoers = os.listdir(dname)
+            self.assertEquals(len(sudoers), 1,
+                              'The sudoer file was not recreated')
+            sudoers_file = os.path.join(dname, sudoers[0])
+            self.assertIn(e2.data, open(sudoers_file, 'r').read(),
+                    'The sudoers entry was not reapplied')
+
             # Remove policy
             gp_db = store.get_gplog(machine_creds.get_username())
             del_gpos = get_deleted_gpos_list(gp_db, [])
diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo
new file mode 100644 (file)
index 0000000..7ea9bca
--- /dev/null
@@ -0,0 +1 @@
+samba.tests.gpo.GPOTests.test_gp_centrify_sudoers_ext*