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: 1 addition & 0 deletions app/controllers/concerns/idv/phone_otp_rate_limitable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def reset_attempt_count_if_user_no_longer_locked_out

def handle_too_many_otp_sends
analytics.idv_phone_confirmation_otp_rate_limit_sends
irs_attempts_api_tracker.idv_phone_otp_sent_rate_limited
handle_max_attempts('otp_requests')
end

Expand Down
7 changes: 7 additions & 0 deletions app/services/irs_attempts_api/tracker_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ def idv_document_upload_submitted(
)
end

# Tracks Idv phone OTP sent rate limits
def idv_phone_otp_sent_rate_limited
track_event(
:idv_phone_otp_sent_rate_limited,
)
end

# The user has exceeded the rate limit during idv document upload
def idv_document_upload_rate_limited
track_event(
Expand Down
36 changes: 36 additions & 0 deletions spec/controllers/concerns/idv/phone_otp_rate_limitable_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require 'rails_helper'

RSpec.describe Idv::PhoneOtpRateLimitable, type: :controller do
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for adding specs for this previously untested controller!!!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 to that!

controller ApplicationController do
include Idv::PhoneOtpRateLimitable

def handle_max_attempts(_arg = nil)
true
end
end

describe '#handle_too_many_otp_sends' do
before do
stub_analytics
stub_attempts_tracker
allow(@analytics).to receive(:track_event)
allow(@irs_attempts_api_tracker).to receive(:track_event)
end

it 'calls analytics tracking event' do
subject.handle_too_many_otp_sends

expect(@analytics).to have_received(:track_event).with(
'Idv: Phone OTP sends rate limited',
)
end

it 'calls irs tracking event idv_phone_otp_sent_rate_limited' do
subject.handle_too_many_otp_sends

expect(@irs_attempts_api_tracker).to have_received(:track_event).with(
:idv_phone_otp_sent_rate_limited,
)
end
end
end