gpo: Test rsop output for Sudoers policy
authorDavid Mulder <dmulder@suse.com>
Thu, 6 Aug 2020 20:53:02 +0000 (14:53 -0600)
committerDavid Mulder <dmulder@samba.org>
Thu, 27 Aug 2020 15:59:32 +0000 (15:59 +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 6b9106cb45012aba16edf0986985ca325522f90d..90b1d81bc7a53a08219ceb7c3e32f627c2c0b223 100644 (file)
@@ -469,6 +469,8 @@ class GPOTests(tests.TestCase):
         gp_extensions.append(gp_krb_ext(logger, self.lp, machine_creds, store))
         gp_extensions.append(gp_scripts_ext(logger, self.lp, machine_creds,
             store))
+        gp_extensions.append(gp_sudoers_ext(logger, self.lp, machine_creds,
+            store))
 
         # Create registry stage data
         reg_pol = os.path.join(local_path, policies, '%s/MACHINE/REGISTRY.POL')
@@ -478,8 +480,13 @@ class GPOTests(tests.TestCase):
         e.valuename = b'Software\\Policies\\Samba\\Unix Settings'
         e.type = 1
         e.data = b'echo hello world'
-        reg_stage.num_entries = 1
-        reg_stage.entries = [e]
+        e2 = preg.entry()
+        e2.keyname = b'Software\\Policies\\Samba\\Unix Settings\\Sudo Rights'
+        e2.valuename = b'Software\\Policies\\Samba\\Unix Settings'
+        e2.type = 1
+        e2.data = b'fakeu  ALL=(ALL) NOPASSWD: ALL'
+        reg_stage.num_entries = 2
+        reg_stage.entries = [e, e2]
 
         # Create krb stage date
         gpofile = os.path.join(local_path, policies, '%s/MACHINE/MICROSOFT/' \
@@ -512,5 +519,12 @@ class GPOTests(tests.TestCase):
                                   'Daily Scripts not found')
                     self.assertIn('echo hello world', ret['Daily Scripts'],
                                   'Daily script was not created')
+                # Check the Sudoers Extension
+                elif type(ext) == gp_sudoers_ext:
+                    self.assertIn('Sudo Rights', ret.keys(),
+                                  'Sudoers not found')
+                    self.assertIn('fakeu  ALL=(ALL) NOPASSWD: ALL',
+                                  ret['Sudo Rights'],
+                                  'Sudoers policy not created')
             unstage_file(gpofile % g.name)
             unstage_file(reg_pol % g.name)
diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo
new file mode 100644 (file)
index 0000000..b1c8285
--- /dev/null
@@ -0,0 +1 @@
+samba.tests.gpo.samba.tests.gpo.GPOTests.test_rsop