diff --git a/app/views/shared/_troubleshooting_options.html.erb b/app/views/shared/_troubleshooting_options.html.erb index c52fe69741b..696cfbfbe6d 100644 --- a/app/views/shared/_troubleshooting_options.html.erb +++ b/app/views/shared/_troubleshooting_options.html.erb @@ -2,7 +2,7 @@ locals: * heading_tag: Tag name for heading. Does not affect visual appearance. Defaults to :h2. * heading: Heading text. -* options: List of link options to display, as an array of hashes with `url`, `text`, `external` values. +* options: List of link options to display, as an array of hashes with `url`, `text`, `new_tab` values. * class: Additional class names to add to wrapper element. %> <% if local_assigns[:options].presence %> diff --git a/app/views/two_factor_authentication/sms_opt_in/error.html.erb b/app/views/two_factor_authentication/sms_opt_in/error.html.erb index 8a2a648f89f..5e18dd8ca60 100644 --- a/app/views/two_factor_authentication/sms_opt_in/error.html.erb +++ b/app/views/two_factor_authentication/sms_opt_in/error.html.erb @@ -30,6 +30,7 @@ { url: MarketingSite.contact_url, text: t('links.contact_support', app_name: APP_NAME), + new_tab: true, }, ].select(&:present?), ) %> diff --git a/lib/telephony/pinpoint/sms_sender.rb b/lib/telephony/pinpoint/sms_sender.rb index f604f075bf3..3feda57391b 100644 --- a/lib/telephony/pinpoint/sms_sender.rb +++ b/lib/telephony/pinpoint/sms_sender.rb @@ -45,7 +45,11 @@ def send(message:, to:, country_code:, otp: nil) ) finish = Time.zone.now response = build_response(pinpoint_response, start: start, finish: finish) - return response if response.success? + if response.success? || + response.error.is_a?(OptOutError) || + response.error.is_a?(PermanentFailureError) + return response + end PinpointHelper.notify_pinpoint_failover( error: response.error, region: sms_config.region, diff --git a/spec/lib/telephony/pinpoint/sms_sender_spec.rb b/spec/lib/telephony/pinpoint/sms_sender_spec.rb index 9decf608076..4ee8c39792e 100644 --- a/spec/lib/telephony/pinpoint/sms_sender_spec.rb +++ b/spec/lib/telephony/pinpoint/sms_sender_spec.rb @@ -252,7 +252,7 @@ def ==(other) end end - context 'when the first config errors' do + context 'when the first config errors with a transient error' do before do Pinpoint::MockClient.message_response_result_status_code = 400 Pinpoint::MockClient.message_response_result_delivery_status = 'DUPLICATE' @@ -271,6 +271,44 @@ def ==(other) end end + context 'when the first config errors with an opt out error' do + before do + Pinpoint::MockClient.message_response_result_status_code = 400 + Pinpoint::MockClient.message_response_result_delivery_status = 'OPT_OUT' + end + + it 'only tries one region and returns an error' do + expect(backup_mock_client).to_not receive(:send_messages) + + response = subject.send( + message: 'This is a test!', + to: '+1 (123) 456-7890', + country_code: 'US', + ) + expect(response.success?).to eq(false) + expect(response.error).to be_present + end + end + + context 'when the first config errors with a permanent error' do + before do + Pinpoint::MockClient.message_response_result_status_code = 400 + Pinpoint::MockClient.message_response_result_delivery_status = 'PERMANENT_FAILURE' + end + + it 'only tries one region and returns an error' do + expect(backup_mock_client).to_not receive(:send_messages) + + response = subject.send( + message: 'This is a test!', + to: '+1 (123) 456-7890', + country_code: 'US', + ) + expect(response.success?).to eq(false) + expect(response.error).to be_present + end + end + context 'when the first config raises a timeout exception' do let(:raised_error_message) { 'Seahorse::Client::NetworkingError: Net::ReadTimeout' } diff --git a/spec/views/two_factor_authentication/sms_opt_in/error.html.erb_spec.rb b/spec/views/two_factor_authentication/sms_opt_in/error.html.erb_spec.rb index 0a644d9932c..4a27e8dce8e 100644 --- a/spec/views/two_factor_authentication/sms_opt_in/error.html.erb_spec.rb +++ b/spec/views/two_factor_authentication/sms_opt_in/error.html.erb_spec.rb @@ -23,6 +23,16 @@ end context 'troubleshooting links' do + it 'links to the contact form in a new window' do + render + + expect(rendered).to have_link( + t('links.contact_support', app_name: APP_NAME), + href: MarketingSite.contact_url, + class: 'usa-link--external', + ) + end + context 'without an other_mfa_options_url' do let(:other_mfa_options_url) { nil }