1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-18 08:23:51 +03:00

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>
This commit is contained in:
Andreas Schneider
2023-02-08 10:17:05 +01:00
committed by Andrew Bartlett
parent ae315397a6
commit af27b1d375

View File

@@ -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"],