mirror of
https://github.com/samba-team/samba.git
synced 2025-12-20 16:23:51 +03:00
samba-tool: Test gpo Security list
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
committed by
David Mulder
parent
eea46a38eb
commit
aba8ece11d
@@ -66,6 +66,7 @@ from samba import param
|
|||||||
from samba.credentials import SMB_SIGNING_REQUIRED
|
from samba.credentials import SMB_SIGNING_REQUIRED
|
||||||
from samba.netcmd.common import attr_default
|
from samba.netcmd.common import attr_default
|
||||||
from samba.common import get_bytes
|
from samba.common import get_bytes
|
||||||
|
from configparser import ConfigParser
|
||||||
|
|
||||||
|
|
||||||
def gpo_flags_string(value):
|
def gpo_flags_string(value):
|
||||||
@@ -1996,15 +1997,39 @@ PasswordComplexity Password must meet complexity requirements
|
|||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
class cmd_list_security(Command):
|
||||||
|
"""List Samba Security 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_security(SuperCommand):
|
class cmd_security(SuperCommand):
|
||||||
"""Manage Security Group Policy Objects"""
|
"""Manage Security Group Policy Objects"""
|
||||||
subcommands = {}
|
subcommands = {}
|
||||||
subcommands["set"] = cmd_set_security()
|
subcommands["set"] = cmd_set_security()
|
||||||
|
subcommands["list"] = cmd_list_security()
|
||||||
|
|
||||||
class cmd_manage(SuperCommand):
|
class cmd_manage(SuperCommand):
|
||||||
"""Manage Group Policy Objects"""
|
"""Manage Group Policy Objects"""
|
||||||
subcommands = {}
|
subcommands = {}
|
||||||
subcommands["sudoers"] = cmd_sudoers()
|
subcommands["sudoers"] = cmd_sudoers()
|
||||||
|
subcommands["security"] = cmd_security()
|
||||||
|
|
||||||
class cmd_gpo(SuperCommand):
|
class cmd_gpo(SuperCommand):
|
||||||
"""Group Policy Object (GPO) management."""
|
"""Group Policy Object (GPO) management."""
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ from samba.tests.gpo import stage_file, unstage_file
|
|||||||
from samba.dcerpc import preg
|
from samba.dcerpc import preg
|
||||||
from samba.ndr import ndr_pack, ndr_unpack
|
from samba.ndr import ndr_pack, ndr_unpack
|
||||||
from samba.common import get_string
|
from samba.common import get_string
|
||||||
|
from configparser import ConfigParser
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
source_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../.."))
|
source_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../.."))
|
||||||
|
|
||||||
@@ -584,6 +586,38 @@ class GpoCmdTestCase(SambaToolCmdTest):
|
|||||||
self.assertNotIn('MaxTicketAge = 10', inf_pol_contents,
|
self.assertNotIn('MaxTicketAge = 10', inf_pol_contents,
|
||||||
'The test entry was still found!')
|
'The test entry was still found!')
|
||||||
|
|
||||||
|
def test_security_list(self):
|
||||||
|
(result, out, err) = self.runsublevelcmd("gpo", ("manage", "security",
|
||||||
|
"set"), self.gpo_guid,
|
||||||
|
'MaxTicketAge', '10',
|
||||||
|
"-H", "ldap://%s" %
|
||||||
|
os.environ["SERVER"],
|
||||||
|
"-U%s%%%s" %
|
||||||
|
(os.environ["USERNAME"],
|
||||||
|
os.environ["PASSWORD"]))
|
||||||
|
self.assertCmdSuccess(result, out, err,
|
||||||
|
'Failed to set MaxTicketAge')
|
||||||
|
|
||||||
|
(result, out, err) = self.runsublevelcmd("gpo", ("manage", "security",
|
||||||
|
"list"), self.gpo_guid,
|
||||||
|
"-H", "ldap://%s" %
|
||||||
|
os.environ["SERVER"],
|
||||||
|
"-U%s%%%s" %
|
||||||
|
(os.environ["USERNAME"],
|
||||||
|
os.environ["PASSWORD"]))
|
||||||
|
self.assertIn('MaxTicketAge = 10', out, 'The test entry was not found!')
|
||||||
|
|
||||||
|
(result, out, err) = self.runsublevelcmd("gpo", ("manage", "security",
|
||||||
|
"set"), self.gpo_guid,
|
||||||
|
'MaxTicketAge',
|
||||||
|
"-H", "ldap://%s" %
|
||||||
|
os.environ["SERVER"],
|
||||||
|
"-U%s%%%s" %
|
||||||
|
(os.environ["USERNAME"],
|
||||||
|
os.environ["PASSWORD"]))
|
||||||
|
self.assertCmdSuccess(result, out, err,
|
||||||
|
'Failed to unset MaxTicketAge')
|
||||||
|
|
||||||
def test_sudoers_remove(self):
|
def test_sudoers_remove(self):
|
||||||
lp = LoadParm()
|
lp = LoadParm()
|
||||||
lp.load(os.environ['SERVERCONFFILE'])
|
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_security_list
|
||||||
Reference in New Issue
Block a user