]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
gp: Test that samba-tool gpo manage lists gpme sudoers
authorDavid Mulder <dmulder@samba.org>
Wed, 16 Nov 2022 17:44:22 +0000 (10:44 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 21 Nov 2022 21:01:30 +0000 (21:01 +0000)
The file format for storing the sudo rules
changed in samba-tool, but these can still be
added via the GPME. We should still include them
here.

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

index d60e5b96c34994faf91d48626bed2c1357503dd9..f1a9a14ea164d206dc3c5eb9626f36ad056a3415 100644 (file)
@@ -825,6 +825,21 @@ class GpoCmdTestCase(SambaToolCmdTest):
         ret = stage_file(vgp_xml, etree.tostring(stage, 'utf-8'))
         self.assertTrue(ret, 'Could not create the target %s' % vgp_xml)
 
+        reg_pol = os.path.join(local_path, lp.get('realm').lower(), 'Policies',
+                               self.gpo_guid, 'Machine/Registry.pol')
+
+        # Stage the Registry.pol file with test data
+        stage = preg.file()
+        e = preg.entry()
+        e.keyname = b'Software\\Policies\\Samba\\Unix Settings\\Sudo Rights'
+        e.valuename = b'Software\\Policies\\Samba\\Unix Settings'
+        e.type = 1
+        e.data = b'fakeu3 ALL=(ALL) NOPASSWD: ALL'
+        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)
+
         sudoer = 'fakeu ALL=(ALL) NOPASSWD: ALL'
         sudoer2 = 'fakeu2,fakeg2% ALL=(ALL) NOPASSWD: ALL'
         sudoer_no_principal = 'ALL ALL=(ALL) NOPASSWD: ALL'
@@ -839,6 +854,7 @@ class GpoCmdTestCase(SambaToolCmdTest):
         self.assertCmdSuccess(result, out, err, 'Sudoers list failed')
         self.assertIn(sudoer, out, 'The test entry was not found!')
         self.assertIn(sudoer2, out, 'The test entry was not found!')
+        self.assertIn(get_string(e.data), out, 'The test entry was not found!')
         self.assertIn(sudoer_no_principal, out,
                       'The test entry was not found!')
 
@@ -877,6 +893,8 @@ class GpoCmdTestCase(SambaToolCmdTest):
 
         # Unstage the manifest.xml file
         unstage_file(vgp_xml)
+        # Unstage the Registry.pol file
+        unstage_file(reg_pol)
 
     def test_symlink_list(self):
         lp = LoadParm()
diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo
new file mode 100644 (file)
index 0000000..1c578f3
--- /dev/null
@@ -0,0 +1 @@
+^samba.tests.samba_tool.gpo.samba.tests.samba_tool.gpo.GpoCmdTestCase.test_sudoers_list