Skip to content

LG-11454: Improve robustness of WebAuthn controller specs#9783

Merged
aduth merged 2 commits intomainfrom
aduth-lg-11454-webauthn-edit-specs
Dec 18, 2023
Merged

LG-11454: Improve robustness of WebAuthn controller specs#9783
aduth merged 2 commits intomainfrom
aduth-lg-11454-webauthn-edit-specs

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Dec 18, 2023

🎫 Ticket

Relates to LG-11454 (originally #9674, #9742)

🛠 Summary of changes

Adds additional test cases for the WebAuthn controllers implemented in #9742 to verify expected behaviors around checking ownership of the configuration.

Some of this was originally intended to be covered by the associated form's specs, with existing coverage for an "invalid" submission scenario being sufficient coverage for the controller's behaviors. However, there are additional controller-specific behaviors not previously covered (e.g. WebauthnController#validate_configuration_exists).

These behaviors worked as intended, but additional test cases could help prevent future regressions.

📜 Testing Plan

Verify tests pass:

  1. rspec spec/controllers/users/webauthn_controller_spec.rb spec/controllers/api/internal/two_factor_authentication/webauthn_controller_spec.rb

changelog: User-Facing Improvements, Face or Touch Unlock, Add option to rename face or touch unlock in account dashboard
@aduth aduth requested a review from a team December 18, 2023 15:23
@aduth aduth changed the title LG-11454: Improve robustness of WebauthnController#edit specs LG-11454: Improve robustness of WebAuthn controller specs Dec 18, 2023
success: false,
error: t('errors.manage_authenticator.internal_error'),
)
expect(response.status).to eq(400)
Copy link
Contributor

Choose a reason for hiding this comment

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

in other apps I've considered these 404's? 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in other apps I've considered these 404's? 🤷

That's a good point. This feels partly like a limitation of the FormResponse pattern we're using, since there's not a built-in way for an added error to signal that it should trigger a specific HTTP status code.

A couple options could be:

Copy link
Contributor

Choose a reason for hiding this comment

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

its probably not worth all that for this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'll merge this as-is, but I'd be motivated to try to find a solution to the problem described above, since it's likely we'd continue to run into it if we build more JSON API controllers.

@aduth aduth merged commit 66f194a into main Dec 18, 2023
@aduth aduth deleted the aduth-lg-11454-webauthn-edit-specs branch December 18, 2023 18:36
@jmdembe jmdembe mentioned this pull request Dec 19, 2023
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