mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
samba-tool: Test gpo smb.conf list command
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
parent
111f07fd58
commit
f74dea08be
@ -2072,11 +2072,39 @@ class cmd_security(SuperCommand):
|
||||
subcommands["set"] = cmd_set_security()
|
||||
subcommands["list"] = cmd_list_security()
|
||||
|
||||
class cmd_list_smb_conf(Command):
|
||||
"""List Samba smb.conf Group Policy from the sysvol
|
||||
"""
|
||||
|
||||
synopsis = "%prog <gpo> [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"]
|
||||
|
||||
def run(self, gpo, H=None, sambaopts=None, credopts=None, versionopts=None):
|
||||
pass
|
||||
|
||||
class cmd_smb_conf(SuperCommand):
|
||||
"""Manage smb.conf Group Policy Objects"""
|
||||
subcommands = {}
|
||||
subcommands["list"] = cmd_list_smb_conf()
|
||||
|
||||
class cmd_manage(SuperCommand):
|
||||
"""Manage Group Policy Objects"""
|
||||
subcommands = {}
|
||||
subcommands["sudoers"] = cmd_sudoers()
|
||||
subcommands["security"] = cmd_security()
|
||||
subcommands["smb_conf"] = cmd_smb_conf()
|
||||
|
||||
class cmd_gpo(SuperCommand):
|
||||
"""Group Policy Object (GPO) management."""
|
||||
|
@ -548,6 +548,37 @@ class GpoCmdTestCase(SambaToolCmdTest):
|
||||
'Filling PolicyDefinitions failed')
|
||||
shutil.rmtree(admx_path)
|
||||
|
||||
def test_smb_conf_list(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\\smb_conf'
|
||||
e.valuename = b'apply group policies'
|
||||
e.type = 4
|
||||
e.data = 1
|
||||
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", "smb_conf",
|
||||
"list"), self.gpo_guid,
|
||||
"-H", "ldap://%s" %
|
||||
os.environ["SERVER"],
|
||||
"-U%s%%%s" %
|
||||
(os.environ["USERNAME"],
|
||||
os.environ["PASSWORD"]))
|
||||
self.assertIn('%s = True' % e.valuename, out, 'The test entry was not found!')
|
||||
|
||||
# Unstage the Registry.pol file
|
||||
unstage_file(reg_pol)
|
||||
|
||||
def test_security_set(self):
|
||||
lp = LoadParm()
|
||||
lp.load(os.environ['SERVERCONFFILE'])
|
||||
|
1
selftest/knownfail.d/gpo
Normal file
1
selftest/knownfail.d/gpo
Normal file
@ -0,0 +1 @@
|
||||
^samba.tests.samba_tool.gpo.samba.tests.samba_tool.gpo.GpoCmdTestCase.test_smb_conf_list
|
Loading…
x
Reference in New Issue
Block a user