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

feat(auth): add options to resendSignUpCode #1422

Merged

Conversation

Jordan-Nelson
Copy link
Member

Issue #, if available: n/a

Description of changes:

  • Add ResendSignUpCodeOptions/AWSCognitoResendSignUpCodeOptions to enable passing metadata in resendSignUpCode()

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Jordan-Nelson Jordan-Nelson requested a review from a team July 21, 2021 20:27
@Jordan-Nelson Jordan-Nelson changed the title feat(auth): add resend signup code options + metadata feat(auth): add options to resendSignUpCode Jul 23, 2021
@frimfram
Copy link
Contributor

Can you please elaborate on what type of testings you have done so that this PR does not introduce regressions? I see some unit tests are done but we are looking for more testing.

@Jordan-Nelson
Copy link
Member Author

Hi @frimfram - For context, I am adding this for use in amplify-flutter.

I have tested an end to end resend sign up code flow from a flutter app with the changes in aws-amplify/amplify-flutter#738 and confirmed that I can see the metadata in a lambda trigger.

If there is something specific you are looking for from a testing perspective, please let me know.

@frimfram
Copy link
Contributor

Please make sure to test edge cases. These are some:

  • Backend error handling (list all possible error cases and test each)
  • Client error such as the phone having no network or slow network.
  • some other edge cases

@Jordan-Nelson
Copy link
Member Author

@frimfram - I have tested the following edge cases. I first tested them with amplify android version 1.21.0 to verify the existing behavior and then tested the same scenarios against this PR (with default options and with options + metadata).

If there are other scenarios you would like to see tested, please let me know.

Scenario Expected Result (based on v1.21.0 behavior) PR w/o metadata PR w/ metadata
No Network AuthException, cause = Unable to execute HTTP request
Non-existent Username UserNotFoundException
No Username InvalidParameterException
Already confirmed user InvalidParameterException
5+ Attempts in a row LimitExceededException
Failure in lambda trigger AuthException, cause = UserLambdaValidationException

@@ -350,10 +352,17 @@ public void confirmSignUp(
@Override
public void resendSignUpCode(
@NonNull String username,
@NonNull AuthResendSignUpCodeOptions options,
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it possible to introduce another overloaded function instead of inserting new NonNull param in a public function? If someone was calling this function, then they would also need to change as a result of this change. For public SDK's it's best to minimize breaking changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

This PR does introduce a new overloaded function. The diff here is a possibly a little misleading since it shows resendSignUpCode being modified. resendSignUpCode definied on like 381 below has the same method signature as before, and it calls this newly added method with a default option. This will not be a breaking change.

Comment on lines -93 to +99
suspend fun resendSignUpCode(username: String): AuthSignUpResult
suspend fun resendSignUpCode(
username: String,
options: AuthResendSignUpCodeOptions = AuthResendSignUpCodeOptions.defaults()
): AuthSignUpResult
Copy link
Contributor

Choose a reason for hiding this comment

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

Same concern as the above - can you think of a way to introduce this in a backward compatible way?

Copy link
Member Author

Choose a reason for hiding this comment

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

The newly added parameter has a default option. This is backwards compatible.

@frimfram frimfram self-requested a review July 29, 2021 20:01
@raphkim raphkim merged commit 3386b21 into aws-amplify:main Aug 2, 2021
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.

4 participants