diff options
author | Andreas Schneider <asn@samba.org> | 2023-02-08 10:17:05 +0100 |
---|---|---|
committer | Jule Anger <janger@samba.org> | 2023-02-24 08:56:14 +0000 |
commit | 9e8cc236bd3111b81289fe35187e6d8e5d843ea8 (patch) | |
tree | 7c18659f0eebc8030acb6740252a924e5b71298d /python/samba | |
parent | bebf313dcb05af6ba7dbc75ea64ad8270562ba1b (diff) | |
download | samba-9e8cc236bd3111b81289fe35187e6d8e5d843ea8.tar.gz |
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 <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
(cherry picked from commit af27b1d37573d165983933d3789a18b12fad0272)
Diffstat (limited to 'python/samba')
-rw-r--r-- | python/samba/tests/samba_tool/user.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/python/samba/tests/samba_tool/user.py b/python/samba/tests/samba_tool/user.py index 700cb89c968..ffae45dd529 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) @@ -999,6 +1004,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 +1032,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"], |