mirror of
https://github.com/samba-team/samba.git
synced 2025-07-27 07:42:04 +03:00
tests: Add tests for samba-tool passwordsettings commands
I've added a test case for 'samba-tool domain passwordsettings set/show' to prove I haven't broken it. It's behaviour shouldn't have changed, but there was no test for it previously. We'll extend these tests in the very near future, when we add samba-tool support for managing PSOs. The base samba_tool test's runsubcmd() only handled commands with exactly one sub-command, i.e. it would handle the command 'samba-tool domain passwordsettings' OK, but not 'samba-tool domain passwordsettings set' (The command still seemed to run OK, but you wouldn't get the output/err back correctly). A new runsublevelcmd() function now handles a varying number of sub-commands. Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Autobuild-User(master): Garming Sam <garming@samba.org> Autobuild-Date(master): Fri May 11 09:06:10 CEST 2018 on sn-devel-144
This commit is contained in:
@ -88,6 +88,23 @@ class SambaToolCmdTest(samba.tests.BlackboxTestCase):
|
||||
result = cmd._run("samba-tool %s %s" % (name, sub), *args)
|
||||
return (result, cmd.outf.getvalue(), cmd.errf.getvalue())
|
||||
|
||||
def runsublevelcmd(self, name, sublevels, *args):
|
||||
"""run a command with any number of sub command levels"""
|
||||
# Same as runsubcmd, except this handles a varying number of sub-command
|
||||
# levels, e.g. 'samba-tool domain passwordsettings pso set', whereas
|
||||
# runsubcmd() only handles exactly one level of sub-commands.
|
||||
# First, traverse the levels of sub-commands to get the actual cmd
|
||||
# object we'll run, and construct the cmd string along the way
|
||||
cmd = cmd_sambatool.subcommands[name]
|
||||
cmd_str = "samba-tool %s" % name
|
||||
for sub in sublevels:
|
||||
cmd = cmd.subcommands[sub]
|
||||
cmd_str += " %s" % sub
|
||||
cmd.outf = StringIO()
|
||||
cmd.errf = StringIO()
|
||||
result = cmd._run(cmd_str, *args)
|
||||
return (result, cmd.outf.getvalue(), cmd.errf.getvalue())
|
||||
|
||||
def assertCmdSuccess(self, exit, out, err, msg=""):
|
||||
self.assertIsNone(exit, msg="exit[%s] stdout[%s] stderr[%s]: %s" % (
|
||||
exit, out, err, msg))
|
||||
|
Reference in New Issue
Block a user