omniauth-oauth 1.0.0.rc1 → 1.2.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1dfca9af1de8c628340193490f5c0e33a3075ce7baab4b72b6e4d07709204b71
4
+ data.tar.gz: 9294cf2611fee8dea9cfd28765c904b2150c6b271f9ae1840eff9e03cc1d97d5
5
+ SHA512:
6
+ metadata.gz: a5b01f08e32d842622a5711071f9925e13f891c70b7f0ca96e0dcdca3957858a2555c821669c809fc29628c95213bd9dca0204374d9e4ab193a7b650dc0a5552
7
+ data.tar.gz: 0a4de26cf1b884da55b1567ca2cfb42b90db8e0fc32e45fe39cc1b588b980f5ebee344bfc8cee54cc128e0f6b99127601708294357975de5ca5d8c2a2e0e8580
@@ -0,0 +1,55 @@
1
+ Metrics/AbcSize:
2
+ Enabled: false
3
+
4
+ Metrics/BlockNesting:
5
+ Max: 2
6
+
7
+ Metrics/LineLength:
8
+ AllowURI: true
9
+ Enabled: false
10
+
11
+ Metrics/MethodLength:
12
+ CountComments: false
13
+ Max: 10
14
+
15
+ Metrics/ParameterLists:
16
+ Max: 4
17
+ CountKeywordArgs: true
18
+
19
+ Style/AccessModifierIndentation:
20
+ EnforcedStyle: outdent
21
+
22
+ Style/CollectionMethods:
23
+ PreferredMethods:
24
+ map: 'collect'
25
+ reduce: 'inject'
26
+ find: 'detect'
27
+ find_all: 'select'
28
+
29
+ Style/Documentation:
30
+ Enabled: false
31
+
32
+ Style/DotPosition:
33
+ EnforcedStyle: trailing
34
+
35
+ Style/DoubleNegation:
36
+ Enabled: false
37
+
38
+ Style/FileName:
39
+ Exclude:
40
+ - 'lib/omniauth-oauth.rb'
41
+
42
+ Style/HashSyntax:
43
+ EnforcedStyle: hash_rockets
44
+
45
+ Style/Lambda:
46
+ Enabled: false
47
+
48
+ Style/SpaceInsideHashLiteralBraces:
49
+ EnforcedStyle: no_space
50
+
51
+ Style/StringLiterals:
52
+ EnforcedStyle: double_quotes
53
+
54
+ Style/TrailingComma:
55
+ EnforcedStyleForMultiline: 'comma'
@@ -0,0 +1,24 @@
1
+ before_install: gem install bundler
2
+ env:
3
+ global:
4
+ - JRUBY_OPTS="$JRUBY_OPTS --debug"
5
+ language: ruby
6
+ rvm:
7
+ - 2.3
8
+ - 2.4
9
+ - 2.5
10
+ - 2.6
11
+ - 2.7
12
+ - 3.0
13
+ - jruby-18mode
14
+ - jruby-19mode
15
+ - jruby-head
16
+ - rbx-2
17
+ - ruby-head
18
+ matrix:
19
+ allow_failures:
20
+ - rvm: jruby-head
21
+ - rvm: ruby-head
22
+ - rvm: rbx-2 # TODO: Fix
23
+ fast_finish: true
24
+ sudo: false
data/Gemfile CHANGED
@@ -1,11 +1,13 @@
1
- source 'http://rubygems.org'
1
+ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- group :development, :test do
6
- gem 'guard'
7
- gem 'guard-rspec'
8
- gem 'guard-bundler'
9
- gem 'growl'
10
- gem 'rb-fsevent'
5
+ gem "rake"
6
+
7
+ group :test do
8
+ gem "rack-test"
9
+ gem "rspec", "~> 3.2"
10
+ gem "rubocop", ">= 0.30", :platforms => [:ruby_19, :ruby_20, :ruby_21, :ruby_22]
11
+ gem "simplecov"
12
+ gem "webmock"
11
13
  end
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2014 Michael Bleigh, Erik Michaels-Ober and Intridea, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # OmniAuth OAuth
2
2
 
3
- **Note:** This gem is designed to work with the in-beta OmniAuth 1.0
4
- library. It will not be officially released on RubyGems.org until
5
- OmniAuth 1.0 is released.
6
-
7
3
  This gem contains a generic OAuth strategy for OmniAuth. It is meant to
8
4
  serve as a building block strategy for other strategies and not to be
9
5
  used independently (since it has no inherent way to gather uid and user
@@ -14,65 +10,44 @@ info).
14
10
  To create an OmniAuth OAuth strategy using this gem, you can simply
15
11
  subclass it and add a few extra methods like so:
16
12
 
17
- require 'omniauth-oauth'
18
-
19
- module OmniAuth
20
- module Strategies
21
- class SomeSite < OmniAuth::Strategies::OAuth
22
- # Give your strategy a name.
23
- option :name, "some_site"
24
-
25
- # This is where you pass the options you would pass when
26
- # initializing your consumer from the OAuth gem.
27
- option :client_options, {:site => "https://api.somesite.com"}
28
-
29
- # These are called after authentication has succeeded. If
30
- # possible, you should try to set the UID without making
31
- # additional calls (if the user id is returned with the token
32
- # or as a URI parameter). This may not be possible with all
33
- # providers.
34
- uid{ request.params['user_id'] }
35
-
36
- info do
37
- {
38
- :name => raw_info['name'],
39
- :location => raw_info['city']
40
- }
41
- end
13
+ ```ruby
14
+ require 'json'
15
+ require 'omniauth-oauth'
16
+
17
+ module OmniAuth
18
+ module Strategies
19
+ class SomeSite < OmniAuth::Strategies::OAuth
20
+ # Give your strategy a name.
21
+ option :name, "some_site"
22
+
23
+ # This is where you pass the options you would pass when
24
+ # initializing your consumer from the OAuth gem.
25
+ option :client_options, {:site => "https://api.somesite.com"}
26
+
27
+ # These are called after authentication has succeeded. If
28
+ # possible, you should try to set the UID without making
29
+ # additional calls (if the user id is returned with the token
30
+ # or as a URI parameter). This may not be possible with all
31
+ # providers.
32
+ uid{ request.params['user_id'] }
33
+
34
+ info do
35
+ {
36
+ :name => raw_info['name'],
37
+ :location => raw_info['city']
38
+ }
39
+ end
42
40
 
43
- extra do
44
- {
45
- 'raw_info' => raw_info
46
- }
47
- end
41
+ extra do
42
+ {
43
+ 'raw_info' => raw_info
44
+ }
45
+ end
48
46
 
49
- def raw_info
50
- @raw_info ||= MultiJson.decode(access_token.get('/me.json')).body
51
- end
52
- end
47
+ def raw_info
48
+ @raw_info ||= JSON.load(access_token.get('/me.json')).body
53
49
  end
54
50
  end
55
-
56
- That's pretty much it!
57
-
58
- ## License
59
-
60
- Copyright (C) 2011 by Michael Bleigh and Intridea, Inc.
61
-
62
- Permission is hereby granted, free of charge, to any person obtaining a copy
63
- of this software and associated documentation files (the "Software"), to deal
64
- in the Software without restriction, including without limitation the rights
65
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
66
- copies of the Software, and to permit persons to whom the Software is
67
- furnished to do so, subject to the following conditions:
68
-
69
- The above copyright notice and this permission notice shall be included in
70
- all copies or substantial portions of the Software.
71
-
72
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
73
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
74
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
75
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
76
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
77
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
78
- THE SOFTWARE.
51
+ end
52
+ end
53
+ ```
data/Rakefile CHANGED
@@ -1,9 +1,16 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
- require 'rspec/core/rake_task'
3
+ require "rspec/core/rake_task"
4
4
 
5
- desc 'Default: run specs.'
6
- task :default => :spec
7
-
8
- desc "Run specs"
9
5
  RSpec::Core::RakeTask.new
6
+
7
+ begin
8
+ require "rubocop/rake_task"
9
+ RuboCop::RakeTask.new
10
+ rescue LoadError
11
+ task :rubocop do
12
+ $stderr.puts "Rubocop is disabled"
13
+ end
14
+ end
15
+
16
+ task :default => [:spec, :rubocop]
@@ -1,3 +1,2 @@
1
1
  require "omniauth-oauth/version"
2
- require 'omniauth/strategies/oauth'
3
-
2
+ require "omniauth/strategies/oauth"
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module OAuth
3
- VERSION = "1.0.0.rc1"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -1,6 +1,5 @@
1
- require 'multi_json'
2
- require 'oauth'
3
- require 'omniauth'
1
+ require "oauth"
2
+ require "omniauth"
4
3
 
5
4
  module OmniAuth
6
5
  module Strategies
@@ -14,6 +13,7 @@ module OmniAuth
14
13
  option :open_timeout, 30
15
14
  option :read_timeout, 30
16
15
  option :authorize_params, {}
16
+ option :request_params, {}
17
17
 
18
18
  attr_reader :access_token
19
19
 
@@ -24,10 +24,10 @@ module OmniAuth
24
24
  consumer
25
25
  end
26
26
 
27
- def request_phase
28
- request_token = consumer.get_request_token(:oauth_callback => callback_url)
29
- session['oauth'] ||= {}
30
- session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
27
+ def request_phase # rubocop:disable MethodLength
28
+ request_token = consumer.get_request_token({:oauth_callback => callback_url}, options.request_params)
29
+ session["oauth"] ||= {}
30
+ session["oauth"][name.to_s] = {"callback_confirmed" => request_token.callback_confirmed?, "request_token" => request_token.token, "request_secret" => request_token.secret}
31
31
 
32
32
  if request_token.callback_confirmed?
33
33
  redirect request_token.authorize_url(options[:authorize_params])
@@ -41,14 +41,14 @@ module OmniAuth
41
41
  fail!(:service_unavailable, e)
42
42
  end
43
43
 
44
- def callback_phase
45
- raise OmniAuth::NoSessionError.new("Session Expired") if session['oauth'].nil?
44
+ def callback_phase # rubocop:disable MethodLength
45
+ fail(OmniAuth::NoSessionError, "Session Expired") if session["oauth"].nil?
46
46
 
47
- request_token = ::OAuth::RequestToken.new(consumer, session['oauth'][name.to_s].delete('request_token'), session['oauth'][name.to_s].delete('request_secret'))
47
+ request_token = ::OAuth::RequestToken.new(consumer, session["oauth"][name.to_s].delete("request_token"), session["oauth"][name.to_s].delete("request_secret"))
48
48
 
49
49
  opts = {}
50
- if session['oauth'][name.to_s]['callback_confirmed']
51
- opts[:oauth_verifier] = request['oauth_verifier']
50
+ if session["oauth"][name.to_s]["callback_confirmed"]
51
+ opts[:oauth_verifier] = request["oauth_verifier"]
52
52
  else
53
53
  opts[:oauth_callback] = callback_url
54
54
  end
@@ -61,21 +61,19 @@ module OmniAuth
61
61
  fail!(:service_unavailable, e)
62
62
  rescue ::OAuth::Unauthorized => e
63
63
  fail!(:invalid_credentials, e)
64
- rescue ::NoMethodError, ::MultiJson::DecodeError => e
65
- fail!(:invalid_response, e)
66
64
  rescue ::OmniAuth::NoSessionError => e
67
65
  fail!(:session_expired, e)
68
66
  end
69
67
 
70
68
  credentials do
71
- {'token' => access_token.token, 'secret' => access_token.secret}
69
+ {"token" => access_token.token, "secret" => access_token.secret}
72
70
  end
73
71
 
74
72
  extra do
75
- {'access_token' => access_token}
73
+ {"access_token" => access_token}
76
74
  end
77
75
  end
78
76
  end
79
77
  end
80
78
 
81
- OmniAuth.config.add_camelization 'oauth', 'OAuth'
79
+ OmniAuth.config.add_camelization "oauth", "OAuth"
@@ -1,21 +1,17 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/omniauth-oauth/version', __FILE__)
1
+ require File.expand_path("../lib/omniauth-oauth/version", __FILE__)
3
2
 
4
3
  Gem::Specification.new do |gem|
5
- gem.authors = ["Michael Bleigh"]
6
- gem.email = ["michael@intridea.com"]
7
- gem.description = %q{A generic OAuth (1.0/1.0a) strategy for OmniAuth.}
8
- gem.summary = %q{A generic OAuth (1.0/1.0a) strategy for OmniAuth.}
4
+ gem.authors = ["Michael Bleigh", "Erik Michaels-Ober"]
5
+ gem.email = ["michael@intridea.com", "sferik@gmail.com"]
6
+ gem.description = "A generic OAuth (1.0/1.0a) strategy for OmniAuth."
7
+ gem.summary = gem.description
9
8
  gem.homepage = "https://github.com/intridea/omniauth-oauth"
9
+ gem.license = "MIT"
10
10
 
11
- gem.add_runtime_dependency 'omniauth', '~> 1.0.0.beta1'
12
- gem.add_runtime_dependency 'oauth'
13
- gem.add_development_dependency 'rspec', '~> 2.6'
14
- gem.add_development_dependency 'webmock'
15
- gem.add_development_dependency 'simplecov'
16
- gem.add_development_dependency 'rack-test'
11
+ gem.add_dependency "omniauth", ">= 1.0", "< 3"
12
+ gem.add_dependency "oauth"
17
13
 
18
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
15
  gem.files = `git ls-files`.split("\n")
20
16
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
17
  gem.name = "omniauth-oauth"
@@ -0,0 +1,21 @@
1
+ $LOAD_PATH.unshift File.expand_path("..", __FILE__)
2
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
3
+ require "simplecov"
4
+ SimpleCov.start do
5
+ minimum_coverage(89.79)
6
+ end
7
+ require "rspec"
8
+ require "rack/test"
9
+ require "webmock/rspec"
10
+ require "omniauth"
11
+ require "omniauth-oauth"
12
+
13
+ OmniAuth.config.request_validation_phase = nil
14
+
15
+ RSpec.configure do |config|
16
+ config.include WebMock::API
17
+ config.include Rack::Test::Methods
18
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
19
+ end
20
+
21
+ OmniAuth.config.logger = Logger.new("/dev/null")
@@ -1,140 +1,147 @@
1
- require 'spec_helper'
1
+ require "helper"
2
2
 
3
3
  describe "OmniAuth::Strategies::OAuth" do
4
4
  class MyOAuthProvider < OmniAuth::Strategies::OAuth
5
- uid{ access_token.token }
6
- info{ {'name' => access_token.token} }
5
+ uid { access_token.token }
6
+ info { {"name" => access_token.token} }
7
7
  end
8
8
 
9
9
  def app
10
- Rack::Builder.new {
10
+ Rack::Builder.new do
11
11
  use OmniAuth::Test::PhonySession
12
12
  use OmniAuth::Builder do
13
- provider MyOAuthProvider, 'abc', 'def', :client_options => {:site => 'https://api.example.org'}, :name => 'example.org'
14
- provider MyOAuthProvider, 'abc', 'def', :client_options => {:site => 'https://api.example.org'}, :authorize_params => {:abc => 'def'}, :name => 'example.org_with_authorize_params'
13
+ provider MyOAuthProvider, "abc", "def", :client_options => {:site => "https://api.example.org"}, :name => "example.org"
14
+ provider MyOAuthProvider, "abc", "def", :client_options => {:site => "https://api.example.org"}, :authorize_params => {:abc => "def"}, :name => "example.org_with_authorize_params"
15
+ provider MyOAuthProvider, "abc", "def", :client_options => {:site => "https://api.example.org"}, :request_params => {:scope => "http://foobar.example.org"}, :name => "example.org_with_request_params"
15
16
  end
16
- run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
17
- }.to_app
17
+ run lambda { |env| [404, {"Content-Type" => "text/plain"}, [env.key?("omniauth.auth").to_s]] }
18
+ end.to_app
18
19
  end
19
20
 
20
21
  def session
21
- last_request.env['rack.session']
22
+ last_request.env["rack.session"]
22
23
  end
23
24
 
24
25
  before do
25
- stub_request(:post, 'https://api.example.org/oauth/request_token').
26
- to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret&oauth_callback_confirmed=true")
26
+ stub_request(:post, "https://api.example.org/oauth/request_token").
27
+ to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret&oauth_callback_confirmed=true")
27
28
  end
28
29
 
29
- it 'should add a camelization for itself' do
30
- OmniAuth::Utils.camelize('oauth').should == 'OAuth'
30
+ it "should add a camelization for itself" do
31
+ expect(OmniAuth::Utils.camelize("oauth")).to eq("OAuth")
31
32
  end
32
33
 
33
- describe '/auth/{name}' do
34
- context 'successful' do
34
+ describe "/auth/{name}" do
35
+ context "successful" do
35
36
  before do
36
- get '/auth/example.org'
37
+ post "/auth/example.org"
37
38
  end
38
39
 
39
- it 'should redirect to authorize_url' do
40
- last_response.should be_redirect
41
- last_response.headers['Location'].should == 'https://api.example.org/oauth/authorize?oauth_token=yourtoken'
40
+ it "should redirect to authorize_url" do
41
+ expect(last_response).to be_redirect
42
+ expect(last_response.headers["Location"]).to eq("https://api.example.org/oauth/authorize?oauth_token=yourtoken")
42
43
  end
43
44
 
44
- it 'should redirect to authorize_url with authorize_params when set' do
45
- get '/auth/example.org_with_authorize_params'
46
- last_response.should be_redirect
47
- [
48
- 'https://api.example.org/oauth/authorize?abc=def&oauth_token=yourtoken',
49
- 'https://api.example.org/oauth/authorize?oauth_token=yourtoken&abc=def'
50
- ].should be_include(last_response.headers['Location'])
45
+ it "should redirect to authorize_url with authorize_params when set" do
46
+ post "/auth/example.org_with_authorize_params"
47
+ expect(last_response).to be_redirect
48
+ expect([
49
+ "https://api.example.org/oauth/authorize?abc=def&oauth_token=yourtoken",
50
+ "https://api.example.org/oauth/authorize?oauth_token=yourtoken&abc=def",
51
+ ]).to be_include(last_response.headers["Location"])
51
52
  end
52
53
 
53
- it 'should set appropriate session variables' do
54
- session['oauth'].should == {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}
54
+ it "should set appropriate session variables" do
55
+ expect(session["oauth"]).to eq("example.org" => {"callback_confirmed" => true, "request_token" => "yourtoken", "request_secret" => "yoursecret"})
56
+ end
57
+
58
+ it "should pass request_params to get_request_token" do
59
+ post "/auth/example.org_with_request_params"
60
+ expect(WebMock).to have_requested(:post, "https://api.example.org/oauth/request_token").
61
+ with { |req| req.body == "scope=http%3A%2F%2Ffoobar.example.org" }
55
62
  end
56
63
  end
57
64
 
58
- context 'unsuccessful' do
65
+ context "unsuccessful" do
59
66
  before do
60
- stub_request(:post, 'https://api.example.org/oauth/request_token').
61
- to_raise(::Net::HTTPFatalError.new(%Q{502 "Bad Gateway"}, nil))
62
- get '/auth/example.org'
67
+ stub_request(:post, "https://api.example.org/oauth/request_token").
68
+ to_raise(::Net::HTTPFatalError.new('502 "Bad Gateway"', nil))
69
+ post "/auth/example.org"
63
70
  end
64
71
 
65
- it 'should call fail! with :service_unavailable' do
66
- last_request.env['omniauth.error'].should be_kind_of(::Net::HTTPFatalError)
67
- last_request.env['omniauth.error.type'] = :service_unavailable
72
+ it "should call fail! with :service_unavailable" do
73
+ expect(last_request.env["omniauth.error"]).to be_kind_of(::Net::HTTPFatalError)
74
+ last_request.env["omniauth.error.type"] = :service_unavailable
68
75
  end
69
76
 
70
77
  context "SSL failure" do
71
78
  before do
72
- stub_request(:post, 'https://api.example.org/oauth/request_token').
73
- to_raise(::OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"))
74
- get '/auth/example.org'
79
+ stub_request(:post, "https://api.example.org/oauth/request_token").
80
+ to_raise(::OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"))
81
+ post "/auth/example.org"
75
82
  end
76
83
 
77
- it 'should call fail! with :service_unavailable' do
78
- last_request.env['omniauth.error'].should be_kind_of(::OpenSSL::SSL::SSLError)
79
- last_request.env['omniauth.error.type'] = :service_unavailable
84
+ it "should call fail! with :service_unavailable" do
85
+ expect(last_request.env["omniauth.error"]).to be_kind_of(::OpenSSL::SSL::SSLError)
86
+ last_request.env["omniauth.error.type"] = :service_unavailable
80
87
  end
81
88
  end
82
89
  end
83
90
  end
84
91
 
85
- describe '/auth/{name}/callback' do
86
- before do
87
- stub_request(:post, 'https://api.example.org/oauth/access_token').
88
- to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret")
89
- get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
92
+ describe "/auth/{name}/callback" do
93
+ before do
94
+ stub_request(:post, "https://api.example.org/oauth/access_token").
95
+ to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret")
96
+ get "/auth/example.org/callback", {:oauth_verifier => "dudeman"}, "rack.session" => {"oauth" => {"example.org" => {"callback_confirmed" => true, "request_token" => "yourtoken", "request_secret" => "yoursecret"}}}
90
97
  end
91
98
 
92
- it 'should exchange the request token for an access token' do
93
- last_request.env['omniauth.auth']['provider'].should == 'example.org'
94
- last_request.env['omniauth.auth']['extra']['access_token'].should be_kind_of(OAuth::AccessToken)
99
+ it "should exchange the request token for an access token" do
100
+ expect(last_request.env["omniauth.auth"]["provider"]).to eq("example.org")
101
+ expect(last_request.env["omniauth.auth"]["extra"]["access_token"]).to be_kind_of(OAuth::AccessToken)
95
102
  end
96
103
 
97
- it 'should call through to the master app' do
98
- last_response.body.should == 'true'
104
+ it "should call through to the master app" do
105
+ expect(last_response.body).to eq("true")
99
106
  end
100
107
 
101
108
  context "bad gateway (or any 5xx) for access_token" do
102
109
  before do
103
- stub_request(:post, 'https://api.example.org/oauth/access_token').
104
- to_raise(::Net::HTTPFatalError.new(%Q{502 "Bad Gateway"}, nil))
105
- get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
110
+ stub_request(:post, "https://api.example.org/oauth/access_token") .
111
+ to_raise(::Net::HTTPFatalError.new('502 "Bad Gateway"', nil))
112
+ get "/auth/example.org/callback", {:oauth_verifier => "dudeman"}, "rack.session" => {"oauth" => {"example.org" => {"callback_confirmed" => true, "request_token" => "yourtoken", "request_secret" => "yoursecret"}}}
106
113
  end
107
114
 
108
- it 'should call fail! with :service_unavailable' do
109
- last_request.env['omniauth.error'].should be_kind_of(::Net::HTTPFatalError)
110
- last_request.env['omniauth.error.type'] = :service_unavailable
115
+ it "should call fail! with :service_unavailable" do
116
+ expect(last_request.env["omniauth.error"]).to be_kind_of(::Net::HTTPFatalError)
117
+ last_request.env["omniauth.error.type"] = :service_unavailable
111
118
  end
112
119
  end
113
120
 
114
121
  context "SSL failure" do
115
122
  before do
116
- stub_request(:post, 'https://api.example.org/oauth/access_token').
117
- to_raise(::OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"))
118
- get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
123
+ stub_request(:post, "https://api.example.org/oauth/access_token") .
124
+ to_raise(::OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"))
125
+ get "/auth/example.org/callback", {:oauth_verifier => "dudeman"}, "rack.session" => {"oauth" => {"example.org" => {"callback_confirmed" => true, "request_token" => "yourtoken", "request_secret" => "yoursecret"}}}
119
126
  end
120
127
 
121
- it 'should call fail! with :service_unavailable' do
122
- last_request.env['omniauth.error'].should be_kind_of(::OpenSSL::SSL::SSLError)
123
- last_request.env['omniauth.error.type'] = :service_unavailable
128
+ it "should call fail! with :service_unavailable" do
129
+ expect(last_request.env["omniauth.error"]).to be_kind_of(::OpenSSL::SSL::SSLError)
130
+ last_request.env["omniauth.error.type"] = :service_unavailable
124
131
  end
125
132
  end
126
133
  end
127
134
 
128
- describe '/auth/{name}/callback with expired session' do
135
+ describe "/auth/{name}/callback with expired session" do
129
136
  before do
130
- stub_request(:post, 'https://api.example.org/oauth/access_token').
131
- to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret")
132
- get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {}}
137
+ stub_request(:post, "https://api.example.org/oauth/access_token").
138
+ to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret")
139
+ get "/auth/example.org/callback", {:oauth_verifier => "dudeman"}, "rack.session" => {}
133
140
  end
134
141
 
135
- it 'should call fail! with :session_expired' do
136
- last_request.env['omniauth.error'].should be_kind_of(::OmniAuth::NoSessionError)
137
- last_request.env['omniauth.error.type'] = :session_expired
142
+ it "should call fail! with :session_expired" do
143
+ expect(last_request.env["omniauth.error"]).to be_kind_of(::OmniAuth::NoSessionError)
144
+ last_request.env["omniauth.error.type"] = :session_expired
138
145
  end
139
146
  end
140
147
  end
metadata CHANGED
@@ -1,125 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
5
- prerelease: 6
4
+ version: 1.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Michael Bleigh
8
+ - Erik Michaels-Ober
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-28 00:00:00.000000000Z
12
+ date: 2021-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
16
- requirement: &70325064916980 !ruby/object:Gem::Requirement
17
- none: false
16
+ requirement: !ruby/object:Gem::Requirement
18
17
  requirements:
19
- - - ~>
18
+ - - ">="
20
19
  - !ruby/object:Gem::Version
21
- version: 1.0.0.beta1
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: *70325064916980
25
- - !ruby/object:Gem::Dependency
26
- name: oauth
27
- requirement: &70325064911880 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ! '>='
20
+ version: '1.0'
21
+ - - "<"
31
22
  - !ruby/object:Gem::Version
32
- version: '0'
23
+ version: '3'
33
24
  type: :runtime
34
25
  prerelease: false
35
- version_requirements: *70325064911880
36
- - !ruby/object:Gem::Dependency
37
- name: rspec
38
- requirement: &70325064903940 !ruby/object:Gem::Requirement
39
- none: false
26
+ version_requirements: !ruby/object:Gem::Requirement
40
27
  requirements:
41
- - - ~>
28
+ - - ">="
42
29
  - !ruby/object:Gem::Version
43
- version: '2.6'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70325064903940
47
- - !ruby/object:Gem::Dependency
48
- name: webmock
49
- requirement: &70325064902900 !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
30
+ version: '1.0'
31
+ - - "<"
53
32
  - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *70325064902900
33
+ version: '3'
58
34
  - !ruby/object:Gem::Dependency
59
- name: simplecov
60
- requirement: &70325064900880 !ruby/object:Gem::Requirement
61
- none: false
35
+ name: oauth
36
+ requirement: !ruby/object:Gem::Requirement
62
37
  requirements:
63
- - - ! '>='
38
+ - - ">="
64
39
  - !ruby/object:Gem::Version
65
40
  version: '0'
66
- type: :development
41
+ type: :runtime
67
42
  prerelease: false
68
- version_requirements: *70325064900880
69
- - !ruby/object:Gem::Dependency
70
- name: rack-test
71
- requirement: &70325064897300 !ruby/object:Gem::Requirement
72
- none: false
43
+ version_requirements: !ruby/object:Gem::Requirement
73
44
  requirements:
74
- - - ! '>='
45
+ - - ">="
75
46
  - !ruby/object:Gem::Version
76
47
  version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: *70325064897300
80
48
  description: A generic OAuth (1.0/1.0a) strategy for OmniAuth.
81
49
  email:
82
50
  - michael@intridea.com
51
+ - sferik@gmail.com
83
52
  executables: []
84
53
  extensions: []
85
54
  extra_rdoc_files: []
86
55
  files:
87
- - .gitignore
88
- - .rspec
56
+ - ".gitignore"
57
+ - ".rspec"
58
+ - ".rubocop.yml"
59
+ - ".travis.yml"
89
60
  - Gemfile
90
- - Guardfile
61
+ - LICENSE.md
91
62
  - README.md
92
63
  - Rakefile
93
64
  - lib/omniauth-oauth.rb
94
65
  - lib/omniauth-oauth/version.rb
95
66
  - lib/omniauth/strategies/oauth.rb
96
67
  - omniauth-oauth.gemspec
68
+ - spec/helper.rb
97
69
  - spec/omniauth/strategies/oauth_spec.rb
98
- - spec/spec_helper.rb
99
70
  homepage: https://github.com/intridea/omniauth-oauth
100
- licenses: []
71
+ licenses:
72
+ - MIT
73
+ metadata: {}
101
74
  post_install_message:
102
75
  rdoc_options: []
103
76
  require_paths:
104
77
  - lib
105
78
  required_ruby_version: !ruby/object:Gem::Requirement
106
- none: false
107
79
  requirements:
108
- - - ! '>='
80
+ - - ">="
109
81
  - !ruby/object:Gem::Version
110
82
  version: '0'
111
83
  required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
84
  requirements:
114
- - - ! '>'
85
+ - - ">="
115
86
  - !ruby/object:Gem::Version
116
- version: 1.3.1
87
+ version: '0'
117
88
  requirements: []
118
- rubyforge_project:
119
- rubygems_version: 1.8.10
89
+ rubygems_version: 3.0.3
120
90
  signing_key:
121
- specification_version: 3
91
+ specification_version: 4
122
92
  summary: A generic OAuth (1.0/1.0a) strategy for OmniAuth.
123
93
  test_files:
94
+ - spec/helper.rb
124
95
  - spec/omniauth/strategies/oauth_spec.rb
125
- - spec/spec_helper.rb
data/Guardfile DELETED
@@ -1,11 +0,0 @@
1
- guard 'rspec', :version => 2 do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { "spec" }
5
- end
6
-
7
-
8
- guard 'bundler' do
9
- watch('Gemfile')
10
- watch(/^.+\.gemspec/)
11
- end
@@ -1,16 +0,0 @@
1
- $:.unshift File.expand_path('..', __FILE__)
2
- $:.unshift File.expand_path('../../lib', __FILE__)
3
- require 'simplecov'
4
- SimpleCov.start
5
- require 'rspec'
6
- require 'rack/test'
7
- require 'webmock/rspec'
8
- require 'omniauth'
9
- require 'omniauth-oauth'
10
-
11
- RSpec.configure do |config|
12
- config.include WebMock::API
13
- config.include Rack::Test::Methods
14
- config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
- end
16
-