diff --git a/app/services/idv/steps/ipp/ssn_step.rb b/app/services/idv/steps/ipp/ssn_step.rb index e3ce2202ee0..53a8b5b995f 100644 --- a/app/services/idv/steps/ipp/ssn_step.rb +++ b/app/services/idv/steps/ipp/ssn_step.rb @@ -5,13 +5,17 @@ class SsnStep < DocAuthBaseStep STEP_INDICATOR_STEP = :verify_info def call + unless updating_ssn + flow_session[:threatmetrix_session_id] = generate_threatmetrix_session_id + end flow_session[:pii_from_user][:ssn] = flow_params[:ssn] + idv_session.delete('applicant') end def extra_view_variables { - updating_ssn: flow_session[:pii_from_user][:ssn].present?, + updating_ssn: updating_ssn, } end @@ -20,6 +24,15 @@ def extra_view_variables def form_submit Idv::SsnFormatForm.new(current_user).submit(permit(:ssn)) end + + def updating_ssn + flow_session.dig(:pii_from_user, :ssn).present? + end + + def generate_threatmetrix_session_id + return unless IdentityConfig.store.proofing_device_profiling_collecting_enabled + SecureRandom.uuid + end end end end diff --git a/app/services/idv/steps/ssn_step.rb b/app/services/idv/steps/ssn_step.rb index 0a3a33f5bf7..57fb9b6c2e2 100644 --- a/app/services/idv/steps/ssn_step.rb +++ b/app/services/idv/steps/ssn_step.rb @@ -6,13 +6,17 @@ class SsnStep < DocAuthBaseStep def call return invalid_state_response if invalid_state? + unless updating_ssn + flow_session[:threatmetrix_session_id] = generate_threatmetrix_session_id + end flow_session[:pii_from_doc][:ssn] = flow_params[:ssn] + idv_session.delete('applicant') end def extra_view_variables { - updating_ssn: flow_session.dig(:pii_from_doc, :ssn).present?, + updating_ssn: updating_ssn, } end @@ -26,10 +30,19 @@ def invalid_state? flow_session[:pii_from_doc].nil? end + def updating_ssn + flow_session.dig(:pii_from_doc, :ssn).present? + end + def invalid_state_response mark_step_incomplete(:document_capture) FormResponse.new(success: false) end + + def generate_threatmetrix_session_id + return unless IdentityConfig.store.proofing_device_profiling_collecting_enabled + SecureRandom.uuid + end end end end diff --git a/app/views/idv/shared/_ssn.html.erb b/app/views/idv/shared/_ssn.html.erb index a79f37fc4a4..259876f0baa 100644 --- a/app/views/idv/shared/_ssn.html.erb +++ b/app/views/idv/shared/_ssn.html.erb @@ -28,6 +28,17 @@ locals: <%= new_window_link_to(t('doc_auth.instructions.learn_more'), MarketingSite.security_and_privacy_practices_url) %>

+<% if IdentityConfig.store.proofing_device_profiling_collecting_enabled %> + <% unless IdentityConfig.store.lexisnexis_threatmetrix_org_id.empty? || updating_ssn %> + + + <% end %> +<% end %> + <% if IdentityConfig.store.proofer_mock_fallback %>
diff --git a/config/application.yml.default b/config/application.yml.default index c8f835fddda..ad689687c6a 100644 --- a/config/application.yml.default +++ b/config/application.yml.default @@ -144,7 +144,7 @@ lexisnexis_trueid_noliveness_nocropping_workflow: customers.gsa.trueid.workflow # LexisNexis ThreatMetrix ########################################## lexisnexis_threatmetrix_base_url: https://www.example.com lexisnexis_threatmetrix_request_mode: testing -lexisnexis_threatmetrix_account_id: test_account +lexisnexis_threatmetrix_org_id: test_account lexisnexis_threatmetrix_username: test_username lexisnexis_threatmetrix_password: test_password lexisnexis_threatmetrix_instant_verify_timeout: 1.0 diff --git a/lib/identity_config.rb b/lib/identity_config.rb index bbeeed761d2..f041799e976 100644 --- a/lib/identity_config.rb +++ b/lib/identity_config.rb @@ -212,7 +212,7 @@ def self.build_store(config_map) config.add(:lexisnexis_trueid_timeout, type: :float) config.add(:lexisnexis_threatmetrix_base_url, type: :string) config.add(:lexisnexis_threatmetrix_request_mode, type: :string) - config.add(:lexisnexis_threatmetrix_account_id, type: :string) + config.add(:lexisnexis_threatmetrix_org_id, type: :string) config.add(:lexisnexis_threatmetrix_username, type: :string) config.add(:lexisnexis_threatmetrix_password, type: :string) config.add(:lexisnexis_threatmetrix_instant_verify_timeout, type: :float) diff --git a/spec/services/idv/steps/ipp/ssn_step_spec.rb b/spec/services/idv/steps/ipp/ssn_step_spec.rb index 6cff2b2acc9..0a3f430e5af 100644 --- a/spec/services/idv/steps/ipp/ssn_step_spec.rb +++ b/spec/services/idv/steps/ipp/ssn_step_spec.rb @@ -6,6 +6,7 @@ let(:session) { { sp: { issuer: service_provider.issuer } } } let(:user) { build(:user) } let(:service_provider) { create(:service_provider) } + let(:threatmetrix_session_id) { nil } let(:controller) do instance_double( 'controller', @@ -16,7 +17,11 @@ end let(:flow) do - Idv::Flows::InPersonFlow.new(controller, {}, 'idv/in_person') + Idv::Flows::InPersonFlow.new(controller, {}, 'idv/in_person').tap do |flow| + flow.flow_session = { + pii_from_user: {}, + } + end end subject(:step) do @@ -39,5 +44,26 @@ expect(session[:idv]['applicant']).to be_blank end end + + context 'with proofing device profiling collecting enabled' do + it 'adds a session id to flow session' do + allow(IdentityConfig.store). + to receive(:proofing_device_profiling_collecting_enabled). + and_return(true) + step.call + + expect(flow.flow_session[:threatmetrix_session_id]).to_not eq(nil) + end + + it 'does not change threatmetrix_session_id when updating ssn' do + allow(IdentityConfig.store). + to receive(:proofing_device_profiling_collecting_enabled). + and_return(true) + step.call + session_id = flow.flow_session[:threatmetrix_session_id] + step.call + expect(flow.flow_session[:threatmetrix_session_id]).to eq(session_id) + end + end end end diff --git a/spec/services/idv/steps/ssn_step_spec.rb b/spec/services/idv/steps/ssn_step_spec.rb index 218dc44fcdf..9252ccee7fb 100644 --- a/spec/services/idv/steps/ssn_step_spec.rb +++ b/spec/services/idv/steps/ssn_step_spec.rb @@ -39,7 +39,9 @@ let(:flow) do Idv::Flows::DocAuthFlow.new(controller, {}, 'idv/doc_auth').tap do |flow| - flow.flow_session = { pii_from_doc: pii_from_doc } + flow.flow_session = { + pii_from_doc: pii_from_doc, + } end end @@ -67,6 +69,37 @@ expect(session[:idv]['applicant']).to be_blank end end + + context 'with proofing device profiling collecting enabled' do + it 'adds a session id to flow session' do + allow(IdentityConfig.store). + to receive(:proofing_device_profiling_collecting_enabled). + and_return(true) + step.call + + expect(flow.flow_session[:threatmetrix_session_id]).to_not eq(nil) + end + + it 'does not change threatmetrix_session_id when updating ssn' do + allow(IdentityConfig.store). + to receive(:proofing_device_profiling_collecting_enabled). + and_return(true) + step.call + session_id = flow.flow_session[:threatmetrix_session_id] + step.call + expect(flow.flow_session[:threatmetrix_session_id]).to eq(session_id) + end + end + + context 'with proofing device profiling collecting disabled' do + it 'does not add a session id to flow session' do + allow(IdentityConfig.store). + to receive(:proofing_device_profiling_collecting_enabled). + and_return(false) + step.call + expect(flow.flow_session[:threatmetrix_session_id]).to eq(nil) + end + end end context 'when pii_from_doc is not present' do diff --git a/spec/views/idv/shared/_ssn.html.erb_spec.rb b/spec/views/idv/shared/_ssn.html.erb_spec.rb new file mode 100644 index 00000000000..55e9c13af5f --- /dev/null +++ b/spec/views/idv/shared/_ssn.html.erb_spec.rb @@ -0,0 +1,119 @@ +require 'rails_helper' + +describe 'idv/shared/_ssn.html.erb' do + include Devise::Test::ControllerHelpers + + let(:proofing_device_profiling_collecting_enabled) { nil } + let(:lexisnexis_threatmetrix_org_id) { 'test_org_id' } + let(:session_id) { 'ABCD-1234' } + let(:updating_ssn) { false } + let(:js_domain) { 'h.online-metrix.net' } + + let(:tags_js_url) { + "https://#{js_domain}/fp/tags.js?org_id=#{lexisnexis_threatmetrix_org_id}&session_id=#{session_id}" + } + + let(:tags_iframe_url) { + "https://#{js_domain}/fp/tags?org_id=#{lexisnexis_threatmetrix_org_id}&session_id=#{session_id}" + } + + before :each do + allow(view).to receive(:url_for).and_return('https://example.com/') + + allow(IdentityConfig.store). + to receive(:proofing_device_profiling_collecting_enabled). + and_return(proofing_device_profiling_collecting_enabled) + allow(IdentityConfig.store). + to receive(:lexisnexis_threatmetrix_org_id).and_return(lexisnexis_threatmetrix_org_id) + + render partial: 'idv/shared/ssn', locals: { + flow_session: { + threatmetrix_session_id: session_id, + }, + success_alert_enabled: false, + updating_ssn: updating_ssn, + } + end + + context 'when threatmetrix collection enabled' do + let(:proofing_device_profiling_collecting_enabled) { true } + + context 'and org id specified' do + context 'and entering ssn for the first time' do + describe '