[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Wed Jul 17 14:22:02 UTC 2024
The branch, master has been updated
via 818bd2dcb3c python:tests: make test_export_keytab_nochange_update() more reliable
from 687139144a2 s3:auth: allow real plaintext authentication
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 818bd2dcb3c67728f4e82722154e25023a09c919
Author: Stefan Metzmacher <metze at samba.org>
Date: Wed Jul 17 07:03:34 2024 +0000
python:tests: make test_export_keytab_nochange_update() more reliable
net.export_keytab() includes the current timestamp into the resulting
keytab. So we need to make sure the two compared exports actually
run within the same second.
And klist may also print the keytab filename...
Signed-off-by: Stefan Metzmacher <metze at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
Autobuild-Date(master): Wed Jul 17 14:21:30 UTC 2024 on atb-devel-224
-----------------------------------------------------------------------
Summary of changes:
python/samba/tests/dckeytab.py | 42 ++++++++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 6 deletions(-)
Changeset truncated at 500 lines:
diff --git a/python/samba/tests/dckeytab.py b/python/samba/tests/dckeytab.py
index 9dee64e0cea..56be897e0f0 100644
--- a/python/samba/tests/dckeytab.py
+++ b/python/samba/tests/dckeytab.py
@@ -18,6 +18,7 @@
import os
import subprocess
+import time
from samba.net import Net
from samba import enable_net_export_keytab
@@ -148,10 +149,38 @@ class DCKeytabTests(TestCaseInTempDir):
self.addCleanup(self.samdb.deleteuser, "keytab_testuser")
net = Net(None, self.lp)
- self.addCleanup(self.rm_files, self.ktfile)
- net.export_keytab(keytab=self.ktfile, principal=new_principal)
- self.assertTrue(os.path.exists(self.ktfile), 'keytab was not created')
+ self.addCleanup(self.rm_files, self.ktfile)
+ ktfile1 = self.ktfile + ".1"
+ self.addCleanup(self.rm_files, ktfile1, allow_missing=True)
+ ktfile2 = self.ktfile + ".2"
+ self.addCleanup(self.rm_files, ktfile2, allow_missing=True)
+
+ # The export includes the current timestamp
+ # so we better do both exports within the
+ # same second.
+ #
+ # First we sleep until we reach the next second
+ now = time.time()
+ next = float(int(now)+1)
+ sleep = next-now
+ time.sleep(sleep)
+ start = time.time()
+ net.export_keytab(keytab=ktfile1, principal=new_principal)
+ net.export_keytab(keytab=ktfile2, principal=new_principal)
+ end = time.time()
+ self.assertTrue(os.path.exists(ktfile1), 'keytab1 was not created')
+ self.assertTrue(os.path.exists(ktfile2), 'keytab2 was not created')
+ print("now: %f" % now)
+ print("next: %f" % next)
+ print("sleep: %f" % sleep)
+ print("start: %f" % start)
+ print("end: %f" % end)
+ self.assertEqual(int(end), int(start))
+
+ # The output may contain the file name
+ # so we have to use self.ktfile...
+ os.rename(ktfile1, self.ktfile)
cmd = ['klist', '-K', '-C', '-t', '-k', self.ktfile]
keytab_orig_content = subprocess.Popen(
cmd,
@@ -163,9 +192,10 @@ class DCKeytabTests(TestCaseInTempDir):
with open(self.ktfile, 'rb') as bytes_kt:
keytab_orig_bytes = bytes_kt.read()
- net.export_keytab(keytab=self.ktfile, principal=new_principal)
- self.assertTrue(os.path.exists(self.ktfile), 'keytab was not created')
-
+ # The output may contain the file name
+ # so we have to use self.ktfile...
+ os.rename(ktfile2, self.ktfile)
+ cmd = ['klist', '-K', '-C', '-t', '-k', self.ktfile]
keytab_content = subprocess.Popen(
cmd,
shell=False,
--
Samba Shared Repository
More information about the samba-cvs
mailing list