mozilla-services / python-autograph-utils

A library to simplify use of Autograph
Other
5 stars 4 forks source link

Fix deprecated call to `utcnow()` #51

Closed leplatrem closed 1 month ago

leplatrem commented 1 month ago

Without this, the _now() returns a datetime without timezone, and breaks in the real world: https://github.com/mozilla-services/telescope/pull/1493 and https://github.com/mozilla/remote-settings/pull/667

The tests don't catch this because they mock _now() :/

leplatrem commented 1 month ago

Not sure if this needs to be a "fast merge" (e.g. if something is broken)

Only current 1.0 version is broken, no running service

_now() in some way so that this kind of thing won't happen again. We seemed to treat a symptom and not a cause.

I know exactly what you mean. I thought of doing like this in the tests but didn't find it very elegant either:

from autograph_utils import _now

def test_now_is_timezone_aware():
    assert _now() > datetime.datetime(2024, 9, 26, tzinfo=timezone.utc)

But I could also add a test that check for expiration without using the fixed_now fixture.