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
18 changes: 18 additions & 0 deletions app/controllers/concerns/idv/document_capture_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ def selfie_requirement_met?
stored_result.selfie_check_performed?
end

def redirect_to_correct_vendor(vendor, in_hybrid_mobile)
Comment thread
amirbey marked this conversation as resolved.
expected_doc_auth_vendor = doc_auth_vendor
return if vendor == expected_doc_auth_vendor
return if vendor == Idp::Constants::Vendors::LEXIS_NEXIS &&
expected_doc_auth_vendor == Idp::Constants::Vendors::MOCK

correct_path = case expected_doc_auth_vendor
when Idp::Constants::Vendors::SOCURE
in_hybrid_mobile ? idv_hybrid_mobile_socure_document_capture_path
: idv_socure_document_capture_path
when Idp::Constants::Vendors::LEXIS_NEXIS, Idp::Constants::Vendors::MOCK
in_hybrid_mobile ? idv_hybrid_mobile_document_capture_path
: idv_document_capture_path
end

redirect_to correct_path
end

private

def track_document_issuing_state(user, state)
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/idv/document_capture_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@ class DocumentCaptureController < ApplicationController
before_action :confirm_step_allowed, unless: -> { allow_direct_ipp? }
before_action :override_csp_to_allow_acuant
before_action :set_usps_form_presenter
before_action -> { redirect_to_correct_vendor(Idp::Constants::Vendors::LEXIS_NEXIS, false) }

def show
analytics.idv_doc_auth_document_capture_visited(**analytics_arguments)

Funnel::DocAuth::RegisterStep.new(current_user.id, sp_session[:issuer]).
call('document_capture', :view, true)

case doc_auth_vendor
when Idp::Constants::Vendors::SOCURE
redirect_to idv_socure_document_capture_url
when Idp::Constants::Vendors::LEXIS_NEXIS, Idp::Constants::Vendors::MOCK
render :show, locals: extra_view_variables
end
render :show, locals: extra_view_variables
end

def update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class DocumentCaptureController < ApplicationController
before_action :override_csp_to_allow_acuant
before_action :confirm_document_capture_needed, only: :show
before_action :set_usps_form_presenter
before_action -> { redirect_to_correct_vendor(Idp::Constants::Vendors::LEXIS_NEXIS, true) }

def show
analytics.idv_doc_auth_document_capture_visited(**analytics_arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class DocumentCaptureController < ApplicationController

check_or_render_not_found -> { IdentityConfig.store.socure_enabled }
before_action :check_valid_document_capture_session, except: [:update]
before_action -> { redirect_to_correct_vendor(Idp::Constants::Vendors::SOCURE, true) }

def show
Funnel::DocAuth::RegisterStep.new(document_capture_user.id, sp_session[:issuer]).
Expand Down
1 change: 1 addition & 0 deletions app/controllers/idv/socure/document_capture_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class DocumentCaptureController < ApplicationController
check_or_render_not_found -> { IdentityConfig.store.socure_enabled }
before_action :confirm_not_rate_limited
before_action :confirm_step_allowed
before_action -> { redirect_to_correct_vendor(Idp::Constants::Vendors::SOCURE, false) }

# reconsider and maybe remove these when implementing the real
# update handler
Expand Down
16 changes: 14 additions & 2 deletions spec/controllers/idv/document_capture_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@
}
end

let(:idv_vendor) { Idp::Constants::Vendors::LEXIS_NEXIS }

before do
allow(IdentityConfig.store).to receive(:doc_auth_vendor).and_return(
Idp::Constants::Vendors::LEXIS_NEXIS,
idv_vendor,
)
allow(IdentityConfig.store).to receive(:doc_auth_vendor_default).and_return(
Idp::Constants::Vendors::LEXIS_NEXIS,
idv_vendor,
)
end

Expand All @@ -130,6 +132,16 @@
expect(assigns(:presenter)).to be_kind_of(Idv::InPerson::UspsFormPresenter)
end

context 'when we try to use this controller but we should be using the Socure version' do
let(:idv_vendor) { Idp::Constants::Vendors::SOCURE }

it 'redirects to the Socure controller' do
get :show

expect(response).to redirect_to idv_socure_document_capture_url
end
end

it 'renders the show template' do
expect(subject).to receive(:render).with(
:show,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
let(:document_capture_session_requested_at) { Time.zone.now }
let(:document_capture_session_result_captured_at) { Time.zone.now + 1.second }
let(:document_capture_session_result_success) { true }
let(:idv_vendor) { Idp::Constants::Vendors::MOCK }

before do
stub_analytics

session[:doc_capture_user_id] = user&.id
session[:document_capture_session_uuid] = document_capture_session_uuid

allow(IdentityConfig.store).to receive(:doc_auth_vendor).and_return(idv_vendor)
allow(IdentityConfig.store).to receive(:doc_auth_vendor_default).and_return(idv_vendor)
end

describe 'before_actions' do
Expand Down Expand Up @@ -55,6 +59,16 @@
}
end

context 'when we try to use this controller but we should be using the Socure version' do
let(:idv_vendor) { Idp::Constants::Vendors::SOCURE }

it 'redirects to the Socure controller' do
get :show

expect(response).to redirect_to idv_hybrid_mobile_socure_document_capture_url
end
end

it 'renders the show template' do
expect(subject).to receive(:render).with(
:show,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@
end
end

context 'when we try to use this controller but we should be using the LN/mock version' do
let(:idv_vendor) { Idp::Constants::Vendors::LEXIS_NEXIS }

it 'redirects to the LN/mock controller' do
get :show
expect(response).to redirect_to idv_hybrid_mobile_document_capture_url
end
end

context 'happy path' do
let(:response_redirect_url) { 'https://idv.test/dance' }
let(:docv_transaction_token) { '176dnc45d-2e34-46f3-82217-6f540ae90673' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@
subject.idv_session.document_capture_session_uuid = expected_uuid
end

context 'when we try to use this controller but we should be using the LN/mock version' do
let(:idv_vendor) { Idp::Constants::Vendors::LEXIS_NEXIS }

it 'redirects to the LN/mock controller' do
get :show
expect(response).to redirect_to idv_document_capture_url
end
end

context 'happy path' do
let(:response_redirect_url) { 'https://idv.test/dance' }
let(:docv_transaction_token) { '176dnc45d-2e34-46f3-82217-6f540ae90673' }
Expand Down
9 changes: 9 additions & 0 deletions spec/features/idv/hybrid_mobile/entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,22 @@
let(:link_to_visit) { link_sent_via_sms }

context 'valid link' do
before do
allow(IdentityConfig.store).to receive(:socure_enabled).and_return(true)
end

it 'puts the user on the document capture page' do
expect(link_to_visit).to be

Capybara.using_session('mobile') do
visit link_to_visit
# Should have redirected to the actual doc capture url
expect(current_url).to eql(idv_hybrid_mobile_document_capture_url)

# Confirm that we end up on the LN / Mock page even if we try to
# go to the Socure one.
visit idv_hybrid_mobile_socure_document_capture_url
expect(page).to have_current_path(idv_hybrid_mobile_document_capture_url)
end
end
end
Expand Down
7 changes: 6 additions & 1 deletion spec/features/idv/hybrid_mobile/hybrid_mobile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

before do
allow(FeatureManagement).to receive(:doc_capture_polling_enabled?).and_return(true)
allow(IdentityConfig.store).to receive(:socure_enabled).and_return(true)
allow(IdentityConfig.store).to receive(:use_vot_in_sp_requests).and_return(true)
allow(Telephony).to receive(:send_doc_auth_link).and_wrap_original do |impl, config|
@sms_link = config[:link]
Expand Down Expand Up @@ -44,7 +45,11 @@
# Confirm that jumping to LinkSent page does not cause errors
visit idv_link_sent_url
expect(page).to have_current_path(root_url)
visit idv_hybrid_mobile_document_capture_url

# Confirm that we end up on the LN / Mock page even if we try to
# go to the Socure one.
visit idv_hybrid_mobile_socure_document_capture_url
expect(page).to have_current_path(idv_hybrid_mobile_document_capture_url)
Comment on lines +51 to +52
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.

Can we add this quick test to the other document capture feature tests (standard, standard socure, and hybrid socure)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added to the standard flow feature spec. Will bring up Socure feature specs as a 16th minute today.


# Confirm that clicking cancel and then coming back doesn't cause errors
click_link 'Cancel'
Expand Down