omniauth-oauth 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d51821d2156b46cf7954f1ac30678998f5f2a93b
4
+ data.tar.gz: 8b8fceab109adc5085bb894c5c18fd7eeac5cb0d
5
+ SHA512:
6
+ metadata.gz: 9ed599e75401adf88aef86315b2dc00d035e77a91cea8c5922ad2c46c14dc312570884202e75b22c5985fe4c303058d8fbd123db252ba0bf28eff79a78dc5404
7
+ data.tar.gz: 4f9ea2ffcf4ac1731605358d5420b0870843082fa96f7628508e0c6bac6e4b116c7bd2426ed39d822a50bb49c1dda5f85d0d4777d4c4b488609fcf316606c52d
@@ -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,22 @@
1
+ before_install: gem install bundler
2
+ env:
3
+ global:
4
+ - JRUBY_OPTS="$JRUBY_OPTS --debug"
5
+ language: ruby
6
+ rvm:
7
+ - 1.8.7
8
+ - 1.9.3
9
+ - 2.0.0
10
+ - 2.1
11
+ - 2.2
12
+ - jruby-18mode
13
+ - jruby-19mode
14
+ - jruby-head
15
+ - rbx-2
16
+ - ruby-head
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: jruby-head
20
+ - rvm: ruby-head
21
+ fast_finish: true
22
+ 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) 2012 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.1"
3
+ VERSION = "1.1.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
@@ -25,10 +24,10 @@ module OmniAuth
25
24
  consumer
26
25
  end
27
26
 
28
- def request_phase
27
+ def request_phase # rubocop:disable MethodLength
29
28
  request_token = consumer.get_request_token({:oauth_callback => callback_url}, options.request_params)
30
- session['oauth'] ||= {}
31
- session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
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}
32
31
 
33
32
  if request_token.callback_confirmed?
34
33
  redirect request_token.authorize_url(options[:authorize_params])
@@ -42,14 +41,14 @@ module OmniAuth
42
41
  fail!(:service_unavailable, e)
43
42
  end
44
43
 
45
- def callback_phase
46
- 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?
47
46
 
48
- 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"))
49
48
 
50
49
  opts = {}
51
- if session['oauth'][name.to_s]['callback_confirmed']
52
- opts[:oauth_verifier] = request['oauth_verifier']
50
+ if session["oauth"][name.to_s]["callback_confirmed"]
51
+ opts[:oauth_verifier] = request["oauth_verifier"]
53
52
  else
54
53
  opts[:oauth_callback] = callback_url
55
54
  end
@@ -62,21 +61,19 @@ module OmniAuth
62
61
  fail!(:service_unavailable, e)
63
62
  rescue ::OAuth::Unauthorized => e
64
63
  fail!(:invalid_credentials, e)
65
- rescue ::MultiJson::DecodeError => e
66
- fail!(:invalid_response, e)
67
64
  rescue ::OmniAuth::NoSessionError => e
68
65
  fail!(:session_expired, e)
69
66
  end
70
67
 
71
68
  credentials do
72
- {'token' => access_token.token, 'secret' => access_token.secret}
69
+ {"token" => access_token.token, "secret" => access_token.secret}
73
70
  end
74
71
 
75
72
  extra do
76
- {'access_token' => access_token}
73
+ {"access_token" => access_token}
77
74
  end
78
75
  end
79
76
  end
80
77
  end
81
78
 
82
- OmniAuth.config.add_camelization 'oauth', 'OAuth'
79
+ OmniAuth.config.add_camelization "oauth", "OAuth"
@@ -1,21 +1,18 @@
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'
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"
12
+ gem.add_dependency "oauth"
13
+ gem.add_development_dependency "bundler", "~> 1.9"
17
14
 
18
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
16
  gem.files = `git ls-files`.split("\n")
20
17
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
18
  gem.name = "omniauth-oauth"
@@ -0,0 +1,19 @@
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.8)
6
+ end
7
+ require "rspec"
8
+ require "rack/test"
9
+ require "webmock/rspec"
10
+ require "omniauth"
11
+ require "omniauth-oauth"
12
+
13
+ RSpec.configure do |config|
14
+ config.include WebMock::API
15
+ config.include Rack::Test::Methods
16
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
17
+ end
18
+
19
+ OmniAuth.config.logger = Logger.new("/dev/null")
@@ -1,147 +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'
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'
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"
16
16
  end
17
- run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
18
- }.to_app
17
+ run lambda { |env| [404, {"Content-Type" => "text/plain"}, [env.key?("omniauth.auth").to_s]] }
18
+ end.to_app
19
19
  end
20
20
 
21
21
  def session
22
- last_request.env['rack.session']
22
+ last_request.env["rack.session"]
23
23
  end
24
24
 
25
25
  before do
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")
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")
28
28
  end
29
29
 
30
- it 'should add a camelization for itself' do
31
- OmniAuth::Utils.camelize('oauth').should == 'OAuth'
30
+ it "should add a camelization for itself" do
31
+ expect(OmniAuth::Utils.camelize("oauth")).to eq("OAuth")
32
32
  end
33
33
 
34
- describe '/auth/{name}' do
35
- context 'successful' do
34
+ describe "/auth/{name}" do
35
+ context "successful" do
36
36
  before do
37
- get '/auth/example.org'
37
+ get "/auth/example.org"
38
38
  end
39
39
 
40
- it 'should redirect to authorize_url' do
41
- last_response.should be_redirect
42
- 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")
43
43
  end
44
44
 
45
- it 'should redirect to authorize_url with authorize_params when set' do
46
- get '/auth/example.org_with_authorize_params'
47
- last_response.should be_redirect
48
- [
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
- ].should be_include(last_response.headers['Location'])
45
+ it "should redirect to authorize_url with authorize_params when set" do
46
+ get "/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"])
52
52
  end
53
53
 
54
- it 'should set appropriate session variables' do
55
- 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
56
  end
57
57
 
58
- it 'should pass request_params to get_request_token' do
59
- get '/auth/example.org_with_request_params'
60
- WebMock.should have_requested(:post, 'https://api.example.org/oauth/request_token').
61
- with {|req| req.body == "scope=http%3a%2f%2ffoobar.example.org" }
58
+ it "should pass request_params to get_request_token" do
59
+ get "/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" }
62
62
  end
63
63
  end
64
64
 
65
- context 'unsuccessful' do
65
+ context "unsuccessful" do
66
66
  before do
67
- stub_request(:post, 'https://api.example.org/oauth/request_token').
68
- to_raise(::Net::HTTPFatalError.new(%Q{502 "Bad Gateway"}, nil))
69
- 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
+ get "/auth/example.org"
70
70
  end
71
71
 
72
- it 'should call fail! with :service_unavailable' do
73
- last_request.env['omniauth.error'].should be_kind_of(::Net::HTTPFatalError)
74
- 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
75
75
  end
76
76
 
77
77
  context "SSL failure" do
78
78
  before do
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
- 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
+ get "/auth/example.org"
82
82
  end
83
83
 
84
- it 'should call fail! with :service_unavailable' do
85
- last_request.env['omniauth.error'].should be_kind_of(::OpenSSL::SSL::SSLError)
86
- 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
87
87
  end
88
88
  end
89
89
  end
90
90
  end
91
91
 
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'}}}}
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"}}}
97
97
  end
98
98
 
99
- it 'should exchange the request token for an access token' do
100
- last_request.env['omniauth.auth']['provider'].should == 'example.org'
101
- 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)
102
102
  end
103
103
 
104
- it 'should call through to the master app' do
105
- last_response.body.should == 'true'
104
+ it "should call through to the master app" do
105
+ expect(last_response.body).to eq("true")
106
106
  end
107
107
 
108
108
  context "bad gateway (or any 5xx) for access_token" do
109
109
  before do
110
- stub_request(:post, 'https://api.example.org/oauth/access_token').
111
- to_raise(::Net::HTTPFatalError.new(%Q{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'}}}}
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"}}}
113
113
  end
114
114
 
115
- it 'should call fail! with :service_unavailable' do
116
- last_request.env['omniauth.error'].should be_kind_of(::Net::HTTPFatalError)
117
- 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
118
118
  end
119
119
  end
120
120
 
121
121
  context "SSL failure" do
122
122
  before do
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'}}}}
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"}}}
126
126
  end
127
127
 
128
- it 'should call fail! with :service_unavailable' do
129
- last_request.env['omniauth.error'].should be_kind_of(::OpenSSL::SSL::SSLError)
130
- 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
131
131
  end
132
132
  end
133
133
  end
134
134
 
135
- describe '/auth/{name}/callback with expired session' do
135
+ describe "/auth/{name}/callback with expired session" do
136
136
  before do
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' => {}}
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" => {}
140
140
  end
141
141
 
142
- it 'should call fail! with :session_expired' do
143
- last_request.env['omniauth.error'].should be_kind_of(::OmniAuth::NoSessionError)
144
- 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
145
145
  end
146
146
  end
147
147
  end
metadata CHANGED
@@ -1,126 +1,104 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
5
- prerelease:
4
+ version: 1.1.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: 2012-03-02 00:00:00.000000000 Z
12
+ date: 2015-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
16
- requirement: &70329159031760 !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
20
  version: '1.0'
22
21
  type: :runtime
23
22
  prerelease: false
24
- version_requirements: *70329159031760
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
25
28
  - !ruby/object:Gem::Dependency
26
29
  name: oauth
27
- requirement: &70329159031340 !ruby/object:Gem::Requirement
28
- none: false
30
+ requirement: !ruby/object:Gem::Requirement
29
31
  requirements:
30
- - - ! '>='
32
+ - - ">="
31
33
  - !ruby/object:Gem::Version
32
34
  version: '0'
33
35
  type: :runtime
34
36
  prerelease: false
35
- version_requirements: *70329159031340
36
- - !ruby/object:Gem::Dependency
37
- name: rspec
38
- requirement: &70329159030800 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: '2.6'
44
- type: :development
45
- prerelease: false
46
- version_requirements: *70329159030800
47
- - !ruby/object:Gem::Dependency
48
- name: webmock
49
- requirement: &70329159030380 !ruby/object:Gem::Requirement
50
- none: false
37
+ version_requirements: !ruby/object:Gem::Requirement
51
38
  requirements:
52
- - - ! '>='
39
+ - - ">="
53
40
  - !ruby/object:Gem::Version
54
41
  version: '0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: *70329159030380
58
42
  - !ruby/object:Gem::Dependency
59
- name: simplecov
60
- requirement: &70329159029920 !ruby/object:Gem::Requirement
61
- none: false
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
62
45
  requirements:
63
- - - ! '>='
46
+ - - "~>"
64
47
  - !ruby/object:Gem::Version
65
- version: '0'
48
+ version: '1.9'
66
49
  type: :development
67
50
  prerelease: false
68
- version_requirements: *70329159029920
69
- - !ruby/object:Gem::Dependency
70
- name: rack-test
71
- requirement: &70329159029500 !ruby/object:Gem::Requirement
72
- none: false
51
+ version_requirements: !ruby/object:Gem::Requirement
73
52
  requirements:
74
- - - ! '>='
53
+ - - "~>"
75
54
  - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: *70329159029500
55
+ version: '1.9'
80
56
  description: A generic OAuth (1.0/1.0a) strategy for OmniAuth.
81
57
  email:
82
58
  - michael@intridea.com
59
+ - sferik@gmail.com
83
60
  executables: []
84
61
  extensions: []
85
62
  extra_rdoc_files: []
86
63
  files:
87
- - .gitignore
88
- - .rspec
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - ".rubocop.yml"
67
+ - ".travis.yml"
89
68
  - Gemfile
90
- - Guardfile
69
+ - LICENSE.md
91
70
  - README.md
92
71
  - Rakefile
93
72
  - lib/omniauth-oauth.rb
94
73
  - lib/omniauth-oauth/version.rb
95
74
  - lib/omniauth/strategies/oauth.rb
96
75
  - omniauth-oauth.gemspec
76
+ - spec/helper.rb
97
77
  - spec/omniauth/strategies/oauth_spec.rb
98
- - spec/spec_helper.rb
99
78
  homepage: https://github.com/intridea/omniauth-oauth
100
- licenses: []
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
101
82
  post_install_message:
102
83
  rdoc_options: []
103
84
  require_paths:
104
85
  - lib
105
86
  required_ruby_version: !ruby/object:Gem::Requirement
106
- none: false
107
87
  requirements:
108
- - - ! '>='
88
+ - - ">="
109
89
  - !ruby/object:Gem::Version
110
90
  version: '0'
111
91
  required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
92
  requirements:
114
- - - ! '>='
93
+ - - ">="
115
94
  - !ruby/object:Gem::Version
116
95
  version: '0'
117
96
  requirements: []
118
97
  rubyforge_project:
119
- rubygems_version: 1.8.11
98
+ rubygems_version: 2.4.5
120
99
  signing_key:
121
- specification_version: 3
100
+ specification_version: 4
122
101
  summary: A generic OAuth (1.0/1.0a) strategy for OmniAuth.
123
102
  test_files:
103
+ - spec/helper.rb
124
104
  - spec/omniauth/strategies/oauth_spec.rb
125
- - spec/spec_helper.rb
126
- has_rdoc:
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
-