From ddc023080da56f4cf850b49c356094caae9637a7 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Tue, 6 Oct 2026 00:11:43 +0100 Subject: [PATCH] Test the stated span with a key that covers now The test that checks a recent minute is served from a span the creator stated read the clock, whilst the stand in end point it used answers for no moment after 14 September 2026. From 21 September 2026 the end point therefore answered with a key whose span did not hold the minutes asked about, each one was fetched, and the test failed with three requests where it expects one. The creator in the test now states one key for the day either side of now, as the .NET test does, so the test no longer depends on the dates in the fixture schedule and keeps checking after the last key in the fixture has started. --- tests/test_public_key_fetch.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/tests/test_public_key_fetch.py b/tests/test_public_key_fetch.py index c176ad1..967c521 100644 --- a/tests/test_public_key_fetch.py +++ b/tests/test_public_key_fetch.py @@ -576,12 +576,25 @@ async def test_a_recent_minute_is_served_where_the_creator_stated_the_span(self) """The drift allowance, which keeps minutes near now out of a cache built from confirmed minutes, does not apply to a span the creator stated itself, so live identifiers cost one request per key rather - than one per minute.""" - end_point = self.end_point() - now = datetime.now(timezone.utc) - current = key_fixtures.schedule().key_in_force(now) - if current is None or key_fixtures.schedule().next_start_after(current) is None: - self.skipTest("the fixture schedule has no key after the one in force now") + than one per minute. + + The minutes asked about are read from the clock, and the stand in end + point answers from the schedule for no moment after its + REQUEST_MOMENT, so the creator here states one key for the day either + side of now instead.""" + now = datetime.now(timezone.utc).replace(second=0, microsecond=0) + day = timedelta(days=1) + pem = key_fixtures.schedule().keys[0].public_key_pem + stated = endpoints.public_key_answer(pem, now - day, now + day, None) + + class OneKey(KeyEndPoint): + def body( + self, date: Optional[str], format: Optional[str] + ) -> Optional[str]: + return stated + + end_point = OneKey() + self.started.append(end_point) await self._pem_at(end_point, now - timedelta(minutes=1)) await self._pem_at(end_point, now) await self._pem_at(end_point, now - timedelta(minutes=10))