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): adds hub events to updateUserAttributes api #10731

Merged
merged 14 commits into from Dec 7, 2022

Conversation

helgabalashova
Copy link
Contributor

@helgabalashova helgabalashova commented Dec 1, 2022

Description of changes

adds hub event to Auth.updateUserAttributes to determine if verification of the attribute is required. Feature requested by UI team. Decision to implement it using Hub events was made by Auth and UI team to avoid breaking change.

Issue #, if available

#9134

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

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

@helgabalashova helgabalashova requested a review from a team as a code owner December 1, 2022 23:10
packages/auth/src/Auth.ts Outdated Show resolved Hide resolved
packages/auth/src/Auth.ts Outdated Show resolved Hide resolved
packages/auth/src/Auth.ts Outdated Show resolved Hide resolved
packages/auth/src/Auth.ts Outdated Show resolved Hide resolved
packages/auth/src/Auth.ts Show resolved Hide resolved
packages/auth/src/Auth.ts Outdated Show resolved Hide resolved
@haverchuck haverchuck self-requested a review December 2, 2022 17:29
Copy link
Contributor

@haverchuck haverchuck left a comment

Choose a reason for hiding this comment

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

Can we create and/or update tests?

@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2022

Codecov Report

Merging #10731 (afb3950) into main (b4d2769) will increase coverage by 0.01%.
The diff coverage is 88.23%.

@@            Coverage Diff             @@
##             main   #10731      +/-   ##
==========================================
+ Coverage   86.14%   86.16%   +0.01%     
==========================================
  Files         196      196              
  Lines       18337    18351      +14     
  Branches     3902     3905       +3     
==========================================
+ Hits        15797    15812      +15     
+ Misses       2465     2464       -1     
  Partials       75       75              
Impacted Files Coverage Δ
...ages/amazon-cognito-identity-js/src/CognitoUser.js 79.18% <0.00%> (ø)
packages/auth/src/Auth.ts 87.36% <100.00%> (+0.23%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

AllanZhengYP
AllanZhengYP previously approved these changes Dec 5, 2022
Copy link
Contributor

@AllanZhengYP AllanZhengYP left a comment

Choose a reason for hiding this comment

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

Looks good to me! ⛴

…k, adds third parameter to callback of updateAttributes api
Copy link
Contributor

@elorzafe elorzafe left a comment

Choose a reason for hiding this comment

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

Can you add the change on the d.ts file because is a public facing API, I also have a nit comment.

Overall looks good.
Thanks @helgabalashova

packages/auth/src/Auth.ts Show resolved Hide resolved
packages/auth/src/Auth.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@elorzafe elorzafe left a comment

Choose a reason for hiding this comment

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

Check the d.ts file, I would create another type for updateUserAttribute callback

packages/amazon-cognito-identity-js/index.d.ts Outdated Show resolved Hide resolved
packages/auth/src/Auth.ts Show resolved Hide resolved
jimblanc
jimblanc previously approved these changes Dec 6, 2022
haverchuck
haverchuck previously approved these changes Dec 7, 2022
israx
israx previously approved these changes Dec 7, 2022
Copy link
Contributor

@israx israx left a comment

Choose a reason for hiding this comment

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

lgtm

packages/auth/src/Auth.ts Show resolved Hide resolved
packages/auth/src/Auth.ts Show resolved Hide resolved
Copy link
Contributor

@elorzafe elorzafe left a comment

Choose a reason for hiding this comment

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

Minor issue with Cognito unit test, with that fix I will approve it

Thanks @helgabalashova

Comment on lines 1672 to 1673
.mockImplementationOnce((attrs, callback) => {
callback(null, 'SUCCESS', codeDeliverDetailsResult);
Copy link
Contributor

Choose a reason for hiding this comment

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

This mock is not testing anything in particular, is just testing the mock. What you should do here is mock the cognito client instead. Like this https://github.com/aws-amplify/amplify-js/blob/main/packages/amazon-cognito-identity-js/__tests__/CognitoUser.test.js#L384

Copy link
Contributor

Choose a reason for hiding this comment

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

For testing there are no regressions for the version that has two arguments we need to have a TypeScript test that validates is not introducing a regression. I will approve the PR but before launching to latest we need the integ test in place

Comment on lines +1705 to +1707
const spyon = jest.spyOn(CognitoUser.prototype, 'updateAttributes')
.mockImplementationOnce((attrs, callback) => {
callback(null, 'SUCCESS', codeDeliverDetailsResult);
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 the other, this is testing the mock not the actual code look on this one
https://github.com/aws-amplify/amplify-js/blob/main/packages/amazon-cognito-identity-js/__tests__/CognitoUser.test.js#L384

@@ -2,6 +2,7 @@ declare module 'amazon-cognito-identity-js' {
//import * as AWS from "aws-sdk";

export type NodeCallback<E, T> = (err?: E, result?: T) => void;
export type UpdateAttributesNodeCallback<E, T, K> = (err?: E, result?: T, details?: K) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

nice

elorzafe
elorzafe previously approved these changes Dec 7, 2022
Copy link
Contributor

@elorzafe elorzafe left a comment

Choose a reason for hiding this comment

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

Add the integ test to validate the 2 and 3 version arguments before launching this to latest

@elorzafe
Copy link
Contributor

elorzafe commented Dec 7, 2022

The commit message should be

feat(@aws-amplify/auth,amazon-cognito-identity-js): return code delivery details for updateUserAttributes on Hub event

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.

None yet

7 participants