]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
gpo: Test gpo hourly scripts apply
authorDavid Mulder <dmulder@suse.com>
Thu, 25 Jun 2020 20:15:18 +0000 (14:15 -0600)
committerDavid Mulder <dmulder@samba.org>
Thu, 6 Aug 2020 16:38:35 +0000 (16:38 +0000)
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/tests/gpo.py
selftest/knownfail.d/gpo [new file with mode: 0644]

index 02ff6d97121e2f88ba0fdb6aebea090126e5c97a..18bcf81f40cfe5995aa5cdfa88fd3a702db0f545 100644 (file)
@@ -320,7 +320,7 @@ class GPOTests(tests.TestCase):
             gpttmpl = gpofile % (local_path, guid)
             unstage_file(gpttmpl)
 
-    def test_gp_daily_scripts(self):
+    def test_gp_scripts(self):
         local_path = self.lp.cache_path('gpo_cache')
         guid = '{31B2F340-016D-11D2-945F-00C04FB984F9}'
         reg_pol = os.path.join(local_path, policies, guid,
@@ -340,25 +340,31 @@ class GPOTests(tests.TestCase):
         if ads.connect():
             gpos = ads.get_gpo_list(machine_creds.get_username())
 
-        # Stage the Registry.pol file with test data
-        stage = preg.file()
-        e = preg.entry()
-        e.keyname = b'Software\\Policies\\Samba\\Unix Settings\\Daily Scripts'
-        e.valuename = b'Software\\Policies\\Samba\\Unix Settings'
-        e.type = 1
-        e.data = b'echo hello world'
-        stage.num_entries = 1
-        stage.entries = [e]
-        ret = stage_file(reg_pol, ndr_pack(stage))
-        self.assertTrue(ret, 'Could not create the target %s' % reg_pol)
-
-        # Process all gpos, with temp output directory
-        with TemporaryDirectory() as dname:
-            ext.process_group_policy([], gpos, dname)
-            scripts = os.listdir(dname)
-            self.assertEquals(len(scripts), 1, 'The daily script was not created')
-            out, _ = Popen([os.path.join(dname, scripts[0])], stdout=PIPE).communicate()
-            self.assertIn(b'hello world', out, 'Daily script execution failed')
-
-        # Unstage the Registry.pol file
-        unstage_file(reg_pol)
+        reg_key = b'Software\\Policies\\Samba\\Unix Settings'
+        sections = { b'%s\\Daily Scripts' % reg_key : '.cron.daily',
+                     b'%s\\Hourly Scripts' % reg_key : '.cron.hourly' }
+        for keyname in sections.keys():
+            # Stage the Registry.pol file with test data
+            stage = preg.file()
+            e = preg.entry()
+            e.keyname = keyname
+            e.valuename = b'Software\\Policies\\Samba\\Unix Settings'
+            e.type = 1
+            e.data = b'echo hello world'
+            stage.num_entries = 1
+            stage.entries = [e]
+            ret = stage_file(reg_pol, ndr_pack(stage))
+            self.assertTrue(ret, 'Could not create the target %s' % reg_pol)
+
+            # Process all gpos, with temp output directory
+            with TemporaryDirectory(sections[keyname]) as dname:
+                ext.process_group_policy([], gpos, dname)
+                scripts = os.listdir(dname)
+                self.assertEquals(len(scripts), 1,
+                    'The %s script was not created' % keyname.decode())
+                out, _ = Popen([os.path.join(dname, scripts[0])], stdout=PIPE).communicate()
+                self.assertIn(b'hello world', out,
+                    '%s script execution failed' % keyname.decode())
+
+            # Unstage the Registry.pol file
+            unstage_file(reg_pol)
diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo
new file mode 100644 (file)
index 0000000..27f3459
--- /dev/null
@@ -0,0 +1 @@
+^samba.tests.gpo.samba.tests.gpo.GPOTests.test_gp_scripts