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

Don't always test string claims for Date Time #2622

Merged
merged 4 commits into from
Jun 13, 2024

Conversation

keegan-caruso
Copy link
Contributor

Don't always test string claims for Date Time

Description

Cannot remove APIs in in these internal methods as they are friends

There are serveral claim types that should never
be a datetime value. This changes introduces
a list of claim types that will not be tested if they are a Date Time format.
This list of claim types is not exhaustive.

Added test data for a test token with more claims
and a benchmark using this data.

Benchmark results:

BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3593/23H2/2023Update/SunValley3) (Hyper-V)
Intel Xeon Platinum 8370C CPU 2.80GHz, 1 CPU, 16 logical and 8 physical cores
.NET SDK 8.0.301
[Host] : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
MediumRun : .NET 8.0.6 (8.0.624.26715), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI

Job=MediumRun MaxAbsoluteError=10.0000 ms IterationCount=15
LaunchCount=4 WarmupCount=10

Method Mean Error StdDev P90 P95 P100 Ratio RatioSD Gen0 Allocated Alloc Ratio
JsonWebTokenHandler_ValidateTokenAsync_CreateClaims 45.71 us 0.565 us 1.227 us 47.23 us 47.35 us 47.46 us 1.10 0.03 0.6104 17.63 KB 1.04
JsonWebTokenHandler_ValidateTokenAsync_CreateClaims_WithOptimizations 41.50 us 0.195 us 0.416 us 42.06 us 42.14 us 42.72 us 1.00 0.00 0.6104 16.88 KB 1.00

Fixes #2615

Cannot remove APIs in in these internal methods as they are friends

There are serveral claim types that should never
be a datetime value. This changes introduces
a list of claim types that will not be tested if they
are a Date Time format. This list of claim types is
not exhaustive.

Added test data for a test token with more claims
and a benchmark using this data.
@keegan-caruso keegan-caruso requested a review from a team as a code owner June 2, 2024 03:26
Copy link
Member

@brentschmaltz brentschmaltz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking to add the additional header claim values.

@brentschmaltz brentschmaltz self-requested a review June 11, 2024 22:05
@jennyf19 jennyf19 added this to the 7.6.1 milestone Jun 12, 2024
- Reorder params in new methods
- Rename KnownNonDateTimesClaimTypes to s_knownNonDateTimeClaimTypes
@keegan-caruso keegan-caruso merged commit cb49356 into dev Jun 13, 2024
6 checks passed
@keegan-caruso keegan-caruso deleted the kecaruso/dont-always-try-datetime branch June 13, 2024 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Evaluate usage of DateTime.TryParse for performance
5 participants