Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #5156 - User login flow is interrupted when two-factor authenti…
…cation method security keys is used.
- Loading branch information
Showing
2 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
39 changes: 39 additions & 0 deletions
39
spec/lib/auth/two_factor/authentication_method/security_keys_spec.rb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ | ||
|
||
require 'rails_helper' | ||
require 'rotp' | ||
|
||
RSpec.describe Auth::TwoFactor::AuthenticationMethod::SecurityKeys do | ||
subject(:instance) { described_class.new(user) } | ||
|
||
let(:user) { create(:user) } | ||
|
||
shared_examples 'responding to provided instance method' do |method| | ||
it "responds to '.#{method}'" do | ||
expect(instance).to respond_to(method) | ||
end | ||
end | ||
|
||
it_behaves_like 'responding to provided instance method', :verify | ||
it_behaves_like 'responding to provided instance method', :initiate_configuration | ||
|
||
describe '#initiate_configuration' do | ||
it 'does not require user verification (#5156)' do | ||
expect(instance.initiate_configuration.authenticator_selection).to include(user_verification: 'discouraged') | ||
end | ||
end | ||
|
||
describe '#initiate_authentication' do | ||
let(:two_factor_pref) { create(:user_two_factor_preference, :security_keys, user: user) } | ||
|
||
before do | ||
two_factor_pref | ||
allow(WebAuthn::Credential).to receive(:options_for_get).with(any_args) | ||
instance.initiate_authentication | ||
end | ||
|
||
it 'does not require user verification (#5156)' do | ||
expect(WebAuthn::Credential).to have_received(:options_for_get).with(include(user_verification: 'discouraged')) | ||
end | ||
end | ||
end |