Skip to content

Commit

Permalink
feat: handle client errors correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
kotapeter committed Feb 23, 2018
1 parent 5319e6c commit 4ac114c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/session_validator/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def valid?(msid)

log Logger::DEBUG, "response code: #{response.code}, response body: #{response.body}"

!response.is_a? Net::HTTPNotFound
response.is_a? Net::HTTPSuccess or response.is_a? Net::HTTPServerError
rescue Net::OpenTimeout
log Logger::DEBUG, "open timeout"
true
Expand Down
6 changes: 6 additions & 0 deletions spec/session_validator/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
it { is_expected.to eq false }
end

context "client is not configured properly" do
before { http_request.to_return status: [401, "Unauthorized"] }

it { is_expected.to eq false }
end

context "service is not working properly" do
before { http_request.to_return status: [500, "Internal Server Error"] }

Expand Down

0 comments on commit 4ac114c

Please sign in to comment.