summaryrefslogtreecommitdiff
path: root/python/samba/tests/samba_tool/base.py
AgeCommit message (Collapse)AuthorFilesLines
2025-06-05tests/samba-tool: optionally allow exception to be a failure in .run*()Douglas Bagnall1-7/+20
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13613 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jennifer Sutton <jennifersutton@catalyst.net.nz> Reviewed-by: Rowland Penny <rpenny@samba.org>
2024-03-01pytest:samba-tool: add a flag to print more in runcmdDouglas Bagnall1-3/+19
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-10-24python: getopt: Add HostOptions to avoid need to manually add -HRob van der Linde1-5/+3
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-10-24python: getopt: subclass OptionParser to populate option_classRob van der Linde1-3/+2
The option_class needs to be set correctly for OptionGroups that use self.add_option Override OptionParser `__init__` to change the default Option class to the samba one. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-10-24python: netcmd: parser class in getSamDB should set option_classRob van der Linde1-1/+2
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-10-24python: netcmd: fix import grouping and sorting in base firstRob van der Linde1-3/+4
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-09-29netcmd: tests: make _run a classmethod in SambaToolCmdTestRob van der Linde1-3/+4
So that it can be called from setUpClass as well Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-09-29netcmd: tests: avoid the need to create a random command in GetSamDBRob van der Linde1-21/+10
Also the code that looks over kwargs is somewhat confusing and unnecessary. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-09-11python:tests: Fix code spellingJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-21python:tests: Make getSamDB() a static methodJoseph Sutton1-1/+2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-08make runcmd, runsubcmd, exact aliasesDouglas Bagnall1-16/+5
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-08pytest: samba-tool: coalesce run*cmd functionsDouglas Bagnall1-19/+11
We have had three different functions for resolving samba-tool commands, depending on whether they are nested 1, 2, or n deep (where n could also be 1 or 2). This API evolved around a separation of sub-command names and options, so that the Command that was eventually found could be given the right outf and errf. Now we can just use the same outf and errf for all levels, and we can not care about this distinction. All these functions are now synonyms, and we keep them all for now for backward-compatibility. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-06pytest: SambaToolCmdTest allows easier StringIO replacementDouglas Bagnall1-6/+9
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2021-06-21python/samba/tests: Remove DCs joined to test samba-tool behaviourAndrew Bartlett1-0/+11
Otherwise we have the live DCs spamming the logs looking for the long-gone test servers: Failed to connect host fd00::5357:5f0b on port 135 - NT_STATUS_OBJECT_NAME_NOT_FOUND Failed to connect host fd00::5357:5f0b (6f44653d-18c8-4bf4-b2e7-6f85cf7b0f74._msdcs.addom.samba.example.com) on port 135 - NT_STATUS_OBJECT_NAME_NOT_FOUND. Failed to connect host 10.53.57.11 on port 135 - NT_STATUS_OBJECT_NAME_NOT_FOUND Failed to connect host 10.53.57.11 (6f44653d-18c8-4bf4-b2e7-6f85cf7b0f74._msdcs.addom.samba.example.com) on port 135 - NT_STATUS_OBJECT_NAME_NOT_FOUND. Failed to connect host 10.53.57.12 on port 135 - NT_STATUS_OBJECT_NAME_NOT_FOUND This avoids spamming the GitLab pipeline logs with a lot of noise, as there is a size limit to the output, as well as being cleaner. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2020-11-11SambaToolCmdTest: let assertCmdSuccess() escape ']\n' linesStefan Metzmacher1-2/+5
This gives a much higher chance to see the actual problem without having them filtered by various 'filter-subunit' invocations. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2020-10-29tests: avoid returning an already used ID in randomXid()Jule Anger1-3/+17
The error 'uidNumber xxx is already being used.' in the samba tool tests occurs when the random.randint functions returns the same value twice and therefore a user or group with an already used gid or uid should be created. Avoid this error by adding a list that stores the used IDs, so that the randomXid function can check wheter a value is already used before returning it. Signed-off-by: Jule Anger <ja@sernet.de> Reviewed-by: Björn Baumbach <bb@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Oct 29 18:54:24 UTC 2020 on sn-devel-184
2020-08-11python compat: remove StringIODouglas Bagnall1-1/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-10-19python tests Blackbox: add random_passwordGary Lockyer1-7/+0
Add the random_password method to the BlackboxTestCase class and remove duplicated copies from other test cases. Also use SystemRandom so that the generated passwords are more cryptographically sound. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-09-03python/samba/tests: Use io.StringIO for py3 and StringIO.StrinIO for py2Noel Power1-1/+1
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: fix E303: too many blank lines (2)Joe Guo1-1/+0
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E225: missing whitespace around operatorJoe Guo1-2/+2
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-05-11tests: Add tests for samba-tool passwordsettings commandsTim Beale1-0/+17
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
2018-05-05sambatool tests: make assertMatch use assertInDouglas Bagnall1-1/+2
With a note to tidy this up at some point Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2018-02-12tests: SambaToolCmdTest.assertMatch() indicates what was assertedDouglas Bagnall1-1/+11
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-02-22Correct "overriden" typos.Chris Lamb1-1/+1
Signed-off-by: Chris Lamb <chris@chris-lamb.co.uk> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-08-04tests:samba_tool: pass stdout and stderr to assertCmdSuccess()Stefan Metzmacher1-2/+3
This allows us to generate better assert messages and give the developer some ideas why the command wasn't able to run. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12108 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2016-07-19samba-tool: Put full command and subcommand in informative name when testing ↵Andrew Bartlett1-2/+2
samba-tool These are not used for anything other than to print in the usage, but it seems nicer to match normal invocation of these commands Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2016-06-16selftest: Rebase DrsBaseTestCase on SambaToolCmdTestAndrew Bartlett1-1/+1
This then makes SambaToolCmdTest based on BlackboxTestCase. This allows us to use better command output testing in the fsmo tests Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2013-05-15samba_tool/base.py: Fix typo.Karolin Seeger1-1/+1
Signed-off-by: Karolin Seeger <kseeger@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-02Move python modules from source4/scripting/python/ to python/.Jelmer Vernooij1-0/+114
Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Sat Mar 2 03:57:34 CET 2013 on sn-devel-104