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
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@
get '/second_mfa_setup' => 'users/mfa_selection#index'
patch '/second_mfa_setup' => 'users/mfa_selection#update'
get '/phone_setup' => 'users/phone_setup#index'
patch '/phone_setup' => 'users/phone_setup#create' # TODO: Remove after next deploy
post '/phone_setup' => 'users/phone_setup#create'
get '/users/two_factor_authentication' => 'users/two_factor_authentication#show',
as: :user_two_factor_authentication # route name is used by two_factor_authentication gem
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/rack_attack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
context 'when the number of requests is under the limit' do
it 'does not throttle the request' do
(phone_setups_per_ip_limit - 1).times do
patch '/phone_setup', headers: { REMOTE_ADDR: '1.2.3.4' }
post '/phone_setup', headers: { REMOTE_ADDR: '1.2.3.4' }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the extended commit message, this is fortunately not cause for concern, since throttling applies to any non-GET request:

req.remote_ip if req.path.match?(%r{/add/phone|/phone_setup}) && !req.get?

end

expect(response.status).to eq(302)
Expand All @@ -404,7 +404,7 @@
context 'when the number of requests is over the limit' do
it 'throttles the request' do
(phone_setups_per_ip_limit + 1).times do
patch '/phone_setup', headers: { REMOTE_ADDR: '1.2.3.4' }
post '/phone_setup', headers: { REMOTE_ADDR: '1.2.3.4' }
end

expect(response.status).to eq(429)
Expand Down