diff --git a/app/controllers/concerns/idv/document_capture_concern.rb b/app/controllers/concerns/idv/document_capture_concern.rb index 6445a77e82b..e2f8093a329 100644 --- a/app/controllers/concerns/idv/document_capture_concern.rb +++ b/app/controllers/concerns/idv/document_capture_concern.rb @@ -68,6 +68,8 @@ def redirect_to_correct_vendor(vendor, in_hybrid_mobile) when Idp::Constants::Vendors::SOCURE in_hybrid_mobile ? idv_hybrid_mobile_socure_document_capture_path : idv_socure_document_capture_path + when Idp::Constants::Vendors::MOCK_SOCURE + test_mock_socure_url(hybrid: in_hybrid_mobile ? 1 : 0) when Idp::Constants::Vendors::LEXIS_NEXIS, Idp::Constants::Vendors::MOCK in_hybrid_mobile ? idv_hybrid_mobile_document_capture_path : idv_document_capture_path diff --git a/app/controllers/idv/hybrid_mobile/entry_controller.rb b/app/controllers/idv/hybrid_mobile/entry_controller.rb index 5cc4f9a94b0..0968549b247 100644 --- a/app/controllers/idv/hybrid_mobile/entry_controller.rb +++ b/app/controllers/idv/hybrid_mobile/entry_controller.rb @@ -17,6 +17,8 @@ def show case doc_auth_vendor when Idp::Constants::Vendors::SOCURE redirect_to idv_hybrid_mobile_socure_document_capture_url + when Idp::Constants::Vendors::MOCK_SOCURE + redirect_to test_mock_socure_url(hybrid: 1) when Idp::Constants::Vendors::MOCK, Idp::Constants::Vendors::LEXIS_NEXIS redirect_to idv_hybrid_mobile_document_capture_url end diff --git a/app/controllers/test/mock_socure_document_capture_controller.rb b/app/controllers/test/mock_socure_document_capture_controller.rb new file mode 100644 index 00000000000..99a4efe9a46 --- /dev/null +++ b/app/controllers/test/mock_socure_document_capture_controller.rb @@ -0,0 +1,109 @@ +# frozen_string_literal: true + +module Test + class MockSocureDocumentCaptureController < ApplicationController + before_action :check_not_in_prod + + def show + if verify? + simulate_socure_docv + return + end + + @url = test_mock_socure_url(verify: 1, hybrid: hybrid? ? 1 : 0) + end + + private + + def check_not_in_prod + render_not_found if Rails.env.production? + end + + def build_fake_docv_result_response + DocAuth::Socure::Responses::DocvResultResponse.new( + http_response: Struct.new(:body, keyword_init: true).new( + body: JSON.generate( + { + referenceId: SecureRandom.uuid, + documentVerification: { + customerProfile: { + customerUserId: '', + userId: SecureRandom.uuid, + }, + decision: { + name: '', + value: 'accept', + }, + documentData: { + dob: '1938-01-01', + documentNumber: 'ABCD-1234', + expirationDate: (Time.zone.now + 1.year).to_date, + firstName: 'Joey', + issueDate: 3.years.ago.to_date, + middleName: 'Joe-Joe', + surName: 'Junior Shabbadoo', + parsedAddress: { + physicalAddress: '1234 Fake St.', + physicalAddress2: 'Unit 99', + city: 'Fakeville', + state: 'CA', + zip: '90210', + }, + }, + documentType: { + state: 'WA', + country: 'US', + }, + reasonCodes: [], + }, + + }, + ), + ), + ) + end + + def document_capture_session + DocumentCaptureSession.find_by( + uuid: if idv_session.present? + idv_session.document_capture_session_uuid + else + session[:document_capture_session_uuid] + end, + ) + end + + def hybrid? + params[:hybrid].to_i == 1 + end + + def idv_session + return nil if user_session.nil? + + @idv_session ||= Idv::Session.new( + user_session: user_session, + current_user: current_user, + service_provider: current_sp, + ) + end + + def simulate_socure_docv + # Fake what the Socure webhook processor would've done. + # TODO: It'd be cool to just call the webhook processing code here + + document_capture_session.store_result_from_response( + build_fake_docv_result_response, + ) + + if hybrid? + redirect_to idv_hybrid_mobile_capture_complete_url + else + redirect_to idv_socure_document_capture_update_url + end + end + + def verify? + params[:verify].to_i == 1 + end + end +end diff --git a/app/views/idv/shared/_doc_capture_interstitial.html.erb b/app/views/idv/shared/_doc_capture_interstitial.html.erb index 3175374accf..308bc2c324e 100644 --- a/app/views/idv/shared/_doc_capture_interstitial.html.erb +++ b/app/views/idv/shared/_doc_capture_interstitial.html.erb @@ -8,6 +8,12 @@ ) %> <% end %> +<% if local_assigns.fetch(:show_test_mode_warning, false) %> +
+ +
+<% end %> + <%= render PageHeadingComponent.new do %> <%= t('doc_auth.headings.verify_with_phone') %> <% end %> diff --git a/app/views/test/mock_socure_document_capture/show.html.erb b/app/views/test/mock_socure_document_capture/show.html.erb new file mode 100644 index 00000000000..a1f5f9005f3 --- /dev/null +++ b/app/views/test/mock_socure_document_capture/show.html.erb @@ -0,0 +1 @@ +<%= render 'idv/shared/doc_capture_interstitial', show_test_mode_warning: true %> diff --git a/config/routes.rb b/config/routes.rb index cfd32ce457d..babf886058a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -177,6 +177,8 @@ put '/s3/:key' => 'fake_s3#update' get '/session_data' => 'session_data#index' + + get '/mock_socure' => 'mock_socure_document_capture#show' end end diff --git a/lib/idp/constants.rb b/lib/idp/constants.rb index e9b66cca1d7..e37cb673b41 100644 --- a/lib/idp/constants.rb +++ b/lib/idp/constants.rb @@ -14,6 +14,7 @@ module Vendors LEXIS_NEXIS = 'lexis_nexis' SOCURE = 'socure' MOCK = 'mock' + MOCK_SOCURE = 'mock_socure' USPS = 'usps' AAMVA = 'aamva' AAMVA_UNSUPPORTED_JURISDICTION = 'UnsupportedJurisdiction'