From b6803568b5796a83c8b487cb93ee5564edad704a Mon Sep 17 00:00:00 2001 From: Matt Hinz Date: Fri, 15 Nov 2024 14:53:08 -0800 Subject: [PATCH 1/2] Add idv_resolution_default_vendor config Start the process of separating configuration of the resolution proofer mock fallback from the address proofer mock fallback. For a short period of time, we'll need to continue to support the old method of configuration (until staging and prod configs can be updated). [skip changelog] --- ...stant_verify_residential_address_plugin.rb | 33 +++++++++- .../instant_verify_state_id_address_plugin.rb | 33 +++++++++- config/application.yml.default | 1 + lib/identity_config.rb | 5 ++ ..._verify_residential_address_plugin_spec.rb | 61 +++++++++++++++++-- ...ant_verify_state_id_address_plugin_spec.rb | 61 +++++++++++++++++-- 6 files changed, 182 insertions(+), 12 deletions(-) diff --git a/app/services/proofing/resolution/plugins/instant_verify_residential_address_plugin.rb b/app/services/proofing/resolution/plugins/instant_verify_residential_address_plugin.rb index 7c8f6efd17b..5500b944136 100644 --- a/app/services/proofing/resolution/plugins/instant_verify_residential_address_plugin.rb +++ b/app/services/proofing/resolution/plugins/instant_verify_residential_address_plugin.rb @@ -24,8 +24,36 @@ def call( end def proofer - @proofer ||= - if IdentityConfig.store.proofer_mock_fallback + @proofer ||= begin + # Historically, proofer_mock_fallback has controlled whether we + # use mock implementations of the Resolution and Address proofers + # (true = use mock, false = don't use mock). + # We are transitioning to a place where we will have separate + # configs for both. For the time being, we want to keep support for + # proofer_mock_fallback here. This can be removed after this code + # has been deployed and configs have been updated in all relevant + # environments. + + old_config_says_mock = IdentityConfig.store.proofer_mock_fallback + old_config_says_iv = !old_config_says_mock + new_config_says_mock = + IdentityConfig.store.idv_resolution_default_vendor == :mock + new_config_says_iv = + IdentityConfig.store.idv_resolution_default_vendor == :instant_verify + + proofer_type = + if new_config_says_mock && old_config_says_iv + # This will be the case immediately after deployment, when + # environment configs have not been updated. We need to + # fall back to the old config here. + :instant_verify + elsif new_config_says_iv + :instant_verify + else + :mock + end + + if proofer_type == :mock Proofing::Mock::ResolutionMockClient.new else Proofing::LexisNexis::InstantVerify::Proofer.new( @@ -39,6 +67,7 @@ def proofer request_mode: IdentityConfig.store.lexisnexis_request_mode, ) end + end end def residential_address_unnecessary_result diff --git a/app/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin.rb b/app/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin.rb index c3fe246cb06..b113f4bc52f 100644 --- a/app/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin.rb +++ b/app/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin.rb @@ -44,8 +44,36 @@ def call( end def proofer - @proofer ||= - if IdentityConfig.store.proofer_mock_fallback + @proofer ||= begin + # Historically, proofer_mock_fallback has controlled whether we + # use mock implementations of the Resolution and Address proofers + # (true = use mock, false = don't use mock). + # We are transitioning to a place where we will have separate + # configs for both. For the time being, we want to keep support for + # proofer_mock_fallback here. This can be removed after this code + # has been deployed and configs have been updated in all relevant + # environments. + + old_config_says_mock = IdentityConfig.store.proofer_mock_fallback + old_config_says_iv = !old_config_says_mock + new_config_says_mock = + IdentityConfig.store.idv_resolution_default_vendor == :mock + new_config_says_iv = + IdentityConfig.store.idv_resolution_default_vendor == :instant_verify + + proofer_type = + if new_config_says_mock && old_config_says_iv + # This will be the case immediately after deployment, when + # environment configs have not been updated. We need to + # fall back to the old config here. + :instant_verify + elsif new_config_says_iv + :instant_verify + else + :mock + end + + if proofer_type == :mock Proofing::Mock::ResolutionMockClient.new else Proofing::LexisNexis::InstantVerify::Proofer.new( @@ -59,6 +87,7 @@ def proofer request_mode: IdentityConfig.store.lexisnexis_request_mode, ) end + end end def resolution_cannot_pass diff --git a/config/application.yml.default b/config/application.yml.default index 74b313ec0a3..2dbc7fbe7f3 100644 --- a/config/application.yml.default +++ b/config/application.yml.default @@ -158,6 +158,7 @@ idv_available: true idv_contact_phone_number: (844) 555-5555 idv_max_attempts: 5 idv_min_age_years: 13 +idv_resolution_default_vendor: mock idv_send_link_attempt_window_in_minutes: 10 idv_send_link_max_attempts: 5 idv_socure_reason_code_download_enabled: false diff --git a/lib/identity_config.rb b/lib/identity_config.rb index b859c70528b..ff40a55b211 100644 --- a/lib/identity_config.rb +++ b/lib/identity_config.rb @@ -176,6 +176,11 @@ def self.store config.add(:idv_contact_phone_number, type: :string) config.add(:idv_max_attempts, type: :integer) config.add(:idv_min_age_years, type: :integer) + config.add( + :idv_resolution_default_vendor, + type: :symbol, + enum: [:instant_verify, :mock], + ) config.add(:idv_send_link_attempt_window_in_minutes, type: :integer) config.add(:idv_send_link_max_attempts, type: :integer) config.add(:idv_socure_reason_code_download_enabled, type: :boolean) diff --git a/spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb b/spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb index be7dd860d03..c7590e649fd 100644 --- a/spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb +++ b/spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb @@ -19,10 +19,6 @@ described_class.new end - before do - allow(plugin.proofer).to receive(:proof).and_return(proofer_result) - end - describe '#call' do def sp_cost_count_for_issuer SpCost.where(cost_type: :lexis_nexis_resolution, issuer: current_sp.issuer).count @@ -45,6 +41,10 @@ def sp_cost_count_with_transaction_id ) end + before do + allow(plugin.proofer).to receive(:proof).and_return(proofer_result) + end + context 'remote unsupervised proofing' do let(:applicant_pii) { Idp::Constants::MOCK_IDV_APPLICANT_WITH_SSN } let(:ipp_enrollment_in_progress) { false } @@ -128,4 +128,57 @@ def sp_cost_count_with_transaction_id end end end + + describe '#proofer' do + subject(:proofer) { plugin.proofer } + + before do + allow(IdentityConfig.store).to receive(:proofer_mock_fallback). + and_return(proofer_mock_fallback) + allow(IdentityConfig.store).to receive(:idv_resolution_default_vendor). + and_return(idv_resolution_default_vendor) + end + + context 'when proofer_mock_fallback is set to true' do + let(:proofer_mock_fallback) { true } + + context 'and idv_resolution_default_vendor is set to :instant_verify' do + let(:idv_resolution_default_vendor) do + :instant_verify + end + + it 'creates an Instant Verify proofer because the new setting takes precedence' do + expect(proofer).to be_an_instance_of(Proofing::LexisNexis::InstantVerify::Proofer) + end + end + + context 'and idv_resolution_default_vendor is set to :mock' do + let(:idv_resolution_default_vendor) { :mock } + + it 'creates a mock proofer because the two settings agree' do + expect(proofer).to be_an_instance_of(Proofing::Mock::ResolutionMockClient) + end + end + end + + context 'when proofer_mock_fallback is set to false' do + let(:proofer_mock_fallback) { false } + + context 'and idv_resolution_default_vendor is set to :instant_verify' do + let(:idv_resolution_default_vendor) { :instant_verify } + + it 'creates an Instant Verify proofer because the two settings agree' do + expect(proofer).to be_an_instance_of(Proofing::LexisNexis::InstantVerify::Proofer) + end + end + + context 'and idv_resolution_default_vendor is set to :mock' do + let(:idv_resolution_default_vendor) { :mock } + + it 'creates an Instant Verify proofer to support transition between configs' do + expect(proofer).to be_an_instance_of(Proofing::LexisNexis::InstantVerify::Proofer) + end + end + end + end end diff --git a/spec/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin_spec.rb b/spec/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin_spec.rb index 43c0edbfeb6..f0873bf3966 100644 --- a/spec/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin_spec.rb +++ b/spec/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin_spec.rb @@ -29,10 +29,6 @@ described_class.new end - before do - allow(plugin.proofer).to receive(:proof).and_return(proofer_result) - end - describe '#call' do subject(:call) do plugin.call( @@ -44,6 +40,10 @@ ) end + before do + allow(plugin.proofer).to receive(:proof).and_return(proofer_result) + end + context 'remote unsupervised proofing' do let(:ipp_enrollment_in_progress) { false } @@ -286,4 +286,57 @@ end end end + + describe '#proofer' do + subject(:proofer) { plugin.proofer } + + before do + allow(IdentityConfig.store).to receive(:proofer_mock_fallback). + and_return(proofer_mock_fallback) + allow(IdentityConfig.store).to receive(:idv_resolution_default_vendor). + and_return(idv_resolution_default_vendor) + end + + context 'when proofer_mock_fallback is set to true' do + let(:proofer_mock_fallback) { true } + + context 'and idv_resolution_default_vendor is set to :instant_verify' do + let(:idv_resolution_default_vendor) do + :instant_verify + end + + it 'creates an Instant Verify proofer because the new setting takes precedence' do + expect(proofer).to be_an_instance_of(Proofing::LexisNexis::InstantVerify::Proofer) + end + end + + context 'and idv_resolution_default_vendor is set to :mock' do + let(:idv_resolution_default_vendor) { :mock } + + it 'creates a mock proofer because the two settings agree' do + expect(proofer).to be_an_instance_of(Proofing::Mock::ResolutionMockClient) + end + end + end + + context 'when proofer_mock_fallback is set to false' do + let(:proofer_mock_fallback) { false } + + context 'and idv_resolution_default_vendor is set to :instant_verify' do + let(:idv_resolution_default_vendor) { :instant_verify } + + it 'creates an Instant Verify proofer because the two settings agree' do + expect(proofer).to be_an_instance_of(Proofing::LexisNexis::InstantVerify::Proofer) + end + end + + context 'and idv_resolution_default_vendor is set to :mock' do + let(:idv_resolution_default_vendor) { :mock } + + it 'creates an Instant Verify proofer to support transition between configs' do + expect(proofer).to be_an_instance_of(Proofing::LexisNexis::InstantVerify::Proofer) + end + end + end + end end From 5326031e4a10c2ce55507edf407a2a96bb512679 Mon Sep 17 00:00:00 2001 From: Matt Hinz Date: Mon, 18 Nov 2024 12:44:02 -0800 Subject: [PATCH 2/2] Clarify a spec name --- .../plugins/instant_verify_residential_address_plugin_spec.rb | 4 +++- .../plugins/instant_verify_state_id_address_plugin_spec.rb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb b/spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb index c7590e649fd..ed9cab23033 100644 --- a/spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb +++ b/spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb @@ -147,9 +147,11 @@ def sp_cost_count_with_transaction_id :instant_verify end - it 'creates an Instant Verify proofer because the new setting takes precedence' do + # rubocop:disable Layout/LineLength + it 'creates an Instant Verify proofer because the new setting takes precedence over the old one when the old one is set to its default value' do expect(proofer).to be_an_instance_of(Proofing::LexisNexis::InstantVerify::Proofer) end + # rubocop:enable Layout/LineLength end context 'and idv_resolution_default_vendor is set to :mock' do diff --git a/spec/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin_spec.rb b/spec/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin_spec.rb index f0873bf3966..e395a45d64f 100644 --- a/spec/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin_spec.rb +++ b/spec/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin_spec.rb @@ -305,9 +305,11 @@ :instant_verify end - it 'creates an Instant Verify proofer because the new setting takes precedence' do + # rubocop:disable Layout/LineLength + it 'creates an Instant Verify proofer because the new setting takes precedence over the old one when the old one is set to its default value' do expect(proofer).to be_an_instance_of(Proofing::LexisNexis::InstantVerify::Proofer) end + # rubocop:enable Layout/LineLength end context 'and idv_resolution_default_vendor is set to :mock' do