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 @@ -41,8 +41,8 @@ def body
def handle_http_response(http_response)
LexisNexis::Responses::TrueIdResponse.new(
http_response,
liveness_checking_required,
config,
liveness_checking_required,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see - this change is needed because of the argument order here.

Thanks for fixing this!

)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@
expect(request_stub).to have_been_requested
end
end

context 'fails document authentication' do
it 'fails response with errors' do
include_liveness = liveness_checking_required && !selfie_image.nil?
request_stub_liveness = stub_request(:post, full_url).with do |request|
JSON.parse(request.body, symbolize_names: true)[:Document][:Selfie].present?
end.to_return(body: response_body_with_doc_auth_errors(include_liveness), status: 201)
request_stub = stub_request(:post, full_url).with do |request|
!JSON.parse(request.body, symbolize_names: true)[:Document][:Selfie].present?
end.to_return(body: response_body_with_doc_auth_errors(include_liveness), status: 201)

response = subject.fetch

expect(response.success?).to eq(false)
expect(response.errors.keys).to contain_exactly(:general, :front, :back, :hints)
expect(response.errors[:general]).to contain_exactly(DocAuth::Errors::GENERAL_ERROR)
expect(response.errors[:front]).to contain_exactly(DocAuth::Errors::FALLBACK_FIELD_LEVEL)
expect(response.errors[:back]).to contain_exactly(DocAuth::Errors::FALLBACK_FIELD_LEVEL)
expect(response.errors[:hints]).to eq(true)
expect(response.exception).to be_nil
if include_liveness
expect(request_stub_liveness).to have_been_requested
else
expect(request_stub).to have_been_requested
end
end
end
end

context 'with liveness_checking_enabled as false' do
Expand Down Expand Up @@ -136,3 +163,37 @@ def response_body(include_liveness)
],
}.to_json
end

def response_body_with_doc_auth_errors(include_liveness)
{
Status: {
TransactionStatus: 'passed',
},
Products: [
{
ProductType: 'TrueID',
ProductStatus: 'pass',
ParameterDetails: [
{
Group: 'AUTHENTICATION_RESULT',
Name: 'DocAuthResult',
Values: [
{
Value: 'Failed',
},
],
},
*(
if include_liveness
[
Group: 'PORTRAIT_MATCH_RESULT',
Name: 'FaceMatchResult',
Values: [{ Value: 'Success' }],
]
end
),
],
},
],
}.to_json
end