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 Locale.US for Android #238

Merged
merged 3 commits into from
May 25, 2023
Merged

Conversation

Mecharyry
Copy link
Contributor

@Mecharyry Mecharyry commented Apr 11, 2023

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

📋 Changes

Offering as an alternative to #206.

This aligns how Android and iOS parse dates. iOS is already formatting dates to ISO8601String by directly taking the expiresAt property, without modification. Android on the other hand is modifying this expiresAt by allowing it to be localised to whatever the systems getDefaultLocale is.

To solve the issues we have seen with ar this ensures that all dates are using a consistent Locale of Locale.US. The test added credentials_test is used just to illustrate the breaking change is used to illustrate the issue with Arabic vs US English, but is actually fixed at the native level.

📎 References

No references.

🎯 Testing

Put your device into Arabic and attempt to use this library to log in. You'll notice that it works in this MR but doesn't on main

@Mecharyry Mecharyry requested a review from a team as a code owner April 11, 2023 15:55
@stevehobbsdev
Copy link
Contributor

Thankss @Mecharyry - can you elaborate on the breaking change? Does it introduce one?

@Mecharyry
Copy link
Contributor Author

Thankss @Mecharyry - can you elaborate on the breaking change? Does it introduce one?

Sorry I goofed when writing the description. I meant to write that the test class illustrates why parsing an Arabic specific date time breaks vs a US one. I've updated the description.

@poovamraj
Copy link
Contributor

@stevehobbsdev I'd prefer this solution as well over the other. LGTM 👍

@@ -55,7 +55,7 @@ class LoginApiRequestHandler : ApiRequestHandler {
override fun onSuccess(credentials: Credentials) {
val scope = credentials.scope?.split(" ") ?: listOf()
val sdf =
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault())
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' as that is the one used in Android and iOS.

@@ -43,7 +43,7 @@ class LoginWithOtpApiRequestHandler: ApiRequestHandler {
override fun onSuccess(credentials: Credentials) {
val scope = credentials.scope?.split(" ") ?: listOf()
val sdf =
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault())
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.US)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above for all the format strings

@codecov
Copy link

codecov bot commented May 12, 2023

Codecov Report

Patch coverage: 97.36% and project coverage change: -0.08 ⚠️

Comparison is base (4fd061e) 98.74% compared to head (ead54f2) 98.67%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #238      +/-   ##
============================================
- Coverage     98.74%   98.67%   -0.08%     
- Complexity       82       85       +3     
============================================
  Files            80       85       +5     
  Lines          1439     1506      +67     
  Branches        320      331      +11     
============================================
+ Hits           1421     1486      +65     
- Misses            6        7       +1     
- Partials         12       13       +1     
Flag Coverage Δ
auth0_flutter 100.00% <100.00%> (ø)
auth0_flutter_android 96.74% <100.00%> (+0.14%) ⬆️
auth0_flutter_ios 99.84% <96.29%> (-0.16%) ⬇️
auth0_flutter_platform_interface 99.00% <94.44%> (-0.29%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...auth0_flutter/AuthenticationExceptionExtensions.kt 100.00% <ø> (ø)
...ses/AuthAPI/AuthAPILoginWithOTPMethodHandler.swift 100.00% <ø> (ø)
auth0_flutter/lib/auth0_flutter.dart 100.00% <ø> (ø)
...0_flutter/ios/Classes/AuthAPI/AuthAPIHandler.swift 97.67% <50.00%> (-2.33%) ⬇️
...latform_interface/lib/src/auth/challenge_type.dart 75.00% <75.00%> (ø)
...tlin/com/auth0/auth0_flutter/Auth0FlutterPlugin.kt 72.22% <100.00%> (+0.79%) ⬆️
...ter/request_handlers/api/LoginApiRequestHandler.kt 97.22% <100.00%> (ø)
...uest_handlers/api/LoginWithOtpApiRequestHandler.kt 96.55% <100.00%> (ø)
...dlers/api/MultifactorChallengeApiRequestHandler.kt 100.00% <100.00%> (ø)
...ter/request_handlers/api/RenewApiRequestHandler.kt 96.66% <100.00%> (ø)
... and 9 more

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Mecharyry
Copy link
Contributor Author

@poovamraj Sorry for the delay, I've made the requested changes!

@stevehobbsdev stevehobbsdev mentioned this pull request May 17, 2023
6 tasks
@Mecharyry
Copy link
Contributor Author

@poovamraj @stevehobbsdev Can I get some eyes on this? It would be great to merge this so I can stop maintaining a fork 😄

@Mecharyry Mecharyry requested a review from poovamraj May 18, 2023 09:50
@stevehobbsdev
Copy link
Contributor

@Mecharyry Thanks for your patience here. We're gearing up for a new release that includes web support, this PR will be included along with that work. We're aiming for that release within the next week or so.

@stevehobbsdev stevehobbsdev linked an issue May 25, 2023 that may be closed by this pull request
6 tasks
Copy link
Contributor

@poovamraj poovamraj left a comment

Choose a reason for hiding this comment

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

Checked the repo for use of Locale.getDefault(). Looks fine to me +1

@stevehobbsdev stevehobbsdev merged commit e8be71e into auth0:main May 25, 2023
This was referenced May 25, 2023
@stevehobbsdev
Copy link
Contributor

@Mecharyry FYI This has been included in v1.2.0-beta.1, we're expecting this to come out of beta next week 👍🏻

Thanks again for your contrubution!

This was referenced May 31, 2023
@Widcket Widcket mentioned this pull request Oct 12, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Invalid date format" bug
4 participants