Skip to content

Commit 4ac114c

Browse files
committed
feat: handle client errors correctly
1 parent 5319e6c commit 4ac114c

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/session_validator/client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def valid?(msid)
3131

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

34-
!response.is_a? Net::HTTPNotFound
34+
response.is_a? Net::HTTPSuccess or response.is_a? Net::HTTPServerError
3535
rescue Net::OpenTimeout
3636
log Logger::DEBUG, "open timeout"
3737
true

spec/session_validator/client_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
it { is_expected.to eq false }
4747
end
4848

49+
context "client is not configured properly" do
50+
before { http_request.to_return status: [401, "Unauthorized"] }
51+
52+
it { is_expected.to eq false }
53+
end
54+
4955
context "service is not working properly" do
5056
before { http_request.to_return status: [500, "Internal Server Error"] }
5157

0 commit comments

Comments
 (0)