sorcery 0.5.21 → 0.6.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.
Files changed (68) hide show
  1. data/README.rdoc +9 -1
  2. data/VERSION +1 -1
  3. data/lib/sorcery/controller/submodules/activity_logging.rb +11 -7
  4. data/lib/sorcery/controller/submodules/brute_force_protection.rb +8 -5
  5. data/lib/sorcery/controller/submodules/external.rb +11 -6
  6. data/lib/sorcery/controller/submodules/http_basic_auth.rb +11 -6
  7. data/lib/sorcery/controller/submodules/remember_me.rb +14 -5
  8. data/lib/sorcery/controller/submodules/session_timeout.rb +3 -1
  9. data/lib/sorcery/controller.rb +12 -9
  10. data/lib/sorcery/crypto_providers/aes256.rb +8 -5
  11. data/lib/sorcery/crypto_providers/bcrypt.rb +12 -6
  12. data/lib/sorcery/crypto_providers/sha256.rb +2 -1
  13. data/lib/sorcery/crypto_providers/sha512.rb +2 -1
  14. data/lib/sorcery/initializers/initializer.rb +125 -36
  15. data/lib/sorcery/model/adapters/active_record.rb +2 -2
  16. data/lib/sorcery/model/adapters/mongoid.rb +4 -4
  17. data/lib/sorcery/model/submodules/activity_logging.rb +7 -6
  18. data/lib/sorcery/model/submodules/brute_force_protection.rb +10 -6
  19. data/lib/sorcery/model/submodules/external.rb +4 -2
  20. data/lib/sorcery/model/submodules/remember_me.rb +4 -3
  21. data/lib/sorcery/model/submodules/reset_password.rb +16 -8
  22. data/lib/sorcery/model/submodules/user_activation.rb +23 -10
  23. data/lib/sorcery/model/temporary_token.rb +3 -2
  24. data/lib/sorcery/model.rb +58 -26
  25. data/lib/sorcery/test_helpers/internal/rails.rb +6 -2
  26. data/lib/sorcery/test_helpers/internal/sinatra.rb +1 -1
  27. data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +1 -1
  28. data/lib/sorcery/test_helpers/internal.rb +2 -1
  29. data/sorcery.gemspec +20 -2
  30. data/spec/Gemfile.lock +1 -1
  31. data/spec/rails3/Gemfile.lock +1 -1
  32. data/spec/rails3/spec/controller_oauth2_spec.rb +3 -24
  33. data/spec/rails3/spec/controller_oauth_spec.rb +3 -24
  34. data/spec/rails3/spec/controller_spec.rb +2 -2
  35. data/spec/rails3/spec/user_activation_spec.rb +2 -168
  36. data/spec/rails3/spec/user_activity_logging_spec.rb +2 -30
  37. data/spec/rails3/spec/user_brute_force_protection_spec.rb +2 -35
  38. data/spec/rails3/spec/user_oauth_spec.rb +2 -26
  39. data/spec/rails3/spec/user_remember_me_spec.rb +2 -45
  40. data/spec/rails3/spec/user_reset_password_spec.rb +3 -168
  41. data/spec/rails3/spec/user_spec.rb +3 -283
  42. data/spec/rails3_mongoid/Gemfile.lock +1 -1
  43. data/spec/rails3_mongoid/app/models/authentication.rb +3 -3
  44. data/spec/rails3_mongoid/spec/user_activation_spec.rb +2 -171
  45. data/spec/rails3_mongoid/spec/user_activity_logging_spec.rb +2 -25
  46. data/spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb +2 -35
  47. data/spec/rails3_mongoid/spec/user_oauth_spec.rb +2 -28
  48. data/spec/rails3_mongoid/spec/user_remember_me_spec.rb +2 -45
  49. data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +2 -176
  50. data/spec/rails3_mongoid/spec/user_spec.rb +3 -285
  51. data/spec/shared_examples/controller_oauth2_shared_examples.rb +37 -0
  52. data/spec/shared_examples/controller_oauth_shared_examples.rb +37 -0
  53. data/spec/shared_examples/user_activation_shared_examples.rb +173 -0
  54. data/spec/shared_examples/user_activity_logging_shared_examples.rb +27 -0
  55. data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +37 -0
  56. data/spec/shared_examples/user_oauth_shared_examples.rb +31 -0
  57. data/spec/shared_examples/user_remember_me_shared_examples.rb +47 -0
  58. data/spec/shared_examples/user_reset_password_shared_examples.rb +177 -0
  59. data/spec/shared_examples/user_shared_examples.rb +292 -0
  60. data/spec/sinatra/Gemfile.lock +1 -1
  61. data/spec/sinatra/spec/controller_oauth2_spec.rb +3 -24
  62. data/spec/sinatra/spec/controller_oauth_spec.rb +3 -24
  63. data/spec/sinatra/spec/controller_spec.rb +2 -2
  64. data/spec/sinatra_modular/Gemfile.lock +1 -1
  65. data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +3 -24
  66. data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +3 -24
  67. data/spec/sinatra_modular/spec_modular/controller_spec.rb +2 -2
  68. metadata +20 -2
@@ -0,0 +1,292 @@
1
+ shared_examples_for "rails_3_core_model" do
2
+ describe User, "loaded plugin configuration" do
3
+ after(:each) do
4
+ User.sorcery_config.reset!
5
+ end
6
+
7
+ it "should enable configuration option 'username_attribute_name'" do
8
+ sorcery_model_property_set(:username_attribute_name, :email)
9
+ User.sorcery_config.username_attribute_name.should equal(:email)
10
+ end
11
+
12
+ it "should enable configuration option 'password_attribute_name'" do
13
+ sorcery_model_property_set(:password_attribute_name, :mypassword)
14
+ User.sorcery_config.password_attribute_name.should equal(:mypassword)
15
+ end
16
+
17
+ it "should enable configuration option 'email_attribute_name'" do
18
+ sorcery_model_property_set(:email_attribute_name, :my_email)
19
+ User.sorcery_config.email_attribute_name.should equal(:my_email)
20
+ end
21
+
22
+ it "should enable configuration option 'crypted_password_attribute_name'" do
23
+ sorcery_model_property_set(:crypted_password_attribute_name, :password)
24
+ User.sorcery_config.crypted_password_attribute_name.should equal(:password)
25
+ end
26
+
27
+ it "should enable configuration option 'salt_attribute_name'" do
28
+ sorcery_model_property_set(:salt_attribute_name, :my_salt)
29
+ User.sorcery_config.salt_attribute_name.should equal(:my_salt)
30
+ end
31
+
32
+ it "should enable configuration option 'encryption_algorithm'" do
33
+ sorcery_model_property_set(:encryption_algorithm, :none)
34
+ User.sorcery_config.encryption_algorithm.should equal(:none)
35
+ end
36
+
37
+ it "should enable configuration option 'encryption_key'" do
38
+ sorcery_model_property_set(:encryption_key, 'asdadas424234242')
39
+ User.sorcery_config.encryption_key.should == 'asdadas424234242'
40
+ end
41
+
42
+ it "should enable configuration option 'custom_encryption_provider'" do
43
+ sorcery_model_property_set(:encryption_algorithm, :custom)
44
+ sorcery_model_property_set(:custom_encryption_provider, Array)
45
+ User.sorcery_config.custom_encryption_provider.should equal(Array)
46
+ end
47
+
48
+ it "should enable configuration option 'salt_join_token'" do
49
+ salt_join_token = "--%%*&-"
50
+ sorcery_model_property_set(:salt_join_token, salt_join_token)
51
+ User.sorcery_config.salt_join_token.should equal(salt_join_token)
52
+ end
53
+
54
+ it "should enable configuration option 'stretches'" do
55
+ stretches = 15
56
+ sorcery_model_property_set(:stretches, stretches)
57
+ User.sorcery_config.stretches.should equal(stretches)
58
+ end
59
+
60
+ end
61
+
62
+ # ----------------- PLUGIN ACTIVATED -----------------------
63
+ describe User, "when activated with sorcery" do
64
+ before(:all) do
65
+ sorcery_reload!()
66
+ end
67
+
68
+ before(:each) do
69
+ User.delete_all
70
+ end
71
+
72
+ it "should respond to class method authenticate" do
73
+ ActiveRecord::Base.should_not respond_to(:authenticate) if defined?(ActiveRecord)
74
+ User.should respond_to(:authenticate)
75
+ end
76
+
77
+ it "authenticate should return true if credentials are good" do
78
+ create_new_user
79
+ User.authenticate(@user.send(User.sorcery_config.username_attribute_name), 'secret').should be_true
80
+ end
81
+
82
+ it "authenticate should return false if credentials are bad" do
83
+ create_new_user
84
+ User.authenticate(@user.send(User.sorcery_config.username_attribute_name), 'wrong!').should be_false
85
+ end
86
+
87
+ specify { User.should respond_to(:encrypt) }
88
+
89
+ it "subclass should inherit config if defined so" do
90
+ sorcery_reload!([],{:subclasses_inherit_config => true})
91
+ class Admin < User
92
+ end
93
+ Admin.sorcery_config.should_not be_nil
94
+ Admin.sorcery_config.should == User.sorcery_config
95
+ end
96
+
97
+ it "subclass should not inherit config if not defined so" do
98
+ sorcery_reload!([],{:subclasses_inherit_config => false})
99
+ class Admin2 < User
100
+ end
101
+ Admin2.sorcery_config.should be_nil
102
+ end
103
+ end
104
+
105
+ # ----------------- REGISTRATION -----------------------
106
+ describe User, "registration" do
107
+
108
+ before(:all) do
109
+ sorcery_reload!()
110
+ end
111
+
112
+ before(:each) do
113
+ User.delete_all
114
+ end
115
+
116
+ it "by default, encryption_provider should not be nil" do
117
+ User.sorcery_config.encryption_provider.should_not be_nil
118
+ end
119
+
120
+ it "should encrypt password when a new user is saved" do
121
+ create_new_user
122
+ User.sorcery_config.encryption_provider.matches?(@user.send(User.sorcery_config.crypted_password_attribute_name),'secret',@user.salt).should be_true
123
+ end
124
+
125
+ it "should clear the virtual password field if the encryption process worked" do
126
+ create_new_user
127
+ @user.password.should be_nil
128
+ end
129
+
130
+ it "should not clear the virtual password field if save failed due to validity" do
131
+ create_new_user
132
+ User.class_eval do
133
+ validates_format_of :email, :with => /^(.)+@(.)+$/, :if => Proc.new {|r| r.email}, :message => "is invalid"
134
+ end
135
+ @user.password = 'blupush'
136
+ @user.email = 'asd'
137
+ @user.save
138
+ @user.password.should_not be_nil
139
+ end
140
+
141
+ it "should not clear the virtual password field if save failed due to exception" do
142
+ create_new_user
143
+ @user.password = '4blupush'
144
+ @user.username = nil
145
+ User.class_eval do
146
+ validates_presence_of :username
147
+ end
148
+ begin
149
+ @user.save! # triggers validation exception since username field is required.
150
+ rescue
151
+ end
152
+ @user.password.should_not be_nil
153
+ end
154
+
155
+ it "should not encrypt the password twice when a user is updated" do
156
+ create_new_user
157
+ @user.email = "blup@bla.com"
158
+ @user.save!
159
+ User.sorcery_config.encryption_provider.matches?(@user.send(User.sorcery_config.crypted_password_attribute_name),'secret',@user.salt).should be_true
160
+ end
161
+
162
+ it "should replace the crypted_password in case a new password is set" do
163
+ create_new_user
164
+ @user.password = 'new_secret'
165
+ @user.save!
166
+ User.sorcery_config.encryption_provider.matches?(@user.send(User.sorcery_config.crypted_password_attribute_name),'secret',@user.salt).should be_false
167
+ end
168
+
169
+ end
170
+
171
+ # ----------------- PASSWORD ENCRYPTION -----------------------
172
+ describe User, "special encryption cases" do
173
+ before(:all) do
174
+ sorcery_reload!()
175
+ @text = "Some Text!"
176
+ end
177
+
178
+ before(:each) do
179
+ User.delete_all
180
+ end
181
+
182
+ after(:each) do
183
+ User.sorcery_config.reset!
184
+ end
185
+
186
+ it "should work with no password encryption" do
187
+ sorcery_model_property_set(:encryption_algorithm, :none)
188
+ create_new_user
189
+ User.authenticate(@user.send(User.sorcery_config.username_attribute_name), 'secret').should be_true
190
+ end
191
+
192
+ it "should work with custom password encryption" do
193
+ class MyCrypto
194
+ def self.encrypt(*tokens)
195
+ tokens.flatten.join('').gsub(/e/,'A')
196
+ end
197
+
198
+ def self.matches?(crypted,*tokens)
199
+ crypted == encrypt(*tokens)
200
+ end
201
+ end
202
+ sorcery_model_property_set(:encryption_algorithm, :custom)
203
+ sorcery_model_property_set(:custom_encryption_provider, MyCrypto)
204
+ create_new_user
205
+ User.authenticate(@user.send(User.sorcery_config.username_attribute_name), 'secret').should be_true
206
+ end
207
+
208
+ it "if encryption algo is aes256, it should set key to crypto provider" do
209
+ sorcery_model_property_set(:encryption_algorithm, :aes256)
210
+ sorcery_model_property_set(:encryption_key, nil)
211
+ expect{User.encrypt(@text)}.to raise_error(ArgumentError)
212
+ sorcery_model_property_set(:encryption_key, "asd234dfs423fddsmndsflktsdf32343")
213
+ expect{User.encrypt(@text)}.to_not raise_error(ArgumentError)
214
+ end
215
+
216
+ it "if encryption algo is aes256, it should set key to crypto provider, even if attributes are set in reverse" do
217
+ sorcery_model_property_set(:encryption_key, nil)
218
+ sorcery_model_property_set(:encryption_algorithm, :none)
219
+ sorcery_model_property_set(:encryption_key, "asd234dfs423fddsmndsflktsdf32343")
220
+ sorcery_model_property_set(:encryption_algorithm, :aes256)
221
+ expect{User.encrypt(@text)}.to_not raise_error(ArgumentError)
222
+ end
223
+
224
+ it "if encryption algo is md5 it should work" do
225
+ sorcery_model_property_set(:encryption_algorithm, :md5)
226
+ User.encrypt(@text).should == Sorcery::CryptoProviders::MD5.encrypt(@text)
227
+ end
228
+
229
+ it "if encryption algo is sha1 it should work" do
230
+ sorcery_model_property_set(:encryption_algorithm, :sha1)
231
+ User.encrypt(@text).should == Sorcery::CryptoProviders::SHA1.encrypt(@text)
232
+ end
233
+
234
+ it "if encryption algo is sha256 it should work" do
235
+ sorcery_model_property_set(:encryption_algorithm, :sha256)
236
+ User.encrypt(@text).should == Sorcery::CryptoProviders::SHA256.encrypt(@text)
237
+ end
238
+
239
+ it "if encryption algo is sha512 it should work" do
240
+ sorcery_model_property_set(:encryption_algorithm, :sha512)
241
+ User.encrypt(@text).should == Sorcery::CryptoProviders::SHA512.encrypt(@text)
242
+ end
243
+
244
+ it "salt should be random for each user and saved in db" do
245
+ sorcery_model_property_set(:salt_attribute_name, :salt)
246
+ create_new_user
247
+ @user.salt.should_not be_nil
248
+ end
249
+
250
+ it "if salt is set should use it to encrypt" do
251
+ sorcery_model_property_set(:salt_attribute_name, :salt)
252
+ sorcery_model_property_set(:encryption_algorithm, :sha512)
253
+ create_new_user
254
+ @user.crypted_password.should_not == Sorcery::CryptoProviders::SHA512.encrypt('secret')
255
+ @user.crypted_password.should == Sorcery::CryptoProviders::SHA512.encrypt('secret',@user.salt)
256
+ end
257
+
258
+ it "if salt_join_token is set should use it to encrypt" do
259
+ sorcery_model_property_set(:salt_attribute_name, :salt)
260
+ sorcery_model_property_set(:salt_join_token, "-@=>")
261
+ sorcery_model_property_set(:encryption_algorithm, :sha512)
262
+ create_new_user
263
+ @user.crypted_password.should_not == Sorcery::CryptoProviders::SHA512.encrypt('secret')
264
+ Sorcery::CryptoProviders::SHA512.join_token = ""
265
+ @user.crypted_password.should_not == Sorcery::CryptoProviders::SHA512.encrypt('secret',@user.salt)
266
+ Sorcery::CryptoProviders::SHA512.join_token = User.sorcery_config.salt_join_token
267
+ @user.crypted_password.should == Sorcery::CryptoProviders::SHA512.encrypt('secret',@user.salt)
268
+ end
269
+
270
+ end
271
+ end
272
+
273
+ shared_examples_for "external_user" do
274
+ before(:each) do
275
+ User.delete_all
276
+ end
277
+
278
+ it "should respond to 'external?'" do
279
+ create_new_user
280
+ @user.should respond_to(:external?)
281
+ end
282
+
283
+ it "external? should be false for regular users" do
284
+ create_new_user
285
+ @user.external?.should be_false
286
+ end
287
+
288
+ it "external? should be true for external users" do
289
+ create_new_external_user(:twitter)
290
+ @user.external?.should be_true
291
+ end
292
+ end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- sorcery (0.5.2)
4
+ sorcery (0.5.30)
5
5
  bcrypt-ruby (~> 2.1.4)
6
6
  oauth (>= 0.4.4)
7
7
  oauth (>= 0.4.4)
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/controller_oauth2_shared_examples')
2
3
 
3
4
  def stub_all_oauth2_requests!
4
5
  @client = OAuth2::Client.new("key","secret", :site => "http://myapi.com")
@@ -58,30 +59,8 @@ describe 'MyApp' do
58
59
  end
59
60
  end
60
61
 
61
- describe Sinatra::Application, "'create_from'" do
62
- before(:each) do
63
- stub_all_oauth2_requests!
64
- User.delete_all
65
- Authentication.delete_all
66
- end
67
-
68
- it "should create a new user" do
69
- sorcery_model_property_set(:authentications_class, Authentication)
70
- sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "name"})
71
- lambda do
72
- get "/test_create_from_provider", :provider => "facebook"
73
- end.should change(User, :count).by(1)
74
- User.first.username.should == "Noam Ben Ari"
75
- end
76
-
77
- it "should support nested attributes" do
78
- sorcery_model_property_set(:authentications_class, Authentication)
79
- sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "hometown/name"})
80
- lambda do
81
- get "/test_create_from_provider", :provider => "facebook"
82
- end.should change(User, :count).by(1)
83
- User.first.username.should == "Haifa, Israel"
84
- end
62
+ describe Sinatra::Application do
63
+ it_behaves_like "oauth2_controller"
85
64
  end
86
65
 
87
66
  describe Sinatra::Application, "OAuth with User Activation features" do
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/controller_oauth_shared_examples')
2
3
  require 'ostruct'
3
4
 
4
5
  def stub_all_oauth_requests!
@@ -63,30 +64,8 @@ describe Sinatra::Application do
63
64
  end
64
65
  end
65
66
 
66
- describe Sinatra::Application, "'create_from'" do
67
- before(:each) do
68
- stub_all_oauth_requests!
69
- User.delete_all
70
- Authentication.delete_all
71
- end
72
-
73
- it "should create a new user" do
74
- sorcery_model_property_set(:authentications_class, Authentication)
75
- sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
76
- lambda do
77
- get :test_create_from_provider, :provider => "twitter"
78
- end.should change(User, :count).by(1)
79
- User.first.username.should == "nbenari"
80
- end
81
-
82
- it "should support nested attributes" do
83
- sorcery_model_property_set(:authentications_class, Authentication)
84
- sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "status/text"})
85
- lambda do
86
- get :test_create_from_provider, :provider => "twitter"
87
- end.should change(User, :count).by(1)
88
- User.first.username.should == "coming soon to sorcery gem: twitter and facebook authentication support."
89
- end
67
+ describe Sinatra::Application do
68
+ it_behaves_like "oauth_controller"
90
69
  end
91
70
 
92
71
  describe Sinatra::Application, "OAuth with User Activation features" do
@@ -14,8 +14,8 @@ describe Sinatra::Application do
14
14
  end
15
15
 
16
16
  it "should enable configuration option 'user_class'" do
17
- sorcery_controller_property_set(:user_class, TestUser)
18
- Sorcery::Controller::Config.user_class.should equal(TestUser)
17
+ sorcery_controller_property_set(:user_class, "TestUser")
18
+ Sorcery::Controller::Config.user_class.should == "TestUser"
19
19
  end
20
20
 
21
21
  it "should enable configuration option 'not_authenticated_action'" do
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- sorcery (0.5.2)
4
+ sorcery (0.5.30)
5
5
  bcrypt-ruby (~> 2.1.4)
6
6
  oauth (>= 0.4.4)
7
7
  oauth (>= 0.4.4)
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/controller_oauth2_shared_examples')
2
3
 
3
4
  def stub_all_oauth2_requests!
4
5
  @client = OAuth2::Client.new("key","secret", :site => "http://myapi.com")
@@ -58,30 +59,8 @@ describe 'MyApp' do
58
59
  end
59
60
  end
60
61
 
61
- describe Modular, "'create_from'" do
62
- before(:each) do
63
- stub_all_oauth2_requests!
64
- User.delete_all
65
- Authentication.delete_all
66
- end
67
-
68
- it "should create a new user" do
69
- sorcery_model_property_set(:authentications_class, Authentication)
70
- sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "name"})
71
- lambda do
72
- get "/test_create_from_provider", :provider => "facebook"
73
- end.should change(User, :count).by(1)
74
- User.first.username.should == "Noam Ben Ari"
75
- end
76
-
77
- it "should support nested attributes" do
78
- sorcery_model_property_set(:authentications_class, Authentication)
79
- sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "hometown/name"})
80
- lambda do
81
- get "/test_create_from_provider", :provider => "facebook"
82
- end.should change(User, :count).by(1)
83
- User.first.username.should == "Haifa, Israel"
84
- end
62
+ describe Modular do
63
+ it_behaves_like "oauth2_controller"
85
64
  end
86
65
 
87
66
  describe Modular, "OAuth with User Activation features" do
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/controller_oauth_shared_examples')
2
3
  require 'ostruct'
3
4
 
4
5
  def stub_all_oauth_requests!
@@ -63,30 +64,8 @@ describe Modular do
63
64
  end
64
65
  end
65
66
 
66
- describe Modular, "'create_from'" do
67
- before(:each) do
68
- stub_all_oauth_requests!
69
- User.delete_all
70
- Authentication.delete_all
71
- end
72
-
73
- it "should create a new user" do
74
- sorcery_model_property_set(:authentications_class, Authentication)
75
- sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
76
- lambda do
77
- get :test_create_from_provider, :provider => "twitter"
78
- end.should change(User, :count).by(1)
79
- User.first.username.should == "nbenari"
80
- end
81
-
82
- it "should support nested attributes" do
83
- sorcery_model_property_set(:authentications_class, Authentication)
84
- sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "status/text"})
85
- lambda do
86
- get :test_create_from_provider, :provider => "twitter"
87
- end.should change(User, :count).by(1)
88
- User.first.username.should == "coming soon to sorcery gem: twitter and facebook authentication support."
89
- end
67
+ describe Modular do
68
+ it_behaves_like "oauth_controller"
90
69
  end
91
70
 
92
71
  describe Modular, "OAuth with User Activation features" do
@@ -14,8 +14,8 @@ describe Modular do
14
14
  end
15
15
 
16
16
  it "should enable configuration option 'user_class'" do
17
- sorcery_controller_property_set(:user_class, TestUser)
18
- Sorcery::Controller::Config.user_class.should equal(TestUser)
17
+ sorcery_controller_property_set(:user_class, "TestUser")
18
+ Sorcery::Controller::Config.user_class.should == "TestUser"
19
19
  end
20
20
 
21
21
  it "should enable configuration option 'not_authenticated_action'" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: sorcery
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.21
5
+ version: 0.6.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Noam Ben Ari
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-20 00:00:00 +03:00
13
+ date: 2011-07-30 00:00:00 +03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -422,6 +422,15 @@ files:
422
422
  - spec/rails3_mongoid/spec/user_reset_password_spec.rb
423
423
  - spec/rails3_mongoid/spec/user_spec.rb
424
424
  - spec/rails3_mongoid/vendor/plugins/.gitkeep
425
+ - spec/shared_examples/controller_oauth2_shared_examples.rb
426
+ - spec/shared_examples/controller_oauth_shared_examples.rb
427
+ - spec/shared_examples/user_activation_shared_examples.rb
428
+ - spec/shared_examples/user_activity_logging_shared_examples.rb
429
+ - spec/shared_examples/user_brute_force_protection_shared_examples.rb
430
+ - spec/shared_examples/user_oauth_shared_examples.rb
431
+ - spec/shared_examples/user_remember_me_shared_examples.rb
432
+ - spec/shared_examples/user_reset_password_shared_examples.rb
433
+ - spec/shared_examples/user_shared_examples.rb
425
434
  - spec/sinatra/Gemfile
426
435
  - spec/sinatra/Gemfile.lock
427
436
  - spec/sinatra/Rakefile
@@ -581,6 +590,15 @@ test_files:
581
590
  - spec/rails3_mongoid/spec/user_remember_me_spec.rb
582
591
  - spec/rails3_mongoid/spec/user_reset_password_spec.rb
583
592
  - spec/rails3_mongoid/spec/user_spec.rb
593
+ - spec/shared_examples/controller_oauth2_shared_examples.rb
594
+ - spec/shared_examples/controller_oauth_shared_examples.rb
595
+ - spec/shared_examples/user_activation_shared_examples.rb
596
+ - spec/shared_examples/user_activity_logging_shared_examples.rb
597
+ - spec/shared_examples/user_brute_force_protection_shared_examples.rb
598
+ - spec/shared_examples/user_oauth_shared_examples.rb
599
+ - spec/shared_examples/user_remember_me_shared_examples.rb
600
+ - spec/shared_examples/user_reset_password_shared_examples.rb
601
+ - spec/shared_examples/user_shared_examples.rb
584
602
  - spec/sinatra/authentication.rb
585
603
  - spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb
586
604
  - spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb