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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment on lines +46 to +48
Copy link
Contributor

Choose a reason for hiding this comment

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

Very minor: the examples in the tests say "the new setting takes precedence," but here the comment says we "fall back to the old config" which suggests it's the other way around. They're not discussing the same thing and the behavior is actually consistent, but if you see an easy way to make the wording consistent, it might further prevent confusion for anyone looking at this first thing in the morning while under-caffeinated. (Hypothetically speaking.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is a case of bad spec name. I changed it to 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. The idea is that, when proofer_mock_fallback is false, that is an indication that it has (probably) not been actively configured. If the new setting is set to a non-default value, we should use that instead.

:instant_verify
elsif new_config_says_iv
:instant_verify
else
:mock
end
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a fan of really expressive code like this for this sort of thing.

I think customarily we'd argue that old_config_says_mock is unneeded as a variable, and the first two cases of this conditional could be combined. But in temporary code handling something a little complicated to reason about? This makes it really easy to understand.


if proofer_type == :mock
Comment on lines +27 to +56
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that these blocks (and the added specs) are identical for the two plugins--the intention is that this is temporary code (cleanup PR coming), soon to be further streamlined in another PR.

Proofing::Mock::ResolutionMockClient.new
else
Proofing::LexisNexis::InstantVerify::Proofer.new(
Expand All @@ -39,6 +67,7 @@ def proofer
request_mode: IdentityConfig.store.lexisnexis_request_mode,
)
end
end
end

def residential_address_unnecessary_result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -59,6 +87,7 @@ def proofer
request_mode: IdentityConfig.store.lexisnexis_request_mode,
)
end
end
end

def resolution_cannot_pass
Expand Down
1 change: 1 addition & 0 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/identity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)
Comment on lines +179 to +183
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This, it turns out, is a much better thing to do than raise errors in application code if the setting is misconfigured

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }
Expand Down Expand Up @@ -128,4 +128,59 @@ 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

# 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 }

Expand Down Expand Up @@ -286,4 +286,59 @@
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

# 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
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