tddium_client 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWY1M2VlODU2YmQ3N2FjM2VlMDk4YjI5YzZlYWI1MDc4ZDUxZTlmMw==
4
+ NTBjNmMzY2QzMWU5MzFiZTAyMzA0ODBhOTg3MTFmZDQzYTIwMGY2MQ==
5
5
  data.tar.gz: !binary |-
6
- ZjIxMDM1NWZmMTY2ZGQ5ODMwZjlmYTFmMjU4ODM1NTc1MjE2NTYyMA==
6
+ NDNiNDM2NjM1OWRhNjE2ZGE5YjZmZDU3NzIyYzVmMDBhOTMxNmVkYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDc2ZWEwOTcyYzQyZTRmNWJjY2EwY2QyYjYzMDFjZWNhMDIyZThmMjAwYjgz
10
- Njk5YWYzNGFjOTJhZjczNzAzZjEzYzUyOGVkMjU1NzQzMGI0YWRmNWI1ZTky
11
- ODhjNGQ1NDliOWJlZjUwNjIwZTI0MWI4NzkwNTgwYmFlODY0Yzg=
9
+ MDQxZGQzNWM3M2JmZTQwMDQxMWZkNWQxM2UwNTFlMzUxZTg4NmYyYmVhNDI5
10
+ NTExODUxNzI0MWMyZWJjYTU5M2U3MDNjYjllNDU5NjRmZWUwMzBhMDM2NzBk
11
+ N2NlMzkxZmQ4Y2Y3MjVmZjU1NDA4M2MzMzRlYTMzZTJlZTE1ZGY=
12
12
  data.tar.gz: !binary |-
13
- ODU1ZjhlNDA1NDI5OGI0YTUyMWUxOWEzY2ZjMTAwNDM0YmJhMmYyNzg5ZTAw
14
- MDY5YzEzNTYyNTcyYTE2MGVkYTcyNDQ1OGE2NDVhNjg0ZjYzYThmNTJmYTk2
15
- ZTIwNjdkZjIyMjUxMzBlNWVjOWJkZGIzMmQ2YWQ0MTY5MTQ1OWI=
13
+ YjIwOGEyMGMxMWIzZmMxNTg4ODc2NzdjMzE4Njc5MTNhOGFjMmFlMjUxNTI1
14
+ OTA1NDI4MTQzNGM5MTM5NTc1ZGE2YWJmZjFmYWI3ODRjNDY4NmQ5Mzc0MTc5
15
+ MWQ2YTk0ZDQ5OTViYTJhOTZjYmEwYmFmYjk1NzVkM2ExMzI2M2M=
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tddium_client (0.5.1)
4
+ tddium_client (0.5.2)
5
5
  httpclient (>= 2.2.5)
6
6
  json
7
7
 
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2011, 2012, 2013, 2015 Solano Labs All Rights Reserved
2
2
 
3
3
  module TddiumClient
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.2"
5
5
  end
@@ -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.1
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-06-12 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient