Skip to content
This repository has been archived by the owner on Jun 12, 2021. It is now read-only.

Commit

Permalink
LG-3309 Fix for prod bug that prevented connecting to LexisNexis for …
Browse files Browse the repository at this point in the history
…proofing (#13)

LG-3309 Fix for prod bug that prevented connecting to LexisNexis for proofing.
  • Loading branch information
amathews-fs authored Aug 14, 2020
1 parent 42074c7 commit 188eeeb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/lexisnexis/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ def initialize(attributes)
end

def send
conn = Faraday.new do |f|
f.options[:timeout] = timeout
end

Response.new(
Faraday.post(url, body: body, headers: headers, timeout: timeout)
conn.post(url, body, headers)
)
rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
# NOTE: This is only for when Faraday is using NET::HTTP if the adapter is changed
Expand Down
7 changes: 6 additions & 1 deletion lib/lexisnexis/threat_metrix/verification_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ def initialize(attributes)
end

def send
conn = Faraday.new do |f|
f.options[:timeout] = timeout
end

ThreatMetrix::Response.new(
Faraday.post(url, body: body, headers: headers, timeout: timeout)
conn.post(url, body.to_json, headers)
)
rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
# NOTE: This is only for when Faraday is using NET::HTTP if the adapter is changed
Expand Down Expand Up @@ -85,6 +89,7 @@ def org_id
def headers
{
'Accept' => 'application/json',
'Content-Type' => 'application/json',
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lexisnexis/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module LexisNexis
VERSION = '2.1.0'.freeze
VERSION = '2.2.0'.freeze
end
12 changes: 12 additions & 0 deletions spec/lib/instant_verify/proofer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,17 @@
)
end
end

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: Fixtures.instant_verify_success_response_json, status: 200)

verification_request.send

expect(request).to have_been_requested.once
end
end
end
end
7 changes: 6 additions & 1 deletion spec/lib/threat_metrix/verification_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,18 @@
let(:body) { Fixtures.threat_metrix_response_json }

before do
#Needed because there is a randomly generated session_id
test_body = request.body
test_body.delete(:session_id)

stub_request(:post, 'https://h-api.online-metrix.net/api/attribute-query').
with(body: hash_including(test_body), headers: request.headers).
to_return(status: 200, body: body, headers: { 'Content-Type' => 'application/json' })
end

subject(:response) { request.send }

it 'is successful for a succesful request' do
it 'is successful for a successful request' do
expect(response.verification_status).to eq('passed')
end

Expand Down

0 comments on commit 188eeeb

Please sign in to comment.