omniauth-auth0 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -0
  3. data/{LICENSE.md → LICENSE} +0 -0
  4. data/README.md +23 -1
  5. data/examples/ruby-on-rails-webapp/.gitignore +17 -0
  6. data/examples/ruby-on-rails-webapp/Gemfile +48 -0
  7. data/examples/ruby-on-rails-webapp/README.md +20 -0
  8. data/examples/ruby-on-rails-webapp/README.rdoc +28 -0
  9. data/examples/ruby-on-rails-webapp/Rakefile +6 -0
  10. data/examples/ruby-on-rails-webapp/app/assets/images/.keep +0 -0
  11. data/examples/ruby-on-rails-webapp/app/assets/javascripts/application.js +13 -0
  12. data/examples/ruby-on-rails-webapp/app/assets/javascripts/home.js.erb +10 -0
  13. data/examples/ruby-on-rails-webapp/app/assets/stylesheets/application.css +114 -0
  14. data/examples/ruby-on-rails-webapp/app/controllers/application_controller.rb +5 -0
  15. data/examples/ruby-on-rails-webapp/app/controllers/auth0_controller.rb +14 -0
  16. data/examples/ruby-on-rails-webapp/app/controllers/concerns/.keep +0 -0
  17. data/examples/ruby-on-rails-webapp/app/controllers/dashboard_controller.rb +5 -0
  18. data/examples/ruby-on-rails-webapp/app/controllers/home_controller.rb +5 -0
  19. data/examples/ruby-on-rails-webapp/app/controllers/secured_controller.rb +13 -0
  20. data/examples/ruby-on-rails-webapp/app/helpers/application_helper.rb +2 -0
  21. data/examples/ruby-on-rails-webapp/app/helpers/callback_helper.rb +2 -0
  22. data/examples/ruby-on-rails-webapp/app/helpers/dashboard_helper.rb +2 -0
  23. data/examples/ruby-on-rails-webapp/app/helpers/home_helper.rb +2 -0
  24. data/examples/ruby-on-rails-webapp/app/mailers/.keep +0 -0
  25. data/examples/ruby-on-rails-webapp/app/models/.keep +0 -0
  26. data/examples/ruby-on-rails-webapp/app/models/concerns/.keep +0 -0
  27. data/examples/ruby-on-rails-webapp/app/views/auth0/failure.html.erb +4 -0
  28. data/examples/ruby-on-rails-webapp/app/views/dashboard/show.html.erb +12 -0
  29. data/examples/ruby-on-rails-webapp/app/views/home/show.html.erb +17 -0
  30. data/examples/ruby-on-rails-webapp/app/views/layouts/application.html.erb +21 -0
  31. data/examples/ruby-on-rails-webapp/bin/bundle +3 -0
  32. data/examples/ruby-on-rails-webapp/bin/rails +4 -0
  33. data/examples/ruby-on-rails-webapp/bin/rake +4 -0
  34. data/examples/ruby-on-rails-webapp/bin/spring +18 -0
  35. data/examples/ruby-on-rails-webapp/config.ru +4 -0
  36. data/examples/ruby-on-rails-webapp/config/application.rb +32 -0
  37. data/examples/ruby-on-rails-webapp/config/boot.rb +4 -0
  38. data/examples/ruby-on-rails-webapp/config/database.yml +20 -0
  39. data/examples/ruby-on-rails-webapp/config/environment.rb +5 -0
  40. data/examples/ruby-on-rails-webapp/config/environments/development.rb +39 -0
  41. data/examples/ruby-on-rails-webapp/config/environments/production.rb +85 -0
  42. data/examples/ruby-on-rails-webapp/config/environments/test.rb +39 -0
  43. data/examples/ruby-on-rails-webapp/config/initializers/01_dotenv.rb +4 -0
  44. data/examples/ruby-on-rails-webapp/config/initializers/auth0.rb +9 -0
  45. data/examples/ruby-on-rails-webapp/config/initializers/backtrace_silencers.rb +7 -0
  46. data/examples/ruby-on-rails-webapp/config/initializers/cookies_serializer.rb +3 -0
  47. data/examples/ruby-on-rails-webapp/config/initializers/filter_parameter_logging.rb +4 -0
  48. data/examples/ruby-on-rails-webapp/config/initializers/inflections.rb +16 -0
  49. data/examples/ruby-on-rails-webapp/config/initializers/mime_types.rb +4 -0
  50. data/examples/ruby-on-rails-webapp/config/initializers/session_store.rb +3 -0
  51. data/examples/ruby-on-rails-webapp/config/initializers/wrap_parameters.rb +14 -0
  52. data/examples/ruby-on-rails-webapp/config/locales/en.yml +23 -0
  53. data/examples/ruby-on-rails-webapp/config/routes.rb +66 -0
  54. data/examples/ruby-on-rails-webapp/config/secrets.yml +35 -0
  55. data/examples/ruby-on-rails-webapp/db/seeds.rb +7 -0
  56. data/examples/ruby-on-rails-webapp/lib/assets/.keep +0 -0
  57. data/examples/ruby-on-rails-webapp/lib/tasks/.keep +0 -0
  58. data/examples/ruby-on-rails-webapp/log/.keep +0 -0
  59. data/examples/ruby-on-rails-webapp/public/404.html +67 -0
  60. data/examples/ruby-on-rails-webapp/public/422.html +67 -0
  61. data/examples/ruby-on-rails-webapp/public/500.html +66 -0
  62. data/examples/ruby-on-rails-webapp/public/favicon.ico +0 -0
  63. data/examples/ruby-on-rails-webapp/public/robots.txt +5 -0
  64. data/examples/ruby-on-rails-webapp/test/controllers/.keep +0 -0
  65. data/examples/ruby-on-rails-webapp/test/controllers/callback_controller_test.rb +14 -0
  66. data/examples/ruby-on-rails-webapp/test/controllers/dashboard_controller_test.rb +9 -0
  67. data/examples/ruby-on-rails-webapp/test/controllers/home_controller_test.rb +9 -0
  68. data/examples/ruby-on-rails-webapp/test/fixtures/.keep +0 -0
  69. data/examples/ruby-on-rails-webapp/test/helpers/.keep +0 -0
  70. data/examples/ruby-on-rails-webapp/test/helpers/callback_helper_test.rb +4 -0
  71. data/examples/ruby-on-rails-webapp/test/helpers/dashboard_helper_test.rb +4 -0
  72. data/examples/ruby-on-rails-webapp/test/helpers/home_helper_test.rb +4 -0
  73. data/examples/ruby-on-rails-webapp/test/integration/.keep +0 -0
  74. data/examples/ruby-on-rails-webapp/test/mailers/.keep +0 -0
  75. data/examples/ruby-on-rails-webapp/test/models/.keep +0 -0
  76. data/examples/ruby-on-rails-webapp/test/test_helper.rb +13 -0
  77. data/examples/ruby-on-rails-webapp/vendor/assets/javascripts/.keep +0 -0
  78. data/examples/ruby-on-rails-webapp/vendor/assets/stylesheets/.keep +0 -0
  79. data/lib/omniauth-auth0.rb +1 -1
  80. data/lib/omniauth-auth0/version.rb +3 -0
  81. data/lib/omniauth/strategies/auth0.rb +9 -2
  82. data/omniauth-auth0.gemspec +3 -2
  83. data/spec/omniauth/strategies/auth0_spec.rb +45 -34
  84. metadata +116 -28
  85. data/lib/auth0/version.rb +0 -3
@@ -0,0 +1,35 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 44943afd8bfa7c8f48302d23a56af7a44766e516fc9b2585e9b198fb55e628e1a11ff2b876f193068f23dac95031e2d36fce28341f429076fcc322df68a4c572
15
+ auth0_client_id: <%= ENV["AUTH0_CLIENT_ID"] %>
16
+ auth0_client_secret: <%= ENV["AUTH0_CLIENT_SECRET"] %>
17
+ auth0_domain: <%= ENV["AUTH0_DOMAIN"] %>
18
+ auth0_callback_url: <%= ENV["AUTH0_CALLBACK_URL"] %>
19
+
20
+
21
+ test:
22
+ secret_key_base: 730ab4e74b6278ea9ecf8da4975ce7959836fc082b4974eb3cb65e0026be59b6502082b23fcecea9c611b5e5059632f876cdc7d5b31b3e80fc7c7b76c70e85b3
23
+ auth0_client_id: <%= ENV["AUTH0_CLIENT_ID"] %>
24
+ auth0_client_secret: <%= ENV["AUTH0_CLIENT_SECRET"] %>
25
+ auth0_domain: <%= ENV["AUTH0_DOMAIN"] %>
26
+ auth0_callback_url: <%= ENV["AUTH0_CALLBACK_URL"] %>
27
+
28
+ # Do not keep production secrets in the repository,
29
+ # instead read values from the environment.
30
+ production:
31
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
32
+ auth0_client_id: <%= ENV["AUTH0_CLIENT_ID"] %>
33
+ auth0_client_secret: <%= ENV["AUTH0_CLIENT_SECRET"] %>
34
+ auth0_domain: <%= ENV["AUTH0_DOMAIN"] %>
35
+ auth0_callback_url: <%= ENV["AUTH0_CALLBACK_URL"] %>
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
File without changes
File without changes
File without changes
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class CallbackControllerTest < ActionController::TestCase
4
+ test "should get store" do
5
+ get :store
6
+ assert_response :success
7
+ end
8
+
9
+ test "should get failure" do
10
+ get :failure
11
+ assert_response :success
12
+ end
13
+
14
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class DashboardControllerTest < ActionController::TestCase
4
+ test "should get show" do
5
+ get :show
6
+ assert_response :success
7
+ end
8
+
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ class HomeControllerTest < ActionController::TestCase
4
+ test "should get show" do
5
+ get :show
6
+ assert_response :success
7
+ end
8
+
9
+ end
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class CallbackHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class DashboardHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class HomeHelperTest < ActionView::TestCase
4
+ end
File without changes
File without changes
@@ -0,0 +1,13 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require File.expand_path('../../config/environment', __FILE__)
3
+ require 'rails/test_help'
4
+
5
+ class ActiveSupport::TestCase
6
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
7
+ #
8
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
+ # -- they do not yet inherit this setting
10
+ fixtures :all
11
+
12
+ # Add more helper methods to be used by all tests here...
13
+ end
@@ -1,2 +1,2 @@
1
- require "auth0/version"
1
+ require "omniauth-auth0/version"
2
2
  require "omniauth/strategies/auth0"
@@ -0,0 +1,3 @@
1
+ module Auth0
2
+ VERSION = "1.4.0"
3
+ end
@@ -1,3 +1,4 @@
1
+ require "base64"
1
2
  require "omniauth-oauth2"
2
3
 
3
4
  module OmniAuth
@@ -23,8 +24,8 @@ module OmniAuth
23
24
  @options.connection = args[4] unless args[4].nil?
24
25
 
25
26
  @options.client_options.site = "https://#{options[:namespace]}"
26
- @options.client_options.authorize_url = "https://#{options[:namespace]}/authorize"
27
- @options.client_options.token_url = "https://#{options[:namespace]}/oauth/token"
27
+ @options.client_options.authorize_url = "https://#{options[:namespace]}/authorize?#{client_info_querystring}"
28
+ @options.client_options.token_url = "https://#{options[:namespace]}/oauth/token?#{client_info_querystring}"
28
29
  @options.client_options.userinfo_url = "https://#{options[:namespace]}/userinfo"
29
30
  end
30
31
 
@@ -70,6 +71,12 @@ module OmniAuth
70
71
  def raw_info
71
72
  @raw_info ||= access_token.get(options.client_options.userinfo_url).parsed
72
73
  end
74
+
75
+ private
76
+ def client_info_querystring
77
+ client_info = JSON.dump({name: 'omniauth-auth0', version: ::Auth0::VERSION})
78
+ "auth0Client=" + Base64.urlsafe_encode64(client_info)
79
+ end
73
80
  end
74
81
  end
75
82
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "auth0/version"
3
+ require "omniauth-auth0/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "omniauth-auth0"
@@ -30,6 +30,7 @@ omniauth-auth0 is the omniauth strategy for Auth0.
30
30
  s.add_development_dependency 'simplecov', '~> 0.9', '>= 0.9.1'
31
31
  s.add_development_dependency 'webmock', '~> 1.20', '>= 1.20.4'
32
32
  s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
33
-
33
+ s.add_development_dependency 'gem-release', '~> 0.7'
34
+
34
35
  s.license = 'MIT'
35
36
  end
@@ -9,12 +9,12 @@ describe OmniAuth::Strategies::Auth0 do
9
9
  before :each do
10
10
  OmniAuth.config.test_mode = true
11
11
  @request = double('Request')
12
- @request.stub(:params) { {} }
13
- @request.stub(:cookies) { {} }
14
- @request.stub(:env) { {} }
12
+ allow(@request).to receive(:params)
13
+ allow(@request).to receive(:cookies)
14
+ allow(@request).to receive(:env)
15
15
 
16
16
  @session = double('Session')
17
- @session.stub(:delete).with('omniauth.state').and_return('state')
17
+ allow(@session).to receive(:delete).with('omniauth.state').and_return('state')
18
18
  end
19
19
 
20
20
  after do
@@ -24,24 +24,33 @@ describe OmniAuth::Strategies::Auth0 do
24
24
  subject do
25
25
  OmniAuth::Strategies::Auth0.new(app,
26
26
  "client_id", "client_secret", "tenny.auth0.com:3000").tap do |strategy|
27
- strategy.stub(:request) { @request }
27
+ allow(strategy).to receive(:request) { @request }
28
28
  end
29
29
  end
30
30
 
31
31
  context "initiation" do
32
+ let(:base64_token) {
33
+ Base64.urlsafe_encode64('{"name":"omniauth-auth0","version":"'+Auth0::VERSION+'"}')
34
+ }
35
+
32
36
  it "uses the correct site" do
33
- subject.options.client_options.site.
34
- should == "https://tenny.auth0.com:3000"
37
+ expect(subject.options.client_options.site).to eql "https://tenny.auth0.com:3000"
35
38
  end
36
39
 
37
40
  it "uses the correct authorize_url" do
38
- subject.options.client_options.authorize_url.
39
- should == "https://tenny.auth0.com:3000/authorize"
41
+ expect(subject.options.client_options.authorize_url).
42
+ to eql "https://tenny.auth0.com:3000/authorize?auth0Client=#{base64_token}"
43
+
40
44
  end
41
45
 
42
46
  it "uses the correct token_url" do
43
- subject.options.client_options.token_url.
44
- should == "https://tenny.auth0.com:3000/oauth/token"
47
+ expect(subject.options.client_options.token_url).
48
+ to eql "https://tenny.auth0.com:3000/oauth/token?auth0Client=#{base64_token}"
49
+ end
50
+
51
+ it "uses the correct userinfo url" do
52
+ expect(subject.options.client_options.userinfo_url).
53
+ to eql "https://tenny.auth0.com:3000/userinfo"
45
54
  end
46
55
 
47
56
  it "should raise an ArgumentError error if no namespace passed" do
@@ -59,11 +68,11 @@ describe OmniAuth::Strategies::Auth0 do
59
68
  end
60
69
 
61
70
  it "authorize params" do
62
- subject.stub(:request) { double('Request', {:params => {
71
+ allow(subject).to receive(:request) { double('Request', {:params => {
63
72
  "connection" => "google-oauth2", "redirect_uri" => "redirect_uri" }, :env => {}}) }
64
- subject.authorize_params.include?("connection").should == true
65
- subject.authorize_params.include?("state").should == true
66
- subject.authorize_params.include?("redirect_uri").should == true
73
+ expect(subject.authorize_params).to include("connection")
74
+ expect(subject.authorize_params).to include("state")
75
+ expect(subject.authorize_params).to include("redirect_uri")
67
76
  end
68
77
  end
69
78
 
@@ -90,66 +99,68 @@ describe OmniAuth::Strategies::Auth0 do
90
99
  "picture" => "pic",
91
100
  "user_id" => "google-oauth2|102835921788417079450"
92
101
  }
93
- subject.stub(:raw_info) { @raw_info }
102
+ allow(subject).to receive(:raw_info) { @raw_info }
94
103
  end
95
104
 
96
105
  context "info" do
97
106
  it 'returns the uid (required)' do
98
- subject.uid.should eq('google-oauth2|102835921788417079450')
107
+ expect(subject.uid).to eq('google-oauth2|102835921788417079450')
99
108
  end
100
109
 
101
110
  it 'returns the name (required)' do
102
- subject.info[:name].should eq('FirstName LastName')
111
+ expect(subject.info[:name]).to eq('FirstName LastName')
103
112
  end
104
113
 
105
114
  it 'returns the email' do
106
- subject.info[:email].should eq('user@mail.com')
115
+ expect(subject.info[:email]).to eq('user@mail.com')
107
116
  end
108
117
 
109
118
  it 'returns the nickname' do
110
- subject.info[:nickname].should eq('nick')
119
+ expect(subject.info[:nickname]).to eq('nick')
111
120
  end
112
121
 
113
122
  it 'returns the last name' do
114
- subject.info[:last_name].should eq('LastName')
123
+ expect(subject.info[:last_name]).to eq('LastName')
115
124
  end
116
125
 
117
126
  it 'returns the first name' do
118
- subject.info[:first_name].should eq('FirstName')
127
+ expect(subject.info[:first_name]).to eq('FirstName')
119
128
  end
120
129
 
121
130
  it 'returns the location' do
122
- subject.info[:location].should eq('en')
131
+ expect(subject.info[:location]).to eq('en')
123
132
  end
124
133
 
125
134
  it 'returns the image' do
126
- subject.info[:image].should eq('pic')
135
+ expect(subject.info[:image]).to eq('pic')
127
136
  end
128
137
  end
129
138
 
130
139
  context "get token" do
131
140
  before :each do
132
141
  @access_token = double('OAuth2::AccessToken')
133
- @access_token.stub(:token)
134
- @access_token.stub(:expires?)
135
- @access_token.stub(:expires_at)
136
- @access_token.stub(:refresh_token)
137
- @access_token.stub(:params)
138
- subject.stub(:access_token) { @access_token }
142
+
143
+ allow(@access_token).to receive(:token)
144
+ allow(@access_token).to receive(:expires?)
145
+ allow(@access_token).to receive(:expires_at)
146
+ allow(@access_token).to receive(:refresh_token)
147
+ allow(@access_token).to receive(:params)
148
+
149
+ allow(subject).to receive(:access_token) { @access_token }
139
150
  end
140
151
 
141
152
  it 'returns a Hash' do
142
- subject.credentials.should be_a(Hash)
153
+ expect(subject.credentials).to be_a(Hash)
143
154
  end
144
155
 
145
156
  it 'returns the token' do
146
- @access_token.stub(:token) {
157
+ allow(@access_token).to receive(:token) {
147
158
  {
148
159
  :access_token => "OTqSFa9zrh0VRGAZHH4QPJISCoynRwSy9FocUazuaU950EVcISsJo3pST11iTCiI",
149
160
  :token_type => "bearer"
150
161
  } }
151
- subject.credentials['token'][:access_token].should eq('OTqSFa9zrh0VRGAZHH4QPJISCoynRwSy9FocUazuaU950EVcISsJo3pST11iTCiI')
152
- subject.credentials['token'][:token_type].should eq('bearer')
162
+ expect(subject.credentials['token'][:access_token]).to eq('OTqSFa9zrh0VRGAZHH4QPJISCoynRwSy9FocUazuaU950EVcISsJo3pST11iTCiI')
163
+ expect(subject.credentials['token'][:token_type]).to eq('bearer')
153
164
  end
154
165
  end
155
166
  end