Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion knapsack_rspec_report.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
"spec/features/phone/confirmation_spec.rb": 202.880041808,
"spec/features/phone/default_phone_selection_spec.rb": 33.68962708,
"spec/features/phone/edit_phone_spec.rb": 21.15221282,
"spec/features/phone/rate_limitting_spec.rb": 93.738608051,
"spec/features/phone/rate_limiting_spec.rb": 93.738608051,
"spec/features/phone/remove_phone_spec.rb": 12.755412848,
"spec/features/remember_device/cookie_expiration_spec.rb": 6.613393484,
"spec/features/remember_device/phone_spec.rb": 58.912246182000004,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'rails_helper'

RSpec.describe 'phone rate limitting', allowed_extra_analytics: [:*] do
RSpec.describe 'phone rate limiting', allowed_extra_analytics: [:*] do
let(:phone) { '2025551234' }

context 'on sign up' do
let!(:user) { sign_up_and_set_password }

it_behaves_like 'phone rate limitting', :sms
it_behaves_like 'phone rate limitting', :voice
it_behaves_like 'phone rate limiting', :sms
it_behaves_like 'phone rate limiting', :voice

def visit_otp_confirmation(delivery_method)
select_2fa_option(:phone)
Expand All @@ -20,8 +20,8 @@ def visit_otp_confirmation(delivery_method)
context 'on add phone' do
let(:user) { create(:user, :fully_registered) }

it_behaves_like 'phone rate limitting', :sms
it_behaves_like 'phone rate limitting', :voice
it_behaves_like 'phone rate limiting', :sms
it_behaves_like 'phone rate limiting', :voice

def visit_otp_confirmation(delivery_method)
sign_in_live_with_2fa(user)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.shared_examples 'phone rate limitting' do |delivery_method|
RSpec.shared_examples 'phone rate limiting' do |delivery_method|
let(:max_confirmation_attempts) { 4 }
let(:max_otp_sends) { 2 }
let(:min_attempts) { 2 }
Expand All @@ -20,7 +20,7 @@

expect(page).to have_content(t('two_factor_authentication.max_otp_requests_reached'))
expect_user_to_be_rate_limitted
expect_rate_limitting_to_expire
expect_rate_limiting_to_expire
end

it 'limits the number of times a code can be sent to a phone across accounts' do
Expand All @@ -40,7 +40,7 @@
expect(page).to have_content(t('two_factor_authentication.max_otp_requests_reached'))

expect_user_to_be_rate_limitted
expect_rate_limitting_to_expire
expect_rate_limiting_to_expire
end

it 'limits the number of times the user can enter an OTP' do
Expand Down Expand Up @@ -78,7 +78,7 @@

expect(page).to have_content(t('two_factor_authentication.max_otp_login_attempts_reached'))
expect_user_to_be_rate_limitted
expect_rate_limitting_to_expire
expect_rate_limiting_to_expire
end

def expect_user_to_be_rate_limitted
Expand All @@ -94,7 +94,7 @@ def expect_user_to_be_rate_limitted
expect(page).to have_content(t('two_factor_authentication.max_generic_login_attempts_reached'))
end

def expect_rate_limitting_to_expire
def expect_rate_limiting_to_expire
travel (IdentityConfig.store.lockout_period_in_minutes + 1).minutes do
visit root_path

Expand Down