tests samba_tool: fix flapping user-virtualCryptSHA test
authorGary Lockyer <gary@catalyst.net.nz>
Thu, 3 Aug 2017 18:45:37 +0000 (06:45 +1200)
committerGarming Sam <garming@samba.org>
Mon, 7 Aug 2017 03:34:23 +0000 (05:34 +0200)
Fix flapping test, occasionally a password would be generated that failed
the password criteria, which resulted in the test user not being
created.  The tests relying on this user being present then failed.

This patch ensures that the generated password contains at least one digit,
at least one upper case letter and at least one lower case letter.
The generated passwords do not contain special characters to avoid shell
escaping issues.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Garming Sam <garming@samba.org>
Autobuild-Date(master): Mon Aug  7 05:34:24 CEST 2017 on sn-devel-144

python/samba/tests/samba_tool/user_virtualCryptSHA.py

index 3ac4661a46e23c122a7a8668879f66a1d2830513..909de373f5eb559f95982b91d00a12253e6d51a9 100644 (file)
@@ -37,9 +37,17 @@ import string
 USER_NAME = "CryptSHATestUser"
 # Create a random 32 character password, containing only letters and
 # digits to avoid issues when used on the command line.
-USER_PASS = ''.join(random.choice(string.ascii_uppercase +
-                                  string.ascii_lowercase +
-                                  string.digits) for _ in range(32))
+# Ensuring the password includes at least:
+#   1 upper case letter
+#   1 lower case letter
+#   1 digit.
+#
+USER_PASS = (''.join(random.choice(string.ascii_uppercase +
+                                   string.ascii_lowercase +
+                                   string.digits) for _ in range(29)) +
+             random.choice(string.ascii_uppercase) +
+             random.choice(string.ascii_lowercase) +
+             random.choice(string.digits))
 HASH_OPTION = "password hash userPassword schemes"
 
 # Get the value of an attribute from the output string