Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gemspec

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem 'faraday', ['>= 0.8', '< 2.0'], :platforms => [:jruby_18, :ruby_18]
gem 'faraday', ['>= 0.8', '< 3.0'], :platforms => [:jruby_18, :ruby_18]
gem 'jwt'
gem 'overcommit'
gem 'rake'
Expand Down
11 changes: 4 additions & 7 deletions lib/oauth2/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,12 @@ def site=(value)

# The Faraday connection object
def connection
@connection ||= begin
conn = Faraday.new(site, options[:connection_opts])
if options[:connection_build]
conn.build do |b|
options[:connection_build].call(b)
@connection ||=
Faraday.new(site, options[:connection_opts]) do |builder|
if options[:connection_build]
options[:connection_build].call(builder)
end
end
conn
end
end

# The authorize endpoint URL of the OAuth2 provider
Expand Down
2 changes: 1 addition & 1 deletion oauth2.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'oauth2/version'

Gem::Specification.new do |spec|
spec.add_dependency 'faraday', ['>= 0.8', '< 2.0']
spec.add_dependency 'faraday', ['>= 0.8', '< 3.0']
spec.add_dependency 'jwt', ['>= 1.0', '< 3.0']
spec.add_dependency 'multi_json', '~> 1.3'
spec.add_dependency 'multi_xml', '~> 0.5'
Expand Down
4 changes: 2 additions & 2 deletions spec/oauth2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
it 'is able to pass a block to configure the connection' do
connection = double('connection')
builder = double('builder')
allow(connection).to receive(:build).and_yield(builder)
allow(Faraday).to receive(:new).and_yield(builder)
allow(Faraday::Connection).to receive(:new).and_return(connection)

expect(builder).to receive(:adapter).with(:test)
Expand Down Expand Up @@ -517,7 +517,7 @@ def stubbed_client(params = {}, &stubs)
context 'with SSL options' do
subject do
cli = described_class.new('abc', 'def', :site => 'https://api.example.com', :ssl => {:ca_file => 'foo.pem'})
cli.connection.build do |b|
cli.connection = Faraday.new(cli.site, cli.options[:connection_opts]) do |b|
b.adapter :test
end
cli
Expand Down
3 changes: 2 additions & 1 deletion spec/oauth2/strategy/assertion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

let(:client) do
cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
cli.connection.build do |b|
cli.connection = Faraday.new(cli.site, cli.options[:connection_opts]) do |b|
b.request :url_encoded
b.adapter :test do |stub|
stub.post('/oauth/token') do |env|
case @mode
Expand Down
3 changes: 2 additions & 1 deletion spec/oauth2/strategy/password_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

let(:client) do
cli = OAuth2::Client.new('abc', 'def', :site => 'http://api.example.com')
cli.connection.build do |b|
cli.connection = Faraday.new(cli.site, cli.options[:connection_opts]) do |b|
b.request :url_encoded
b.adapter :test do |stub|
stub.post('/oauth/token') do |env|
case @mode
Expand Down