diff options
author | David Mulder <dmulder@suse.com> | 2020-11-09 16:08:59 -0700 |
---|---|---|
committer | David Mulder <dmulder@samba.org> | 2020-12-09 17:38:28 +0000 |
commit | f67a3644f413dd4c902af6970cd18cf17f469cd2 (patch) | |
tree | 1c446bcd31fe0cfaedd29724da0e9f3554c42d82 /python/samba/tests/samba_tool | |
parent | 5f9d2456fbaeeb5674edb228a3022ee749376715 (diff) | |
download | samba-f67a3644f413dd4c902af6970cd18cf17f469cd2.tar.gz |
samba-tool: Test gpo Sudoers remove command
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Diffstat (limited to 'python/samba/tests/samba_tool')
-rw-r--r-- | python/samba/tests/samba_tool/gpo.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/python/samba/tests/samba_tool/gpo.py b/python/samba/tests/samba_tool/gpo.py index ca3f237f76d..c170602454a 100644 --- a/python/samba/tests/samba_tool/gpo.py +++ b/python/samba/tests/samba_tool/gpo.py @@ -546,6 +546,35 @@ class GpoCmdTestCase(SambaToolCmdTest): 'Filling PolicyDefinitions failed') shutil.rmtree(admx_path) + def test_sudoers_remove(self): + lp = LoadParm() + lp.load(os.environ['SERVERCONFFILE']) + local_path = lp.get('path', 'sysvol') + 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'fakeu 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) + + (result, out, err) = self.runsublevelcmd("gpo", ("manage", "sudoers", + "remove"), self.gpo_guid, + get_string(e.data), + "-H", "ldap://%s" % + os.environ["SERVER"], + "-U%s%%%s" % + (os.environ["USERNAME"], + os.environ["PASSWORD"])) + self.assertCmdSuccess(result, out, err, 'Sudoers remove failed') + def test_sudoers_add(self): lp = LoadParm() lp.load(os.environ['SERVERCONFFILE']) |