LG-11454: Improve robustness of WebAuthn controller specs#9783
Merged
Conversation
changelog: User-Facing Improvements, Face or Touch Unlock, Add option to rename face or touch unlock in account dashboard
zachmargolis
approved these changes
Dec 18, 2023
| success: false, | ||
| error: t('errors.manage_authenticator.internal_error'), | ||
| ) | ||
| expect(response.status).to eq(400) |
Contributor
There was a problem hiding this comment.
in other apps I've considered these 404's? 🤷
Contributor
Author
There was a problem hiding this comment.
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:
- Validate this in the controller, similar to what we're already doing with the fallback no-JavaScript controller
- Invent a custom
optionsvalue which represents the expected status code, e.g.errors.add(..., http_status: 404)
Contributor
There was a problem hiding this comment.
its probably not worth all that for this PR
Contributor
Author
There was a problem hiding this comment.
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.
jmdembe
approved these changes
Dec 18, 2023
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎫 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:
rspec spec/controllers/users/webauthn_controller_spec.rb spec/controllers/api/internal/two_factor_authentication/webauthn_controller_spec.rb