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 app/controllers/idv/document_capture_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def extra_view_variables
skip_doc_auth_from_socure: idv_session.skip_doc_auth_from_socure,
opted_in_to_in_person_proofing: idv_session.opted_in_to_in_person_proofing,
doc_auth_selfie_capture: resolved_authn_context_result.facial_match?,
socure_errors_timeout_url: idv_socure_errors_timeout_url,
socure_errors_timeout_url: idv_socure_document_capture_errors_url(error_code: :timeout),
}.merge(
acuant_sdk_upgrade_a_b_testing_variables,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def extra_view_variables
failure_to_proof_url: return_to_sp_failure_to_proof_url(step: 'document_capture'),
doc_auth_selfie_capture: resolved_authn_context_result.facial_match?,
skip_doc_auth_from_socure: @skip_doc_auth_from_socure,
socure_errors_timeout_url: idv_hybrid_mobile_socure_errors_timeout_url,
socure_errors_timeout_url: idv_hybrid_mobile_socure_document_capture_errors_url(
error_code: :timeout,
),
}.merge(
acuant_sdk_upgrade_a_b_testing_variables,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def show

# placeholder until we get an error page for url not being present
if @url.nil?
redirect_to idv_hybrid_mobile_socure_document_capture_errors_url
redirect_to idv_hybrid_mobile_socure_document_capture_errors_url(
error_code: :url_not_found,
)
return
end

Expand Down Expand Up @@ -98,7 +100,9 @@ def wait_for_result?
# If the stored_result is nil, the job fetching the results has not completed.
analytics.idv_doc_auth_document_capture_polling_wait_visited(**analytics_arguments)
if wait_timed_out?
redirect_to idv_hybrid_mobile_socure_errors_timeout_path
redirect_to idv_hybrid_mobile_socure_document_capture_errors_url(
error_code: :timeout,
)
else
@refresh_interval =
IdentityConfig.store.doc_auth_socure_wait_polling_refresh_max_seconds
Expand Down
17 changes: 9 additions & 8 deletions app/controllers/idv/hybrid_mobile/socure/errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,19 @@ class ErrorsController < ApplicationController
include SocureErrorsConcern

def show
error_code = error_code_for(handle_stored_result)
error_code = error_params[:error_code]
if error_code.nil?
error_code = error_code_for(handle_stored_result)
end
track_event(error_code: error_code)
@presenter = socure_errors_presenter(error_code)
end

def timeout
track_event(error_code: :timeout)
@presenter = socure_errors_presenter(:timeout)
render :show
end

def self.step_info
Idv::StepInfo.new(
key: :hybrid_socure_errors,
controller: self,
action: :timeout,
action: :show,
next_steps: [FlowPolicy::FINAL],
preconditions: ->(idv_session:, user:) do
true
Expand All @@ -37,6 +34,10 @@ def self.step_info

private

def error_params
params.permit(:error_code)
end

def rate_limiter
RateLimiter.new(user: document_capture_session&.user, rate_limit_type: :idv_doc_auth)
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/idv/socure/document_capture_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def show

# placeholder until we get an error page for url not being present
if @url.nil?
redirect_to idv_socure_document_capture_errors_url
redirect_to idv_socure_document_capture_errors_url(error_code: :url_not_found)
return
end

Expand Down Expand Up @@ -119,7 +119,7 @@ def wait_for_result?
# If the stored_result is nil, the job fetching the results has not completed.
analytics.idv_doc_auth_document_capture_polling_wait_visited(**analytics_arguments)
if wait_timed_out?
redirect_to idv_socure_errors_timeout_path
redirect_to idv_socure_document_capture_errors_url(error_code: :timeout)
else
@refresh_interval =
IdentityConfig.store.doc_auth_socure_wait_polling_refresh_max_seconds
Expand Down
17 changes: 9 additions & 8 deletions app/controllers/idv/socure/errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ class ErrorsController < ApplicationController
before_action :confirm_step_allowed

def show
error_code = error_code_for(handle_stored_result)
error_code = error_params[:error_code]
if error_code.nil?
error_code = error_code_for(handle_stored_result)
end
track_event(error_code: error_code)
@presenter = socure_errors_presenter(error_code)
end

def timeout
track_event(error_code: :timeout)
@presenter = socure_errors_presenter(:timeout)
render :show
end

def self.step_info
Idv::StepInfo.new(
key: :socure_errors,
controller: self,
action: :timeout,
action: :show,
next_steps: [FlowPolicy::FINAL],
preconditions: ->(idv_session:, user:) do
true
Expand All @@ -38,6 +35,10 @@ def self.step_info

private

def error_params
params.permit(:error_code)
end

def rate_limiter
RateLimiter.new(user: idv_session.current_user, rate_limit_type: :idv_doc_auth)
end
Expand Down
12 changes: 7 additions & 5 deletions app/presenters/socure_error_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def body_text
end

def rate_limit_text
return if error_code == :url_not_found

if remaining_attempts == 1
t('doc_auth.rate_limit_warning.singular_html')
else
Expand Down Expand Up @@ -67,7 +69,7 @@ def troubleshooting_heading
end

def options
return [] if error_code == :timeout
return [] if error_code == :timeout || error_code == :url_not_found

[
{
Expand Down Expand Up @@ -141,10 +143,10 @@ def remapped_error(error_code)
end

def heading_string_for(error_code)
case error_code
case error_code.to_sym
when :network
t('doc_auth.headers.general.network_error')
when :timeout
when :timeout, :url_not_found
t('idv.errors.technical_difficulties')
else
# i18n-tasks-use t('doc_auth.headers.unreadable_id')
Expand All @@ -158,10 +160,10 @@ def heading_string_for(error_code)
end

def error_string_for(error_code)
case error_code
case error_code.to_sym
when :network
t('doc_auth.errors.general.new_network_error')
when :timeout
when :timeout, :url_not_found
t('idv.errors.try_again_later')
else
if remapped_error(error_code) == 'underage' # special handling because it says 'Login.gov'
Expand Down
17 changes: 0 additions & 17 deletions app/views/idv/socure/errors/timeout.html.erb

This file was deleted.

2 changes: 0 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@
get '/socure/document_capture' => 'socure/document_capture#show'
get '/socure/document_capture_update' => 'socure/document_capture#update', as: :socure_document_capture_update
get '/socure/document_capture_errors' => 'socure/errors#show', as: :socure_document_capture_errors
get '/socure/errors/timeout' => 'socure/errors#timeout'
# This route is included in SMS messages sent to users who start the IdV hybrid flow. It
# should be kept short, and should not include underscores ("_").
get '/documents' => 'hybrid_mobile/entry#show', as: :hybrid_mobile_entry
Expand All @@ -378,7 +377,6 @@
get '/hybrid_mobile/socure/document_capture' => 'hybrid_mobile/socure/document_capture#show'
get '/hybrid_mobile/socure/document_capture_update' => 'hybrid_mobile/socure/document_capture#update', as: :hybrid_mobile_socure_document_capture_update
get '/hybrid_mobile/socure/document_capture_errors' => 'hybrid_mobile/socure/errors#show', as: :hybrid_mobile_socure_document_capture_errors
get '/hybrid_mobile/socure/errors/timeout' => 'hybrid_mobile/socure/errors#timeout'
get '/hybrid_handoff' => 'hybrid_handoff#show'
put '/hybrid_handoff' => 'hybrid_handoff#update'
get '/link_sent' => 'link_sent#show'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
let(:user) { create(:user) }
let(:stored_result) { nil }
let(:socure_docv_enabled) { true }
let(:socure_docv_verification_data_test_mode) { false }

let(:document_capture_session) do
DocumentCaptureSession.create(
Expand All @@ -17,8 +18,12 @@
)
end
let(:document_capture_session_uuid) { document_capture_session&.uuid }

let(:socure_docv_verification_data_test_mode) { false }
let(:no_url_socure_route) do
idv_hybrid_mobile_socure_document_capture_errors_url(error_code: :url_not_found)
end
let(:timeout_socure_route) do
idv_hybrid_mobile_socure_document_capture_errors_url(error_code: :timeout)
end

before do
allow(IdentityConfig.store).to receive(:socure_docv_enabled)
Expand Down Expand Up @@ -244,7 +249,7 @@
it 'redirects to idv unavailable url' do
get(:show)

expect(response).to redirect_to(idv_hybrid_mobile_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
expect(controller.send(:instance_variable_get, :@url)).not_to be
end
end
Expand Down Expand Up @@ -289,7 +294,7 @@
it 'connection timeout still responds to user' do
stub_request(:post, fake_socure_endpoint).to_raise(Faraday::ConnectionFailed)
get(:show)
expect(response).to redirect_to(idv_hybrid_mobile_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
end

it 'socure error response still gives a result to user' do
Expand All @@ -298,7 +303,7 @@
body: JSON.generate(failed_response_body),
)
get(:show)
expect(response).to redirect_to(idv_hybrid_mobile_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
end

it 'socure nil response still gives a result to user' do
Expand All @@ -307,7 +312,7 @@
body: nil,
)
get(:show)
expect(response).to redirect_to(idv_hybrid_mobile_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
end

it 'socure nil response still gives a result to user' do
Expand All @@ -316,7 +321,7 @@
body: JSON.generate(response_body_401),
)
get(:show)
expect(response).to redirect_to(idv_hybrid_mobile_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
end

it 'socure nil response still gives a result to user' do
Expand All @@ -325,7 +330,7 @@
body: JSON.generate(no_doc_found_response_body),
)
get(:show)
expect(response).to redirect_to(idv_hybrid_mobile_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
end
end
context 'reuse of valid capture app urls when appropriate' do
Expand Down Expand Up @@ -427,7 +432,7 @@

it 'redirects to the hybrid mobile socure errors timeout page' do
get(:update)
expect(response).to redirect_to(idv_hybrid_mobile_socure_errors_timeout_url)
expect(response).to redirect_to(timeout_socure_route)
end
end
end
Expand Down
16 changes: 9 additions & 7 deletions spec/controllers/idv/socure/document_capture_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
let(:doc_auth_success) { true }
let(:socure_docv_enabled) { true }
let(:socure_docv_verification_data_test_mode) { false }
let(:no_url_socure_route) { idv_socure_document_capture_errors_url(error_code: :url_not_found) }
let(:timeout_socure_route) { idv_socure_document_capture_errors_url(error_code: :timeout) }

let(:stored_result) do
DocumentCaptureSessionResult.new(
Expand Down Expand Up @@ -255,7 +257,7 @@
it 'redirects to the errors page' do
get(:show)

expect(response).to redirect_to(idv_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
expect(controller.send(:instance_variable_get, :@url)).not_to be
end
end
Expand Down Expand Up @@ -306,7 +308,7 @@
it 'connection timeout still responds to user' do
stub_request(:post, fake_socure_endpoint).to_raise(Faraday::ConnectionFailed)
get(:show)
expect(response).to redirect_to(idv_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
end

it 'socure error response still gives a result to user' do
Expand All @@ -315,7 +317,7 @@
body: JSON.generate(failed_response_body),
)
get(:show)
expect(response).to redirect_to(idv_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
end

it 'socure nil response still gives a result to user' do
Expand All @@ -324,7 +326,7 @@
body: nil,
)
get(:show)
expect(response).to redirect_to(idv_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
end

it 'socure nil response still gives a result to user' do
Expand All @@ -333,7 +335,7 @@
body: JSON.generate(response_body_401),
)
get(:show)
expect(response).to redirect_to(idv_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
end

it 'socure nil response still gives a result to user' do
Expand All @@ -342,7 +344,7 @@
body: JSON.generate(no_doc_found_response_body),
)
get(:show)
expect(response).to redirect_to(idv_socure_document_capture_errors_url)
expect(response).to redirect_to(no_url_socure_route)
end
end

Expand Down Expand Up @@ -426,7 +428,7 @@

it 'redirect to a Try again page' do
get(:update)
expect(response).to redirect_to(idv_socure_errors_timeout_path)
expect(response).to redirect_to(timeout_socure_route)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/idv/socure/errors_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
subject.idv_session.socure_docv_wait_polling_started_at = Time.zone.now
end

describe '#timeout' do
describe '#show' do
it 'logs an event' do
get(:timeout)
get(:show)

expect(@analytics).to have_logged_event(:idv_doc_auth_socure_error_visited)
end
Expand Down
Loading