From 144112be3bddb17aa91e936dffd1337f41298123 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Sun, 29 Mar 2026 10:16:25 +0000 Subject: [PATCH] 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. --- test/scapy/layers/tls/cert.uts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/scapy/layers/tls/cert.uts b/test/scapy/layers/tls/cert.uts index 35a8d050059..cb3b363397e 100644 --- a/test/scapy/layers/tls/cert.uts +++ b/test/scapy/layers/tls/cert.uts @@ -329,7 +329,13 @@ x.notAfter == (2026, 3, 30, 7, 38, 59, 0, 89, -1) = Cert class : test remainingDays assert abs(x.remainingDays("02/12/11")) > 5000 -assert abs(x.remainingDays("Feb 12 10:00:00 2011 Paris, Madrid")) > 1 +assert abs(x.remainingDays("Feb 12 10:00:00 2011 UTC")) > 5000 + +from unittest.mock import patch +import time + +with patch('time.localtime', return_value=time.struct_time((2026, 3, 1, 0, 0, 0, 6, 60, 0))): + assert abs(x.remainingDays("Feb 12 10:00:00 2011 Paris, Madrid")) > 1 = Cert class : Checking RSA public key assert type(x.pubkey) is PubKeyRSA @@ -1104,4 +1110,4 @@ assert [x.buffer for x in aikOpaque.policyDigestList.digests] == [ 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', b'', b'\x04\x8e\x9a:\xce\x08X?y\xf3D\xffx[\xbe\xa9\xf0z\xc7\xfa3%\xb3\xd4\x9a!\xddQ\x94\xc6XP', -] \ No newline at end of file +]