diff --git a/app/jobs/resolution_proofing_job.rb b/app/jobs/resolution_proofing_job.rb index 44401a8914e..b8cd4e08a95 100644 --- a/app/jobs/resolution_proofing_job.rb +++ b/app/jobs/resolution_proofing_job.rb @@ -76,7 +76,7 @@ def perform( if IdentityConfig.store.idv_socure_shadow_mode_enabled SocureShadowModeProofingJob.perform_later( - document_capture_session_result_id: document_capture_session.result_id, + document_capture_session_result_id: document_capture_session&.result_id, encrypted_arguments:, service_provider_issuer:, user_email: user_email_for_proofing(user), diff --git a/app/services/proofing/resolution/plugins/aamva_plugin.rb b/app/services/proofing/resolution/plugins/aamva_plugin.rb index 979bd3fd5ef..376e8b7e9a3 100644 --- a/app/services/proofing/resolution/plugins/aamva_plugin.rb +++ b/app/services/proofing/resolution/plugins/aamva_plugin.rb @@ -15,13 +15,13 @@ class AamvaPlugin def call( applicant_pii:, current_sp:, - instant_verify_state_id_address_result:, + state_id_address_resolution_result:, ipp_enrollment_in_progress:, timer: ) - should_proof = should_proof_state_id_with_aamva?( + should_proof = should_proof_state_id?( applicant_pii:, - instant_verify_state_id_address_result:, + state_id_address_resolution_result:, ipp_enrollment_in_progress:, ) @@ -85,37 +85,37 @@ def same_address_as_id?(applicant_pii) applicant_pii[:same_address_as_id].to_s == 'true' end - def should_proof_state_id_with_aamva?( + def should_proof_state_id?( applicant_pii:, - instant_verify_state_id_address_result:, + state_id_address_resolution_result:, ipp_enrollment_in_progress: ) return false unless aamva_supports_state_id_jurisdiction?(applicant_pii) # If the user is in in-person-proofing and they have changed their address then # they are not eligible for get-to-yes if !ipp_enrollment_in_progress || same_address_as_id?(applicant_pii) - user_can_pass_after_state_id_check?(instant_verify_state_id_address_result:) + user_can_pass_after_state_id_check?(state_id_address_resolution_result:) else - instant_verify_state_id_address_result.success? + state_id_address_resolution_result.success? end end def user_can_pass_after_state_id_check?( - instant_verify_state_id_address_result: + state_id_address_resolution_result: ) - return true if instant_verify_state_id_address_result.success? + return true if state_id_address_resolution_result.success? # For failed IV results, this method validates that the user is eligible to pass if the # failed attributes are covered by the same attributes in a successful AAMVA response # aka the Get-to-Yes w/ AAMVA feature. - if !instant_verify_state_id_address_result. + if !state_id_address_resolution_result. failed_result_can_pass_with_additional_verification? return false end attributes_aamva_can_pass = [:address, :dob, :state_id_number] attributes_requiring_additional_verification = - instant_verify_state_id_address_result.attributes_requiring_additional_verification + state_id_address_resolution_result.attributes_requiring_additional_verification results_that_cannot_pass_aamva = attributes_requiring_additional_verification - attributes_aamva_can_pass 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 deleted file mode 100644 index 85b1fb8a6eb..00000000000 --- a/app/services/proofing/resolution/plugins/instant_verify_residential_address_plugin.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -module Proofing - module Resolution - module Plugins - class InstantVerifyResidentialAddressPlugin - def call( - applicant_pii:, - current_sp:, - ipp_enrollment_in_progress:, - timer: - ) - return residential_address_unnecessary_result unless ipp_enrollment_in_progress - - timer.time('residential address') do - proofer.proof(applicant_pii) - end.tap do |result| - Db::SpCost::AddSpCost.call( - current_sp, - :lexis_nexis_resolution, - transaction_id: result.transaction_id, - ) - end - end - - def proofer - @proofer ||= - case IdentityConfig.store.idv_resolution_default_vendor - when :instant_verify - Proofing::LexisNexis::InstantVerify::Proofer.new( - instant_verify_workflow: IdentityConfig.store.lexisnexis_instant_verify_workflow, - account_id: IdentityConfig.store.lexisnexis_account_id, - base_url: IdentityConfig.store.lexisnexis_base_url, - username: IdentityConfig.store.lexisnexis_username, - password: IdentityConfig.store.lexisnexis_password, - hmac_key_id: IdentityConfig.store.lexisnexis_hmac_key_id, - hmac_secret_key: IdentityConfig.store.lexisnexis_hmac_secret_key, - request_mode: IdentityConfig.store.lexisnexis_request_mode, - ) - when :mock - Proofing::Mock::ResolutionMockClient.new - end - end - - def residential_address_unnecessary_result - Proofing::Resolution::Result.new( - success: true, errors: {}, exception: nil, vendor_name: 'ResidentialAddressNotRequired', - ) - end - end - end - end -end diff --git a/app/services/proofing/resolution/plugins/residential_address_plugin.rb b/app/services/proofing/resolution/plugins/residential_address_plugin.rb new file mode 100644 index 00000000000..4ad356b86ba --- /dev/null +++ b/app/services/proofing/resolution/plugins/residential_address_plugin.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module Proofing + module Resolution + module Plugins + class ResidentialAddressPlugin + attr_reader :proofer, :sp_cost_token + + def initialize( + proofer:, + sp_cost_token: + ) + @proofer = proofer + @sp_cost_token = sp_cost_token + end + + def call( + applicant_pii:, + current_sp:, + ipp_enrollment_in_progress:, + timer: + ) + return residential_address_unnecessary_result unless ipp_enrollment_in_progress + + timer.time('residential address') do + proofer.proof(applicant_pii) + end.tap do |result| + Db::SpCost::AddSpCost.call( + current_sp, + :lexis_nexis_resolution, + transaction_id: result.transaction_id, + ) + end + end + + def residential_address_unnecessary_result + Proofing::Resolution::Result.new( + success: true, errors: {}, exception: nil, vendor_name: 'ResidentialAddressNotRequired', + ) + end + end + end + end +end diff --git a/app/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin.rb b/app/services/proofing/resolution/plugins/state_id_address_plugin.rb similarity index 59% rename from app/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin.rb rename to app/services/proofing/resolution/plugins/state_id_address_plugin.rb index b2e1303d417..59768fbf28d 100644 --- a/app/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin.rb +++ b/app/services/proofing/resolution/plugins/state_id_address_plugin.rb @@ -3,7 +3,9 @@ module Proofing module Resolution module Plugins - class InstantVerifyStateIdAddressPlugin + class StateIdAddressPlugin + attr_reader :proofer, :sp_cost_token + SECONDARY_ID_ADDRESS_MAP = { identity_doc_address1: :address1, identity_doc_address2: :address2, @@ -12,18 +14,26 @@ class InstantVerifyStateIdAddressPlugin identity_doc_zipcode: :zipcode, }.freeze + def initialize( + proofer:, + sp_cost_token: + ) + @proofer = proofer + @sp_cost_token = sp_cost_token + end + def call( applicant_pii:, current_sp:, - instant_verify_residential_address_result:, + residential_address_resolution_result:, ipp_enrollment_in_progress:, timer: ) if same_address_as_id?(applicant_pii) && ipp_enrollment_in_progress - return instant_verify_residential_address_result + return residential_address_resolution_result end - return resolution_cannot_pass unless instant_verify_residential_address_result.success? + return resolution_cannot_pass unless residential_address_resolution_result.success? applicant_pii_with_state_id_address = if ipp_enrollment_in_progress @@ -43,25 +53,6 @@ def call( end end - def proofer - @proofer ||= - case IdentityConfig.store.idv_resolution_default_vendor - when :instant_verify - Proofing::LexisNexis::InstantVerify::Proofer.new( - instant_verify_workflow: IdentityConfig.store.lexisnexis_instant_verify_workflow, - account_id: IdentityConfig.store.lexisnexis_account_id, - base_url: IdentityConfig.store.lexisnexis_base_url, - username: IdentityConfig.store.lexisnexis_username, - password: IdentityConfig.store.lexisnexis_password, - hmac_key_id: IdentityConfig.store.lexisnexis_hmac_key_id, - hmac_secret_key: IdentityConfig.store.lexisnexis_hmac_secret_key, - request_mode: IdentityConfig.store.lexisnexis_request_mode, - ) - when :mock - Proofing::Mock::ResolutionMockClient.new - end - end - def resolution_cannot_pass Proofing::Resolution::Result.new( success: false, errors: {}, exception: nil, vendor_name: 'ResolutionCannotPass', diff --git a/app/services/proofing/resolution/progressive_proofer.rb b/app/services/proofing/resolution/progressive_proofer.rb index 757a4f244e9..2fbe8c9c3bd 100644 --- a/app/services/proofing/resolution/progressive_proofer.rb +++ b/app/services/proofing/resolution/progressive_proofer.rb @@ -8,17 +8,19 @@ module Resolution # 2. The user has only provided one address for their residential and identity document # address or separate residential and identity document addresses class ProgressiveProofer + class InvalidProofingVendorError; end + attr_reader :aamva_plugin, - :instant_verify_residential_address_plugin, - :instant_verify_state_id_address_plugin, :threatmetrix_plugin + PROOFING_VENDOR_SP_COST_TOKENS = { + mock: :mock_resolution, + instant_verify: :lexis_nexis_resolution, + socure_kyc: :socure_resolution, + }.freeze + def initialize @aamva_plugin = Plugins::AamvaPlugin.new - @instant_verify_residential_address_plugin = - Plugins::InstantVerifyResidentialAddressPlugin.new - @instant_verify_state_id_address_plugin = - Plugins::InstantVerifyStateIdAddressPlugin.new @threatmetrix_plugin = Plugins::ThreatMetrixPlugin.new end @@ -50,17 +52,17 @@ def proof( user_email:, ) - instant_verify_residential_address_result = instant_verify_residential_address_plugin.call( + residential_address_resolution_result = residential_address_plugin.call( applicant_pii:, current_sp:, ipp_enrollment_in_progress:, timer:, ) - instant_verify_state_id_address_result = instant_verify_state_id_address_plugin.call( + state_id_address_resolution_result = state_id_address_plugin.call( applicant_pii:, current_sp:, - instant_verify_residential_address_result:, + residential_address_resolution_result:, ipp_enrollment_in_progress:, timer:, ) @@ -68,7 +70,7 @@ def proof( state_id_result = aamva_plugin.call( applicant_pii:, current_sp:, - instant_verify_state_id_address_result:, + state_id_address_resolution_result:, ipp_enrollment_in_progress:, timer:, ) @@ -76,14 +78,92 @@ def proof( ResultAdjudicator.new( device_profiling_result: device_profiling_result, ipp_enrollment_in_progress: ipp_enrollment_in_progress, - resolution_result: instant_verify_state_id_address_result, + resolution_result: state_id_address_resolution_result, should_proof_state_id: aamva_plugin.aamva_supports_state_id_jurisdiction?(applicant_pii), state_id_result: state_id_result, - residential_resolution_result: instant_verify_residential_address_result, + residential_resolution_result: residential_address_resolution_result, same_address_as_id: applicant_pii[:same_address_as_id], applicant_pii: applicant_pii, ) end + + def proofing_vendor + @proofing_vendor ||= begin + default_vendor = IdentityConfig.store.idv_resolution_default_vendor + alternate_vendor = IdentityConfig.store.idv_resolution_alternate_vendor + alternate_vendor_percent = IdentityConfig.store.idv_resolution_alternate_vendor_percent + + if alternate_vendor == :none + return default_vendor + end + + if (rand * 100) <= alternate_vendor_percent + alternate_vendor + else + default_vendor + end + end + end + + def residential_address_plugin + @residential_address_plugin ||= Plugins::ResidentialAddressPlugin.new( + proofer: create_proofer, + sp_cost_token:, + ) + end + + def state_id_address_plugin + @state_id_address_plugin ||= Plugins::StateIdAddressPlugin.new( + proofer: create_proofer, + sp_cost_token:, + ) + end + + def create_proofer + case proofing_vendor + when :instant_verify then create_instant_verify_proofer + when :mock then create_mock_proofer + when :socure_kyc then create_socure_proofer + else + raise InvalidProofingVendorError, "#{proofing_vendor} is not a valid proofing vendor" + end + end + + def create_instant_verify_proofer + Proofing::LexisNexis::InstantVerify::Proofer.new( + instant_verify_workflow: IdentityConfig.store.lexisnexis_instant_verify_workflow, + account_id: IdentityConfig.store.lexisnexis_account_id, + base_url: IdentityConfig.store.lexisnexis_base_url, + username: IdentityConfig.store.lexisnexis_username, + password: IdentityConfig.store.lexisnexis_password, + hmac_key_id: IdentityConfig.store.lexisnexis_hmac_key_id, + hmac_secret_key: IdentityConfig.store.lexisnexis_hmac_secret_key, + request_mode: IdentityConfig.store.lexisnexis_request_mode, + ) + end + + def create_mock_proofer + Proofing::Mock::ResolutionMockClient.new + end + + def create_socure_proofer + Proofing::Socure::IdPlus::Proofer.new( + Proofing::Socure::IdPlus::Config.new( + api_key: IdentityConfig.store.socure_idplus_api_key, + base_url: IdentityConfig.store.socure_idplus_base_url, + timeout: IdentityConfig.store.socure_idplus_timeout_in_seconds, + ), + ) + end + + def sp_cost_token + PROOFING_VENDOR_SP_COST_TOKENS[proofing_vendor].tap do |token| + if !token.present? + raise InvalidProofingVendorError, + "No cost token present for proofing vendor #{proofing_vendor}" + end + end + end end end end diff --git a/app/services/proofing/socure/id_plus/proofer.rb b/app/services/proofing/socure/id_plus/proofer.rb index 4184fed409d..2bbb2ef7b14 100644 --- a/app/services/proofing/socure/id_plus/proofer.rb +++ b/app/services/proofing/socure/id_plus/proofer.rb @@ -34,14 +34,14 @@ def initialize(config) # @param [Hash] applicant # @return [Proofing::Resolution::Result] def proof(applicant) - input = Input.new(applicant.except(:phone_source)) + input = Input.new(applicant.slice(*Input.members)) request = Request.new(config:, input:) response = request.send_request build_result_from_response(response) - rescue Proofing::TimeoutError, RequestError => err + rescue Proofing::TimeoutError, Request::Error => err build_result_from_error(err) end diff --git a/app/services/proofing/socure/id_plus/request.rb b/app/services/proofing/socure/id_plus/request.rb index 881c495d63d..74b380ffe0b 100644 --- a/app/services/proofing/socure/id_plus/request.rb +++ b/app/services/proofing/socure/id_plus/request.rb @@ -3,42 +3,42 @@ module Proofing module Socure module IdPlus - class RequestError < StandardError - def initialize(wrapped) - @wrapped = wrapped - super(build_message) - end + class Request + class Error < StandardError + def initialize(wrapped) + @wrapped = wrapped + super(build_message) + end - def reference_id - return @reference_id if defined?(@reference_id) - @reference_id = response_body.is_a?(Hash) ? - response_body['referenceId'] : - nil - end + def reference_id + return @reference_id if defined?(@reference_id) + @reference_id = response_body.is_a?(Hash) ? + response_body['referenceId'] : + nil + end - def response_body - return @response_body if defined?(@response_body) - @response_body = wrapped.try(:response_body) - end + def response_body + return @response_body if defined?(@response_body) + @response_body = wrapped.try(:response_body) + end - def response_status - return @response_status if defined?(@response_status) - @response_status = wrapped.try(:response_status) - end + def response_status + return @response_status if defined?(@response_status) + @response_status = wrapped.try(:response_status) + end - private + private - attr_reader :wrapped + attr_reader :wrapped - def build_message - message = response_body.is_a?(Hash) ? response_body['msg'] : nil - message ||= wrapped.message - status = response_status ? " (#{response_status})" : '' - [message, status].join('') + def build_message + message = response_body.is_a?(Hash) ? response_body['msg'] : nil + message ||= wrapped.message + status = response_status ? " (#{response_status})" : '' + [message, status].join('') + end end - end - class Request attr_reader :config, :input SERVICE_NAME = 'socure_id_plus' @@ -78,7 +78,7 @@ def send_request 'Timed out waiting for verification response' end - raise RequestError, e + raise Error, e end def body diff --git a/config/application.yml.default b/config/application.yml.default index 5a8aba29407..3e72fd32c6f 100644 --- a/config/application.yml.default +++ b/config/application.yml.default @@ -156,6 +156,8 @@ idv_available: true idv_contact_phone_number: (844) 555-5555 idv_max_attempts: 5 idv_min_age_years: 13 +idv_resolution_alternate_vendor: none +idv_resolution_alternate_vendor_percent: 0 idv_resolution_default_vendor: mock idv_send_link_attempt_window_in_minutes: 10 idv_send_link_max_attempts: 5 diff --git a/lib/identity_config.rb b/lib/identity_config.rb index 44938a1fc13..bf04825a906 100644 --- a/lib/identity_config.rb +++ b/lib/identity_config.rb @@ -174,10 +174,16 @@ 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_alternate_vendor, + type: :symbol, + enum: [:instant_verify, :socure_kyc, :mock, :none], + ) + config.add(:idv_resolution_alternate_vendor_percent, type: :integer) config.add( :idv_resolution_default_vendor, type: :symbol, - enum: [:instant_verify, :mock], + enum: [:instant_verify, :socure_kyc, :mock], ) config.add(:idv_send_link_attempt_window_in_minutes, type: :integer) config.add(:idv_send_link_max_attempts, type: :integer) diff --git a/spec/config/initializers/idv_config_spec.rb b/spec/config/initializers/idv_config_spec.rb new file mode 100644 index 00000000000..e69de29bb2d diff --git a/spec/services/proofing/resolution/plugins/aamva_plugin_spec.rb b/spec/services/proofing/resolution/plugins/aamva_plugin_spec.rb index cfd24e0c754..f23c51056c4 100644 --- a/spec/services/proofing/resolution/plugins/aamva_plugin_spec.rb +++ b/spec/services/proofing/resolution/plugins/aamva_plugin_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Proofing::Resolution::Plugins::AamvaPlugin do let(:applicant_pii) { Idp::Constants::MOCK_IDV_APPLICANT_WITH_SSN } let(:current_sp) { build(:service_provider) } - let(:instant_verify_state_id_address_result) { nil } + let(:state_id_address_resolution_result) { nil } let(:ipp_enrollment_in_progress) { false } let(:proofer) { instance_double(Proofing::Aamva::Proofer, proof: proofer_result) } let(:proofer_result) do @@ -40,7 +40,7 @@ def sp_cost_count_with_transaction_id plugin.call( applicant_pii:, current_sp:, - instant_verify_state_id_address_result:, + state_id_address_resolution_result:, ipp_enrollment_in_progress:, timer: JobHelpers::Timer.new, ) @@ -60,7 +60,7 @@ def sp_cost_count_with_transaction_id end context 'InstantVerify succeeded' do - let(:instant_verify_state_id_address_result) do + let(:state_id_address_resolution_result) do Proofing::Resolution::Result.new( success: true, vendor_name: 'lexisnexis:instant_verify', @@ -96,7 +96,7 @@ def sp_cost_count_with_transaction_id context 'InstantVerify failed' do context 'and the failure can possibly be covered by AAMVA' do - let(:instant_verify_state_id_address_result) do + let(:state_id_address_resolution_result) do Proofing::Resolution::Result.new( success: false, vendor_name: 'lexisnexis:instant_verify', @@ -120,7 +120,7 @@ def sp_cost_count_with_transaction_id end context 'but the failure cannot be covered by AAMVA' do - let(:instant_verify_state_id_address_result) do + let(:state_id_address_resolution_result) do Proofing::Resolution::Result.new( success: false, vendor_name: 'lexisnexis:instant_verify', @@ -164,7 +164,7 @@ def sp_cost_count_with_transaction_id context 'residential address same as id address' do let(:applicant_pii) { Idp::Constants::MOCK_IDV_APPLICANT_SAME_ADDRESS_AS_ID } - let(:instant_verify_state_id_address_result) do + let(:state_id_address_resolution_result) do Proofing::Resolution::Result.new( success: true, vendor_name: 'lexisnexis:instant_verify', @@ -184,7 +184,7 @@ def sp_cost_count_with_transaction_id context 'InstantVerify failed' do context 'and the failure can possibly be covered by AAMVA' do - let(:instant_verify_state_id_address_result) do + let(:state_id_address_resolution_result) do Proofing::Resolution::Result.new( success: false, vendor_name: 'lexisnexis:instant_verify', @@ -204,7 +204,7 @@ def sp_cost_count_with_transaction_id end context 'but the failure cannot be covered by AAMVA' do - let(:instant_verify_state_id_address_result) do + let(:state_id_address_resolution_result) do Proofing::Resolution::Result.new( success: false, vendor_name: 'lexisnexis:instant_verify', @@ -236,7 +236,7 @@ def sp_cost_count_with_transaction_id context 'InstantVerify succeeded for residential address' do context 'and InstantVerify passed for id address' do - let(:instant_verify_state_id_address_result) do + let(:state_id_address_resolution_result) do Proofing::Resolution::Result.new( success: true, vendor_name: 'lexisnexis:instant_verify', @@ -255,7 +255,7 @@ def sp_cost_count_with_transaction_id context 'and InstantVerify failed for state id address' do context 'but the failure can possibly be covered by AAMVA' do - let(:instant_verify_state_id_address_result) do + let(:state_id_address_resolution_result) do Proofing::Resolution::Result.new( success: false, vendor_name: 'lexisnexis:instant_verify', @@ -275,7 +275,7 @@ def sp_cost_count_with_transaction_id end context 'and the failure cannot be covered by AAMVA' do - let(:instant_verify_state_id_address_result) do + let(:state_id_address_resolution_result) do Proofing::Resolution::Result.new( success: false, vendor_name: 'lexisnexis:instant_verify', diff --git a/spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb b/spec/services/proofing/resolution/plugins/residential_address_plugin_spec.rb similarity index 79% rename from spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb rename to spec/services/proofing/resolution/plugins/residential_address_plugin_spec.rb index 3f4df349359..e8af3647ee9 100644 --- a/spec/services/proofing/resolution/plugins/instant_verify_residential_address_plugin_spec.rb +++ b/spec/services/proofing/resolution/plugins/residential_address_plugin_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe Proofing::Resolution::Plugins::InstantVerifyResidentialAddressPlugin do +RSpec.describe Proofing::Resolution::Plugins::ResidentialAddressPlugin do let(:current_sp) { build(:service_provider) } let(:ipp_enrollment_in_progress) { false } @@ -11,12 +11,21 @@ Proofing::Resolution::Result.new( success: true, transaction_id: proofer_transaction_id, - vendor_name: 'lexisnexis:instant_verify', + vendor_name: 'test_resolution_vendor', ) end + let(:proofer) do + instance_double(Proofing::LexisNexis::InstantVerify::Proofer, proof: proofer_result) + end + + let(:sp_cost_token) { :test_cost_token } + subject(:plugin) do - described_class.new + described_class.new( + proofer:, + sp_cost_token:, + ) end describe '#call' do @@ -128,29 +137,4 @@ def sp_cost_count_with_transaction_id end end end - - describe '#proofer' do - subject(:proofer) { plugin.proofer } - - before do - allow(IdentityConfig.store).to receive(:idv_resolution_default_vendor). - and_return(idv_resolution_default_vendor) - end - - context 'idv_resolution_default_vendor is set to :instant_verify' do - let(:idv_resolution_default_vendor) { :instant_verify } - - it 'creates an Instant Verify proofer' do - expect(proofer).to be_an_instance_of(Proofing::LexisNexis::InstantVerify::Proofer) - end - end - - context 'idv_resolution_default_vendor is set to :mock' do - let(:idv_resolution_default_vendor) { :mock } - - it 'creates a mock proofer' do - expect(proofer).to be_an_instance_of(Proofing::Mock::ResolutionMockClient) - 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/state_id_address_plugin_spec.rb similarity index 78% rename from spec/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin_spec.rb rename to spec/services/proofing/resolution/plugins/state_id_address_plugin_spec.rb index 1b654c8f3d2..de3ed2161bc 100644 --- a/spec/services/proofing/resolution/plugins/instant_verify_state_id_address_plugin_spec.rb +++ b/spec/services/proofing/resolution/plugins/state_id_address_plugin_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -RSpec.describe Proofing::Resolution::Plugins::InstantVerifyStateIdAddressPlugin do +RSpec.describe Proofing::Resolution::Plugins::StateIdAddressPlugin do let(:applicant_pii) { Idp::Constants::MOCK_IDV_APPLICANT_SAME_ADDRESS_AS_ID } let(:current_sp) { build(:service_provider) } - let(:instant_verify_residential_address_result) do + let(:residential_address_resolution_result) do Proofing::Resolution::Result.new( success: true, errors: {}, exception: nil, - vendor_name: 'lexisnexis:instant_verify', + vendor_name: 'test_resolution_vendor', ) end @@ -21,12 +21,21 @@ success: true, errors: {}, exception: nil, - vendor_name: 'lexisnexis:instant_verify', + vendor_name: 'test_resolution_vendor', ) end + let(:proofer) do + instance_double(Proofing::LexisNexis::InstantVerify::Proofer, proof: proofer_result) + end + + let(:sp_cost_token) { :test_cost_token } + subject(:plugin) do - described_class.new + described_class.new( + proofer:, + sp_cost_token:, + ) end describe '#call' do @@ -35,15 +44,11 @@ applicant_pii:, current_sp:, ipp_enrollment_in_progress:, - instant_verify_residential_address_result:, + residential_address_resolution_result:, timer: JobHelpers::Timer.new, ) 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 } @@ -61,18 +66,17 @@ it 'passes state id address to proofer' do expect(plugin.proofer). to receive(:proof). - with(hash_including(state_id_address)). - and_call_original + with(hash_including(state_id_address)) call end - context 'when InstantVerify call succeeds' do + context 'when vendor call succeeds' do it 'returns the proofer result' do expect(call).to eql(proofer_result) end - it 'records a LexisNexis SP cost' do + it 'records correct SP cost' do expect { call }. to change { SpCost.where( @@ -83,13 +87,13 @@ end end - context 'when InstantVerify call fails' do + context 'when vendor call fails' do let(:proofer_result) do Proofing::Resolution::Result.new( success: false, errors: {}, exception: nil, - vendor_name: 'lexisnexis:instant_verify', + vendor_name: 'test_resolution_vendor', ) end @@ -108,7 +112,7 @@ end end - context 'when InstantVerify call results in exception' do + context 'when vendor call results in exception' do let(:proofer_result) do Proofing::Resolution::Result.new( success: false, @@ -139,7 +143,7 @@ it 'reuses residential address result' do result = call expect(plugin.proofer).not_to have_received(:proof) - expect(result).to eql(instant_verify_residential_address_result) + expect(result).to eql(residential_address_resolution_result) end it 'does not add a new LexisNexis SP cost (since residential address result was reused)' do @@ -176,15 +180,14 @@ } end - context 'LexisNexis InstantVerify passes for residential address' do - it 'calls the InstantVerify Proofer with state id address' do - expect(plugin.proofer).to receive(:proof).with(hash_including(state_id_address)). - and_call_original + context 'LexisNexis vendor passes for residential address' do + it 'calls the vendor Proofer with state id address' do + expect(plugin.proofer).to receive(:proof).with(hash_including(state_id_address)) call end - context 'when InstantVerify call succeeds' do + context 'when vendor call succeeds' do it 'returns the proofer result' do expect(call).to eql(proofer_result) end @@ -200,7 +203,7 @@ end end - context 'when InstantVerify call fails' do + context 'when vendor call fails' do let(:proofer_result) do Proofing::Resolution::Result.new( success: false, @@ -225,7 +228,7 @@ end end - context 'when InstantVerify call results in exception' do + context 'when vendor call results in exception' do let(:proofer_result) do Proofing::Resolution::Result.new( success: false, @@ -250,8 +253,8 @@ end end - context 'LexisNexis InstantVerify failed for residential address' do - let(:instant_verify_residential_address_result) do + context 'LexisNexis vendor failed for residential address' do + let(:residential_address_resolution_result) do Proofing::Resolution::Result.new( success: false, errors: {}, @@ -286,29 +289,4 @@ end end end - - describe '#proofer' do - subject(:proofer) { plugin.proofer } - - before do - allow(IdentityConfig.store).to receive(:idv_resolution_default_vendor). - and_return(idv_resolution_default_vendor) - end - - context 'idv_resolution_default_vendor is set to :instant_verify' do - let(:idv_resolution_default_vendor) { :instant_verify } - - it 'creates an Instant Verify proofer' do - expect(proofer).to be_an_instance_of(Proofing::LexisNexis::InstantVerify::Proofer) - end - end - - context 'idv_resolution_default_vendor is set to :mock' do - let(:idv_resolution_default_vendor) { :mock } - - it 'creates a mock proofer' do - expect(proofer).to be_an_instance_of(Proofing::Mock::ResolutionMockClient) - end - end - end end diff --git a/spec/services/proofing/resolution/progressive_proofer_spec.rb b/spec/services/proofing/resolution/progressive_proofer_spec.rb index 10723e687da..5b7eab4a20a 100644 --- a/spec/services/proofing/resolution/progressive_proofer_spec.rb +++ b/spec/services/proofing/resolution/progressive_proofer_spec.rb @@ -1,116 +1,14 @@ require 'rails_helper' RSpec.describe Proofing::Resolution::ProgressiveProofer do - let(:applicant_pii) { Idp::Constants::MOCK_IDV_APPLICANT_WITH_SSN } - let(:ipp_enrollment_in_progress) { false } - let(:request_ip) { Faker::Internet.ip_v4_address } - let(:threatmetrix_session_id) { SecureRandom.uuid } - let(:user_email) { Faker::Internet.email } - let(:current_sp) { build(:service_provider) } - - let(:instant_verify_residential_address_plugin) do - Proofing::Resolution::Plugins::InstantVerifyResidentialAddressPlugin.new - end - - let(:instant_verify_residential_address_result) do - Proofing::Resolution::Result.new( - success: true, - transaction_id: 'iv-residential', - ) - end - - let(:instant_verify_residential_address_proofer) do - instance_double( - Proofing::LexisNexis::InstantVerify::Proofer, - proof: instant_verify_residential_address_result, - ) - end - - let(:instant_verify_state_id_address_plugin) do - Proofing::Resolution::Plugins::InstantVerifyStateIdAddressPlugin.new - end - - let(:instant_verify_state_id_address_result) do - Proofing::Resolution::Result.new( - success: true, - transaction_id: 'iv-state-id', - ) - end - - let(:instant_verify_state_id_address_proofer) do - instance_double( - Proofing::LexisNexis::InstantVerify::Proofer, - proof: instant_verify_state_id_address_result, - ) - end - - let(:aamva_plugin) { Proofing::Resolution::Plugins::AamvaPlugin.new } - - let(:aamva_result) do - Proofing::StateIdResult.new( - success: false, - transaction_id: 'aamva-123', - ) - end - - let(:aamva_proofer) { instance_double(Proofing::Aamva::Proofer, proof: aamva_result) } - - let(:threatmetrix_plugin) do - Proofing::Resolution::Plugins::ThreatMetrixPlugin.new - end - - let(:threatmetrix_result) do - Proofing::DdpResult.new( - success: true, - transaction_id: 'ddp-123', - ) - end - - let(:threatmetrix_proofer) do - instance_double( - Proofing::LexisNexis::Ddp::Proofer, - proof: threatmetrix_result, - ) - end - subject(:progressive_proofer) { described_class.new } - before do - allow(progressive_proofer).to receive(:threatmetrix_plugin).and_return(threatmetrix_plugin) - allow(threatmetrix_plugin).to receive(:proofer).and_return(threatmetrix_proofer) - - allow(progressive_proofer).to receive(:aamva_plugin).and_return(aamva_plugin) - allow(aamva_plugin).to receive(:proofer).and_return(aamva_proofer) - - allow(progressive_proofer).to receive(:instant_verify_residential_address_plugin). - and_return(instant_verify_residential_address_plugin) - allow(instant_verify_residential_address_plugin).to receive(:proofer). - and_return(instant_verify_residential_address_proofer) - - allow(progressive_proofer).to receive(:instant_verify_state_id_address_plugin). - and_return(instant_verify_state_id_address_plugin) - allow(instant_verify_state_id_address_plugin).to receive(:proofer). - and_return(instant_verify_state_id_address_proofer) - end - it 'assigns aamva_plugin' do expect(described_class.new.aamva_plugin).to be_a( Proofing::Resolution::Plugins::AamvaPlugin, ) end - it 'assigns instant_verify_residential_address_plugin' do - expect(described_class.new.instant_verify_residential_address_plugin).to be_a( - Proofing::Resolution::Plugins::InstantVerifyResidentialAddressPlugin, - ) - end - - it 'assigns instant_verify_state_id_address_plugin' do - expect(described_class.new.instant_verify_state_id_address_plugin).to be_a( - Proofing::Resolution::Plugins::InstantVerifyStateIdAddressPlugin, - ) - end - it 'assigns threatmetrix_plugin' do expect(described_class.new.threatmetrix_plugin).to be_a( Proofing::Resolution::Plugins::ThreatMetrixPlugin, @@ -118,6 +16,62 @@ end describe '#proof' do + let(:applicant_pii) { Idp::Constants::MOCK_IDV_APPLICANT_WITH_SSN } + let(:ipp_enrollment_in_progress) { false } + let(:request_ip) { Faker::Internet.ip_v4_address } + let(:threatmetrix_session_id) { SecureRandom.uuid } + let(:user_email) { Faker::Internet.email } + let(:current_sp) { build(:service_provider) } + + let(:residential_address_resolution_result) do + Proofing::Resolution::Result.new( + success: true, + transaction_id: 'residential-resolution-tx', + ) + end + + let(:state_id_address_resolution_result) do + Proofing::Resolution::Result.new( + success: true, + transaction_id: 'state-id-resolution-tx', + ) + end + + let(:resolution_proofing_results) do + # In cases where both calls are made, the residential call is made + # before the state id address call + [residential_address_resolution_result, state_id_address_resolution_result] + end + + let(:resolution_proofer) do + instance_double( + Proofing::LexisNexis::InstantVerify::Proofer, + ) + end + + let(:aamva_result) do + Proofing::StateIdResult.new( + success: false, + transaction_id: 'aamva-123', + ) + end + + let(:aamva_proofer) { instance_double(Proofing::Aamva::Proofer, proof: aamva_result) } + + let(:threatmetrix_result) do + Proofing::DdpResult.new( + success: true, + transaction_id: 'ddp-123', + ) + end + + let(:threatmetrix_proofer) do + instance_double( + Proofing::LexisNexis::Ddp::Proofer, + proof: threatmetrix_result, + ) + end + subject(:proof) do progressive_proofer.proof( applicant_pii:, @@ -130,20 +84,37 @@ ) end + before do + allow(resolution_proofer).to receive(:proof).and_return(*resolution_proofing_results) + allow(progressive_proofer).to receive(:create_proofer). + and_return(resolution_proofer) + + allow(progressive_proofer.threatmetrix_plugin).to receive(:proofer). + and_return(threatmetrix_proofer) + + allow(progressive_proofer.aamva_plugin).to receive(:proofer). + and_return(aamva_proofer) + end + context 'remote unsupervised proofing' do + let(:resolution_proofing_results) do + # No call is made for residential address on remote unsupervised path + [state_id_address_resolution_result] + end + it 'calls AamvaPlugin' do - expect(aamva_plugin).to receive(:call).with( + expect(progressive_proofer.aamva_plugin).to receive(:call).with( applicant_pii:, current_sp:, - instant_verify_state_id_address_result:, + state_id_address_resolution_result:, ipp_enrollment_in_progress: false, timer: an_instance_of(JobHelpers::Timer), ) proof end - it 'calls InstantVerifyResidentialAddressPlugin' do - expect(instant_verify_residential_address_plugin).to receive(:call).with( + it 'calls ResidentialAddressPlugin' do + expect(progressive_proofer.residential_address_plugin).to receive(:call).with( applicant_pii:, current_sp:, ipp_enrollment_in_progress: false, @@ -152,11 +123,11 @@ proof end - it 'calls InstantVerifyStateIdAddressPlugin' do - expect(instant_verify_state_id_address_plugin).to receive(:call).with( + it 'calls StateIdAddressPlugin' do + expect(progressive_proofer.state_id_address_plugin).to receive(:call).with( applicant_pii:, current_sp:, - instant_verify_residential_address_result: satisfy do |result| + residential_address_resolution_result: satisfy do |result| expect(result.success?).to eql(true) expect(result.vendor_name).to eql('ResidentialAddressNotRequired') end, @@ -167,7 +138,7 @@ end it 'calls ThreatMetrixPlugin' do - expect(threatmetrix_plugin).to receive(:call).with( + expect(progressive_proofer.threatmetrix_plugin).to receive(:call).with( applicant_pii:, current_sp:, request_ip:, @@ -182,7 +153,7 @@ proof.tap do |result| expect(result).to be_an_instance_of(Proofing::Resolution::ResultAdjudicator) - expect(result.resolution_result).to eql(instant_verify_state_id_address_result) + expect(result.resolution_result).to eql(state_id_address_resolution_result) expect(result.state_id_result).to eql(aamva_result) expect(result.device_profiling_result).to eql(threatmetrix_result) expect(result.residential_resolution_result).to satisfy do |result| @@ -201,15 +172,15 @@ context 'residential address is same as id' do let(:applicant_pii) { Idp::Constants::MOCK_IDV_APPLICANT_SAME_ADDRESS_AS_ID } - let(:instant_verify_state_id_address_result) do - instant_verify_residential_address_result + let(:state_id_address_resolution_result) do + residential_address_resolution_result end it 'calls AamvaPlugin' do - expect(aamva_plugin).to receive(:call).with( + expect(progressive_proofer.aamva_plugin).to receive(:call).with( applicant_pii:, current_sp:, - instant_verify_state_id_address_result:, + state_id_address_resolution_result:, ipp_enrollment_in_progress: true, timer: an_instance_of(JobHelpers::Timer), ) @@ -217,8 +188,8 @@ proof end - it 'calls InstantVerifyResidentialAddressPlugin' do - expect(instant_verify_residential_address_plugin).to receive(:call).with( + it 'calls ResidentialAddressPlugin' do + expect(progressive_proofer.residential_address_plugin).to receive(:call).with( applicant_pii:, current_sp:, ipp_enrollment_in_progress: true, @@ -227,11 +198,11 @@ proof end - it 'calls InstantVerifyStateIdAddressPlugin' do - expect(instant_verify_state_id_address_plugin).to receive(:call).with( + it 'calls StateIdAddressPlugin' do + expect(progressive_proofer.state_id_address_plugin).to receive(:call).with( applicant_pii:, current_sp:, - instant_verify_residential_address_result:, + residential_address_resolution_result:, ipp_enrollment_in_progress: true, timer: an_instance_of(JobHelpers::Timer), ).and_call_original @@ -239,7 +210,7 @@ end it 'calls ThreatMetrixPlugin' do - expect(threatmetrix_plugin).to receive(:call).with( + expect(progressive_proofer.threatmetrix_plugin).to receive(:call).with( applicant_pii:, current_sp:, request_ip:, @@ -254,11 +225,11 @@ proof.tap do |result| expect(result).to be_an_instance_of(Proofing::Resolution::ResultAdjudicator) - expect(result.resolution_result).to eql(instant_verify_state_id_address_result) + expect(result.resolution_result).to eql(state_id_address_resolution_result) expect(result.state_id_result).to eql(aamva_result) expect(result.device_profiling_result).to eql(threatmetrix_result) expect(result.residential_resolution_result).to( - eql(instant_verify_state_id_address_result), + eql(state_id_address_resolution_result), ) expect(result.ipp_enrollment_in_progress).to eql(true) expect(proof.same_address_as_id).to eq(applicant_pii[:same_address_as_id]) @@ -270,7 +241,7 @@ let(:applicant_pii) { Idp::Constants::MOCK_IDV_APPLICANT_STATE_ID_ADDRESS } it 'calls ThreatMetrixPlugin' do - expect(threatmetrix_plugin).to receive(:call).with( + expect(progressive_proofer.threatmetrix_plugin).to receive(:call).with( applicant_pii:, current_sp:, request_ip:, @@ -281,8 +252,8 @@ proof end - it 'calls InstantVerifyResidentialAddressPlugin' do - expect(instant_verify_residential_address_plugin).to receive(:call).with( + it 'calls ResidentialAddressPlugin' do + expect(progressive_proofer.residential_address_plugin).to receive(:call).with( applicant_pii:, current_sp:, ipp_enrollment_in_progress: true, @@ -291,11 +262,11 @@ proof end - it 'calls InstantVerifyStateIdAddressPlugin' do - expect(instant_verify_state_id_address_plugin).to receive(:call).with( + it 'calls StateIdAddressPlugin' do + expect(progressive_proofer.state_id_address_plugin).to receive(:call).with( applicant_pii:, current_sp:, - instant_verify_residential_address_result:, + residential_address_resolution_result:, ipp_enrollment_in_progress: true, timer: an_instance_of(JobHelpers::Timer), ).and_call_original @@ -303,10 +274,10 @@ end it 'calls AamvaPlugin' do - expect(aamva_plugin).to receive(:call).with( + expect(progressive_proofer.aamva_plugin).to receive(:call).with( applicant_pii:, current_sp:, - instant_verify_state_id_address_result:, + state_id_address_resolution_result:, ipp_enrollment_in_progress: true, timer: an_instance_of(JobHelpers::Timer), ).and_call_original @@ -316,11 +287,11 @@ it 'returns a ResultAdjudicator' do proof.tap do |result| expect(result).to be_an_instance_of(Proofing::Resolution::ResultAdjudicator) - expect(result.resolution_result).to eql(instant_verify_state_id_address_result) + expect(result.resolution_result).to eql(state_id_address_resolution_result) expect(result.state_id_result).to eql(aamva_result) expect(result.device_profiling_result).to eql(threatmetrix_result) expect(result.residential_resolution_result).to( - eql(instant_verify_residential_address_result), + eql(residential_address_resolution_result), ) expect(result.ipp_enrollment_in_progress).to eql(true) expect(result.same_address_as_id).to eql('false') @@ -339,12 +310,15 @@ it 'does not pass the phone number to plugins' do expected_applicant_pii = applicant_pii.except(:best_effort_phone_number_for_socure) - [ - aamva_plugin, - instant_verify_residential_address_plugin, - instant_verify_state_id_address_plugin, - threatmetrix_plugin, - ].each do |plugin| + plugin_methods = %i[ + aamva_plugin + residential_address_plugin + state_id_address_plugin + threatmetrix_plugin + ] + + plugin_methods.each do |plugin_method_name| + plugin = progressive_proofer.send(plugin_method_name) expect(plugin).to receive(:call).with( hash_including( applicant_pii: expected_applicant_pii, @@ -356,4 +330,166 @@ end end end + + describe '#proofing_vendor' do + let(:idv_resolution_default_vendor) { :default_vendor } + let(:idv_resolution_alternate_vendor) { :alternate_vendor } + let(:idv_resolution_alternate_vendor_percent) { 0 } + + subject(:proofing_vendor) { progressive_proofer.proofing_vendor } + + before do + allow(IdentityConfig.store).to receive(:idv_resolution_default_vendor). + and_return(idv_resolution_default_vendor) + allow(IdentityConfig.store).to receive(:idv_resolution_alternate_vendor). + and_return(idv_resolution_alternate_vendor) + allow(IdentityConfig.store).to receive(:idv_resolution_alternate_vendor_percent). + and_return(idv_resolution_alternate_vendor_percent) + end + + context 'when default is set to 100%' do + it 'uses the default' do + expect(proofing_vendor).to eql(:default_vendor) + end + end + + context 'when alternate is set to 100%' do + let(:idv_resolution_alternate_vendor_percent) { 100 } + + it 'uses the alternate' do + expect(proofing_vendor).to eql(:alternate_vendor) + end + end + + context 'when no alternate is set' do + let(:idv_resolution_alternate_vendor) { :none } + + it 'uses default' do + expect(proofing_vendor).to eql(:default_vendor) + end + + context 'and alternate is set to > 0' do + let(:idv_resolution_alternate_vendor_percent) { 100 } + it 'uses default' do + expect(proofing_vendor).to eql(:default_vendor) + end + end + end + end + + describe '#residential_address_plugin' do + let(:proofing_vendor) { nil } + + before do + allow(progressive_proofer).to receive(:proofing_vendor).and_return(proofing_vendor) + end + + context 'when proofing_vendor is :instant_verify' do + let(:proofing_vendor) { :instant_verify } + + it 'returns ResidentialAddressPlugin with an InstantVerify proofer' do + expect(progressive_proofer.residential_address_plugin).to be_an_instance_of( + Proofing::Resolution::Plugins::ResidentialAddressPlugin, + ) + + expect(progressive_proofer.residential_address_plugin.proofer).to be_an_instance_of( + Proofing::LexisNexis::InstantVerify::Proofer, + ) + end + end + + context 'when proofing_vendor is :mock' do + let(:proofing_vendor) { :mock } + + it 'returns ResidentialAddressPlugin with a mock proofer' do + expect(progressive_proofer.residential_address_plugin).to be_an_instance_of( + Proofing::Resolution::Plugins::ResidentialAddressPlugin, + ) + + expect(progressive_proofer.residential_address_plugin.proofer).to be_an_instance_of( + Proofing::Mock::ResolutionMockClient, + ) + end + end + + context 'when proofing_vendor is :socure_kyc' do + let(:proofing_vendor) { :socure_kyc } + + it 'returns ResidentialAddressPlugin with a Socure proofer' do + expect(progressive_proofer.residential_address_plugin).to be_an_instance_of( + Proofing::Resolution::Plugins::ResidentialAddressPlugin, + ) + + expect(progressive_proofer.residential_address_plugin.proofer).to be_an_instance_of( + Proofing::Socure::IdPlus::Proofer, + ) + end + end + + context 'when proofing_vendor is another value' do + let(:proofing_vendor) { :a_dog } + + it 'raises an error' do + expect { progressive_proofer.residential_address_plugin }.to raise_error + end + end + end + + describe '#state_id_address_plugin' do + let(:proofing_vendor) { nil } + + before do + allow(progressive_proofer).to receive(:proofing_vendor).and_return(proofing_vendor) + end + + context 'when proofing_vendor is :instant_verify' do + let(:proofing_vendor) { :instant_verify } + + it 'returns StateIdAddressPlugin with an InstantVerify proofer' do + expect(progressive_proofer.state_id_address_plugin).to be_an_instance_of( + Proofing::Resolution::Plugins::StateIdAddressPlugin, + ) + + expect(progressive_proofer.state_id_address_plugin.proofer).to be_an_instance_of( + Proofing::LexisNexis::InstantVerify::Proofer, + ) + end + end + + context 'when proofing_vendor is :socure_kyc' do + let(:proofing_vendor) { :socure_kyc } + + it 'returns StateIdAddressPlugin with a Socure proofer' do + expect(progressive_proofer.state_id_address_plugin).to be_an_instance_of( + Proofing::Resolution::Plugins::StateIdAddressPlugin, + ) + + expect(progressive_proofer.state_id_address_plugin.proofer).to be_an_instance_of( + Proofing::Socure::IdPlus::Proofer, + ) + end + end + + context 'when proofing_vendor is :mock' do + let(:proofing_vendor) { :mock } + + it 'returns StateIdAddressPlugin with a mock proofer' do + expect(progressive_proofer.state_id_address_plugin).to be_an_instance_of( + Proofing::Resolution::Plugins::StateIdAddressPlugin, + ) + + expect(progressive_proofer.state_id_address_plugin.proofer).to be_an_instance_of( + Proofing::Mock::ResolutionMockClient, + ) + end + end + + context 'when proofing_vendor is another value' do + let(:proofing_vendor) { :🦨 } + + it 'raises an error' do + expect { progressive_proofer.state_id_address_plugin }.to raise_error + end + end + end end diff --git a/spec/services/proofing/socure/id_plus/proofer_spec.rb b/spec/services/proofing/socure/id_plus/proofer_spec.rb index 9393dd588c2..a95c06893e9 100644 --- a/spec/services/proofing/socure/id_plus/proofer_spec.rb +++ b/spec/services/proofing/socure/id_plus/proofer_spec.rb @@ -172,6 +172,17 @@ end end + context 'when applicant includes extra fields' do + let(:applicant) do + { + some_weird_field_the_proofer_is_not_expecting: ':ohno:', + } + end + it 'does not raise an error' do + expect { result }.not_to raise_error + end + end + context 'when request times out' do before do stub_request(:post, URI.join(base_url, '/api/3.0/EmailAuthScore').to_s). @@ -224,7 +235,7 @@ end it 'includes exception details' do - expect(result.exception).to be_an_instance_of(Proofing::Socure::IdPlus::RequestError) + expect(result.exception).to be_an_instance_of(Proofing::Socure::IdPlus::Request::Error) end end end @@ -253,7 +264,7 @@ end it 'includes exception details' do - expect(result.exception).to be_an_instance_of(Proofing::Socure::IdPlus::RequestError) + expect(result.exception).to be_an_instance_of(Proofing::Socure::IdPlus::Request::Error) end end end @@ -278,7 +289,7 @@ end it 'includes exception details' do - expect(result.exception).to be_an_instance_of(Proofing::Socure::IdPlus::RequestError) + expect(result.exception).to be_an_instance_of(Proofing::Socure::IdPlus::Request::Error) end end end diff --git a/spec/services/proofing/socure/id_plus/request_spec.rb b/spec/services/proofing/socure/id_plus/request_spec.rb index 7ff73f5d5e8..333ee26285d 100644 --- a/spec/services/proofing/socure/id_plus/request_spec.rb +++ b/spec/services/proofing/socure/id_plus/request_spec.rb @@ -148,20 +148,20 @@ ) end - it 'raises RequestError' do + it 'raises Request::Error' do expect do request.send_request end.to raise_error( - Proofing::Socure::IdPlus::RequestError, + Proofing::Socure::IdPlus::Request::Error, 'Request-specific error message goes here (400)', ) end - it 'includes reference_id on RequestError' do + it 'includes reference_id on Request::Error' do expect do request.send_request end.to raise_error( - Proofing::Socure::IdPlus::RequestError, + Proofing::Socure::IdPlus::Request::Error, ) do |err| expect(err.reference_id).to eql('a-big-unique-reference-id') end @@ -186,11 +186,11 @@ ) end - it 'raises RequestError' do + it 'raises Request::Error' do expect do request.send_request end.to raise_error( - Proofing::Socure::IdPlus::RequestError, + Proofing::Socure::IdPlus::Request::Error, 'Request-specific error message goes here (401)', ) end @@ -205,10 +205,10 @@ ) end - it 'raises RequestError' do + it 'raises Request::Error' do expect do request.send_request - end.to raise_error(Proofing::Socure::IdPlus::RequestError) + end.to raise_error(Proofing::Socure::IdPlus::Request::Error) end end @@ -229,8 +229,8 @@ to_raise(Errno::ECONNRESET) end - it 'raises a RequestError' do - expect { request.send_request }.to raise_error Proofing::Socure::IdPlus::RequestError + it 'raises a Request::Error' do + expect { request.send_request }.to raise_error Proofing::Socure::IdPlus::Request::Error end end end