The branch, master has been updated via 5c051eacd42 selftests: Make sure print queue is empty before printing_var_exp test ends via a0996ef86fd Skip running a C program during cross compilation via a4307072d6e python:tests: Make sure we delete the OU for movetest via 69442ae1072 python:tests: Add missing result checks for samba_tool.gpo tests via c4dba61e369 python:tests: Tell dns.resolver to not read /etc/resolv.conf via 804fb07259b python:tests: Fix domain_backup test with Python 3.11 via af27b1d3757 python:tests: Make sure we do not run into issues with already existing users via ae315397a65 python:tests: Use a random machine name for computer_edit.sh test via 8ff1ccc6d6d python:tests: Correctly escape $ in computer_edit.sh via e846a9df603 python:tests: Use a random username for contact_edit.sh test via af1324e3be2 python:tests: Correctly escape $ in contact_edit.sh via 0bcdba952ec python:tests: Use a random username for user_edit.sh tests via a78c38e1f11 python:tests: Correctly escape $ in user_edit.sh via a3b80b656f1 testprogs: Use random user names for kpasswd tests via 5595765d4e5 testprogs: Use random usernames for export keytab tests via 93c7bbf4d2d testprogs: Use random usernames for kinit tests from 0eb459edd8a talloc: remove Python 2 #if clauses
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 5c051eacd425f322995ab53fce74028e44109046 Author: Samuel Cabrero <scabr...@samba.org> Date: Fri Feb 17 17:22:39 2023 +0100 selftests: Make sure print queue is empty before printing_var_exp test ends Although "lpq cache time" is 0 in the test environment the "print_queue_length()" function can still return cached results. This is because the print_queue_length() function calls print_queue_update(), which just sends MSG_PRINTER_UPDATE to the samba-bgqd daemon and returns without waiting for the daemon to update it. This behavior causes problems in the selftests between samba3.blackbox.printing_var_exp and samba3.rpc.spoolss.printserver because when the later enumerates the printers at different levels and compares the results the number of jobs can differ depending if samba-bgqd updates the cache in between print_queue_update() and get_queue_status() in the print_queue_length() function: test: samba3.rpc.spoolss.printserver.printserver.enum_printers(nt4_dc) time: 2023-02-17 13:07:34.043842Z Testing EnumPrinters level 0 Testing EnumPrinters level 1 Testing EnumPrinters level 2 Checking EnumPrinters level 0 printer print_var_exp (ref print_var_exp) time: 2023-02-17 13:07:34.285992Z failure: samba3.rpc.spoolss.printserver.printserver.enum_printers(nt4_dc) [ Exception: Exception: ../../source4/torture/rpc/spoolss.c:1132: cur->info0.cjobs was 1 (0x1), expected 0 (0x0): invalid value To fix it, make sure the queue is empty before printing_var_exp test ends. Signed-off-by: Samuel Cabrero <scabr...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> Autobuild-User(master): Andrew Bartlett <abart...@samba.org> Autobuild-Date(master): Mon Feb 20 22:58:44 UTC 2023 on atb-devel-224 commit a0996ef86fddea45b53e197f520ab8111a10e5c0 Author: Helmut Grohne <hel...@subdivi.de> Date: Sun Feb 5 21:18:13 2023 +0000 Skip running a C program during cross compilation When passing --cross-compile, one has to specify a --cross-answers file and this test cannot be performed anyway, so skip it already. Signed-off-by: Helmut Grohne <hel...@subdivi.de> Reviewed-by: Andreas Schneider <a...@samba.org> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit a4307072d6ea5ddef5b37aa361e9e9f16f7254e7 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 15:44:43 2023 +0100 python:tests: Make sure we delete the OU for movetest UNEXPECTED(failure): samba.tests.samba_tool.group.samba.tests.samba_tool.group.GroupCmdTestCase.test_move(ad_dc_default:local) REASON: Exception: Exception: Traceback (most recent call last): File "python/samba/tests/samba_tool/group.py", line 341, in test_move self.assertCmdSuccess(result, out, err) File "python/samba/tests/samba_tool/base.py", line 97, in assertCmdSuccess self.assertIsNone(exit, msg=msg.replace("\n]\n", "\n] \n")) AssertionError: -1 is not None : exit[-1] stdout[] stderr[ERROR(ldb): Failed to add ou "OU=movetest,DC=addom,DC=samba,DC=example,DC=com" - Entry OU=movetest,DC=addom,DC=samba,DC=example,DC=com already exists BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 69442ae1072eb6dc4c9903122d613c1756ca57c7 Author: Andreas Schneider <a...@samba.org> Date: Thu Feb 9 18:32:59 2023 +0100 python:tests: Add missing result checks for samba_tool.gpo tests BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit c4dba61e3691a1fd15eb63ee69224457102bf961 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 12:21:10 2023 +0100 python:tests: Tell dns.resolver to not read /etc/resolv.conf We explicitly set the nameserver in the next line. Also the file /etc/resolv.conf might not exist on the system (e.g in Fedora mockbuild). BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 804fb07259b87e80993b1916935b626906e04580 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 11:16:12 2023 +0100 python:tests: Fix domain_backup test with Python 3.11 Traceback (most recent call last): File "bin/python/samba/tests/domain_backup.py", line 615, in test_backup_restore_with_conf self._test_backup_restore_with_conf() File "bin/python/samba/tests/domain_backup.py", line 244, in _test_backup_restore_with_conf self.restore_backup(backup_file, ["--configfile=" + smbconf]) File "bin/python/samba/tests/domain_backup.py", line 421, in restore_backup self.run_cmd(args) File "bin/python/samba/tests/domain_backup.py", line 384, in run_cmd self.cleanup_tempdir() File "bin/python/samba/tests/domain_backup.py", line 370, in cleanup_tempdir shutil.rmtree(filepath) File "/usr/lib64/python3.11/shutil.py", line 732, in rmtree _rmtree_safe_fd(fd, path, onerror) File "/usr/lib64/python3.11/shutil.py", line 635, in _rmtree_safe_fd onerror(os.scandir, path, sys.exc_info()) File "/usr/lib64/python3.11/shutil.py", line 631, in _rmtree_safe_fd with os.scandir(topfd) as scandir_it: ^^^^^^^^^^^^^^^^^ NotADirectoryError: [Errno 20] Not a directory: 'st/tmp/tmp7usvex3t/samba-backup-2023-02-08T10-13-18.461113.tar.bz2' BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit af27b1d37573d165983933d3789a18b12fad0272 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 10:17:05 2023 +0100 python:tests: Make sure we do not run into issues with already existing users UNEXPECTED(failure): samba.tests.samba_tool.user.samba.tests.samba_tool.user.UserCmdTestCase.test_getpwent(ad_dc_ntvfs:local) REASON: Exception: Exception: Traceback (most recent call last): File "/builddir/build/BUILD/samba-4.18.0rc2/bin/python/samba/tests/samba_tool/user.py", line 1044, in test_getpwent self.assertCmdSuccess(result, out, err) File "/builddir/build/BUILD/samba-4.18.0rc2/bin/python/samba/tests/samba_tool/base.py", line 97, in assertCmdSuccess self.assertIsNone(exit, msg=msg.replace("\n]\n", "\n] \n")) AssertionError: -1 is not None : exit[-1] stdout[] stderr[ERROR(ldb): Failed to add user 'mockbuild': - LDAP error 68 LDAP_ENTRY_ALREADY_EXISTS - <00002071: samldb: samAccountName 'mockbuild' already in use!> <> ]: UNEXPECTED(failure): samba.tests.samba_tool.user.samba.tests.samba_tool.user.UserCmdTestCase.test_list(ad_dc_ntvfs:local) REASON: Exception: Exception: Traceback (most recent call last): File "/builddir/build/BUILD/samba-4.18.0rc2/bin/python/samba/tests/samba_tool/user.py", line 69, in setUp self.assertCmdSuccess(result, out, err) File "/builddir/build/BUILD/samba-4.18.0rc2/bin/python/samba/tests/samba_tool/base.py", line 97, in assertCmdSuccess self.assertIsNone(exit, msg=msg.replace("\n]\n", "\n] \n")) AssertionError: -1 is not None : exit[-1] stdout[] stderr[ERROR(ldb): Failed to add user 'sambatool1': - LDAP error 68 LDAP_ENTRY_ALREADY_EXISTS - <00002071: samldb: samAccountNa me 'sambatool1' already in use!> <> BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit ae315397a653ec2249b89e246eb46589d4542f75 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 21:40:25 2023 +0100 python:tests: Use a random machine name for computer_edit.sh test BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 8ff1ccc6d6d8804be55f5549910aa11c6a9a7664 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 21:37:06 2023 +0100 python:tests: Correctly escape $ in computer_edit.sh BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit e846a9df60323a77e8222f27be8d31b326ce8d6a Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 18:41:18 2023 +0100 python:tests: Use a random username for contact_edit.sh test BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit af1324e3be28773e0b8cc827c669812e4c257989 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 18:40:04 2023 +0100 python:tests: Correctly escape $ in contact_edit.sh BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 0bcdba952ec887139517841b8882bd6e10c00267 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 10:20:21 2023 +0100 python:tests: Use a random username for user_edit.sh tests BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit a78c38e1f114858bd72738c752d27ef4b4358488 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 15:33:00 2023 +0100 python:tests: Correctly escape $ in user_edit.sh BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit a3b80b656f16049772005bd7b00451aaa5df2dd6 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 08:30:56 2023 +0100 testprogs: Use random user names for kpasswd tests This avoids that subsequent tests because users already exist and cleanup didn't work. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 5595765d4e5918abe8d68423a8036f99675e64e7 Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 08:30:38 2023 +0100 testprogs: Use random usernames for export keytab tests This avoids that subsequent tests because users already exist and cleanup didn't work. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> commit 93c7bbf4d2db73116e5de564b428d6d30504bd5c Author: Andreas Schneider <a...@samba.org> Date: Wed Feb 8 08:29:33 2023 +0100 testprogs: Use random usernames for kinit tests This avoids that subsequent tests because users already exist and cleanup didn't work. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15308 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagn...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> ----------------------------------------------------------------------- Summary of changes: buildtools/wafsamba/wscript | 2 +- python/samba/tests/blackbox/netads_dns.py | 4 ++- python/samba/tests/domain_backup.py | 5 ++- python/samba/tests/samba_tool/computer_edit.sh | 30 ++++++++-------- python/samba/tests/samba_tool/contact_edit.sh | 28 ++++++++------- python/samba/tests/samba_tool/gpo.py | 15 ++++++++ python/samba/tests/samba_tool/group.py | 8 ++--- python/samba/tests/samba_tool/user.py | 21 ++++++++--- python/samba/tests/samba_tool/user_edit.sh | 30 ++++++++-------- source3/script/tests/test_printing_var_exp.sh | 32 +++++++++++++++++ testprogs/blackbox/test_export_keytab_heimdal.sh | 17 ++++----- testprogs/blackbox/test_export_keytab_mit.sh | 4 +-- testprogs/blackbox/test_kinit_heimdal.sh | 46 ++++++++++++------------ testprogs/blackbox/test_kinit_mit.sh | 38 ++++++++++---------- testprogs/blackbox/test_kpasswd_mit.sh | 2 +- 15 files changed, 177 insertions(+), 105 deletions(-) Changeset truncated at 500 lines: diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index a33d26706a5..93af81f1eca 100644 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -378,7 +378,7 @@ def configure(conf): conf.CHECK_CODE('printf("hello world")', define='HAVE_SIMPLE_C_PROG', mandatory=True, - execute=True, + execute=not conf.env.CROSS_COMPILE, headers='stdio.h', msg='Checking simple C program') diff --git a/python/samba/tests/blackbox/netads_dns.py b/python/samba/tests/blackbox/netads_dns.py index 0a491504537..e9f945eaef9 100644 --- a/python/samba/tests/blackbox/netads_dns.py +++ b/python/samba/tests/blackbox/netads_dns.py @@ -30,7 +30,9 @@ class NetAdsDnsTests(BlackboxTestCase): def setUp(self): super(NetAdsDnsTests, self).setUp() nameserver = os.environ["DC_SERVER_IP"] - self.resolver = dns.resolver.Resolver() + # filename=None will disable reading /etc/resolv.conf. The file might + # not exist e.g. on build or CI systems. + self.resolver = dns.resolver.Resolver(filename=None) self.resolver.nameservers = [nameserver] def parse_output(self, output): diff --git a/python/samba/tests/domain_backup.py b/python/samba/tests/domain_backup.py index b890a1030b7..2feef28bcb4 100644 --- a/python/samba/tests/domain_backup.py +++ b/python/samba/tests/domain_backup.py @@ -367,7 +367,10 @@ class DomainBackupBase(BlackboxTestCase): def cleanup_tempdir(self): for filename in os.listdir(self.tempdir): filepath = os.path.join(self.tempdir, filename) - shutil.rmtree(filepath) + if os.path.isfile(filepath): + os.remove(filepath) + elif os.path.isdir(filepath): + shutil.rmtree(filepath) def run_cmd(self, args): """Executes a samba-tool backup/restore command""" diff --git a/python/samba/tests/samba_tool/computer_edit.sh b/python/samba/tests/samba_tool/computer_edit.sh index 500a00d9a34..da32760de35 100755 --- a/python/samba/tests/samba_tool/computer_edit.sh +++ b/python/samba/tests/samba_tool/computer_edit.sh @@ -29,10 +29,12 @@ display_name_con_b64="dGVzdCAHIHN0cmluZwo=" tmpeditor=$(mktemp --suffix .sh -p $SELFTEST_TMPDIR samba-tool-editor-XXXXXXXX) chmod +x $tmpeditor +TEST_MACHINE="$(mktemp -u testmachineXXXXXX)" + create_test_computer() { $PYTHON ${STpath}/source4/scripting/bin/samba-tool \ - computer create testmachine1 \ + computer create ${TEST_MACHINE} \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -48,7 +50,7 @@ $SED -i -e 's/userAccountControl: 4098/userAccountControl: 4096/' $computer_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool \ - computer edit testmachine1 --editor=$tmpeditor \ + computer edit ${TEST_MACHINE} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -60,20 +62,20 @@ add_attribute_base64() #!/usr/bin/env bash computer_ldif="\$1" -grep -v '^$' \$computer_ldif > \${computer_ldif}.tmp +grep -v '^\$' \$computer_ldif > \${computer_ldif}.tmp echo "displayName:: $display_name_b64" >> \${computer_ldif}.tmp mv \${computer_ldif}.tmp \$computer_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool computer edit \ - testmachine1 --editor=$tmpeditor \ + ${TEST_MACHINE} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } get_attribute_base64() { - ${ldbsearch} '(sAMAccountName=testmachine1$)' displayName \ + ${ldbsearch} "(sAMAccountName=${TEST_MACHINE}\$)" displayName \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -88,7 +90,7 @@ grep -v '^displayName' \$computer_ldif >> \${computer_ldif}.tmp mv \${computer_ldif}.tmp \$computer_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool computer edit \ - testmachine1 --editor=$tmpeditor \ + ${TEST_MACHINE} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -100,20 +102,20 @@ add_attribute_base64_control() #!/usr/bin/env bash computer_ldif="\$1" -grep -v '^$' \$computer_ldif > \${computer_ldif}.tmp +grep -v '^\$' \$computer_ldif > \${computer_ldif}.tmp echo "displayName:: $display_name_con_b64" >> \${computer_ldif}.tmp mv \${computer_ldif}.tmp \$computer_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool computer edit \ - testmachine1 --editor=$tmpeditor \ + ${TEST_MACHINE} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } get_attribute_base64_control() { $PYTHON ${STpath}/source4/scripting/bin/samba-tool computer show \ - testmachine1 --attributes=displayName \ + ${TEST_MACHINE} --attributes=displayName \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -121,7 +123,7 @@ get_attribute_force_no_base64() { # LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here. $PYTHON ${STpath}/source4/scripting/bin/samba-tool computer show \ - testmachine1 --attributes=displayName \ + ${TEST_MACHINE} --attributes=displayName \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -137,7 +139,7 @@ sed -i -e 's/displayName:: $display_name_con_b64/displayName: $display_name/' \ \$computer_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool computer edit \ - testmachine1 --editor=$tmpeditor \ + ${TEST_MACHINE} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -156,21 +158,21 @@ sed -i -e 's/displayName: $display_name/displayName: $display_name_new/' \ EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool computer edit \ - testmachine1 --editor=$tmpeditor \ + ${TEST_MACHINE} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } get_changed_attribute_force_no_base64() { $PYTHON ${STpath}/source4/scripting/bin/samba-tool computer show \ - testmachine1 --attributes=displayName \ + ${TEST_MACHINE} --attributes=displayName \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } delete_computer() { $PYTHON ${STpath}/source4/scripting/bin/samba-tool \ - computer delete testmachine1 \ + computer delete ${TEST_MACHINE} \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } diff --git a/python/samba/tests/samba_tool/contact_edit.sh b/python/samba/tests/samba_tool/contact_edit.sh index 3c14ac8de26..d31413dbcd6 100755 --- a/python/samba/tests/samba_tool/contact_edit.sh +++ b/python/samba/tests/samba_tool/contact_edit.sh @@ -28,13 +28,15 @@ display_name_new="Renamed Bjoern" # echo -e "test \a string" | base64 display_name_con_b64="dGVzdCAHIHN0cmluZwo=" +TEST_USER="$(mktemp -u testcontactXXXXXX)" + tmpeditor=$(mktemp --suffix .sh -p $SELFTEST_TMPDIR samba-tool-editor-XXXXXXXX) chmod +x $tmpeditor create_test_contact() { $PYTHON ${STpath}/source4/scripting/bin/samba-tool \ - contact create testcontact1 \ + contact create ${TEST_USER} \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -46,20 +48,20 @@ add_attribute_base64() #!/usr/bin/env bash contact_ldif="\$1" -grep -v '^$' \$contact_ldif > \${contact_ldif}.tmp +grep -v '^\$' \$contact_ldif > \${contact_ldif}.tmp echo "displayName:: $display_name_b64" >> \${contact_ldif}.tmp mv \${contact_ldif}.tmp \$contact_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool contact edit \ - testcontact1 --editor=$tmpeditor \ + ${TEST_USER} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } get_attribute_base64() { - $samba_ldbsearch '(&(objectClass=contact)(name=testcontact1))' \ + $samba_ldbsearch "(&(objectClass=contact)(name=${TEST_USER}))" \ displayName \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -75,7 +77,7 @@ grep -v '^displayName' \$contact_ldif >> \${contact_ldif}.tmp mv \${contact_ldif}.tmp \$contact_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool contact edit \ - testcontact1 --editor=$tmpeditor \ + ${TEST_USER} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -87,20 +89,20 @@ add_attribute_base64_control() #!/usr/bin/env bash contact_ldif="\$1" -grep -v '^$' \$contact_ldif > \${contact_ldif}.tmp +grep -v '^\$' \$contact_ldif > \${contact_ldif}.tmp echo "displayName:: $display_name_con_b64" >> \${contact_ldif}.tmp mv \${contact_ldif}.tmp \$contact_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool contact edit \ - testcontact1 --editor=$tmpeditor \ + ${TEST_USER} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } get_attribute_base64_control() { $PYTHON ${STpath}/source4/scripting/bin/samba-tool contact show \ - testcontact1 --attributes=displayName \ + ${TEST_USER} --attributes=displayName \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -108,7 +110,7 @@ get_attribute_force_no_base64() { # LDB_FLAG_FORCE_NO_BASE64_LDIF should be used here. $PYTHON ${STpath}/source4/scripting/bin/samba-tool contact show \ - testcontact1 --attributes=displayName \ + ${TEST_USER} --attributes=displayName \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -124,7 +126,7 @@ sed -i -e 's/displayName:: $display_name_con_b64/displayName: $display_name/' \ \$contact_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool contact edit \ - testcontact1 --editor=$tmpeditor \ + ${TEST_USER} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -143,21 +145,21 @@ sed -i -e 's/displayName: $display_name/displayName: $display_name_new/' \ EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool contact edit \ - testcontact1 --editor=$tmpeditor \ + ${TEST_USER} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } get_changed_attribute_force_no_base64() { $PYTHON ${STpath}/source4/scripting/bin/samba-tool contact show \ - testcontact1 --attributes=displayName \ + ${TEST_USER} --attributes=displayName \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } delete_contact() { $PYTHON ${STpath}/source4/scripting/bin/samba-tool \ - contact delete testcontact1 \ + contact delete ${TEST_USER} \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } diff --git a/python/samba/tests/samba_tool/gpo.py b/python/samba/tests/samba_tool/gpo.py index d192c1b8115..e8d02d62f0c 100644 --- a/python/samba/tests/samba_tool/gpo.py +++ b/python/samba/tests/samba_tool/gpo.py @@ -266,6 +266,9 @@ class GpoCmdTestCase(SambaToolCmdTest): os.environ["PASSWORD"]), "--restore-metadata") + self.assertCmdSuccess(result, out, err, + "Ensure gpo restore successful") + gpo_guid = "{%s}" % out.split("{")[1].split("}")[0] (result, out, err) = self.runsubcmd("gpo", "backup", gpo_guid, @@ -320,6 +323,9 @@ class GpoCmdTestCase(SambaToolCmdTest): os.environ["PASSWORD"]), "--restore-metadata") + self.assertCmdSuccess(result, out, err, + "Ensure gpo restore successful") + gpo_guid = "{%s}" % out.split("{")[1].split("}")[0] gpo_guid1 = gpo_guid @@ -342,6 +348,9 @@ class GpoCmdTestCase(SambaToolCmdTest): os.environ["PASSWORD"]), "--restore-metadata") + self.assertCmdSuccess(result, out, err, + "Ensure gpo restore successful") + gpo_guid = "{%s}" % out.split("{")[1].split("}")[0] gpo_guid2 = gpo_guid @@ -405,6 +414,9 @@ class GpoCmdTestCase(SambaToolCmdTest): os.environ["PASSWORD"]), "--restore-metadata") + self.assertCmdSuccess(result, out, err, + "Ensure gpo restore successful") + gpo_guid = "{%s}" % out.split("{")[1].split("}")[0] gpo_guid1 = gpo_guid @@ -425,6 +437,9 @@ class GpoCmdTestCase(SambaToolCmdTest): os.environ["PASSWORD"]), "--restore-metadata") + self.assertCmdSuccess(result, out, err, + "Ensure gpo restore successful") + gpo_guid = "{%s}" % out.split("{")[1].split("}")[0] gpo_guid2 = gpo_guid diff --git a/python/samba/tests/samba_tool/group.py b/python/samba/tests/samba_tool/group.py index 2542411d74a..3019b7596d2 100644 --- a/python/samba/tests/samba_tool/group.py +++ b/python/samba/tests/samba_tool/group.py @@ -336,7 +336,9 @@ class GroupCmdTestCase(SambaToolCmdTest): def test_move(self): - full_ou_dn = str(self.samdb.normalize_dn_in_domain("OU=movetest")) + full_ou_dn = str(self.samdb.normalize_dn_in_domain("OU=movetest_grp")) + self.addCleanup(self.samdb.delete, full_ou_dn, ["tree_delete:1"]) + (result, out, err) = self.runsubcmd("ou", "add", full_ou_dn) self.assertCmdSuccess(result, out, err) self.assertEqual(err, "", "There shouldn't be any error message") @@ -363,10 +365,6 @@ class GroupCmdTestCase(SambaToolCmdTest): self.assertIn('Moved group "%s" into "%s"' % (group["name"], new_dn), out) - (result, out, err) = self.runsubcmd("ou", "delete", full_ou_dn) - self.assertCmdSuccess(result, out, err, - "Failed to delete ou '%s'" % full_ou_dn) - def test_show(self): """Assert that we can show a group correctly.""" (result, out, err) = self.runsubcmd("group", "show", "Domain Users", diff --git a/python/samba/tests/samba_tool/user.py b/python/samba/tests/samba_tool/user.py index 700cb89c968..9b6d19b11cb 100644 --- a/python/samba/tests/samba_tool/user.py +++ b/python/samba/tests/samba_tool/user.py @@ -62,6 +62,11 @@ class UserCmdTestCase(SambaToolCmdTest): self.users.append(self._randomUnixUser({"name": "unixuser3"})) self.users.append(self._randomUnixUser({"name": "unixuser4"})) + # Make sure users don't exist + for user in self.users: + if self._find_user(user["name"]): + self.runsubcmd("user", "delete", user["name"]) + # setup the 12 users and ensure they are correct for user in self.users: (result, out, err) = user["createUserFn"](user) @@ -703,7 +708,9 @@ sAMAccountName: %s self.assertGreater(pwd_expires_time, pwd_last_set_time) def test_move(self): - full_ou_dn = str(self.samdb.normalize_dn_in_domain("OU=movetest")) + full_ou_dn = str(self.samdb.normalize_dn_in_domain("OU=movetest_usr")) + self.addCleanup(self.samdb.delete, full_ou_dn, ["tree_delete:1"]) + (result, out, err) = self.runsubcmd("ou", "add", full_ou_dn) self.assertCmdSuccess(result, out, err) self.assertEqual(err, "", "There shouldn't be any error message") @@ -730,10 +737,6 @@ sAMAccountName: %s self.assertIn('Moved user "%s" into "%s"' % (user["name"], new_dn), out) - (result, out, err) = self.runsubcmd("ou", "delete", full_ou_dn) - self.assertCmdSuccess(result, out, err, - "Failed to delete ou '%s'" % full_ou_dn) - def test_rename_surname_initials_givenname(self): """rename the existing surname and given name and add missing initials, then remove them, for all users""" @@ -999,6 +1002,10 @@ sAMAccountName: %s "gecos": gecos, "loginShell": u[6], }) + + # Remove user if it already exists + if self._find_user(u[0]): + self.runsubcmd("user", "delete", u[0]) # check if --rfc2307-from-nss sets the same values as we got from pwd.getpwuid() (result, out, err) = self.runsubcmd("user", "create", user["name"], user["password"], "--surname=%s" % user["surname"], @@ -1023,6 +1030,10 @@ sAMAccountName: %s # # get a user with all random posix attributes user = self._randomPosixUser({"name": u[0]}) + + # Remove user if it already exists + if self._find_user(u[0]): + self.runsubcmd("user", "delete", u[0]) # create a user with posix attributes from nss but override all of them with the # random ones just obtained (result, out, err) = self.runsubcmd("user", "create", user["name"], user["password"], diff --git a/python/samba/tests/samba_tool/user_edit.sh b/python/samba/tests/samba_tool/user_edit.sh index 81a62bb269c..342899f3f0f 100755 --- a/python/samba/tests/samba_tool/user_edit.sh +++ b/python/samba/tests/samba_tool/user_edit.sh @@ -31,10 +31,12 @@ display_name_con_b64="dGVzdCAHIHN0cmluZwo=" tmpeditor=$(mktemp --suffix .sh -p ${SELFTEST_TMPDIR} samba-tool-editor-XXXXXXXX) chmod +x $tmpeditor +TEST_USER="$(mktemp -u sambatoolXXXXXX)" + create_test_user() { $PYTHON ${STpath}/source4/scripting/bin/samba-tool \ - user create sambatool1 --random-password \ + user create ${TEST_USER} --random-password \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -49,7 +51,7 @@ $SED -i -e 's/userAccountControl: 512/userAccountControl: 514/' $user_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool \ - user edit sambatool1 --editor=$tmpeditor \ + user edit ${TEST_USER} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -61,20 +63,20 @@ add_attribute_base64() #!/usr/bin/env bash user_ldif="\$1" -grep -v '^$' \$user_ldif > \${user_ldif}.tmp +grep -v '^\$' \$user_ldif > \${user_ldif}.tmp echo "displayName:: $display_name_b64" >> \${user_ldif}.tmp mv \${user_ldif}.tmp \$user_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool user edit \ - sambatool1 --editor=$tmpeditor \ + ${TEST_USER} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } get_attribute_base64() { - $samba_ldbsearch '(sAMAccountName=sambatool1)' displayName \ + $samba_ldbsearch "(sAMAccountName=${TEST_USER})" displayName \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -89,7 +91,7 @@ grep -v '^displayName' \$user_ldif >> \${user_ldif}.tmp mv \${user_ldif}.tmp \$user_ldif EOF $PYTHON ${STpath}/source4/scripting/bin/samba-tool user edit \ - sambatool1 --editor=$tmpeditor \ + ${TEST_USER} --editor=$tmpeditor \ -H "ldap://$SERVER" "-U$USERNAME" "--password=$PASSWORD" } @@ -101,20 +103,20 @@ add_attribute_base64_control() #!/usr/bin/env bash user_ldif="\$1" -grep -v '^$' \$user_ldif > \${user_ldif}.tmp +grep -v '^\$' \$user_ldif > \${user_ldif}.tmp echo "displayName:: $display_name_con_b64" >> \${user_ldif}.tmp -- Samba Shared Repository