cdnetworks-client 1.1.1 → 1.1.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,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93586b13b1c72ba395781dd8c56667276e23bc43
|
4
|
+
data.tar.gz: a07c0c362ac81150bc0a96faae072048fbcf6e50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 160c5e5c6aefa8b47d5506def0cb209c9938a534dfaffbd126720b8a3c647059dd9ad4ceaa6ae6db2688b085d0f11242741f00784615882793c03ef98b3c09f1
|
7
|
+
data.tar.gz: d746d1004e561a2e4e9e96c9ccae1e863518d0bdb41518d5c666729dfc70f2e60cd465517968d25bed1e03c42cf45a81fc26b520a96ce178bf7a26170ec103ea
|
@@ -11,21 +11,30 @@ module OpenApiError
|
|
11
11
|
"999" => "Temporary error"
|
12
12
|
}
|
13
13
|
|
14
|
-
class
|
14
|
+
class BaseError < StandardError
|
15
|
+
attr_accessor :code, :body
|
15
16
|
|
17
|
+
def initialize(error, code = nil, body = nil)
|
18
|
+
@code = code
|
19
|
+
@body = body
|
20
|
+
super(error)
|
21
|
+
end
|
16
22
|
end
|
17
23
|
|
18
|
-
class
|
24
|
+
class ApiError < BaseError
|
25
|
+
end
|
19
26
|
|
27
|
+
class CriticalApiError < BaseError
|
20
28
|
end
|
21
29
|
|
22
30
|
class ErrorHandler
|
23
31
|
def self.handle_error_response(code, body)
|
24
|
-
if
|
25
|
-
|
32
|
+
if ERROR_CODES[code.to_s]
|
33
|
+
message = "Open API Error #{code}: #{ERROR_CODES[code.to_s]}"
|
26
34
|
else
|
27
|
-
|
35
|
+
message = "Unknown Open API Response Code #{code} (body: #{body})"
|
28
36
|
end
|
37
|
+
raise ApiError.new(message, code, body)
|
29
38
|
end
|
30
39
|
end
|
31
40
|
end
|
@@ -373,7 +373,9 @@ describe CdnetworksClient do
|
|
373
373
|
|
374
374
|
before do
|
375
375
|
@good_token, _ = stub_auth_calls
|
376
|
-
stub_request(:post, "#{@url}/api/rest/getApiKeyList")
|
376
|
+
stub_request(:post, "#{@url}/api/rest/getApiKeyList")
|
377
|
+
.with(body: {"output"=>"json", "sessionToken"=>bad_token})
|
378
|
+
.to_return(body: expired_session_resp)
|
377
379
|
end
|
378
380
|
|
379
381
|
it "re-establishes session if it expires" do
|
@@ -384,17 +386,33 @@ describe CdnetworksClient do
|
|
384
386
|
end
|
385
387
|
|
386
388
|
it "doesn't infinite loop if session can't be re-established" do
|
387
|
-
stub_request(:post, "#{@url}/api/rest/login")
|
389
|
+
stub_request(:post, "#{@url}/api/rest/login")
|
390
|
+
.to_return(body: JSON.pretty_unparse(loginResponse: {resultCode: 101}))
|
388
391
|
expect { @cdn_api.get_api_key_list(bad_token) }.to raise_error(OpenApiError::ApiError)
|
389
392
|
end
|
390
393
|
|
391
394
|
it "gives up if session is not re-established after MAX_SESSION_RETRIES tries" do
|
392
|
-
stub_request(:post, "#{@url}/api/rest/getApiKeyList")
|
395
|
+
stub_request(:post, "#{@url}/api/rest/getApiKeyList")
|
396
|
+
.with(body: {"output"=>"json", "sessionToken"=>@good_token})
|
397
|
+
.to_return(body: expired_session_resp)
|
393
398
|
|
394
399
|
expect { @cdn_api.get_api_key_list(bad_token) }.to raise_error(OpenApiError::CriticalApiError)
|
395
400
|
|
396
401
|
expect(a_request(:post, "#{@url}/api/rest/login")).to have_been_made.times(3)
|
397
402
|
end
|
403
|
+
|
404
|
+
it "keeps code andy body around on the exception" do
|
405
|
+
response = JSON.pretty_unparse(loginResponse: { resultCode: 101 })
|
406
|
+
stub_request(:post, "#{@url}/api/rest/login")
|
407
|
+
.to_return(body: response)
|
408
|
+
|
409
|
+
begin
|
410
|
+
@cdn_api.get_api_key_list(bad_token)
|
411
|
+
rescue OpenApiError::ApiError => e
|
412
|
+
expect(e.code).to eq(101)
|
413
|
+
expect(e.body).to eq(response)
|
414
|
+
end
|
415
|
+
end
|
398
416
|
end
|
399
417
|
|
400
418
|
describe ConfigOpenApi do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cdnetworks-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nell Shamrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|