From: David Mulder Date: Wed, 27 Jan 2021 21:05:29 +0000 (-0700) Subject: samba-tool: Test gpo manage files remove command X-Git-Tag: tevent-0.11.0~1800 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1d67b27429837861c7eac0ed55a4aa69fbffb35;p=thirdparty%2Fsamba.git samba-tool: Test gpo manage files remove command Signed-off-by: David Mulder Reviewed-by: Jeremy Allison --- diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index 81676971f0e..6cb4bbf8d68 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -2668,11 +2668,40 @@ samba-tool gpo manage files add {31B2F340-016D-11D2-945F-00C04FB984F9} ./source. "not have sufficient privileges") raise +class cmd_remove_files(Command): + """Remove VGP Files Group Policy from the sysvol + +This command removes files which would be copied from the sysvol and applied to winbind clients. + +Example: +samba-tool gpo manage files remove {31B2F340-016D-11D2-945F-00C04FB984F9} /usr/share/doc/target.txt + """ + + synopsis = "%prog [options]" + + takes_optiongroups = { + "sambaopts": options.SambaOptions, + "versionopts": options.VersionOptions, + "credopts": options.CredentialsOptions, + } + + takes_options = [ + Option("-H", "--URL", help="LDB URL for database or target server", type=str, + metavar="URL", dest="H"), + ] + + takes_args = ["gpo", "target"] + + def run(self, gpo, target, H=None, sambaopts=None, credopts=None, + versionopts=None): + pass + class cmd_files(SuperCommand): """Manage Files Group Policy Objects""" subcommands = {} subcommands["list"] = cmd_list_files() subcommands["add"] = cmd_add_files() + subcommands["remove"] = cmd_remove_files() class cmd_manage(SuperCommand): """Manage Group Policy Objects""" diff --git a/python/samba/tests/samba_tool/gpo.py b/python/samba/tests/samba_tool/gpo.py index c885198c1b2..05c7f30f0a8 100644 --- a/python/samba/tests/samba_tool/gpo.py +++ b/python/samba/tests/samba_tool/gpo.py @@ -967,6 +967,27 @@ class GpoCmdTestCase(SambaToolCmdTest): os.unlink(source_file) + (result, out, err) = self.runsublevelcmd("gpo", ("manage", + "files", "remove"), + self.gpo_guid, + target_file, "-H", + "ldap://%s" % + os.environ["SERVER"], + "-U%s%%%s" % + (os.environ["USERNAME"], + os.environ["PASSWORD"])) + self.assertCmdSuccess(result, out, err, 'File remove failed') + + (result, out, err) = self.runsublevelcmd("gpo", ("manage", + "files", "list"), + self.gpo_guid, "-H", + "ldap://%s" % + os.environ["SERVER"], + "-U%s%%%s" % + (os.environ["USERNAME"], + os.environ["PASSWORD"])) + self.assertNotIn(target_file, out, 'The test entry was still found!') + def setUp(self): """set up a temporary GPO to work with""" super(GpoCmdTestCase, self).setUp() diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo new file mode 100644 index 00000000000..960b8e57125 --- /dev/null +++ b/selftest/knownfail.d/gpo @@ -0,0 +1 @@ +^samba.tests.samba_tool.gpo.samba.tests.samba_tool.gpo.GpoCmdTestCase.test_files_add