sorcery 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sorcery might be problematic. Click here for more details.

Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +29 -104
  3. data/CHANGELOG.md +13 -1
  4. data/Gemfile +2 -16
  5. data/README.md +124 -272
  6. data/Rakefile +2 -2
  7. data/gemfiles/{mongoid-rails40.gemfile → active_record-rails42.gemfile} +1 -3
  8. data/lib/generators/sorcery/helpers.rb +4 -4
  9. data/lib/generators/sorcery/install_generator.rb +25 -19
  10. data/lib/generators/sorcery/templates/initializer.rb +27 -52
  11. data/lib/generators/sorcery/templates/migration/activity_logging.rb +2 -2
  12. data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +1 -1
  13. data/lib/generators/sorcery/templates/migration/core.rb +3 -3
  14. data/lib/generators/sorcery/templates/migration/external.rb +2 -2
  15. data/lib/generators/sorcery/templates/migration/remember_me.rb +2 -2
  16. data/lib/generators/sorcery/templates/migration/reset_password.rb +2 -2
  17. data/lib/generators/sorcery/templates/migration/user_activation.rb +2 -2
  18. data/lib/sorcery.rb +0 -28
  19. data/lib/sorcery/adapters/active_record_adapter.rb +7 -18
  20. data/lib/sorcery/controller.rb +19 -21
  21. data/lib/sorcery/controller/config.rb +20 -18
  22. data/lib/sorcery/controller/submodules/activity_logging.rb +7 -15
  23. data/lib/sorcery/controller/submodules/brute_force_protection.rb +1 -2
  24. data/lib/sorcery/controller/submodules/external.rb +22 -14
  25. data/lib/sorcery/controller/submodules/http_basic_auth.rb +16 -19
  26. data/lib/sorcery/controller/submodules/remember_me.rb +15 -10
  27. data/lib/sorcery/controller/submodules/session_timeout.rb +7 -8
  28. data/lib/sorcery/crypto_providers/aes256.rb +15 -15
  29. data/lib/sorcery/crypto_providers/bcrypt.rb +19 -21
  30. data/lib/sorcery/crypto_providers/common.rb +1 -1
  31. data/lib/sorcery/crypto_providers/md5.rb +5 -5
  32. data/lib/sorcery/crypto_providers/sha1.rb +5 -5
  33. data/lib/sorcery/crypto_providers/sha256.rb +2 -2
  34. data/lib/sorcery/crypto_providers/sha512.rb +3 -3
  35. data/lib/sorcery/engine.rb +3 -8
  36. data/lib/sorcery/model.rb +24 -32
  37. data/lib/sorcery/model/config.rb +64 -49
  38. data/lib/sorcery/model/submodules/activity_logging.rb +31 -12
  39. data/lib/sorcery/model/submodules/brute_force_protection.rb +23 -23
  40. data/lib/sorcery/model/submodules/external.rb +3 -7
  41. data/lib/sorcery/model/submodules/remember_me.rb +19 -7
  42. data/lib/sorcery/model/submodules/reset_password.rb +32 -36
  43. data/lib/sorcery/model/submodules/user_activation.rb +38 -50
  44. data/lib/sorcery/model/temporary_token.rb +2 -2
  45. data/lib/sorcery/protocols/oauth.rb +3 -9
  46. data/lib/sorcery/protocols/oauth2.rb +0 -2
  47. data/lib/sorcery/providers/base.rb +4 -4
  48. data/lib/sorcery/providers/facebook.rb +5 -8
  49. data/lib/sorcery/providers/github.rb +5 -7
  50. data/lib/sorcery/providers/google.rb +3 -5
  51. data/lib/sorcery/providers/heroku.rb +6 -8
  52. data/lib/sorcery/providers/jira.rb +12 -17
  53. data/lib/sorcery/providers/linkedin.rb +6 -8
  54. data/lib/sorcery/providers/liveid.rb +4 -7
  55. data/lib/sorcery/providers/paypal.rb +60 -0
  56. data/lib/sorcery/providers/salesforce.rb +3 -5
  57. data/lib/sorcery/providers/slack.rb +45 -0
  58. data/lib/sorcery/providers/twitter.rb +4 -6
  59. data/lib/sorcery/providers/vk.rb +3 -5
  60. data/lib/sorcery/providers/wechat.rb +79 -0
  61. data/lib/sorcery/providers/xing.rb +7 -10
  62. data/lib/sorcery/test_helpers/internal.rb +10 -10
  63. data/lib/sorcery/test_helpers/internal/rails.rb +16 -8
  64. data/lib/sorcery/test_helpers/rails/controller.rb +1 -1
  65. data/lib/sorcery/test_helpers/rails/integration.rb +5 -6
  66. data/lib/sorcery/version.rb +1 -1
  67. data/sorcery.gemspec +25 -27
  68. data/spec/active_record/user_activation_spec.rb +2 -3
  69. data/spec/active_record/user_activity_logging_spec.rb +2 -4
  70. data/spec/active_record/user_brute_force_protection_spec.rb +3 -4
  71. data/spec/active_record/user_oauth_spec.rb +3 -4
  72. data/spec/active_record/user_remember_me_spec.rb +3 -4
  73. data/spec/active_record/user_reset_password_spec.rb +2 -3
  74. data/spec/active_record/user_spec.rb +7 -7
  75. data/spec/controllers/controller_activity_logging_spec.rb +13 -24
  76. data/spec/controllers/controller_brute_force_protection_spec.rb +6 -8
  77. data/spec/controllers/controller_http_basic_auth_spec.rb +19 -20
  78. data/spec/controllers/controller_oauth2_spec.rb +125 -100
  79. data/spec/controllers/controller_oauth_spec.rb +86 -66
  80. data/spec/controllers/controller_remember_me_spec.rb +35 -30
  81. data/spec/controllers/controller_session_timeout_spec.rb +14 -15
  82. data/spec/controllers/controller_spec.rb +77 -111
  83. data/spec/orm/active_record.rb +1 -1
  84. data/spec/rails_app/app/active_record/authentication.rb +1 -1
  85. data/spec/rails_app/app/active_record/user.rb +2 -2
  86. data/spec/rails_app/app/controllers/sorcery_controller.rb +89 -24
  87. data/spec/rails_app/app/mailers/sorcery_mailer.rb +16 -17
  88. data/spec/rails_app/config.ru +1 -1
  89. data/spec/rails_app/config/application.rb +7 -7
  90. data/spec/rails_app/config/boot.rb +1 -1
  91. data/spec/rails_app/config/environments/test.rb +1 -1
  92. data/spec/rails_app/config/initializers/compatible_legacy_migration.rb +11 -0
  93. data/spec/rails_app/config/initializers/session_store.rb +3 -3
  94. data/spec/rails_app/config/routes.rb +11 -1
  95. data/spec/rails_app/db/migrate/activation/20101224223622_add_activation_to_users.rb +4 -4
  96. data/spec/rails_app/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +8 -8
  97. data/spec/rails_app/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +5 -5
  98. data/spec/rails_app/db/migrate/core/20101224223620_create_users.rb +5 -5
  99. data/spec/rails_app/db/migrate/external/20101224223628_create_authentications_and_user_providers.rb +3 -3
  100. data/spec/rails_app/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +6 -6
  101. data/spec/rails_app/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +5 -5
  102. data/spec/shared_examples/user_activation_shared_examples.rb +99 -58
  103. data/spec/shared_examples/user_activity_logging_shared_examples.rb +47 -41
  104. data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +19 -24
  105. data/spec/shared_examples/user_oauth_shared_examples.rb +7 -10
  106. data/spec/shared_examples/user_remember_me_shared_examples.rb +90 -21
  107. data/spec/shared_examples/user_reset_password_shared_examples.rb +52 -54
  108. data/spec/shared_examples/user_shared_examples.rb +215 -118
  109. data/spec/sorcery_crypto_providers_spec.rb +63 -76
  110. data/spec/spec_helper.rb +17 -13
  111. metadata +28 -83
  112. data/gemfiles/mongo_mapper-rails40.gemfile +0 -9
  113. data/gemfiles/mongo_mapper-rails41.gemfile +0 -9
  114. data/gemfiles/mongoid-rails41.gemfile +0 -9
  115. data/gemfiles/mongoid3-rails32.gemfile +0 -9
  116. data/lib/sorcery/adapters/data_mapper_adapter.rb +0 -176
  117. data/lib/sorcery/adapters/mongo_mapper_adapter.rb +0 -110
  118. data/lib/sorcery/adapters/mongoid_adapter.rb +0 -97
  119. data/lib/sorcery/railties/tasks.rake +0 -6
  120. data/spec/data_mapper/user_activation_spec.rb +0 -10
  121. data/spec/data_mapper/user_activity_logging_spec.rb +0 -14
  122. data/spec/data_mapper/user_brute_force_protection_spec.rb +0 -9
  123. data/spec/data_mapper/user_oauth_spec.rb +0 -9
  124. data/spec/data_mapper/user_remember_me_spec.rb +0 -8
  125. data/spec/data_mapper/user_reset_password_spec.rb +0 -8
  126. data/spec/data_mapper/user_spec.rb +0 -27
  127. data/spec/mongo_mapper/user_activation_spec.rb +0 -9
  128. data/spec/mongo_mapper/user_activity_logging_spec.rb +0 -8
  129. data/spec/mongo_mapper/user_brute_force_protection_spec.rb +0 -8
  130. data/spec/mongo_mapper/user_oauth_spec.rb +0 -8
  131. data/spec/mongo_mapper/user_remember_me_spec.rb +0 -8
  132. data/spec/mongo_mapper/user_reset_password_spec.rb +0 -8
  133. data/spec/mongo_mapper/user_spec.rb +0 -37
  134. data/spec/mongoid/user_activation_spec.rb +0 -9
  135. data/spec/mongoid/user_activity_logging_spec.rb +0 -8
  136. data/spec/mongoid/user_brute_force_protection_spec.rb +0 -8
  137. data/spec/mongoid/user_oauth_spec.rb +0 -8
  138. data/spec/mongoid/user_remember_me_spec.rb +0 -8
  139. data/spec/mongoid/user_reset_password_spec.rb +0 -8
  140. data/spec/mongoid/user_spec.rb +0 -51
  141. data/spec/orm/data_mapper.rb +0 -48
  142. data/spec/orm/mongo_mapper.rb +0 -10
  143. data/spec/orm/mongoid.rb +0 -22
  144. data/spec/rails_app/app/data_mapper/authentication.rb +0 -8
  145. data/spec/rails_app/app/data_mapper/user.rb +0 -7
  146. data/spec/rails_app/app/mongo_mapper/authentication.rb +0 -6
  147. data/spec/rails_app/app/mongo_mapper/user.rb +0 -7
  148. data/spec/rails_app/app/mongoid/authentication.rb +0 -7
  149. data/spec/rails_app/app/mongoid/user.rb +0 -7
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe SorceryController do
4
- describe "plugin configuration" do
3
+ describe SorceryController, type: :controller do
4
+ describe 'plugin configuration' do
5
5
  before(:all) do
6
6
  sorcery_reload!
7
7
  end
@@ -12,9 +12,9 @@ describe SorceryController do
12
12
  end
13
13
 
14
14
  it "enables configuration option 'user_class'" do
15
- sorcery_controller_property_set(:user_class, "TestUser")
15
+ sorcery_controller_property_set(:user_class, 'TestUser')
16
16
 
17
- expect(Sorcery::Controller::Config.user_class).to eq "TestUser"
17
+ expect(Sorcery::Controller::Config.user_class).to eq 'TestUser'
18
18
  end
19
19
 
20
20
  it "enables configuration option 'not_authenticated_action'" do
@@ -22,11 +22,10 @@ describe SorceryController do
22
22
 
23
23
  expect(Sorcery::Controller::Config.not_authenticated_action).to eq :my_action
24
24
  end
25
-
26
25
  end
27
26
 
28
27
  # ----------------- PLUGIN ACTIVATED -----------------------
29
- context "when activated with sorcery" do
28
+ context 'when activated with sorcery' do
30
29
  let(:user) { double('user', id: 42) }
31
30
 
32
31
  before(:all) do
@@ -48,160 +47,128 @@ describe SorceryController do
48
47
 
49
48
  specify { should respond_to(:current_user) }
50
49
 
51
- it "login(username,password) returns the user when success and set the session with user.id" do
52
- expect(User).to receive(:authenticate).with('bla@bla.com', 'secret').and_return(user)
53
-
54
- get :test_login, :email => 'bla@bla.com', :password => 'secret'
55
-
56
- expect(assigns[:user]).to eq user
57
- expect(session[:user_id]).to eq "42"
58
- end
59
-
60
- it "login(email,password) returns the user when success and set the session with user.id" do
61
- expect(User).to receive(:authenticate).with('bla@bla.com', 'secret').and_return(user)
62
-
63
- get :test_login, :email => 'bla@bla.com', :password => 'secret'
64
-
65
- expect(assigns[:user]).to eq user
66
- expect(session[:user_id]).to eq user.id.to_s
67
- end
68
-
69
- it "login(username,password) returns nil and not set the session when failure" do
70
- expect(User).to receive(:authenticate).with('bla@bla.com', 'opensesame!').and_return(nil)
71
-
72
- get :test_login, :email => 'bla@bla.com', :password => 'opensesame!'
73
-
74
- expect(assigns[:user]).to be_nil
75
- expect(session[:user_id]).to be_nil
76
- end
77
-
78
- it "login(email,password) returns the user when success and set the session with the _csrf_token" do
79
- expect(User).to receive(:authenticate).with('bla@bla.com', 'secret').and_return(user)
80
- get :test_login, :email => 'bla@bla.com', :password => 'secret'
81
-
82
- expect(session[:_csrf_token]).not_to be_nil
83
- end
50
+ specify { should respond_to(:require_login) }
84
51
 
85
- it "login(username,password) returns nil and not set the session when upper case username" do
86
- skip('DM Adapter dependant') if SORCERY_ORM == :data_mapper
87
- get :test_login, :email => 'BLA@BLA.COM', :password => 'secret'
52
+ describe '#login' do
53
+ context 'when succeeds' do
54
+ before do
55
+ expect(User).to receive(:authenticate).with('bla@bla.com', 'secret').and_return(user)
56
+ get :test_login, params: { email: 'bla@bla.com', password: 'secret' }
57
+ end
88
58
 
89
- expect(assigns[:user]).to be_nil
90
- expect(session[:user_id]).to be_nil
91
- end
59
+ it 'assigns user to @user variable' do
60
+ expect(assigns[:user]).to eq user
61
+ end
92
62
 
93
- # TODO: move test to model
94
- it "login(username,password) returns the user and set the session with user.id when upper case username and config is downcase before authenticating" do
95
- sorcery_model_property_set(:downcase_username_before_authenticating, true)
96
- expect(User).to receive(:authenticate).with('BLA@BLA.COM', 'secret').and_return(user)
97
- get :test_login, :email => 'BLA@BLA.COM', :password => 'secret'
98
-
99
- expect(assigns[:user]).to eq user
100
- expect(session[:user_id]).to eq user.id.to_s
101
- end
63
+ it 'writes user id in session' do
64
+ expect(session[:user_id]).to eq user.id.to_s
65
+ end
102
66
 
103
- # TODO: move test to model
104
- it "login(username,password) returns nil and not set the session when user was created with upper case username, config is default, and log in username is lower case" do
105
- skip('DM Adapter dependant') if SORCERY_ORM == :data_mapper
106
- expect(User).to receive(:authenticate).with('bla1@bla.com', 'secret1').and_return(nil)
107
- get :test_login, :email => 'bla1@bla.com', :password => 'secret1'
67
+ it 'sets csrf token in session' do
68
+ expect(session[:_csrf_token]).not_to be_nil
69
+ end
70
+ end
108
71
 
109
- expect(assigns[:user]).to be_nil
110
- expect(session[:user_id]).to be_nil
111
- end
72
+ context 'when fails' do
73
+ before do
74
+ expect(User).to receive(:authenticate).with('bla@bla.com', 'opensesame!').and_return(nil)
75
+ get :test_login, params: { email: 'bla@bla.com', password: 'opensesame!' }
76
+ end
112
77
 
113
- # TODO: move test to model
114
- it "login(username,password) returns the user and set the session with user.id when user was created with upper case username and config is downcase before authenticating" do
115
- skip('DM Adapter dependant') if SORCERY_ORM == :data_mapper
116
- sorcery_model_property_set(:downcase_username_before_authenticating, true)
117
- expect(User).to receive(:authenticate).with('bla1@bla.com', 'secret1').and_return(user)
118
- get :test_login, :email => 'bla1@bla.com', :password => 'secret1'
78
+ it 'sets @user variable to nil' do
79
+ expect(assigns[:user]).to be_nil
80
+ end
119
81
 
120
- expect(assigns[:user]).to eq user
121
- expect(session[:user_id]).to eq user.id.to_s
82
+ it 'sets user_id in session to nil' do
83
+ expect(session[:user_id]).to be_nil
84
+ end
85
+ end
122
86
  end
123
87
 
124
- it "logout clears the session" do
125
- cookies[:remember_me_token] = nil
126
- session[:user_id] = user.id.to_s
127
- expect(User.sorcery_adapter).to receive(:find_by_id).with("42") { user }
128
- get :test_logout
88
+ describe '#logout' do
89
+ it 'clears the session' do
90
+ cookies[:remember_me_token] = nil
91
+ session[:user_id] = user.id.to_s
92
+ expect(User.sorcery_adapter).to receive(:find_by_id).with('42') { user }
93
+ get :test_logout
129
94
 
130
- expect(session[:user_id]).to be_nil
95
+ expect(session[:user_id]).to be_nil
96
+ end
131
97
  end
132
98
 
133
- it "logged_in? returns true if logged in" do
134
- session[:user_id] = user.id.to_s
135
- expect(User.sorcery_adapter).to receive(:find_by_id).with("42") { user }
99
+ describe '#logged_in?' do
100
+ it 'returns true when user is logged in' do
101
+ session[:user_id] = user.id.to_s
102
+ expect(User.sorcery_adapter).to receive(:find_by_id).with('42') { user }
136
103
 
137
- expect(subject.logged_in?).to be true
138
- end
104
+ expect(subject.logged_in?).to be true
105
+ end
139
106
 
140
- it "logged_in? returns false if not logged in" do
141
- session[:user_id] = nil
107
+ it 'returns false when user is not logged in' do
108
+ session[:user_id] = nil
142
109
 
143
- expect(subject.logged_in?).to be false
110
+ expect(subject.logged_in?).to be false
111
+ end
144
112
  end
145
113
 
146
- it "current_user returns the user instance if logged in" do
147
- session[:user_id] = user.id.to_s
148
- expect(User.sorcery_adapter).to receive(:find_by_id).with("42") { user }
114
+ describe '#current_user' do
115
+ it 'current_user returns the user instance if logged in' do
116
+ session[:user_id] = user.id.to_s
117
+ expect(User.sorcery_adapter).to receive(:find_by_id).once.with('42') { user }
149
118
 
150
- 2.times { expect(subject.current_user).to eq user } # memoized!
151
- end
119
+ 2.times { expect(subject.current_user).to eq user } # memoized!
120
+ end
152
121
 
153
- it "current_user returns false if not logged in" do
154
- session[:user_id] = nil
155
- expect(User.sorcery_adapter).to_not receive(:find_by_id)
122
+ it 'current_user returns false if not logged in' do
123
+ session[:user_id] = nil
124
+ expect(User.sorcery_adapter).to_not receive(:find_by_id)
156
125
 
157
- 2.times { expect(subject.current_user).to be_nil } # memoized!
126
+ 2.times { expect(subject.current_user).to be_nil } # memoized!
127
+ end
158
128
  end
159
129
 
160
- specify { should respond_to(:require_login) }
161
-
162
- it "calls the configured 'not_authenticated_action' when authenticate before_filter fails" do
130
+ it "calls the configured 'not_authenticated_action' when authenticate before_action fails" do
163
131
  session[:user_id] = nil
164
132
  sorcery_controller_property_set(:not_authenticated_action, :test_not_authenticated_action)
165
133
  get :test_logout
166
134
 
167
- expect(response.body).to eq "test_not_authenticated_action"
135
+ expect(response).to be_a_success
168
136
  end
169
137
 
170
- it "require_login before_filter saves the url that the user originally wanted" do
138
+ it 'require_login before_action saves the url that the user originally wanted' do
171
139
  get :some_action
172
140
 
173
- expect(session[:return_to_url]).to eq "http://test.host/some_action"
174
- expect(response).to redirect_to("http://test.host/")
141
+ expect(session[:return_to_url]).to eq 'http://test.host/some_action'
142
+ expect(response).to redirect_to('http://test.host/')
175
143
  end
176
144
 
177
- it "require_login before_filter does not save the url that the user originally wanted upon all non-get http methods" do
145
+ it 'require_login before_action does not save the url that the user originally wanted upon all non-get http methods' do
178
146
  [:post, :put, :delete].each do |m|
179
- self.send(m, :some_action)
147
+ send(m, :some_action)
180
148
 
181
149
  expect(session[:return_to_url]).to be_nil
182
150
  end
183
151
  end
184
152
 
185
- it "on successful login the user is redirected to the url he originally wanted" do
186
- session[:return_to_url] = "http://test.host/some_action"
187
- post :test_return_to, :email => 'bla@bla.com', :password => 'secret'
153
+ it 'on successful login the user is redirected to the url he originally wanted' do
154
+ session[:return_to_url] = 'http://test.host/some_action'
155
+ post :test_return_to, params: { email: 'bla@bla.com', password: 'secret' }
188
156
 
189
- expect(response).to redirect_to("http://test.host/some_action")
190
- expect(flash[:notice]).to eq "haha!"
157
+ expect(response).to redirect_to('http://test.host/some_action')
158
+ expect(flash[:notice]).to eq 'haha!'
191
159
  end
192
160
 
193
-
194
161
  # --- auto_login(user) ---
195
162
  specify { should respond_to(:auto_login) }
196
163
 
197
- it "auto_login(user) los in a user instance" do
164
+ it 'auto_login(user) los in a user instance' do
198
165
  session[:user_id] = nil
199
166
  subject.auto_login(user)
200
167
 
201
168
  expect(subject.logged_in?).to be true
202
169
  end
203
170
 
204
- it "auto_login(user) works even if current_user was already set to false" do
171
+ it 'auto_login(user) works even if current_user was already set to false' do
205
172
  get :test_logout
206
173
 
207
174
  expect(session[:user_id]).to be_nil
@@ -214,5 +181,4 @@ describe SorceryController do
214
181
  expect(assigns[:result]).to eq user
215
182
  end
216
183
  end
217
-
218
184
  end
@@ -17,5 +17,5 @@ def teardown_orm
17
17
  end
18
18
 
19
19
  def migrations_path
20
- Rails.root.join("db", "migrate", "core")
20
+ Rails.root.join('db', 'migrate', 'core')
21
21
  end
@@ -1,3 +1,3 @@
1
1
  class Authentication < ActiveRecord::Base
2
2
  belongs_to :user
3
- end
3
+ end
@@ -1,5 +1,5 @@
1
1
  class User < ActiveRecord::Base
2
- has_many :authentications, :dependent => :destroy
3
- has_many :user_providers, :dependent => :destroy
2
+ has_many :authentications, dependent: :destroy
3
+ has_many :user_providers, dependent: :destroy
4
4
  accepts_nested_attributes_for :authentications
5
5
  end
@@ -3,31 +3,30 @@ require 'oauth'
3
3
  class SorceryController < ActionController::Base
4
4
  protect_from_forgery
5
5
 
6
- before_filter :require_login_from_http_basic, only: [:test_http_basic_auth]
7
- before_filter :require_login, only: [:test_logout, :test_should_be_logged_in, :some_action]
6
+ before_action :require_login_from_http_basic, only: [:test_http_basic_auth]
7
+ before_action :require_login, only: [:test_logout, :test_logout_with_force_forget_me, :test_should_be_logged_in, :some_action]
8
8
 
9
- def index
10
- end
9
+ def index; end
11
10
 
12
11
  def some_action
13
- render nothing: true
12
+ head :ok
14
13
  end
15
14
 
16
15
  def some_action_making_a_non_persisted_change_to_the_user
17
16
  current_user.email = 'to_be_ignored'
18
- render nothing: true
17
+ head :ok
19
18
  end
20
19
 
21
20
  def test_login
22
21
  @user = login(params[:email], params[:password])
23
- render nothing: true
22
+ head :ok
24
23
  end
25
24
 
26
25
  def test_auto_login
27
26
  @user = User.first
28
27
  auto_login(@user)
29
28
  @result = current_user
30
- render nothing: true
29
+ head :ok
31
30
  end
32
31
 
33
32
  def test_return_to
@@ -37,50 +36,57 @@ class SorceryController < ActionController::Base
37
36
 
38
37
  def test_logout
39
38
  logout
40
- render nothing: true
39
+ head :ok
41
40
  end
42
41
 
43
42
  def test_logout_with_remember
44
43
  remember_me!
45
44
  logout
46
- render nothing: true
45
+ head :ok
46
+ end
47
+
48
+ def test_logout_with_force_forget_me
49
+ remember_me!
50
+ force_forget_me!
51
+ logout
52
+ head :ok
47
53
  end
48
54
 
49
55
  def test_login_with_remember
50
56
  @user = login(params[:email], params[:password])
51
57
  remember_me!
52
58
 
53
- render nothing: true
59
+ head :ok
54
60
  end
55
61
 
56
62
  def test_login_with_remember_in_login
57
63
  @user = login(params[:email], params[:password], params[:remember])
58
64
 
59
- render nothing: true
65
+ head :ok
60
66
  end
61
67
 
62
68
  def test_login_from_cookie
63
69
  @user = current_user
64
- render nothing: true
70
+ head :ok
65
71
  end
66
72
 
67
73
  def test_not_authenticated_action
68
- render text: 'test_not_authenticated_action'
74
+ head :ok
69
75
  end
70
76
 
71
77
  def test_should_be_logged_in
72
- render nothing: true
78
+ head :ok
73
79
  end
74
80
 
75
81
  def test_http_basic_auth
76
- render text: 'HTTP Basic Auth'
82
+ head :ok
77
83
  end
78
84
 
79
85
  def login_at_test_twitter
80
86
  login_at(:twitter)
81
87
  end
82
88
 
83
- alias :login_at_test :login_at_test_twitter
89
+ alias login_at_test login_at_test_twitter
84
90
 
85
91
  def login_at_test_facebook
86
92
  login_at(:facebook)
@@ -90,6 +96,14 @@ class SorceryController < ActionController::Base
90
96
  login_at(:github)
91
97
  end
92
98
 
99
+ def login_at_test_paypal
100
+ login_at(:paypal)
101
+ end
102
+
103
+ def login_at_test_wechat
104
+ login_at(:wechat)
105
+ end
106
+
93
107
  def login_at_test_google
94
108
  login_at(:google)
95
109
  end
@@ -110,8 +124,12 @@ class SorceryController < ActionController::Base
110
124
  login_at(:salesforce)
111
125
  end
112
126
 
127
+ def login_at_test_slack
128
+ login_at(:slack)
129
+ end
130
+
113
131
  def login_at_test_with_state
114
- login_at(:facebook, {state: 'bla'})
132
+ login_at(:facebook, state: 'bla')
115
133
  end
116
134
 
117
135
  def test_login_from_twitter
@@ -122,7 +140,7 @@ class SorceryController < ActionController::Base
122
140
  end
123
141
  end
124
142
 
125
- alias :test_login_from :test_login_from_twitter
143
+ alias test_login_from test_login_from_twitter
126
144
 
127
145
  def test_login_from_facebook
128
146
  if @user = login_from(:facebook)
@@ -140,6 +158,22 @@ class SorceryController < ActionController::Base
140
158
  end
141
159
  end
142
160
 
161
+ def test_login_from_paypal
162
+ if @user = login_from(:paypal)
163
+ redirect_to 'bla', notice: 'Success!'
164
+ else
165
+ redirect_to 'blu', alert: 'Failed!'
166
+ end
167
+ end
168
+
169
+ def test_login_from_wechat
170
+ if @user = login_from(:wechat)
171
+ redirect_to 'bla', notice: 'Success!'
172
+ else
173
+ redirect_to 'blu', alert: 'Failed!'
174
+ end
175
+ end
176
+
143
177
  def test_login_from_google
144
178
  if @user = login_from(:google)
145
179
  redirect_to 'bla', notice: 'Success!'
@@ -180,6 +214,14 @@ class SorceryController < ActionController::Base
180
214
  end
181
215
  end
182
216
 
217
+ def test_login_from_slack
218
+ if @user = login_from(:slack)
219
+ redirect_to 'bla', notice: 'Success!'
220
+ else
221
+ redirect_to 'blu', alert: 'Failed!'
222
+ end
223
+ end
224
+
183
225
  def test_return_to_with_external_twitter
184
226
  if @user = login_from(:twitter)
185
227
  redirect_back_or_to 'bla', notice: 'Success!'
@@ -196,7 +238,7 @@ class SorceryController < ActionController::Base
196
238
  end
197
239
  end
198
240
 
199
- alias :test_return_to_with_external :test_return_to_with_external_twitter
241
+ alias test_return_to_with_external test_return_to_with_external_twitter
200
242
 
201
243
  def test_return_to_with_external_facebook
202
244
  if @user = login_from(:facebook)
@@ -214,6 +256,22 @@ class SorceryController < ActionController::Base
214
256
  end
215
257
  end
216
258
 
259
+ def test_return_to_with_external_paypal
260
+ if @user = login_from(:paypal)
261
+ redirect_back_or_to 'bla', notice: 'Success!'
262
+ else
263
+ redirect_to 'blu', alert: 'Failed!'
264
+ end
265
+ end
266
+
267
+ def test_return_to_with_external_wechat
268
+ if @user = login_from(:wechat)
269
+ redirect_back_or_to 'bla', notice: 'Success!'
270
+ else
271
+ redirect_to 'blu', alert: 'Failed!'
272
+ end
273
+ end
274
+
217
275
  def test_return_to_with_external_google
218
276
  if @user = login_from(:google)
219
277
  redirect_back_or_to 'bla', notice: 'Success!'
@@ -246,6 +304,14 @@ class SorceryController < ActionController::Base
246
304
  end
247
305
  end
248
306
 
307
+ def test_return_to_with_external_slack
308
+ if @user = login_from(:slack)
309
+ redirect_back_or_to 'bla', notice: 'Success!'
310
+ else
311
+ redirect_to 'blu', alert: 'Failed!'
312
+ end
313
+ end
314
+
249
315
  def test_create_from_provider
250
316
  provider = params[:provider]
251
317
  login_from(provider)
@@ -260,9 +326,9 @@ class SorceryController < ActionController::Base
260
326
  provider = params[:provider]
261
327
  if logged_in?
262
328
  if @user = add_provider_to_user(provider)
263
- redirect_to "bla", :notice => "Success!"
329
+ redirect_to 'bla', notice: 'Success!'
264
330
  else
265
- redirect_to "blu", :alert => "Failed!"
331
+ redirect_to 'blu', alert: 'Failed!'
266
332
  end
267
333
  end
268
334
  end
@@ -270,7 +336,7 @@ class SorceryController < ActionController::Base
270
336
  def test_create_from_provider_with_block
271
337
  provider = params[:provider]
272
338
  login_from(provider)
273
- @user = create_from(provider) do |user|
339
+ @user = create_from(provider) do |_user|
274
340
  # check uniqueness of email
275
341
  # User.where(email: user.email).empty?
276
342
  false
@@ -281,5 +347,4 @@ class SorceryController < ActionController::Base
281
347
  redirect_to 'blu', alert: 'Failed!'
282
348
  end
283
349
  end
284
-
285
350
  end