tddium_client 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/lib/tddium_client.rb +12 -1
- data/lib/tddium_client/version.rb +1 -1
- data/spec/tddium_client_spec.rb +24 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTBjNmMzY2QzMWU5MzFiZTAyMzA0ODBhOTg3MTFmZDQzYTIwMGY2MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDNiNDM2NjM1OWRhNjE2ZGE5YjZmZDU3NzIyYzVmMDBhOTMxNmVkYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDQxZGQzNWM3M2JmZTQwMDQxMWZkNWQxM2UwNTFlMzUxZTg4NmYyYmVhNDI5
|
10
|
+
NTExODUxNzI0MWMyZWJjYTU5M2U3MDNjYjllNDU5NjRmZWUwMzBhMDM2NzBk
|
11
|
+
N2NlMzkxZmQ4Y2Y3MjVmZjU1NDA4M2MzMzRlYTMzZTJlZTE1ZGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjIwOGEyMGMxMWIzZmMxNTg4ODc2NzdjMzE4Njc5MTNhOGFjMmFlMjUxNTI1
|
14
|
+
OTA1NDI4MTQzNGM5MTM5NTc1ZGE2YWJmZjFmYWI3ODRjNDY4NmQ5Mzc0MTc5
|
15
|
+
MWQ2YTk0ZDQ5OTViYTJhOTZjYmEwYmFmYjk1NzVkM2ExMzI2M2M=
|
data/Gemfile.lock
CHANGED
data/lib/tddium_client.rb
CHANGED
@@ -70,6 +70,16 @@ module TddiumClient
|
|
70
70
|
module Error
|
71
71
|
class Timeout < Base; end
|
72
72
|
|
73
|
+
class APICert < Base
|
74
|
+
def initialize(err)
|
75
|
+
@err = err
|
76
|
+
end
|
77
|
+
|
78
|
+
def message
|
79
|
+
"API Cert Error: #{@err}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
73
83
|
class Server < TddiumClient::Result::Base
|
74
84
|
def to_s
|
75
85
|
"#{http_code} #{http_message}"
|
@@ -140,7 +150,8 @@ module TddiumClient
|
|
140
150
|
tries = 0
|
141
151
|
begin
|
142
152
|
http = @client.send(method, tddium_uri(api_path), :body => call_params.to_json, :header => headers)
|
143
|
-
rescue *ERRORS
|
153
|
+
rescue *ERRORS => e
|
154
|
+
raise Error::APICert.new(e) if e.message =~ /certificate verify failed/
|
144
155
|
tries += 1
|
145
156
|
delay = (tries>>1)*0.05*rand()
|
146
157
|
Kernel.sleep(delay)
|
data/spec/tddium_client_spec.rb
CHANGED
@@ -156,6 +156,16 @@ describe "TddiumClient" do
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
+
describe "APICert" do
|
160
|
+
let(:apicert_error) {TddiumClient::Error::APICert.new("certificate verify failed")}
|
161
|
+
|
162
|
+
describe "#message" do
|
163
|
+
it "should start with 'API Cert Error:' and return err msg" do
|
164
|
+
apicert_error.message.should =~ /^API Cert Error: certificate verify failed/
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
159
169
|
describe "API" do
|
160
170
|
let(:api_error) { TddiumClient::Error::API.new(http_response) }
|
161
171
|
|
@@ -314,9 +324,6 @@ describe "TddiumClient" do
|
|
314
324
|
it_behaves_like "retry on exception" do
|
315
325
|
let (:raised_exception) { Timeout::Error }
|
316
326
|
end
|
317
|
-
it_behaves_like "retry on exception" do
|
318
|
-
let (:raised_exception) { OpenSSL::SSL::SSLError }
|
319
|
-
end
|
320
327
|
it_behaves_like "retry on exception" do
|
321
328
|
let (:raised_exception) { OpenSSL::SSL::Session::SessionError }
|
322
329
|
end
|
@@ -331,6 +338,20 @@ describe "TddiumClient" do
|
|
331
338
|
end
|
332
339
|
end
|
333
340
|
|
341
|
+
context "handle general OpenSSL::SSL::SSLError error" do
|
342
|
+
before { tddium_client.client.stub(EXAMPLE_HTTP_METHOD).and_raise(OpenSSL::SSL::SSLError) }
|
343
|
+
it "should raise exception TddiumClient::Error::Timeout when raised SSLError exception" do
|
344
|
+
expect { tddium_client.call_api(EXAMPLE_HTTP_METHOD, EXAMPLE_TDDIUM_RESOURCE) }.to raise_error(TddiumClient::Error::Timeout)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
context "handle OpenSSL::SSL::SSLError error with cert and raise API Cert error" do
|
349
|
+
before { tddium_client.client.stub(EXAMPLE_HTTP_METHOD).and_raise(OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed")) }
|
350
|
+
it "should raise exception API Cert Error when raised SSLError exception containing 'certificate verify failed'" do
|
351
|
+
expect { tddium_client.call_api(EXAMPLE_HTTP_METHOD, EXAMPLE_TDDIUM_RESOURCE) }.to raise_error(TddiumClient::Error::APICert, /certificate verify failed/)
|
352
|
+
end
|
353
|
+
end
|
354
|
+
|
334
355
|
context "('#{EXAMPLE_HTTP_METHOD}', '#{EXAMPLE_TDDIUM_RESOURCE}', {}, #{EXAMPLE_API_KEY}) # with api_key" do
|
335
356
|
it "should include #{TddiumClient::API_KEY_HEADER}=#{EXAMPLE_API_KEY} in the request headers" do
|
336
357
|
tddium_client.call_api(EXAMPLE_HTTP_METHOD, EXAMPLE_TDDIUM_RESOURCE, {}, EXAMPLE_API_KEY)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tddium_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Moorthi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|