diff --git a/app/services/proofing/aamva/proofer.rb b/app/services/proofing/aamva/proofer.rb index 5f9e855944c..2625b59b426 100644 --- a/app/services/proofing/aamva/proofer.rb +++ b/app/services/proofing/aamva/proofer.rb @@ -29,12 +29,12 @@ def initialize(config) def proof(applicant) aamva_applicant = Aamva::Applicant.from_proofer_applicant(OpenStruct.new(applicant)) - verification_response = Aamva::VerificationClient.new( + response = Aamva::VerificationClient.new( config, ).send_verification_request( applicant: aamva_applicant, ) - build_result_from_response(verification_response) + build_result_from_response(response) rescue => exception NewRelic::Agent.notice_error(exception) Proofing::StateIdResult.new( diff --git a/app/services/proofing/address_result.rb b/app/services/proofing/address_result.rb index d0404c77d1e..46134ba93f3 100644 --- a/app/services/proofing/address_result.rb +++ b/app/services/proofing/address_result.rb @@ -1,7 +1,12 @@ module Proofing class AddressResult - attr :success, :errors, :exception, :vendor_name, :transaction_id, :reference, - :vendor_workflow + attr_reader :success, + :errors, + :exception, + :vendor_name, + :transaction_id, + :reference, + :vendor_workflow def initialize( success:, diff --git a/app/services/proofing/result.rb b/app/services/proofing/ddp_result.rb similarity index 80% rename from app/services/proofing/result.rb rename to app/services/proofing/ddp_result.rb index e07d9eb4328..4912782506c 100644 --- a/app/services/proofing/result.rb +++ b/app/services/proofing/ddp_result.rb @@ -1,7 +1,11 @@ module Proofing - class Result + class DdpResult attr_reader :exception - attr_accessor :context, :transaction_id, :reference, :review_status, :response_body + attr_accessor :context, + :transaction_id, + :reference, + :review_status, + :response_body def initialize( errors: {}, @@ -26,10 +30,6 @@ def add_error(key = :base, error) end # rubocop:enable Style/OptionalArguments - def attributes_requiring_additional_verification - [] - end - def errors @errors.transform_values(&:to_a) end @@ -46,10 +46,6 @@ def failed? !exception? && errors? end - def failed_result_can_pass_with_additional_verification? - false - end - def success? !exception? && !errors? end diff --git a/app/services/proofing/lexis_nexis/config.rb b/app/services/proofing/lexis_nexis/config.rb new file mode 100644 index 00000000000..5fbfb73f422 --- /dev/null +++ b/app/services/proofing/lexis_nexis/config.rb @@ -0,0 +1,24 @@ +module Proofing + module LexisNexis + Config = RedactedStruct.new( + :instant_verify_workflow, + :phone_finder_workflow, + :account_id, + :base_url, + :username, + :password, + :request_mode, + :request_timeout, + :org_id, + :api_key, + keyword_init: true, + allowed_members: [ + :instant_verify_workflow, + :phone_finder_workflow, + :base_url, + :request_mode, + :request_timeout, + ], + ) + end +end diff --git a/app/services/proofing/lexis_nexis/ddp/proofer.rb b/app/services/proofing/lexis_nexis/ddp/proofer.rb index adfd8cc733d..3ff0a776f00 100644 --- a/app/services/proofing/lexis_nexis/ddp/proofer.rb +++ b/app/services/proofing/lexis_nexis/ddp/proofer.rb @@ -30,57 +30,35 @@ def stage end end - Config = RedactedStruct.new( - :instant_verify_workflow, - :phone_finder_workflow, - :account_id, - :base_url, - :username, - :password, - :request_mode, - :request_timeout, - :org_id, - :api_key, - keyword_init: true, - allowed_members: [ - :instant_verify_workflow, - :phone_finder_workflow, - :base_url, - :request_mode, - :request_timeout, - ], - ) - attr_reader :config def initialize(attrs) @config = Config.new(attrs) end - def send_verification_request(applicant) - VerificationRequest.new(config: config, applicant: applicant).send - end - def proof(applicant) - response = send_verification_request(applicant) - process_response(response) + response = VerificationRequest.new(config: config, applicant: applicant).send + build_result_from_response(response) rescue => exception NewRelic::Agent.notice_error(exception) - Proofing::Result.new(exception: exception) + Proofing::DdpResult.new(exception: exception) end private - def process_response(response) - result = Proofing::Result.new - body = response.response_body + def build_result_from_response(verification_response) + result = Proofing::DdpResult.new + body = verification_response.response_body + result.response_body = body result.transaction_id = body['request_id'] request_result = body['request_result'] review_status = body['review_status'] + result.review_status = review_status result.add_error(:request_result, request_result) unless request_result == 'success' result.add_error(:review_status, review_status) unless review_status == 'pass' + result end end diff --git a/app/services/proofing/lexis_nexis/instant_verify/proofer.rb b/app/services/proofing/lexis_nexis/instant_verify/proofer.rb index cc8111c8d3e..73fe1f63ecf 100644 --- a/app/services/proofing/lexis_nexis/instant_verify/proofer.rb +++ b/app/services/proofing/lexis_nexis/instant_verify/proofer.rb @@ -5,7 +5,7 @@ class Proofer attr_reader :config def initialize(config) - @config = LexisNexis::Ddp::Proofer::Config.new(config) + @config = LexisNexis::Config.new(config) end def proof(applicant) diff --git a/app/services/proofing/lexis_nexis/phone_finder/proofer.rb b/app/services/proofing/lexis_nexis/phone_finder/proofer.rb index 41aa31c2358..5cf7838d13c 100644 --- a/app/services/proofing/lexis_nexis/phone_finder/proofer.rb +++ b/app/services/proofing/lexis_nexis/phone_finder/proofer.rb @@ -5,12 +5,12 @@ class Proofer attr_reader :config def initialize(config) - @config = LexisNexis::Ddp::Proofer::Config.new(config) + @config = LexisNexis::Config.new(config) end def proof(applicant) response = VerificationRequest.new(config: config, applicant: applicant).send - return build_result_from_response(response) + build_result_from_response(response) rescue => exception NewRelic::Agent.notice_error(exception) AddressResult.new( diff --git a/app/services/proofing/mock/ddp_mock_client.rb b/app/services/proofing/mock/ddp_mock_client.rb index f67314779cd..a656d9deb44 100644 --- a/app/services/proofing/mock/ddp_mock_client.rb +++ b/app/services/proofing/mock/ddp_mock_client.rb @@ -32,7 +32,7 @@ def stage TRANSACTION_ID = 'ddp-mock-transaction-id-123' def proof(applicant) - result = Proofing::Result.new + result = Proofing::DdpResult.new result.transaction_id = TRANSACTION_ID response_body = File.read( diff --git a/app/services/proofing/resolution_result.rb b/app/services/proofing/resolution_result.rb index bd28078440c..1671d3b3971 100644 --- a/app/services/proofing/resolution_result.rb +++ b/app/services/proofing/resolution_result.rb @@ -1,15 +1,22 @@ module Proofing class ResolutionResult - attr_reader :success, :errors, :exception, :vendor_name, :transaction_id, :verified_attributes, + attr_reader :errors, + :exception, + :success, + :vendor_name, + :transaction_id, + :verified_attributes, :failed_result_can_pass_with_additional_verification, :attributes_requiring_additional_verification, - :reference, :vendor_workflow, :drivers_license_check_info + :reference, + :vendor_workflow, + :drivers_license_check_info def initialize( - success:, - errors:, - exception:, - vendor_name:, + success: nil, + errors: {}, + exception: nil, + vendor_name: nil, transaction_id: '', reference: '', failed_result_can_pass_with_additional_verification: false, @@ -39,10 +46,6 @@ def timed_out? exception.is_a?(Proofing::TimeoutError) end - def failed_result_can_pass_with_additional_verification? - failed_result_can_pass_with_additional_verification - end - def to_h { success: success?, @@ -58,5 +61,9 @@ def to_h drivers_license_check_info: drivers_license_check_info, } end + + def failed_result_can_pass_with_additional_verification? + failed_result_can_pass_with_additional_verification + end end end diff --git a/app/services/proofing/state_id_result.rb b/app/services/proofing/state_id_result.rb index 138a7546c5b..e68ed9443d2 100644 --- a/app/services/proofing/state_id_result.rb +++ b/app/services/proofing/state_id_result.rb @@ -1,12 +1,17 @@ module Proofing class StateIdResult - attr_reader :success, :errors, :exception, :vendor_name, :transaction_id, :verified_attributes + attr_reader :errors, + :exception, + :success, + :vendor_name, + :transaction_id, + :verified_attributes def initialize( - success:, - errors:, - exception:, - vendor_name:, + success: nil, + errors: {}, + exception: nil, + vendor_name: nil, transaction_id: '', verified_attributes: [] ) diff --git a/spec/jobs/resolution_proofing_job_spec.rb b/spec/jobs/resolution_proofing_job_spec.rb index 90a4f9a26a3..05df70d10bd 100644 --- a/spec/jobs/resolution_proofing_job_spec.rb +++ b/spec/jobs/resolution_proofing_job_spec.rb @@ -320,9 +320,9 @@ context 'with a successful response from the proofer' do before do expect(resolution_proofer).to receive(:proof). - and_return(Proofing::Result.new) + and_return(Proofing::ResolutionResult.new) expect(state_id_proofer).to receive(:proof). - and_return(Proofing::Result.new) + and_return(Proofing::StateIdResult.new) Proofing::Mock::DeviceProfilingBackend.new.record_profiling_result( session_id: threatmetrix_session_id, result: 'pass', @@ -355,7 +355,7 @@ end context 'nil response body from ddp' do - let(:ddp_result) { Proofing::Result.new(response_body: nil) } + let(:ddp_result) { Proofing::DdpResult.new(response_body: nil) } before do expect(ddp_proofer).to receive(:proof).and_return(ddp_result) @@ -381,9 +381,9 @@ context 'does call state id with an unsuccessful response from the proofer' do it 'posts back to the callback url' do expect(resolution_proofer).to receive(:proof). - and_return(Proofing::Result.new(exception: 'error')) + and_return(Proofing::ResolutionResult.new(exception: 'error')) expect(state_id_proofer).to receive(:proof). - and_return(Proofing::Result.new) + and_return(Proofing::StateIdResult.new) perform end @@ -394,7 +394,7 @@ it 'does not call state_id proof if resolution proof is successful' do expect(resolution_proofer).to receive(:proof). - and_return(Proofing::Result.new) + and_return(Proofing::ResolutionResult.new) expect(state_id_proofer).not_to receive(:proof) perform diff --git a/spec/services/idv/steps/verify_wait_step_show_spec.rb b/spec/services/idv/steps/verify_wait_step_show_spec.rb index 50131a64948..8338a81d427 100644 --- a/spec/services/idv/steps/verify_wait_step_show_spec.rb +++ b/spec/services/idv/steps/verify_wait_step_show_spec.rb @@ -1,13 +1,15 @@ require 'rails_helper' describe Idv::Steps::VerifyWaitStepShow do + TRANSACTION_ID = 'ddp-mock-transaction-id-123' + include Rails.application.routes.url_helpers let(:user) { build(:user) } let(:issuer) { 'test_issuer' } let(:service_provider) { build(:service_provider, issuer: issuer) } - let(:resolution_transaction_id) { Proofing::Mock::ResolutionMockClient::TRANSACTION_ID } - let(:threatmetrix_transaction_id) { Proofing::Mock::DdpMockClient::TRANSACTION_ID } + let(:resolution_transaction_id) { TRANSACTION_ID } + let(:threatmetrix_transaction_id) { TRANSACTION_ID } let(:request) { FakeRequest.new } diff --git a/spec/services/proofing/aamva/proofing_spec.rb b/spec/services/proofing/aamva/proofing_spec.rb index f0f6fb8351c..18b8ef196e0 100644 --- a/spec/services/proofing/aamva/proofing_spec.rb +++ b/spec/services/proofing/aamva/proofing_spec.rb @@ -5,6 +5,7 @@ let(:aamva_applicant) do Aamva::Applicant.from_proofer_applicant(OpenStruct.new(state_id_data)) end + let(:state_id_data) do { state_id_number: '1234567890', @@ -12,6 +13,7 @@ state_id_type: 'drivers_license', } end + let(:verification_results) do { state_id_number: true, @@ -25,7 +27,9 @@ } end - subject { described_class.new(AamvaFixtures.example_config.to_h) } + subject do + described_class.new(AamvaFixtures.example_config.to_h) + end let(:verification_response) { AamvaFixtures.verification_response } diff --git a/spec/services/proofing/result_spec.rb b/spec/services/proofing/ddp_result_spec.rb similarity index 71% rename from spec/services/proofing/result_spec.rb rename to spec/services/proofing/ddp_result_spec.rb index bc9ffab452d..ddbc121d778 100644 --- a/spec/services/proofing/result_spec.rb +++ b/spec/services/proofing/ddp_result_spec.rb @@ -1,10 +1,10 @@ require 'rails_helper' -describe Proofing::Result do +describe Proofing::DdpResult do describe '#add_error' do shared_examples 'add_error' do |key| it 'returns itself' do - expect(result).to be_an_instance_of(Proofing::Result) + expect(result).to be_an_instance_of(Proofing::DdpResult) end it 'adds an error under the key' do @@ -19,12 +19,12 @@ let(:error) { 'FOOBAR' } context 'with no key' do - let(:result) { Proofing::Result.new.add_error(error) } + let(:result) { Proofing::DdpResult.new.add_error(error) } it_behaves_like 'add_error', :base end context 'with a key' do - let(:result) { Proofing::Result.new.add_error(:foo, error) } + let(:result) { Proofing::DdpResult.new.add_error(:foo, error) } it_behaves_like 'add_error', :foo end end @@ -33,11 +33,11 @@ subject { result.exception? } context 'when there is an exception' do - let(:result) { Proofing::Result.new(exception: StandardError.new) } + let(:result) { Proofing::DdpResult.new(exception: StandardError.new) } it { is_expected.to eq(true) } end context 'when there is no exception' do - let(:result) { Proofing::Result.new } + let(:result) { Proofing::DdpResult.new } it { is_expected.to eq(false) } end end @@ -47,18 +47,18 @@ context 'when there is an error AND an exception' do let(:result) do - Proofing::Result.new(exception: StandardError.new).add_error('foobar') + Proofing::DdpResult.new(exception: StandardError.new).add_error('foobar') end it { is_expected.to eq(false) } end context 'when there is an error and no exception' do - let(:result) { Proofing::Result.new.add_error('foobar') } + let(:result) { Proofing::DdpResult.new.add_error('foobar') } it { is_expected.to eq(true) } end context 'when there is no error' do - let(:result) { Proofing::Result.new } + let(:result) { Proofing::DdpResult.new } it { is_expected.to eq(false) } end end @@ -68,18 +68,18 @@ context 'when there is an error AND an exception' do let(:result) do - Proofing::Result.new(exception: StandardError.new).add_error('foobar') + Proofing::DdpResult.new(exception: StandardError.new).add_error('foobar') end it { is_expected.to eq(false) } end context 'when there is an error and no exception' do - let(:result) { Proofing::Result.new.add_error('foobar') } + let(:result) { Proofing::DdpResult.new.add_error('foobar') } it { is_expected.to eq(false) } end context 'when there is no error and no exception' do - let(:result) { Proofing::Result.new } + let(:result) { Proofing::DdpResult.new } it { is_expected.to eq(true) } end end @@ -88,17 +88,17 @@ subject { result.timed_out? } context 'when there is a timeout error' do - let(:result) { Proofing::Result.new(exception: Proofing::TimeoutError.new) } + let(:result) { Proofing::DdpResult.new(exception: Proofing::TimeoutError.new) } it { is_expected.to eq(true) } end context 'when there is a generic error' do - let(:result) { Proofing::Result.new(exception: StandardError.new) } + let(:result) { Proofing::DdpResult.new(exception: StandardError.new) } it { is_expected.to eq(false) } end context 'when there is no error' do - let(:result) { Proofing::Result.new } + let(:result) { Proofing::DdpResult.new } it { is_expected.to eq(false) } end end @@ -107,7 +107,7 @@ context 'when provided' do it 'is present' do context = { foo: 'bar' } - result = Proofing::Result.new + result = Proofing::DdpResult.new result.context = context expect(result.context).to eq(context) end @@ -118,7 +118,7 @@ context 'when provided' do it 'is present' do transaction_id = 'foo' - result = Proofing::Result.new + result = Proofing::DdpResult.new result.transaction_id = transaction_id expect(result.transaction_id).to eq(transaction_id) end @@ -129,7 +129,7 @@ context 'when provided' do it 'is present' do reference = SecureRandom.uuid - result = Proofing::Result.new + result = Proofing::DdpResult.new result.reference = reference expect(result.reference).to eq(reference) end diff --git a/spec/services/proofing/lexis_nexis/ddp/proofing_spec.rb b/spec/services/proofing/lexis_nexis/ddp/proofing_spec.rb index bdbb813ae1c..bf631a43f95 100644 --- a/spec/services/proofing/lexis_nexis/ddp/proofing_spec.rb +++ b/spec/services/proofing/lexis_nexis/ddp/proofing_spec.rb @@ -21,20 +21,27 @@ uuid_prefix: 'ABCD', } end + let(:verification_request) do Proofing::LexisNexis::Ddp::VerificationRequest.new( applicant: applicant, config: LexisNexisFixtures.example_config, ) end + let(:issuer) { 'fake-issuer' } let(:friendly_name) { 'fake-name' } let(:app_id) { 'fake-app-id' } + # it_behaves_like 'a lexisnexis proofer' + describe '#send' do context 'when the request times out' do it 'raises a timeout error' do - stub_request(:post, verification_request.url).to_timeout + stub_request( + :post, + verification_request.url, + ).to_timeout expect { verification_request.send }.to raise_error( Proofing::TimeoutError, @@ -45,9 +52,17 @@ context 'when the request is made' do it 'it looks like the right request' do - request = stub_request(:post, verification_request.url). - with(body: verification_request.body, headers: verification_request.headers). - to_return(body: LexisNexisFixtures.ddp_success_response_json, status: 200) + request = + stub_request( + :post, + verification_request.url, + ).with( + body: verification_request.body, + headers: verification_request.headers, + ).to_return( + body: LexisNexisFixtures.ddp_success_response_json, + status: 200, + ) verification_request.send @@ -56,27 +71,32 @@ end end - subject(:instance) do - Proofing::LexisNexis::Ddp::Proofer.new(LexisNexisFixtures.example_config.to_h) + subject do + described_class.new(LexisNexisFixtures.example_config.to_h) end describe '#proof' do - subject(:result) { instance.proof(applicant) } - before do ServiceProvider.create( issuer: issuer, friendly_name: friendly_name, app_id: app_id, ) - stub_request(:post, verification_request.url). - to_return(body: response_body, status: 200) + stub_request( + :post, + verification_request.url, + ).to_return( + body: response_body, + status: 200, + ) end context 'when the response is a full match' do let(:response_body) { LexisNexisFixtures.ddp_success_response_json } it 'is a successful result' do + result = subject.proof(applicant) + expect(result.success?).to eq(true) expect(result.errors).to be_empty end @@ -90,7 +110,12 @@ expect(NewRelic::Agent).to receive(:notice_error).with(error) - stub_request(:post, verification_request.url).to_raise(error) + stub_request( + :post, + verification_request.url, + ).to_raise(error) + + result = subject.proof(applicant) expect(result.success?).to eq(false) expect(result.errors).to be_empty diff --git a/spec/services/proofing/lexis_nexis/instant_verify/proofing_spec.rb b/spec/services/proofing/lexis_nexis/instant_verify/proofing_spec.rb index 61304e75c64..fdeb8b9ba9f 100644 --- a/spec/services/proofing/lexis_nexis/instant_verify/proofing_spec.rb +++ b/spec/services/proofing/lexis_nexis/instant_verify/proofing_spec.rb @@ -24,19 +24,24 @@ ) end - it_behaves_like 'a lexisnexis proofer' + it_behaves_like 'a lexisnexis rdp proofer' - subject(:instance) do - Proofing::LexisNexis::InstantVerify::Proofer.new(**LexisNexisFixtures.example_config.to_h) + subject do + described_class.new(**LexisNexisFixtures.example_config.to_h) end describe '#proof' do context 'when the response is a full match' do it 'is a successful result' do - stub_request(:post, verification_request.url). - to_return(body: LexisNexisFixtures.instant_verify_success_response_json, status: 200) + stub_request( + :post, + verification_request.url, + ).to_return( + body: LexisNexisFixtures.instant_verify_success_response_json, + status: 200, + ) - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.success?).to eq(true) expect(result.errors).to eq({}) @@ -55,7 +60,7 @@ status: 200, ) - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.success?).to eq(false) expect(result.errors).to include( @@ -72,9 +77,12 @@ context 'when the request times out' do it 'retuns a timeout result' do - stub_request(:post, verification_request.url).to_timeout + stub_request( + :post, + verification_request.url, + ).to_timeout - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.success?).to eq(false) expect(result.errors).to eq({}) @@ -86,9 +94,12 @@ context 'when an error is raised' do it 'returns a result with an exception' do - stub_request(:post, verification_request.url).to_raise(RuntimeError.new('fancy test error')) + stub_request( + :post, + verification_request.url, + ).to_raise(RuntimeError.new('fancy test error')) - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.success?).to eq(false) expect(result.errors).to eq({}) @@ -109,7 +120,7 @@ status: 200, ) - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.failed_result_can_pass_with_additional_verification?).to eq(true) expect(result.attributes_requiring_additional_verification).to eq([:dob]) @@ -128,7 +139,7 @@ status: 200, ) - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.failed_result_can_pass_with_additional_verification?).to eq(false) expect(result.attributes_requiring_additional_verification).to be_empty @@ -139,10 +150,15 @@ end it 'logs drivers license info that is present in the response' do - stub_request(:post, verification_request.url). - to_return(body: LexisNexisFixtures.instant_verify_success_response_json, status: 200) + stub_request( + :post, + verification_request.url, + ).to_return( + body: LexisNexisFixtures.instant_verify_success_response_json, + status: 200, + ) - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.to_h[:drivers_license_check_info]).to eq( 'ItemName' => 'DriversLicenseVerification', diff --git a/spec/services/proofing/lexis_nexis/phone_finder/proofing_spec.rb b/spec/services/proofing/lexis_nexis/phone_finder/proofing_spec.rb index 7651741d8b4..6ba049bc9a6 100644 --- a/spec/services/proofing/lexis_nexis/phone_finder/proofing_spec.rb +++ b/spec/services/proofing/lexis_nexis/phone_finder/proofing_spec.rb @@ -20,10 +20,10 @@ ) end - it_behaves_like 'a lexisnexis proofer' + it_behaves_like 'a lexisnexis rdp proofer' - subject(:instance) do - Proofing::LexisNexis::PhoneFinder::Proofer.new(**LexisNexisFixtures.example_config.to_h) + subject do + described_class.new(**LexisNexisFixtures.example_config.to_h) end describe '#proof' do @@ -32,7 +32,7 @@ stub_request(:post, verification_request.url). to_return(body: LexisNexisFixtures.phone_finder_rdp1_success_response_json, status: 200) - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.success?).to eq(true) expect(result.errors).to eq({}) @@ -45,7 +45,7 @@ stub_request(:post, verification_request.url). to_return(body: LexisNexisFixtures.phone_finder_rdp2_success_response_json, status: 200) - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.success?).to eq(true) expect(result.errors).to eq({}) @@ -57,10 +57,15 @@ context 'when the rdp1 response is a failure' do it 'is a failure result' do - stub_request(:post, verification_request.url). - to_return(body: LexisNexisFixtures.phone_finder_rdp1_fail_response_json, status: 200) + stub_request( + :post, + verification_request.url, + ).to_return( + body: LexisNexisFixtures.phone_finder_rdp1_fail_response_json, + status: 200, + ) - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.success?).to eq(false) expect(result.errors).to include( @@ -69,6 +74,9 @@ ) expect(result.transaction_id).to eq('31000000000000') expect(result.reference).to eq('Reference1') + expect(result.vendor_workflow).to( + eq(LexisNexisFixtures.example_config.phone_finder_workflow), + ) end end @@ -77,7 +85,7 @@ stub_request(:post, verification_request.url). to_return(body: LexisNexisFixtures.phone_finder_rdp2_fail_response_json, status: 200) - result = instance.proof(applicant) + result = subject.proof(applicant) result_json_hash = result.errors[:PhoneFinder].first expect(result.success?).to eq(false) @@ -92,7 +100,7 @@ it 'retuns a timeout result' do stub_request(:post, verification_request.url).to_timeout - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.success?).to eq(false) expect(result.errors).to eq({}) @@ -105,7 +113,7 @@ it 'returns a result with an exception' do stub_request(:post, verification_request.url).to_raise(RuntimeError.new('fancy test error')) - result = instance.proof(applicant) + result = subject.proof(applicant) expect(result.success?).to eq(false) expect(result.errors).to eq({}) diff --git a/spec/support/lexis_nexis_fixtures.rb b/spec/support/lexis_nexis_fixtures.rb index a1c75db4614..253a0cd2925 100644 --- a/spec/support/lexis_nexis_fixtures.rb +++ b/spec/support/lexis_nexis_fixtures.rb @@ -3,7 +3,7 @@ module LexisNexisFixtures class << self def example_config - Proofing::LexisNexis::Ddp::Proofer::Config.new( + Proofing::LexisNexis::Config.new( base_url: 'https://example.com', request_mode: 'testing', account_id: 'test_account', @@ -15,7 +15,7 @@ def example_config end def example_ddp_config - Proofing::LexisNexis::Ddp::Proofer::Config.new( + Proofing::LexisNexis::Config.new( api_key: 'test_api_key', base_url: 'https://example.com', org_id: 'test_org_id', diff --git a/spec/support/shared_examples/lexis_nexis.rb b/spec/support/shared_examples/lexis_nexis.rb index c900056a443..8ef1a88e2fd 100644 --- a/spec/support/shared_examples/lexis_nexis.rb +++ b/spec/support/shared_examples/lexis_nexis.rb @@ -1,9 +1,8 @@ -shared_examples 'a lexisnexis proofer' do +shared_examples 'a lexisnexis rdp proofer' do let(:verification_status) { 'passed' } let(:conversation_id) { 'foo' } let(:reference) { SecureRandom.uuid } let(:verification_errors) { {} } - let(:result) { Proofing::Result.new } before do response = instance_double(Proofing::LexisNexis::Response) @@ -15,11 +14,11 @@ allow(verification_request).to receive(:send).and_return(response) allow(verification_request.class).to receive(:new). - with(applicant: applicant, config: kind_of(Proofing::LexisNexis::Ddp::Proofer::Config)). + with(applicant: applicant, config: kind_of(Proofing::LexisNexis::Config)). and_return(verification_request) end - describe '#proof_applicant' do + describe '#proof' do context 'when proofing succeeds' do it 'results in a successful result' do result = subject.proof(applicant)