mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Use UTC timezone when handling keys in kasp test library
When working with key timestamps, ensure we correctly set the UTC
timezone in order for the tests to work consistently regardless of the
local time setting.
(cherry picked from commit f840deba33
)
This commit is contained in:
@@ -17,8 +17,7 @@ import subprocess
|
|||||||
import time
|
import time
|
||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta, timezone
|
||||||
from datetime import timedelta
|
|
||||||
|
|
||||||
import dns
|
import dns
|
||||||
import isctest.log
|
import isctest.log
|
||||||
@@ -54,7 +53,9 @@ class KeyTimingMetadata:
|
|||||||
def __init__(self, timestamp: str):
|
def __init__(self, timestamp: str):
|
||||||
if int(timestamp) <= 0:
|
if int(timestamp) <= 0:
|
||||||
raise ValueError(f'invalid timing metadata value: "{timestamp}"')
|
raise ValueError(f'invalid timing metadata value: "{timestamp}"')
|
||||||
self.value = datetime.strptime(timestamp, self.FORMAT)
|
self.value = datetime.strptime(timestamp, self.FORMAT).replace(
|
||||||
|
tzinfo=timezone.utc
|
||||||
|
)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.value.strftime(self.FORMAT)
|
return self.value.strftime(self.FORMAT)
|
||||||
@@ -95,7 +96,7 @@ class KeyTimingMetadata:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def now() -> "KeyTimingMetadata":
|
def now() -> "KeyTimingMetadata":
|
||||||
result = KeyTimingMetadata.__new__(KeyTimingMetadata)
|
result = KeyTimingMetadata.__new__(KeyTimingMetadata)
|
||||||
result.value = datetime.now()
|
result.value = datetime.now(timezone.utc)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user