Currently, token lifetime validation is performed by getting the current time from a DateTime ambient context, as seen here.
(I know there's other places where DateTime is used to get the current time, this is just an example)
This leads to flaky, non-deterministic tests, as there's no control of the current time whatsoever.
With the introduction of TimeProvider in .NET 8, there's an out-of-the-box solution for abstracting time.
My proposal here is adopt TimeProvider instead of relying directly on static DateTime class.
Currently, token lifetime validation is performed by getting the current time from a DateTime ambient context, as seen here.
(I know there's other places where DateTime is used to get the current time, this is just an example)
This leads to flaky, non-deterministic tests, as there's no control of the current time whatsoever.
With the introduction of TimeProvider in .NET 8, there's an out-of-the-box solution for abstracting time.
My proposal here is adopt TimeProvider instead of relying directly on static DateTime class.