-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add request specs for authentication flows #91
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
Add request specs for authentication flows #91
Conversation
…ations` offenses
| challenge = WebAuthn.configuration.encoder.encode(SecureRandom.random_bytes(32)) | ||
| raw_credential = fake_client.create(challenge: challenge) | ||
| webauthn_credential = WebAuthn::Credential.from_create(raw_credential) | ||
| webauthn_credential.verify(challenge) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it really make sense to verify the credential if it's just for test setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah my bad. It's not needed at all 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed it in c9dda01 -> ✅
|
|
||
| raw_credential = fake_client.create(challenge: creation_options.challenge) | ||
| webauthn_credential = WebAuthn::Credential.from_create(raw_credential) | ||
| webauthn_credential.verify(creation_options.challenge) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here.
| end | ||
| end | ||
|
|
||
| describe "sign-in without 2FA" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe reflect something like "sign in with a user with 2FA disabled"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like it!
Updated in d1a25e9 -> ✅
brauliomartinezlm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
| # This configuration was generated by | ||
| # `rubocop --auto-gen-config` | ||
| # on 2026-01-02 20:36:46 UTC using RuboCop version 1.79.1. | ||
| # The point is for the user to remove these configuration records | ||
| # one by one as the offenses are removed from the code base. | ||
| # Note that changes in the inspected code, or installation of new | ||
| # versions of RuboCop, may require this file to be generated again. | ||
|
|
||
| # Offense count: 1 | ||
| # Configuration parameters: Max, CountAsOne. | ||
| RSpec/ExampleLength: | ||
| Exclude: | ||
| - 'spec/requests/devise/two_factor_authentication_spec.rb' | ||
|
|
||
| # Offense count: 9 | ||
| # Configuration parameters: Max. | ||
| RSpec/MultipleExpectations: | ||
| Exclude: | ||
| - 'spec/requests/devise/passkey_authentication_spec.rb' | ||
| - 'spec/requests/devise/two_factor_authentication_spec.rb' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we disable these cops instead of creating a rubocop_todo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was planning on disabling them after this PR so that's why I added them to this file
Motivation
Right now we don't have specific tests for our strategies apart from our system tests, which because of its nature don't really cover all the edge cases. This is leading to weird behaviors such as the one described in #88.
The goal of this PR is to add request specs to test the different authentication flows, which the different edge case, in order to try to test all the strategies and how they work together.
This could in term allow us to stop relying too much in our system tests which have been behaving a little bit flaky.
Details
This PR adds two request specs:
spec/requests/devise/passkey_authentication_spec.rb(for testing authentication with passkeys) andspec/requests/devise/two_factor_authentication_spec.rb(for testing authentication with email/password and 2FA).