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

[4/X] [DXCDT-175] Add recovery code to guardian resource and refactor #216

Merged
merged 7 commits into from
Jul 7, 2022

Conversation

sergiught
Copy link
Contributor

@sergiught sergiught commented Jul 5, 2022

Description

Add recovery code to guardian resource and refactor.

Checklist

Note: Checklist required to be completed before a PR is considered to be reviewable.

Auth0 Code of Conduct

Auth0 General Contribution Guidelines

Changes include test coverage?

  • Yes
  • Not needed

Does the description provide the correct amount of context?

  • Yes, the description provides enough context for the reviewer to understand what these changes accomplish

Have you updated the documentation?

  • Yes, I've updated the appropriate docs
  • Not needed

Is this code ready for production?

  • Yes, all code changes are intentional and no debugging calls are left over

@sergiught sergiught self-assigned this Jul 5, 2022
@sergiught sergiught changed the base branch from feature/DXCDT-175-guardian++part1 to feature/DXCDT-175-guardian++-part3 July 5, 2022 20:00
@sergiught sergiught force-pushed the feature/DXCDT-175-guardian++-part3 branch from 82ac5fb to dc34f25 Compare July 6, 2022 13:41
@sergiught sergiught force-pushed the feature/DXCDT-175-guardian-final-refactor branch from 6bdbca8 to 393aaaa Compare July 6, 2022 13:44
@sergiught sergiught marked this pull request as ready for review July 6, 2022 13:45
@sergiught sergiught requested a review from a team as a code owner July 6, 2022 13:45
@sergiught sergiught requested a review from Widcket July 6, 2022 13:46
@sergiught sergiught marked this pull request as draft July 6, 2022 13:47
@sergiught sergiught removed request for a team and Widcket July 6, 2022 13:47
@sergiught sergiught force-pushed the feature/DXCDT-175-guardian-final-refactor branch from 393aaaa to abf36b2 Compare July 6, 2022 16:37
@codecov-commenter
Copy link

Codecov Report

Merging #216 (abf36b2) into feature/DXCDT-175-guardian++-part3 (dc34f25) will increase coverage by 0.54%.
The diff coverage is 89.58%.

@@                          Coverage Diff                           @@
##           feature/DXCDT-175-guardian++-part3     #216      +/-   ##
======================================================================
+ Coverage                               82.98%   83.52%   +0.54%     
======================================================================
  Files                                      36       36              
  Lines                                    6541     6537       -4     
======================================================================
+ Hits                                     5428     5460      +32     
+ Misses                                    882      858      -24     
+ Partials                                  231      219      -12     
Impacted Files Coverage Δ
auth0/structure_auth0_guardian.go 64.41% <81.25%> (+0.83%) ⬆️
auth0/resource_auth0_guardian.go 90.46% <93.75%> (+10.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc34f25...abf36b2. Read the comment docs.

@@ -37,7 +37,6 @@ func newGuardian() *schema.Resource {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
MinItems: 0,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This gets ignored completely if optional is true.

Comment on lines -265 to +268
multiFactorPolicies, err := api.Guardian.MultiFactor.Policy()
flattenedPolicy, err := flattenMultiFactorPolicy(api)
if err != nil {
return diag.FromErr(err)
}

result := multierror.Append(d.Set("policy", "never"))
if len(*multiFactorPolicies) > 0 {
result = multierror.Append(result, d.Set("policy", (*multiFactorPolicies)[0]))
}
result := multierror.Append(d.Set("policy", flattenedPolicy))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracting this logic somewhere else so it's easier to read through the readGuardian steps.

Comment on lines +347 to +357
result := multierror.Append(
updatePolicy(d, api),
updateEmailFactor(d, api),
updateOTPFactor(d, api),
updateRecoveryCodeFactor(d, api),
updatePhoneFactor(d, api),
updateWebAuthnRoaming(d, api),
updateWebAuthnPlatform(d, api),
updateDUO(d, api),
updatePush(d, api),
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's better if we try al of these updates and report on any accumulated errors instead of failing at the first and not doing any of the others.

Comment on lines +368 to +376
result := multierror.Append(
api.Guardian.MultiFactor.Phone.Enable(false),
api.Guardian.MultiFactor.Email.Enable(false),
api.Guardian.MultiFactor.OTP.Enable(false),
api.Guardian.MultiFactor.RecoveryCode.Enable(false),
api.Guardian.MultiFactor.WebAuthnRoaming.Enable(false),
api.Guardian.MultiFactor.WebAuthnPlatform.Enable(false),
api.Guardian.MultiFactor.DUO.Enable(false),
api.Guardian.MultiFactor.Push.Enable(false),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's better if we try al of these updates and report on any accumulated errors instead of failing at the first and not doing any of the others.

Comment on lines +61 to +68
resource.TestCheckResourceAttr("auth0_guardian.foo", "email", "true"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "otp", "false"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "phone.#", "0"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "duo.#", "0"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "webauthn_platform.#", "0"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "webauthn_roaming.#", "0"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "push.#", "0"),
resource.TestCheckResourceAttr("auth0_guardian.foo", "recovery_code", "false"),
Copy link
Contributor Author

@sergiught sergiught Jul 6, 2022

Choose a reason for hiding this comment

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

We're splitting the 1 big test into multiple ones that focus on distinct MFA types. Also we're now checking the full state for all the possible parameters for a thorough inspection.

@sergiught sergiught marked this pull request as ready for review July 6, 2022 16:42
Base automatically changed from feature/DXCDT-175-guardian++-part3 to main July 7, 2022 07:51
@sergiught sergiught merged commit 2702f6e into main Jul 7, 2022
@sergiught sergiught deleted the feature/DXCDT-175-guardian-final-refactor branch July 7, 2022 07:52
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.

3 participants