Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use TimeProvider instead of DateTime ambient context #2572

Open
alexmurari opened this issue Apr 26, 2024 · 0 comments · May be fixed by #2573
Open

Use TimeProvider instead of DateTime ambient context #2572

alexmurari opened this issue Apr 26, 2024 · 0 comments · May be fixed by #2573

Comments

@alexmurari
Copy link

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 tests, as there's no control of the current time whatsoever, rendering tests not deterministic.

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.

@alexmurari alexmurari linked a pull request Apr 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant