mirror of
https://github.com/samba-team/samba.git
synced 2025-03-01 04:58:35 +03:00
python:tests: Do not have current_time() and current_nt_time() implicitly include clock skew
This is just too error‐prone. current_gkid() will still continue to return the next GKID if it’s within clock skew. Signed-off-by: Jo Sutton <josutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
96ac8144b4
commit
0bc8d1469b
@ -91,17 +91,21 @@ class GkdiBaseTest(TestCase):
|
||||
|
||||
@staticmethod
|
||||
def current_time(offset: Optional[datetime.timedelta] = None) -> datetime.datetime:
|
||||
if offset is None:
|
||||
# Allow for clock skew.
|
||||
offset = timedelta_from_nt_time_delta(MAX_CLOCK_SKEW)
|
||||
|
||||
current_time = datetime.datetime.now(tz=datetime.timezone.utc)
|
||||
return current_time + offset
|
||||
|
||||
if offset is not None:
|
||||
current_time += offset
|
||||
|
||||
return current_time
|
||||
|
||||
def current_nt_time(self, offset: Optional[datetime.timedelta] = None) -> NtTime:
|
||||
return nt_time_from_datetime(self.current_time(offset))
|
||||
|
||||
def current_gkid(self, offset: Optional[datetime.timedelta] = None) -> Gkid:
|
||||
if offset is None:
|
||||
# Allow for clock skew.
|
||||
offset = timedelta_from_nt_time_delta(MAX_CLOCK_SKEW)
|
||||
|
||||
return Gkid.from_nt_time(self.current_nt_time(offset))
|
||||
|
||||
def gkdi_connect(
|
||||
@ -515,13 +519,18 @@ class GkdiBaseTest(TestCase):
|
||||
# which exists so that the samba-tool tests can borrow that
|
||||
# function.
|
||||
|
||||
root_key_guid, root_key_dn = create_root_key(samdb,
|
||||
domain_dn,
|
||||
current_nt_time=self.current_nt_time(),
|
||||
use_start_time=use_start_time,
|
||||
hash_algorithm=hash_algorithm,
|
||||
guid=guid,
|
||||
data=data)
|
||||
root_key_guid, root_key_dn = create_root_key(
|
||||
samdb,
|
||||
domain_dn,
|
||||
current_nt_time=self.current_nt_time(
|
||||
# Allow for clock skew.
|
||||
timedelta_from_nt_time_delta(MAX_CLOCK_SKEW)
|
||||
),
|
||||
use_start_time=use_start_time,
|
||||
hash_algorithm=hash_algorithm,
|
||||
guid=guid,
|
||||
data=data,
|
||||
)
|
||||
|
||||
if guid is not None:
|
||||
# A test may request that a root key have a specific GUID so that
|
||||
|
Loading…
x
Reference in New Issue
Block a user