Skip to content

Commit c59db91

Browse files
committed
tests: patch localtime in the "cert remainingdays" test
to make sure the code where the invalid timezone is passed to exercise the localtime code path doesn't fail as time goes by. The other test was added to exercise the code path where the second format is passed.
1 parent 2b220b9 commit c59db91

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/scapy/layers/tls/cert.uts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,13 @@ x.notAfter == (2026, 3, 30, 7, 38, 59, 0, 89, -1)
329329

330330
= Cert class : test remainingDays
331331
assert abs(x.remainingDays("02/12/11")) > 5000
332-
assert abs(x.remainingDays("Feb 12 10:00:00 2011 Paris, Madrid")) > 1
332+
assert abs(x.remainingDays("Feb 12 10:00:00 2011 UTC")) > 5000
333+
334+
from unittest.mock import patch
335+
import time
336+
337+
with patch('time.localtime', return_value=time.struct_time((2026, 3, 29, 7, 38, 58, 6, 88, 0))):
338+
assert abs(x.remainingDays("Feb 12 10:00:00 2011 Paris, Madrid")) > 1
333339

334340
= Cert class : Checking RSA public key
335341
assert type(x.pubkey) is PubKeyRSA
@@ -1104,4 +1110,4 @@ assert [x.buffer for x in aikOpaque.policyDigestList.digests] == [
11041110
b'\xc4\x13\xa8G\xb1\x11\x12\xb1\xcb\xdd\xd4\xec\xa4\xda\xaa\x15\xa1\x85,\x1c;\xbaWF\x1d%v\x05\xf3\xd5\xafS',
11051111
b'',
11061112
b'\x04\x8e\x9a:\xce\x08X?y\xf3D\xffx[\xbe\xa9\xf0z\xc7\xfa3%\xb3\xd4\x9a!\xddQ\x94\xc6XP',
1107-
]
1113+
]

0 commit comments

Comments
 (0)