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

Fix Date-Time Parsing in GetDurationFromNowInSeconds for Multiple Formats #4964

Merged
merged 5 commits into from
Oct 22, 2024

Conversation

gladjohn
Copy link
Contributor

@gladjohn gladjohn commented Oct 21, 2024

Fixes #4963

Changes proposed in this request
This PR add a new GetDurationFromNowInSeconds specific to MI in MSAL to handle multiple date-time formats while calculating the duration from now. Specifically, the fix:

  • Adds support for Unix timestamps, ISO 8601 and other common date-time formats.
  • Adds improved error handling for unsupported or invalid date formats by throwing an MsalClientException.
  • Ensures that fallback logic only throws an exception after attempting valid date-time parsing strategies.

Testing

  • Added additional test cases to validate handling of various date-time formats including Unix timestamps, ISO 8601, and common date-time formats (MM/dd/yyyy HH:mm:ss, yyyy-MM-dd HH:mm:ss).
  • Added a test case for invalid date-time formats to ensure that the method throws an MsalClientException for malformed input.
  • Extended the Managed Identity tests as well

Performance impact
None

Documentation

  • All relevant documentation is updated.

@gladjohn gladjohn requested a review from a team as a code owner October 21, 2024 16:36
Copy link
Member

@bgavrilMS bgavrilMS left a comment

Choose a reason for hiding this comment

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

The unit test doesn't seem ok.

Copy link
Member

@bgavrilMS bgavrilMS left a comment

Choose a reason for hiding this comment

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

Not fixed.

@gladjohn gladjohn merged commit afb2fa9 into main Oct 22, 2024
5 checks passed
@gladjohn gladjohn deleted the gladjohn/expires_on_fix branch October 22, 2024 14:44
@bgavrilMS
Copy link
Member

@gladjohn - was this bug fixed in all other MSALs?

@gladjohn
Copy link
Contributor Author

gladjohn commented Jan 2, 2025

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] ExpiresOn can be in a different format in MSI
3 participants