[tor-commits] [stem/master] Use UTC timestamp for expiration timestamp

atagar at torproject.org atagar at torproject.org
Thu Mar 30 04:18:03 UTC 2017


commit 5b730b96e1e7354cf09861b24581df1e3b4a0881
Author: Damian Johnson <atagar at torproject.org>
Date:   Wed Mar 29 20:17:30 2017 -0700

    Use UTC timestamp for expiration timestamp
    
    Oops, don't want this to be local time. Found when unit tests failed on a
    system with a different timezone.
---
 stem/descriptor/certificate.py            | 2 +-
 test/unit/descriptor/certificate.py       | 4 ++--
 test/unit/descriptor/server_descriptor.py | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/stem/descriptor/certificate.py b/stem/descriptor/certificate.py
index 4a279a3..d9a36f3 100644
--- a/stem/descriptor/certificate.py
+++ b/stem/descriptor/certificate.py
@@ -161,7 +161,7 @@ class Ed25519CertificateV1(Ed25519Certificate):
       raise ValueError("BUG: Ed25519 certificate type is decoded from one byte. It shouldn't be possible to have a value of %i." % cert_type)
 
     # expiration time is in hours since epoch
-    self.expiration = datetime.datetime.fromtimestamp(stem.util.str_tools._to_int(decoded[2:6]) * 3600)
+    self.expiration = datetime.datetime.utcfromtimestamp(stem.util.str_tools._to_int(decoded[2:6]) * 3600)
 
     self.key_type = stem.util.str_tools._to_int(decoded[6])
     self.key = decoded[7:39]
diff --git a/test/unit/descriptor/certificate.py b/test/unit/descriptor/certificate.py
index 6cbc3b2..a3bea04 100644
--- a/test/unit/descriptor/certificate.py
+++ b/test/unit/descriptor/certificate.py
@@ -62,7 +62,7 @@ class TestEd25519Certificate(unittest.TestCase):
     self.assertEqual(1, cert.version)
     self.assertEqual(cert_bytes, cert.encoded)
     self.assertEqual(CertType.SIGNING, cert.type)
-    self.assertEqual(datetime.datetime(1970, 1, 1, 1, 0), cert.expiration)
+    self.assertEqual(datetime.datetime(1970, 1, 1, 0, 0), cert.expiration)
     self.assertEqual(1, cert.key_type)
     self.assertEqual(b'\x03' * 32, cert.key)
     self.assertEqual(b'\x01' * ED25519_SIGNATURE_LENGTH, cert.signature)
@@ -86,7 +86,7 @@ class TestEd25519Certificate(unittest.TestCase):
     self.assertEqual(1, cert.version)
     self.assertEqual(ED25519_CERT, cert.encoded)
     self.assertEqual(CertType.SIGNING, cert.type)
-    self.assertEqual(datetime.datetime(2015, 8, 28, 19, 0), cert.expiration)
+    self.assertEqual(datetime.datetime(2015, 8, 28, 17, 0), cert.expiration)
     self.assertEqual(1, cert.key_type)
     self.assertEqual(EXPECTED_CERT_KEY, cert.key)
     self.assertEqual([Ed25519Extension(type = 4, flags = [], flag_int = 0, data = EXPECTED_EXTENSION_DATA)], cert.extensions)
diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py
index 8af55c6..38dcdce 100644
--- a/test/unit/descriptor/server_descriptor.py
+++ b/test/unit/descriptor/server_descriptor.py
@@ -268,7 +268,7 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
 
     self.assertEqual(1, desc.certificate.version)
     self.assertEqual(CertType.SIGNING, desc.certificate.type)
-    self.assertEqual(datetime.datetime(2015, 8, 28, 19, 0, 0), desc.certificate.expiration)
+    self.assertEqual(datetime.datetime(2015, 8, 28, 17, 0, 0), desc.certificate.expiration)
     self.assertEqual(1, desc.certificate.key_type)
     self.assertTrue(desc.certificate.key.startswith('\xa5\xb6\x1a\x80D\x0f'))
     self.assertTrue(desc.certificate.signature.startswith('\xc6\x8e\xd3\xae\x0b'))





More information about the tor-commits mailing list