Skip to content

Commit be02455

Browse files
test: set the options in the session
1 parent 5322c74 commit be02455

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

spec/requests/devise/passkey_authentication_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def generate_assertion(fake_client, challenge:, credential:)
3333
describe "sign-in with passkeys" do
3434
let!(:passkey) { create_passkey_for(user, client) }
3535

36+
before do
37+
get account_passkey_authentication_options_path # To set the challenge in session
38+
end
39+
3640
it "completes authentication with valid credential" do
3741
get new_account_session_path
3842

spec/requests/devise/two_factor_authentication_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def generate_assertion(fake_client, challenge:, credential:)
4444

4545
expect(response).to have_http_status(:ok)
4646
expect(flash[:notice]).to eq(I18n.t("devise.failure.two_factor_required"))
47+
get account_security_key_authentication_options_path # To set the challenge in session
4748
expect(session[:current_authentication_resource_id]).to eq(user.id)
4849
expect(session[:two_factor_authentication_challenge]).not_to be_nil
4950

@@ -83,6 +84,7 @@ def generate_assertion(fake_client, challenge:, credential:)
8384

8485
expect(response).to have_http_status(:ok)
8586
expect(flash[:notice]).to include(I18n.t("devise.failure.two_factor_required"))
87+
get account_security_key_authentication_options_path # To set the challenge in session
8688
expect(session[:current_authentication_resource_id]).to eq(user.id)
8789
expect(session[:two_factor_authentication_challenge]).not_to be_nil
8890

@@ -112,6 +114,7 @@ def generate_assertion(fake_client, challenge:, credential:)
112114

113115
expect(response).to have_http_status(:ok)
114116
expect(flash[:notice]).to include(I18n.t("devise.failure.two_factor_required"))
117+
get account_security_key_authentication_options_path # To set the challenge in session
115118
expect(session[:current_authentication_resource_id]).to eq(user.id)
116119
expect(session[:two_factor_authentication_challenge]).not_to be_nil
117120

@@ -142,6 +145,7 @@ def generate_assertion(fake_client, challenge:, credential:)
142145

143146
expect(response).to have_http_status(:ok)
144147
expect(flash[:notice]).to include(I18n.t("devise.failure.two_factor_required"))
148+
get account_security_key_authentication_options_path # To set the challenge in session
145149
expect(session[:current_authentication_resource_id]).to eq(user.id)
146150
expect(session[:two_factor_authentication_challenge]).not_to be_nil
147151

@@ -169,6 +173,7 @@ def generate_assertion(fake_client, challenge:, credential:)
169173

170174
expect(response).to have_http_status(:ok)
171175
expect(flash[:notice]).to include(I18n.t("devise.failure.two_factor_required"))
176+
get account_security_key_authentication_options_path # To set the challenge in session
172177
expect(session[:current_authentication_resource_id]).to eq(user.id)
173178
expect(session[:two_factor_authentication_challenge]).not_to be_nil
174179

0 commit comments

Comments
 (0)