MCPcopy
hub / github.com/django/django / test_timestamp_signer

Method test_timestamp_signer

tests/signing/tests.py:229–244  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

227
228class TestTimestampSigner(SimpleTestCase):
229 def test_timestamp_signer(self):
230 value = "hello"
231 with freeze_time(123456789):
232 signer = signing.TimestampSigner(key="predictable-key")
233 ts = signer.sign(value)
234 self.assertNotEqual(ts, signing.Signer(key="predictable-key").sign(value))
235 self.assertEqual(signer.unsign(ts), value)
236
237 with freeze_time(123456800):
238 self.assertEqual(signer.unsign(ts, max_age=12), value)
239 # max_age parameter can also accept a datetime.timedelta object
240 self.assertEqual(
241 signer.unsign(ts, max_age=datetime.timedelta(seconds=11)), value
242 )
243 with self.assertRaises(signing.SignatureExpired):
244 signer.unsign(ts, max_age=10)
245
246
247class TestBase62(SimpleTestCase):

Callers

nothing calls this directly

Calls 4

signMethod · 0.95
unsignMethod · 0.95
freeze_timeFunction · 0.90
signMethod · 0.45

Tested by

no test coverage detected