[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu Oct 29 18:55:02 UTC 2020


The branch, master has been updated
       via  9214fcec349 tests: avoid returning an already used ID in randomXid()
      from  ebd687335b9 python:tests: Add SAMR password change tests for fips

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9214fcec349bbda1c9ceb25f835b7aef5024f61a
Author: Jule Anger <ja at sernet.de>
Date:   Tue Oct 20 09:42:38 2020 +0200

    tests: avoid returning an already used ID in randomXid()
    
    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 at sernet.de>
    Reviewed-by: Björn Baumbach <bb at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Oct 29 18:54:24 UTC 2020 on sn-devel-184

-----------------------------------------------------------------------

Summary of changes:
 python/samba/tests/samba_tool/base.py | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/tests/samba_tool/base.py b/python/samba/tests/samba_tool/base.py
index 536fbfc1617..00e742e7c5b 100644
--- a/python/samba/tests/samba_tool/base.py
+++ b/python/samba/tests/samba_tool/base.py
@@ -125,10 +125,24 @@ class SambaToolCmdTest(samba.tests.BlackboxTestCase):
         return name
 
     def randomXid(self):
-        # pick some hopefully unused, high UID/GID range to avoid interference
+        # pick some unused, high UID/GID range to avoid interference
         # from the system the test runs on
-        xid = random.randint(4711000, 4799000)
-        return xid
+
+        # initialize a list to store used IDs
+        try:
+            self.used_xids
+        except AttributeError:
+            self.used_xids = []
+
+        # try to get an unused ID
+        failed = 0
+        while failed < 50:
+            xid = random.randint(4711000, 4799000)
+            if xid not in self.used_xids:
+                self.used_xids += [xid]
+                return xid
+            failed += 1
+        assert False, "No Xid are available"
 
     def assertWithin(self, val1, val2, delta, msg=""):
         """Assert that val1 is within delta of val2, useful for time computations"""


-- 
Samba Shared Repository



More information about the samba-cvs mailing list