apipie-bindings 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 177475068b8dce6f1eabdf990f717306ff7a42b9
4
- data.tar.gz: 9965d19d825aebeb323199ed2cb4909692f24d2c
3
+ metadata.gz: 6e8560165daeb6cae4d2530f42a9adc58e1511e3
4
+ data.tar.gz: 9291144917dc1a6111ba60e01de1096338c47b3a
5
5
  SHA512:
6
- metadata.gz: f9cf54f46216b7e354d43219646ffc112355d298cc4ef27f23b8d47621e0344a069561deedb549ae78d8f3e5c9afaa85bc31f3c997f59201db060d504ef90e99
7
- data.tar.gz: f7dd4ec05a1f5e5f664157832c97d3ed07ddb22f248aa9fa3065d385d2fe899b79f268b00ed5b31fe43785482c96359ad61857f9c3bd1e645d771bf2af67905a
6
+ metadata.gz: 59e41d190c6bf09379b1a2b9b7f6f56923a1f9e4adb3289e49a61c61fc23d6c6831c1e57e0273c4b6f1a5cb6f067db502016812e5c3d2c13c093f307060e7891
7
+ data.tar.gz: 360e2e4781f437a0627b015acfb59de2cd291e9c66941d21c548fab65dacf164f3a5fbb88f037125be78ff1f3d7bdee640ed31e5c8c34eba6a620b5ae5317b30
@@ -1,6 +1,11 @@
1
1
  Release notes
2
2
  =============
3
3
 
4
+ ### 0.2.0 (2017-04-24)
5
+ * Support for overriding exceptions from authorizers ([PR #64](https://github.com/Apipie/apipie-bindings/pull/64))
6
+ * Use ssl_ca_file with ssl_ca_path (rest-client < 1.7.0) ([PR #63](https://github.com/Apipie/apipie-bindings/pull/63)) ([#62](https://github.com/Apipie/apipie-bindings/issues/62))
7
+ * Make following redirects compatible with rest-client > 1.8 ([PR #61](https://github.com/Apipie/apipie-bindings/pull/61)) ([#60](https://github.com/Apipie/apipie-bindings/issues/60))
8
+
4
9
  ### 0.1.0 (2017-03-28)
5
10
  * Verify SSL by default ([PR #59](https://github.com/Apipie/apipie-bindings/pull/59))
6
11
  * Do not hide exceptions during cache retrieval ([PR #57](https://github.com/Apipie/apipie-bindings/pull/57))
@@ -98,6 +98,17 @@ module ApipieBindings
98
98
  if (config[:timeout] && config[:timeout].to_i < 0)
99
99
  config[:timeout] = (RestClient.version < '1.7.0') ? -1 : nil
100
100
  end
101
+
102
+ # RestClient < 1.7.0 does not support ssl_ca_path use ssl_ca_file instead
103
+ if options[:ssl_ca_path] && !RestClient::Request.method_defined?(:ssl_opts)
104
+ parsed_uri = URI.parse(@uri)
105
+ cert_file = File.join(options[:ssl_ca_path], "#{parsed_uri.host}.pem")
106
+ if File.exist?(cert_file)
107
+ options[:ssl_ca_file] = cert_file
108
+ log.warn "ssl_ca_path is not supported by RestClient. ssl_ca_file = #{cert_file} was used instead."
109
+ end
110
+ end
111
+
101
112
  @resource_config = {
102
113
  :timeout => config[:timeout],
103
114
  :headers => headers,
@@ -229,10 +240,10 @@ module ApipieBindings
229
240
  response = call_client(client, path, args)
230
241
  update_cache(response.headers[:apipie_checksum])
231
242
  rescue => e
232
- @authenticator.error(e) if authenticate && @authenticator
233
243
  log.error e.message
234
244
  log.debug inspect_data(e)
235
- raise
245
+ override_e = @authenticator.error(e) if authenticate && @authenticator
246
+ raise override_e.is_a?(StandardError) ? override_e : e
236
247
  end
237
248
  end
238
249
 
@@ -323,7 +334,14 @@ module ApipieBindings
323
334
  if [301, 302, 307].include?(response.code) && [:always, :never].include?(@follow_redirects)
324
335
  if @follow_redirects == :always
325
336
  log.debug "Response redirected to #{response.headers[:location]}"
326
- response.follow_redirection(request, result, &block)
337
+
338
+ if response.method(:follow_redirection).arity == 0
339
+ # rest-client > 1.8
340
+ response.follow_redirection(&block)
341
+ else
342
+ # rest-client <= 1.8
343
+ response.follow_redirection(request, result, &block)
344
+ end
327
345
  else
328
346
  raise exception_with_response(response)
329
347
  end
@@ -1,5 +1,5 @@
1
1
  module ApipieBindings
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.1.0'
3
+ @version ||= Gem::Version.new '0.2.0'
4
4
  end
5
5
  end
@@ -259,6 +259,18 @@ describe ApipieBindings::API do
259
259
  end
260
260
  end
261
261
 
262
+ it "raises exception returned from authenticator" do
263
+ Dir.mktmpdir do |dir|
264
+ api = ApipieBindings::API.new(binding_params(dir))
265
+ api.stubs(:call_client).raises(RestClient::Unauthorized)
266
+ authenticator.expects(:error).returns(RuntimeError.new('Custom unauthorized exception'))
267
+ ex = assert_raises RuntimeError do
268
+ api.http_call(:get, '/path')
269
+ end
270
+ assert_equal 'Custom unauthorized exception', ex.message
271
+ end
272
+ end
273
+
262
274
  it "raises exception when authenticator wasn't provided" do
263
275
  Dir.mktmpdir do |dir|
264
276
  api = ApipieBindings::API.new(binding_params(dir, :authenticator => nil))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipie-bindings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Bačovský
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-28 00:00:00.000000000 Z
11
+ date: 2017-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json