apipie-bindings 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/doc/release_notes.md +5 -0
- data/lib/apipie_bindings/action.rb +1 -1
- data/lib/apipie_bindings/api.rb +40 -17
- data/lib/apipie_bindings/authenticators/base.rb +18 -0
- data/lib/apipie_bindings/authenticators/basic_auth.rb +16 -0
- data/lib/apipie_bindings/authenticators/credentials_legacy.rb +24 -0
- data/lib/apipie_bindings/authenticators/oauth.rb +27 -0
- data/lib/apipie_bindings/authenticators.rb +3 -0
- data/lib/apipie_bindings/exceptions.rb +1 -0
- data/lib/apipie_bindings/rest_client_extensions.rb +5 -17
- data/lib/apipie_bindings/version.rb +1 -1
- data/lib/apipie_bindings.rb +1 -0
- data/test/unit/action_test.rb +2 -2
- data/test/unit/api_test.rb +96 -11
- data/test/unit/authenticators/basic_auth_test.rb +17 -0
- data/test/unit/authenticators/credentials_legacy_test.rb +34 -0
- metadata +16 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d30b2c120a24152b99526e83b9b913b0e2cda4b
|
4
|
+
data.tar.gz: 918bb3e69af74ef55f9279dbb70f4ea1a5d33da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f64b123b50ae0183bce9d576d37263fff2fc8e0d23ab986befd8971dd0b47cb9ed341636da77dc2e9c56fda3f514744cd7acc1cc58d0f1f20917e32040ac254
|
7
|
+
data.tar.gz: b4a890d819bead44b94fb8dc916b183b480f6383171d7ba692f64667cbb112e5d081ccef7288048649df22130a75c0e634854f34af8a38d5df8de1076d8077ab
|
data/README.md
CHANGED
@@ -33,8 +33,8 @@ irb> api.resources
|
|
33
33
|
##### Listing actions
|
34
34
|
|
35
35
|
```
|
36
|
-
irb> api.resource(:
|
37
|
-
=> [<Action :index>, <Action :show>, <Action :create>, <Action :update>, <Action :destroy>]
|
36
|
+
irb> api.resource(:roles).actions
|
37
|
+
=> [<Action roles:index>, <Action roles:show>, <Action roles:create>, <Action roles:update>, <Action roles:destroy>]
|
38
38
|
```
|
39
39
|
|
40
40
|
##### Listing routes
|
data/doc/release_notes.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
3
|
|
4
|
+
### 0.0.19 (2016-12-09)
|
5
|
+
* Support for more advanced authentication algorithms ([PR #52](https://github.com/theforeman/apipie-bindings/pull/52))
|
6
|
+
* Show resource when inspecting Action ([PR #50](https://github.com/theforeman/apipie-bindings/pull/50))
|
7
|
+
* Prevent rest-client timeout deprecation warnings ([PR #53](https://github.com/theforeman/apipie-bindings/pull/53))
|
8
|
+
|
4
9
|
### 0.0.18 (2016-08-31)
|
5
10
|
* Recover from exception while inspecting error response ([#48](https://github.com/Apipie/apipie-bindings/issues/48))
|
6
11
|
* Add yard docs for ApipieBindings::Resource class ([#47](https://github.com/Apipie/apipie-bindings/issues/47))
|
data/lib/apipie_bindings/api.rb
CHANGED
@@ -42,9 +42,10 @@ module ApipieBindings
|
|
42
42
|
# if the local cache of API description (JSON) is up to date. By default it is checked
|
43
43
|
# *after* each API request
|
44
44
|
# @option config [Object] :logger (Logger.new(STDERR)) custom logger class
|
45
|
-
# @option config [Number] :timeout API request timeout in seconds
|
45
|
+
# @option config [Number] :timeout API request timeout in seconds, use -1 to disable timeout
|
46
46
|
# @option config [Symbol] :follow_redirects (:default) Possible values are :always, :never and :default.
|
47
47
|
# The :default is to only redirect in GET and HEAD requests (RestClient default)
|
48
|
+
# @option config [AbstractAuthenticator] :authenticator API request authenticator
|
48
49
|
# @param [Hash] options params that are passed to ResClient as-is
|
49
50
|
# @raise [ApipieBindings::ConfigurationError] when no +:uri+ or +:apidoc_cache_dir+ is provided
|
50
51
|
# @example connect to a server
|
@@ -88,8 +89,15 @@ module ApipieBindings
|
|
88
89
|
log.debug "Global headers: #{inspect_data(headers)}"
|
89
90
|
log.debug "Follow redirects: #{@follow_redirects.to_s}"
|
90
91
|
|
91
|
-
|
92
|
+
if config[:authenticator]
|
93
|
+
@authenticator = config[:authenticator]
|
94
|
+
else
|
95
|
+
@authenticator = legacy_authenticator(config)
|
96
|
+
end
|
92
97
|
|
98
|
+
if (config[:timeout] && config[:timeout].to_i < 0)
|
99
|
+
config[:timeout] = (RestClient.version < '1.7.0') ? -1 : nil
|
100
|
+
end
|
93
101
|
@resource_config = {
|
94
102
|
:timeout => config[:timeout],
|
95
103
|
:headers => headers,
|
@@ -112,8 +120,7 @@ module ApipieBindings
|
|
112
120
|
end
|
113
121
|
|
114
122
|
def clear_credentials
|
115
|
-
@
|
116
|
-
@credentials.clear if @credentials
|
123
|
+
@authenticator.clear if @authenticator && @authenticator.respond_to?(:clear)
|
117
124
|
end
|
118
125
|
|
119
126
|
def apidoc
|
@@ -215,14 +222,14 @@ module ApipieBindings
|
|
215
222
|
ex = options[:fake_response ] || empty_response
|
216
223
|
response = create_fake_response(ex.status, ex.response, http_method, URI.join(@uri || 'http://example.com', path).to_s, args)
|
217
224
|
else
|
225
|
+
apidoc_without_auth = (path =~ /\/apidoc\//) && !@apidoc_authenticated
|
226
|
+
authenticate = options[:with_authentication].nil? ? !apidoc_without_auth : options[:with_authentication]
|
218
227
|
begin
|
219
|
-
apidoc_without_auth = (path =~ /\/apidoc\//) && !@apidoc_authenticated
|
220
|
-
authenticate = options[:with_authentication].nil? ? !apidoc_without_auth : options[:with_authentication]
|
221
228
|
client = authenticate ? authenticated_client : unauthenticated_client
|
222
229
|
response = call_client(client, path, args)
|
223
230
|
update_cache(response.headers[:apipie_checksum])
|
224
231
|
rescue => e
|
225
|
-
|
232
|
+
@authenticator.error(e) if authenticate && @authenticator
|
226
233
|
log.error e.message
|
227
234
|
log.debug inspect_data(e)
|
228
235
|
raise
|
@@ -288,6 +295,19 @@ module ApipieBindings
|
|
288
295
|
|
289
296
|
private
|
290
297
|
|
298
|
+
def legacy_authenticator(config)
|
299
|
+
if config[:user] || config[:password]
|
300
|
+
Authenticators::BasicAuth.new(config[:user], config[:password])
|
301
|
+
elsif config[:credentials] && config[:credentials].respond_to?(:to_params)
|
302
|
+
log.warn("Credentials are now deprecated, use custom authenticator instead.")
|
303
|
+
Authenticators::CredentialsLegacy.new(config[:credentials])
|
304
|
+
elsif config[:oauth]
|
305
|
+
log.warn("Passing oauth credentials in hash is now deprecated, use oauth authenticator instead.")
|
306
|
+
oauth = config[:oauth]
|
307
|
+
Authenticators::Oauth.new(oauth[:consumer_key], oauth[:consumer_secret], oauth[:options])
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
291
311
|
def call_client(client, path, args)
|
292
312
|
block = rest_client_call_block
|
293
313
|
client[path].send(*args, &block)
|
@@ -298,6 +318,8 @@ module ApipieBindings
|
|
298
318
|
# include request for rest_client < 1.8.0
|
299
319
|
response.request ||= request
|
300
320
|
|
321
|
+
request.args[:authenticator].response(response) if request && request.args[:authenticator]
|
322
|
+
|
301
323
|
if [301, 302, 307].include?(response.code) && [:always, :never].include?(@follow_redirects)
|
302
324
|
if @follow_redirects == :always
|
303
325
|
log.debug "Response redirected to #{response.headers[:location]}"
|
@@ -325,22 +347,23 @@ module ApipieBindings
|
|
325
347
|
end
|
326
348
|
|
327
349
|
def authenticated_client
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
resource_config.merge!(@credentials.to_params) if @credentials
|
335
|
-
@client_with_auth = RestClient::Resource.new(@config[:uri], resource_config)
|
336
|
-
end
|
337
|
-
@client_with_auth
|
350
|
+
resource_config = @resource_config.dup
|
351
|
+
resource_config[:authenticator] = get_authenticator
|
352
|
+
|
353
|
+
log.debug "Using authenticator: #{resource_config[:authenticator].name}"
|
354
|
+
|
355
|
+
RestClient::Resource.new(@config[:uri], resource_config)
|
338
356
|
end
|
339
357
|
|
340
358
|
def unauthenticated_client
|
341
359
|
@client_without_auth ||= RestClient::Resource.new(@config[:uri], @resource_config)
|
342
360
|
end
|
343
361
|
|
362
|
+
def get_authenticator
|
363
|
+
raise ApipieBindings::AuthenticatorMissingError if @authenticator.nil?
|
364
|
+
@authenticator
|
365
|
+
end
|
366
|
+
|
344
367
|
def retrieve_apidoc_call(path, options={})
|
345
368
|
begin
|
346
369
|
http_call('get', path, {},
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'apipie_bindings/authenticators/base'
|
2
|
+
|
3
|
+
module ApipieBindings
|
4
|
+
module Authenticators
|
5
|
+
class BasicAuth < Base
|
6
|
+
def initialize(user, password)
|
7
|
+
@user = user
|
8
|
+
@password = password
|
9
|
+
end
|
10
|
+
|
11
|
+
def authenticate(request, args)
|
12
|
+
request.basic_auth(@user, @password)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'apipie_bindings/authenticators/base'
|
2
|
+
|
3
|
+
module ApipieBindings
|
4
|
+
module Authenticators
|
5
|
+
class CredentialsLegacy < Base
|
6
|
+
def initialize(credentials)
|
7
|
+
@credentials = credentials
|
8
|
+
end
|
9
|
+
|
10
|
+
def authenticate(request, args)
|
11
|
+
params = @credentials.to_params
|
12
|
+
request.basic_auth(params[:user], params[:password])
|
13
|
+
end
|
14
|
+
|
15
|
+
def error(ex)
|
16
|
+
@credentials.clear if ex.is_a? RestClient::Unauthorized
|
17
|
+
end
|
18
|
+
|
19
|
+
def clear
|
20
|
+
@credentials.clear
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'apipie_bindings/authenticators/base'
|
2
|
+
|
3
|
+
module ApipieBindings
|
4
|
+
module Authenticators
|
5
|
+
class Oauth < Base
|
6
|
+
def initialize(consumer_key, consumer_secret, options = {})
|
7
|
+
@consumer_key = consumer_key
|
8
|
+
@consumer_secret = consumer_secret
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
def authenticate(request, args)
|
13
|
+
uri = URI.parse args[:url]
|
14
|
+
default_options = {
|
15
|
+
:site => "#{uri.scheme}://#{uri.host}:#{uri.port.to_s}",
|
16
|
+
:request_token_path => "",
|
17
|
+
:authorize_path => "",
|
18
|
+
:access_token_path => ""
|
19
|
+
}
|
20
|
+
options = default_options.merge(@options)
|
21
|
+
consumer = OAuth::Consumer.new(@consumer_key, @consumer_secret, options)
|
22
|
+
|
23
|
+
consumer.sign!(request)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -9,26 +9,14 @@ module ApipieBindings
|
|
9
9
|
RestClient::AbstractResponse.send(:include, RequestAccessor) unless RestClient::AbstractResponse.method_defined?(:request)
|
10
10
|
RestClient::Response.send(:include, RequestAccessor) unless RestClient::Response.method_defined?(:request)
|
11
11
|
|
12
|
-
unless RestClient.const_defined? :
|
13
|
-
RestClient::
|
14
|
-
if args[:
|
15
|
-
uri = URI.parse args[:url]
|
16
|
-
default_options = {
|
17
|
-
:site => "#{uri.scheme}://#{uri.host}:#{uri.port.to_s}",
|
18
|
-
:request_token_path => "",
|
19
|
-
:authorize_path => "",
|
20
|
-
:access_token_path => ""
|
21
|
-
}
|
22
|
-
options = default_options.merge args[:oauth][:options] || { }
|
23
|
-
consumer = OAuth::Consumer.new(args[:oauth][:consumer_key], args[:oauth][:consumer_secret], options)
|
24
|
-
|
25
|
-
consumer.sign!(request)
|
26
|
-
end
|
12
|
+
unless RestClient.const_defined? :AUTHENTICATOR_EXTENSION
|
13
|
+
RestClient::AUTHENTICATOR_EXTENSION = lambda do |request, args|
|
14
|
+
args[:authenticator].authenticate(request, args) if args[:authenticator]
|
27
15
|
end
|
28
16
|
end
|
29
17
|
|
30
|
-
unless RestClient.before_execution_procs.include? RestClient::
|
31
|
-
RestClient.add_before_execution_proc &RestClient::
|
18
|
+
unless RestClient.before_execution_procs.include? RestClient::AUTHENTICATOR_EXTENSION
|
19
|
+
RestClient.add_before_execution_proc &RestClient::AUTHENTICATOR_EXTENSION
|
32
20
|
end
|
33
21
|
end
|
34
22
|
end
|
data/lib/apipie_bindings.rb
CHANGED
@@ -5,6 +5,7 @@ require 'apipie_bindings/credentials'
|
|
5
5
|
require 'apipie_bindings/exceptions'
|
6
6
|
require 'apipie_bindings/inflector'
|
7
7
|
require 'apipie_bindings/indifferent_hash'
|
8
|
+
require 'apipie_bindings/authenticators'
|
8
9
|
require 'apipie_bindings/api'
|
9
10
|
require 'apipie_bindings/resource'
|
10
11
|
require 'apipie_bindings/action'
|
data/test/unit/action_test.rb
CHANGED
@@ -118,11 +118,11 @@ describe ApipieBindings::Action do
|
|
118
118
|
|
119
119
|
it "should have name visible in puts" do
|
120
120
|
out, err = capture_io { puts resource.action(:index) }
|
121
|
-
out.must_equal "<Action :index>\n"
|
121
|
+
out.must_equal "<Action users:index>\n"
|
122
122
|
end
|
123
123
|
|
124
124
|
it "should have name visible in inspect" do
|
125
|
-
resource.action(:index).inspect.must_equal "<Action :index>"
|
125
|
+
resource.action(:index).inspect.must_equal "<Action users:index>"
|
126
126
|
end
|
127
127
|
|
128
128
|
it "should have examples" do
|
data/test/unit/api_test.rb
CHANGED
@@ -207,7 +207,7 @@ describe ApipieBindings::API do
|
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
210
|
-
context "
|
210
|
+
context "authenticators" do
|
211
211
|
|
212
212
|
let(:fake_empty_response) {
|
213
213
|
data = ApipieBindings::Example.new('', '', '', 200, '[]')
|
@@ -222,19 +222,104 @@ describe ApipieBindings::API do
|
|
222
222
|
RestClient::Response.create(data.response, net_http_resp, {})
|
223
223
|
end
|
224
224
|
}
|
225
|
+
let(:authenticator) { stub(:name => :auth) }
|
226
|
+
|
227
|
+
def binding_params(cache_dir, params = {})
|
228
|
+
base_params = {
|
229
|
+
:uri => 'http://example.com',
|
230
|
+
:api_version => 2,
|
231
|
+
:apidoc_cache_base_dir => cache_dir,
|
232
|
+
:authenticator => authenticator
|
233
|
+
}
|
234
|
+
base_params.merge(params)
|
235
|
+
end
|
225
236
|
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
:
|
231
|
-
|
232
|
-
|
233
|
-
|
237
|
+
context "when doing authenticated call" do
|
238
|
+
it "passes authenticator to the client" do
|
239
|
+
Dir.mktmpdir do |dir|
|
240
|
+
api = ApipieBindings::API.new(binding_params(dir))
|
241
|
+
api.expects(:call_client).with do |client, path, args|
|
242
|
+
client.options[:authenticator] == authenticator
|
243
|
+
end.returns(fake_empty_response)
|
244
|
+
|
245
|
+
api.http_call(:get, '/path')
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
it "passes error to authenticator" do
|
250
|
+
Dir.mktmpdir do |dir|
|
251
|
+
api = ApipieBindings::API.new(binding_params(dir))
|
252
|
+
api.stubs(:call_client).raises(RestClient::Unauthorized)
|
253
|
+
authenticator.expects(:error).with do |e|
|
254
|
+
e.is_a? RestClient::Unauthorized
|
255
|
+
end
|
256
|
+
assert_raises RestClient::Unauthorized do
|
257
|
+
api.http_call(:get, '/path')
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
it "raises exception when authenticator wasn't provided" do
|
263
|
+
Dir.mktmpdir do |dir|
|
264
|
+
api = ApipieBindings::API.new(binding_params(dir, :authenticator => nil))
|
265
|
+
|
266
|
+
assert_raises ApipieBindings::AuthenticatorMissingError do
|
267
|
+
api.http_call(:get, '/path')
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
context "when :apidoc_authenticated => false" do
|
274
|
+
it "doesn't pass request to authenticator" do
|
275
|
+
Dir.mktmpdir do |dir|
|
276
|
+
api = ApipieBindings::API.new(binding_params(dir, :apidoc_authenticated => false))
|
277
|
+
api.expects(:unauthenticated_client)
|
278
|
+
api.stubs(:call_client).returns(fake_empty_response)
|
279
|
+
|
280
|
+
api.check_cache
|
281
|
+
end
|
282
|
+
end
|
234
283
|
|
235
|
-
|
284
|
+
it "doesn't pass error to authenticator" do
|
285
|
+
Dir.mktmpdir do |dir|
|
286
|
+
api = ApipieBindings::API.new(binding_params(dir, :apidoc_authenticated => false))
|
287
|
+
api.expects(:unauthenticated_client)
|
288
|
+
api.stubs(:call_client).raises(RestClient::Unauthorized)
|
289
|
+
|
290
|
+
authenticator.expects(:error).never
|
291
|
+
api.check_cache
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
it "doesn't pass response to authenticator" do
|
296
|
+
Dir.mktmpdir do |dir|
|
297
|
+
api = ApipieBindings::API.new(binding_params(dir, :apidoc_authenticated => false))
|
298
|
+
api.expects(:unauthenticated_client)
|
299
|
+
api.stubs(:call_client).returns(fake_empty_response)
|
300
|
+
|
301
|
+
authenticator.expects(:response).never
|
302
|
+
api.check_cache
|
303
|
+
end
|
236
304
|
end
|
237
305
|
end
|
306
|
+
end
|
307
|
+
|
308
|
+
context "credentials" do
|
309
|
+
|
310
|
+
let(:fake_empty_response) {
|
311
|
+
data = ApipieBindings::Example.new('', '', '', 200, '[]')
|
312
|
+
net_http_resp = Net::HTTPResponse.new(1.0, data.status, "")
|
313
|
+
if RestClient.version >= '2.0.0'
|
314
|
+
RestClient::Response.create(data.response, net_http_resp,
|
315
|
+
RestClient::Request.new(:method=>'GET', :url=>'http://example.com'))
|
316
|
+
elsif RestClient.version >= '1.8.0'
|
317
|
+
RestClient::Response.create(data.response, net_http_resp, {},
|
318
|
+
RestClient::Request.new(:method=>'GET', :url=>'http://example.com'))
|
319
|
+
else
|
320
|
+
RestClient::Response.create(data.response, net_http_resp, {})
|
321
|
+
end
|
322
|
+
}
|
238
323
|
|
239
324
|
it "should not require credentials for loading apidoc when :apidoc_authenticated => false" do
|
240
325
|
Dir.mktmpdir do |dir|
|
@@ -276,7 +361,7 @@ describe ApipieBindings::API do
|
|
276
361
|
credentials = ApipieBindings::AbstractCredentials.new
|
277
362
|
api = ApipieBindings::API.new({:uri => 'http://example.com', :apidoc_cache_base_dir => dir, :api_version => 2,
|
278
363
|
:credentials => credentials})
|
279
|
-
|
364
|
+
credentials.expects(:clear)
|
280
365
|
api.stubs(:call_client).raises(RestClient::Unauthorized)
|
281
366
|
assert_raises RestClient::Unauthorized do
|
282
367
|
api.http_call(:get, '/path')
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
require 'apipie_bindings/authenticators/basic_auth'
|
3
|
+
|
4
|
+
describe ApipieBindings::Authenticators::BasicAuth do
|
5
|
+
let(:authenticator) { ApipieBindings::Authenticators::BasicAuth.new(user, passwd) }
|
6
|
+
let(:user) { 'john_doe' }
|
7
|
+
let(:passwd) { 'secret_password' }
|
8
|
+
let(:request) { mock() }
|
9
|
+
let(:args) { {} }
|
10
|
+
|
11
|
+
describe '#authenticate' do
|
12
|
+
it 'adds base auth to the request' do
|
13
|
+
request.expects(:basic_auth).with(user, passwd)
|
14
|
+
authenticator.authenticate(request, args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../test_helper')
|
2
|
+
require 'apipie_bindings/authenticators/credentials_legacy'
|
3
|
+
|
4
|
+
describe ApipieBindings::Authenticators::CredentialsLegacy do
|
5
|
+
let(:authenticator) { ApipieBindings::Authenticators::CredentialsLegacy.new(@credentials) }
|
6
|
+
let(:user) { 'john_doe' }
|
7
|
+
let(:passwd) { 'secret_password' }
|
8
|
+
let(:request) { mock() }
|
9
|
+
let(:args) { {} }
|
10
|
+
|
11
|
+
before do
|
12
|
+
@credentials = mock()
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#authenticate' do
|
16
|
+
it 'uses result of to_params for base auth of the request' do
|
17
|
+
@credentials.expects(:to_params).returns({ :user => user, :password => passwd })
|
18
|
+
request.expects(:basic_auth).with(user, passwd)
|
19
|
+
authenticator.authenticate(request, args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#error' do
|
24
|
+
it 'clears credentials on RestClient::Unauthorized' do
|
25
|
+
@credentials.expects(:clear)
|
26
|
+
authenticator.error(RestClient::Unauthorized.new)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'lets other errors pass' do
|
30
|
+
authenticator.error(RuntimeError.new)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
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.0.
|
4
|
+
version: 0.0.19
|
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: 2016-
|
11
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -162,8 +162,10 @@ dependencies:
|
|
162
162
|
- - "<"
|
163
163
|
- !ruby/object:Gem::Version
|
164
164
|
version: 2.0.0
|
165
|
-
description:
|
166
|
-
|
165
|
+
description: 'Bindings for API calls that are documented with Apipie. Bindings are
|
166
|
+
generated on the fly.
|
167
|
+
|
168
|
+
'
|
167
169
|
email: mbacovsk@redhat.com
|
168
170
|
executables: []
|
169
171
|
extensions: []
|
@@ -178,6 +180,11 @@ files:
|
|
178
180
|
- lib/apipie_bindings.rb
|
179
181
|
- lib/apipie_bindings/action.rb
|
180
182
|
- lib/apipie_bindings/api.rb
|
183
|
+
- lib/apipie_bindings/authenticators.rb
|
184
|
+
- lib/apipie_bindings/authenticators/base.rb
|
185
|
+
- lib/apipie_bindings/authenticators/basic_auth.rb
|
186
|
+
- lib/apipie_bindings/authenticators/credentials_legacy.rb
|
187
|
+
- lib/apipie_bindings/authenticators/oauth.rb
|
181
188
|
- lib/apipie_bindings/credentials.rb
|
182
189
|
- lib/apipie_bindings/example.rb
|
183
190
|
- lib/apipie_bindings/exceptions.rb
|
@@ -218,6 +225,8 @@ files:
|
|
218
225
|
- test/dummy/public/index.html
|
219
226
|
- test/unit/action_test.rb
|
220
227
|
- test/unit/api_test.rb
|
228
|
+
- test/unit/authenticators/basic_auth_test.rb
|
229
|
+
- test/unit/authenticators/credentials_legacy_test.rb
|
221
230
|
- test/unit/data/dummy.json
|
222
231
|
- test/unit/example_test.rb
|
223
232
|
- test/unit/indifferent_hash_test.rb
|
@@ -247,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
256
|
version: '0'
|
248
257
|
requirements: []
|
249
258
|
rubyforge_project:
|
250
|
-
rubygems_version: 2.
|
259
|
+
rubygems_version: 2.5.1
|
251
260
|
signing_key:
|
252
261
|
specification_version: 4
|
253
262
|
summary: The Ruby bindings for Apipie documented APIs
|
@@ -281,6 +290,8 @@ test_files:
|
|
281
290
|
- test/dummy/public/index.html
|
282
291
|
- test/unit/action_test.rb
|
283
292
|
- test/unit/api_test.rb
|
293
|
+
- test/unit/authenticators/basic_auth_test.rb
|
294
|
+
- test/unit/authenticators/credentials_legacy_test.rb
|
284
295
|
- test/unit/data/dummy.json
|
285
296
|
- test/unit/example_test.rb
|
286
297
|
- test/unit/indifferent_hash_test.rb
|
@@ -290,4 +301,3 @@ test_files:
|
|
290
301
|
- test/unit/resource_test.rb
|
291
302
|
- test/unit/route_test.rb
|
292
303
|
- test/unit/test_helper.rb
|
293
|
-
has_rdoc: yard
|