sorcery 0.6.1 → 0.7.10
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.
- data/.travis.yml +2 -0
- data/Gemfile +2 -23
- data/Gemfile.lock +105 -77
- data/README.rdoc +32 -59
- data/Rakefile +29 -1
- data/VERSION +1 -1
- data/lib/generators/sorcery/USAGE +22 -0
- data/lib/generators/sorcery/install_generator.rb +77 -0
- data/lib/generators/sorcery/templates/initializer.rb +406 -0
- data/lib/generators/sorcery/templates/migration/activity_logging.rb +17 -0
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +13 -0
- data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/core.rb +3 -3
- data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/external.rb +1 -1
- data/lib/generators/sorcery/templates/migration/remember_me.rb +15 -0
- data/lib/generators/sorcery/templates/migration/reset_password.rb +17 -0
- data/lib/generators/sorcery/templates/migration/user_activation.rb +17 -0
- data/lib/sorcery/controller/submodules/activity_logging.rb +24 -10
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +3 -2
- data/lib/sorcery/controller/submodules/external/protocols/certs/ca-bundle.crt +5182 -0
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +28 -9
- data/lib/sorcery/controller/submodules/external/providers/facebook.rb +12 -4
- data/lib/sorcery/controller/submodules/external/providers/github.rb +89 -0
- data/lib/sorcery/controller/submodules/external/providers/google.rb +90 -0
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +91 -0
- data/lib/sorcery/controller/submodules/external/providers/twitter.rb +8 -2
- data/lib/sorcery/controller/submodules/external.rb +17 -4
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -1
- data/lib/sorcery/controller/submodules/remember_me.rb +26 -15
- data/lib/sorcery/controller/submodules/session_timeout.rb +4 -4
- data/lib/sorcery/controller.rb +61 -38
- data/lib/sorcery/crypto_providers/aes256.rb +7 -3
- data/lib/sorcery/engine.rb +1 -0
- data/lib/sorcery/model/adapters/active_record.rb +17 -1
- data/lib/sorcery/model/adapters/mongo_mapper.rb +54 -0
- data/lib/sorcery/model/adapters/mongoid.rb +22 -4
- data/lib/sorcery/model/submodules/activity_logging.rb +4 -4
- data/lib/sorcery/model/submodules/brute_force_protection.rb +53 -14
- data/lib/sorcery/model/submodules/remember_me.rb +10 -3
- data/lib/sorcery/model/submodules/reset_password.rb +26 -11
- data/lib/sorcery/model/submodules/user_activation.rb +28 -10
- data/lib/sorcery/model/temporary_token.rb +8 -1
- data/lib/sorcery/model.rb +51 -19
- data/lib/sorcery/test_helpers/internal/rails.rb +1 -1
- data/lib/sorcery/test_helpers/rails.rb +2 -2
- data/lib/sorcery.rb +8 -7
- data/sorcery.gemspec +110 -223
- data/spec/Gemfile +1 -1
- data/spec/Gemfile.lock +26 -26
- data/spec/README.md +31 -0
- data/spec/rails3/Gemfile +5 -3
- data/spec/rails3/Gemfile.lock +74 -48
- data/spec/rails3/app/controllers/application_controller.rb +70 -23
- data/spec/rails3/app/mailers/sorcery_mailer.rb +7 -0
- data/spec/rails3/app/views/application/index.html.erb +17 -0
- data/spec/rails3/app/views/sorcery_mailer/send_unlock_token_email.text.erb +1 -0
- data/spec/rails3/config/environments/in_memory.rb +35 -0
- data/spec/rails3/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +2 -0
- data/spec/rails3/spec/controller_activity_logging_spec.rb +33 -3
- data/spec/rails3/spec/controller_brute_force_protection_spec.rb +25 -3
- data/spec/rails3/spec/controller_oauth2_spec.rb +170 -25
- data/spec/rails3/spec/controller_remember_me_spec.rb +37 -6
- data/spec/rails3/spec/controller_session_timeout_spec.rb +4 -4
- data/spec/rails3/spec/controller_spec.rb +60 -2
- data/spec/rails3/spec/integration_spec.rb +23 -0
- data/spec/rails3/spec/spec_helper.rb +6 -5
- data/spec/rails3_mongo_mapper/.gitignore +4 -0
- data/spec/rails3_mongo_mapper/.rspec +1 -0
- data/spec/{sinatra_modular → rails3_mongo_mapper}/Gemfile +6 -5
- data/spec/rails3_mongo_mapper/Gemfile.lock +154 -0
- data/spec/{sinatra → rails3_mongo_mapper}/Rakefile +3 -3
- data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +108 -0
- data/spec/rails3_mongo_mapper/app/helpers/application_helper.rb +2 -0
- data/spec/rails3_mongo_mapper/app/models/authentication.rb +6 -0
- data/spec/rails3_mongo_mapper/app/models/user.rb +5 -0
- data/spec/rails3_mongo_mapper/app/views/layouts/application.html.erb +14 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.html.erb +17 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.text.erb +9 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.html.erb +17 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.text.erb +9 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.html.erb +16 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.text.erb +8 -0
- data/spec/rails3_mongo_mapper/config/application.rb +51 -0
- data/spec/rails3_mongo_mapper/config/boot.rb +13 -0
- data/spec/rails3_mongo_mapper/config/environment.rb +5 -0
- data/spec/rails3_mongo_mapper/config/environments/development.rb +30 -0
- data/spec/rails3_mongo_mapper/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongo_mapper/config/environments/production.rb +49 -0
- data/spec/rails3_mongo_mapper/config/environments/test.rb +35 -0
- data/spec/rails3_mongo_mapper/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails3_mongo_mapper/config/initializers/inflections.rb +10 -0
- data/spec/rails3_mongo_mapper/config/initializers/mime_types.rb +5 -0
- data/spec/rails3_mongo_mapper/config/initializers/mongo.rb +2 -0
- data/spec/rails3_mongo_mapper/config/initializers/secret_token.rb +7 -0
- data/spec/rails3_mongo_mapper/config/initializers/session_store.rb +8 -0
- data/spec/rails3_mongo_mapper/config/locales/en.yml +5 -0
- data/spec/rails3_mongo_mapper/config/routes.rb +59 -0
- data/spec/rails3_mongo_mapper/config.ru +4 -0
- data/spec/rails3_mongo_mapper/db/schema.rb +23 -0
- data/spec/rails3_mongo_mapper/db/seeds.rb +7 -0
- data/spec/rails3_mongo_mapper/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/public/404.html +26 -0
- data/spec/rails3_mongo_mapper/public/422.html +26 -0
- data/spec/rails3_mongo_mapper/public/500.html +26 -0
- data/spec/rails3_mongo_mapper/public/favicon.ico +0 -0
- data/spec/rails3_mongo_mapper/public/images/rails.png +0 -0
- data/spec/rails3_mongo_mapper/public/javascripts/application.js +2 -0
- data/spec/rails3_mongo_mapper/public/javascripts/controls.js +965 -0
- data/spec/rails3_mongo_mapper/public/javascripts/dragdrop.js +974 -0
- data/spec/rails3_mongo_mapper/public/javascripts/effects.js +1123 -0
- data/spec/rails3_mongo_mapper/public/javascripts/prototype.js +6001 -0
- data/spec/rails3_mongo_mapper/public/javascripts/rails.js +175 -0
- data/spec/rails3_mongo_mapper/public/robots.txt +5 -0
- data/spec/rails3_mongo_mapper/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/script/rails +6 -0
- data/spec/rails3_mongo_mapper/spec/controller_spec.rb +163 -0
- data/spec/rails3_mongo_mapper/spec/spec_helper.orig.rb +27 -0
- data/spec/rails3_mongo_mapper/spec/spec_helper.rb +55 -0
- data/spec/rails3_mongo_mapper/spec/user_activation_spec.rb +9 -0
- data/spec/rails3_mongo_mapper/spec/user_activity_logging_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_brute_force_protection_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_oauth_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_remember_me_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_reset_password_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_spec.rb +37 -0
- data/spec/rails3_mongo_mapper/vendor/plugins/.gitkeep +0 -0
- data/spec/rails3_mongoid/Gemfile +2 -1
- data/spec/rails3_mongoid/Gemfile.lock +46 -45
- data/spec/rails3_mongoid/app/controllers/application_controller.rb +5 -0
- data/spec/rails3_mongoid/config/mongoid.yml +1 -1
- data/spec/rails3_mongoid/script/rails +0 -0
- data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +105 -0
- data/spec/rails3_mongoid/spec/controller_spec.rb +174 -0
- data/spec/rails3_mongoid/spec/user_spec.rb +1 -0
- data/spec/shared_examples/user_activation_shared_examples.rb +72 -42
- data/spec/shared_examples/user_remember_me_shared_examples.rb +2 -1
- data/spec/shared_examples/user_reset_password_shared_examples.rb +81 -28
- data/spec/shared_examples/user_shared_examples.rb +36 -8
- data/spec/sorcery_crypto_providers_spec.rb +5 -1
- metadata +239 -346
- data/lib/generators/sorcery_migration/sorcery_migration_generator.rb +0 -24
- data/lib/generators/sorcery_migration/templates/activity_logging.rb +0 -17
- data/lib/generators/sorcery_migration/templates/brute_force_protection.rb +0 -11
- data/lib/generators/sorcery_migration/templates/remember_me.rb +0 -15
- data/lib/generators/sorcery_migration/templates/reset_password.rb +0 -13
- data/lib/generators/sorcery_migration/templates/user_activation.rb +0 -17
- data/lib/sorcery/controller/adapters/sinatra.rb +0 -104
- data/lib/sorcery/initializers/initializer.rb +0 -178
- data/lib/sorcery/sinatra.rb +0 -4
- data/lib/sorcery/test_helpers/internal/sinatra.rb +0 -74
- data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +0 -74
- data/lib/sorcery/test_helpers/sinatra.rb +0 -88
- data/spec/rails3/Rakefile.unused +0 -7
- data/spec/rails3/public/index.html +0 -239
- data/spec/sinatra/Gemfile +0 -15
- data/spec/sinatra/Gemfile.lock +0 -117
- data/spec/sinatra/authentication.rb +0 -3
- data/spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
- data/spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
- data/spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
- data/spec/sinatra/db/migrate/core/20101224223620_create_users.rb +0 -16
- data/spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
- data/spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
- data/spec/sinatra/filters.rb +0 -27
- data/spec/sinatra/modular.rb +0 -157
- data/spec/sinatra/myapp.rb +0 -133
- data/spec/sinatra/spec/controller_activity_logging_spec.rb +0 -85
- data/spec/sinatra/spec/controller_brute_force_protection_spec.rb +0 -70
- data/spec/sinatra/spec/controller_http_basic_auth_spec.rb +0 -53
- data/spec/sinatra/spec/controller_oauth2_spec.rb +0 -99
- data/spec/sinatra/spec/controller_oauth_spec.rb +0 -100
- data/spec/sinatra/spec/controller_remember_me_spec.rb +0 -64
- data/spec/sinatra/spec/controller_session_timeout_spec.rb +0 -57
- data/spec/sinatra/spec/controller_spec.rb +0 -120
- data/spec/sinatra/spec/spec_helper.rb +0 -45
- data/spec/sinatra/user.rb +0 -6
- data/spec/sinatra/views/test_login.erb +0 -4
- data/spec/sinatra_modular/Gemfile.lock +0 -117
- data/spec/sinatra_modular/Rakefile +0 -11
- data/spec/sinatra_modular/authentication.rb +0 -3
- data/spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
- data/spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
- data/spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
- data/spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb +0 -16
- data/spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
- data/spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
- data/spec/sinatra_modular/filters.rb +0 -27
- data/spec/sinatra_modular/modular.rb +0 -157
- data/spec/sinatra_modular/myapp.rb +0 -133
- data/spec/sinatra_modular/sorcery_mailer.rb +0 -25
- data/spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb +0 -85
- data/spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb +0 -70
- data/spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb +0 -53
- data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +0 -99
- data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +0 -100
- data/spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb +0 -64
- data/spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb +0 -57
- data/spec/sinatra_modular/spec_modular/controller_spec.rb +0 -116
- data/spec/sinatra_modular/spec_modular/spec.opts +0 -2
- data/spec/sinatra_modular/spec_modular/spec_helper.rb +0 -51
- data/spec/sinatra_modular/user.rb +0 -6
- data/spec/sinatra_modular/views/test_login.erb +0 -4
- /data/spec/{sinatra → rails3_mongo_mapper/app/mailers}/sorcery_mailer.rb +0 -0
- /data/spec/{sinatra → rails3_mongo_mapper}/spec/spec.opts +0 -0
|
@@ -33,7 +33,20 @@ shared_examples_for "rails_3_reset_password_model" do
|
|
|
33
33
|
sorcery_model_property_set(:reset_password_mailer, TestUser)
|
|
34
34
|
User.sorcery_config.reset_password_mailer.should equal(TestUser)
|
|
35
35
|
end
|
|
36
|
+
|
|
37
|
+
it "should enable configuration option 'reset_password_mailer_disabled'" do
|
|
38
|
+
sorcery_model_property_set(:reset_password_mailer_disabled, :my_reset_password_mailer_disabled)
|
|
39
|
+
User.sorcery_config.reset_password_mailer_disabled.should equal(:my_reset_password_mailer_disabled)
|
|
40
|
+
end
|
|
36
41
|
|
|
42
|
+
it "if mailer is nil and mailer is enabled, throw exception!" do
|
|
43
|
+
expect{sorcery_reload!([:reset_password], :reset_password_mailer_disabled => false)}.to raise_error(ArgumentError)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "if mailer is disabled and mailer is nil, do NOT throw exception" do
|
|
47
|
+
expect{sorcery_reload!([:reset_password], :reset_password_mailer_disabled => true)}.to_not raise_error
|
|
48
|
+
end
|
|
49
|
+
|
|
37
50
|
it "should allow configuration option 'reset_password_email_method_name'" do
|
|
38
51
|
sorcery_model_property_set(:reset_password_email_method_name, :my_mailer_method)
|
|
39
52
|
User.sorcery_config.reset_password_email_method_name.should equal(:my_mailer_method)
|
|
@@ -93,7 +106,7 @@ shared_examples_for "rails_3_reset_password_model" do
|
|
|
93
106
|
create_new_user
|
|
94
107
|
sorcery_model_property_set(:reset_password_expiration_period, 0.1)
|
|
95
108
|
@user.deliver_reset_password_instructions!
|
|
96
|
-
Timecop.travel(Time.now+0.5)
|
|
109
|
+
Timecop.travel(Time.now.in_time_zone+0.5)
|
|
97
110
|
User.load_from_reset_password_token(@user.reset_password_token).should == nil
|
|
98
111
|
end
|
|
99
112
|
|
|
@@ -125,11 +138,69 @@ shared_examples_for "rails_3_reset_password_model" do
|
|
|
125
138
|
@user.reset_password_token.should_not == old_password_code
|
|
126
139
|
end
|
|
127
140
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
141
|
+
context "mailer is enabled" do
|
|
142
|
+
it "should send an email on reset" do
|
|
143
|
+
create_new_user
|
|
144
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
145
|
+
@user.deliver_reset_password_instructions!
|
|
146
|
+
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it "should not send an email if time between emails has not passed since last email" do
|
|
150
|
+
create_new_user
|
|
151
|
+
sorcery_model_property_set(:reset_password_time_between_emails, 10000)
|
|
152
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
153
|
+
@user.deliver_reset_password_instructions!
|
|
154
|
+
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
155
|
+
@user.deliver_reset_password_instructions!
|
|
156
|
+
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it "should send an email if time between emails has passed since last email" do
|
|
160
|
+
create_new_user
|
|
161
|
+
sorcery_model_property_set(:reset_password_time_between_emails, 0.5)
|
|
162
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
163
|
+
@user.deliver_reset_password_instructions!
|
|
164
|
+
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
165
|
+
Timecop.travel(Time.now.in_time_zone+0.5)
|
|
166
|
+
@user.deliver_reset_password_instructions!
|
|
167
|
+
ActionMailer::Base.deliveries.size.should == old_size + 2
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
context "mailer is disabled" do
|
|
172
|
+
|
|
173
|
+
before(:all) do
|
|
174
|
+
sorcery_reload!([:reset_password], :reset_password_mailer_disabled => true, :reset_password_mailer => ::SorceryMailer)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
it "should send an email on reset" do
|
|
178
|
+
create_new_user
|
|
179
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
180
|
+
@user.deliver_reset_password_instructions!
|
|
181
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it "should not send an email if time between emails has not passed since last email" do
|
|
185
|
+
create_new_user
|
|
186
|
+
sorcery_model_property_set(:reset_password_time_between_emails, 10000)
|
|
187
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
188
|
+
@user.deliver_reset_password_instructions!
|
|
189
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
190
|
+
@user.deliver_reset_password_instructions!
|
|
191
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
it "should send an email if time between emails has passed since last email" do
|
|
195
|
+
create_new_user
|
|
196
|
+
sorcery_model_property_set(:reset_password_time_between_emails, 0.5)
|
|
197
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
198
|
+
@user.deliver_reset_password_instructions!
|
|
199
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
200
|
+
Timecop.travel(Time.now.in_time_zone+0.5)
|
|
201
|
+
@user.deliver_reset_password_instructions!
|
|
202
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
203
|
+
end
|
|
133
204
|
end
|
|
134
205
|
|
|
135
206
|
it "when change_password! is called, should delete reset_password_token" do
|
|
@@ -140,26 +211,12 @@ shared_examples_for "rails_3_reset_password_model" do
|
|
|
140
211
|
@user.save!
|
|
141
212
|
@user.reset_password_token.should be_nil
|
|
142
213
|
end
|
|
143
|
-
|
|
144
|
-
it "should
|
|
214
|
+
|
|
215
|
+
it "should return false if time between emails has not passed since last email" do
|
|
145
216
|
create_new_user
|
|
146
217
|
sorcery_model_property_set(:reset_password_time_between_emails, 10000)
|
|
147
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
148
|
-
@user.deliver_reset_password_instructions!
|
|
149
|
-
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
150
218
|
@user.deliver_reset_password_instructions!
|
|
151
|
-
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
it "should send an email if time between emails has passed since last email" do
|
|
155
|
-
create_new_user
|
|
156
|
-
sorcery_model_property_set(:reset_password_time_between_emails, 0.5)
|
|
157
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
158
|
-
@user.deliver_reset_password_instructions!
|
|
159
|
-
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
160
|
-
Timecop.travel(Time.now+0.5)
|
|
161
|
-
@user.deliver_reset_password_instructions!
|
|
162
|
-
ActionMailer::Base.deliveries.size.should == old_size + 2
|
|
219
|
+
@user.deliver_reset_password_instructions!.should == false
|
|
163
220
|
end
|
|
164
221
|
|
|
165
222
|
it "should encrypt properly on reset" do
|
|
@@ -169,9 +226,5 @@ shared_examples_for "rails_3_reset_password_model" do
|
|
|
169
226
|
Sorcery::CryptoProviders::BCrypt.matches?(@user.crypted_password,"blagu",@user.salt).should be_true
|
|
170
227
|
end
|
|
171
228
|
|
|
172
|
-
it "if mailer is nil on activation, throw exception!" do
|
|
173
|
-
expect{sorcery_reload!([:reset_password])}.to raise_error(ArgumentError)
|
|
174
|
-
end
|
|
175
|
-
|
|
176
229
|
end
|
|
177
|
-
end
|
|
230
|
+
end
|
|
@@ -4,9 +4,9 @@ shared_examples_for "rails_3_core_model" do
|
|
|
4
4
|
User.sorcery_config.reset!
|
|
5
5
|
end
|
|
6
6
|
|
|
7
|
-
it "should enable configuration option '
|
|
8
|
-
sorcery_model_property_set(:
|
|
9
|
-
User.sorcery_config.
|
|
7
|
+
it "should enable configuration option 'username_attribute_names'" do
|
|
8
|
+
sorcery_model_property_set(:username_attribute_names, :email)
|
|
9
|
+
User.sorcery_config.username_attribute_names.should == [:email]
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
it "should enable configuration option 'password_attribute_name'" do
|
|
@@ -56,7 +56,6 @@ shared_examples_for "rails_3_core_model" do
|
|
|
56
56
|
sorcery_model_property_set(:stretches, stretches)
|
|
57
57
|
User.sorcery_config.stretches.should equal(stretches)
|
|
58
58
|
end
|
|
59
|
-
|
|
60
59
|
end
|
|
61
60
|
|
|
62
61
|
# ----------------- PLUGIN ACTIVATED -----------------------
|
|
@@ -76,12 +75,12 @@ shared_examples_for "rails_3_core_model" do
|
|
|
76
75
|
|
|
77
76
|
it "authenticate should return true if credentials are good" do
|
|
78
77
|
create_new_user
|
|
79
|
-
User.authenticate(@user.send(User.sorcery_config.
|
|
78
|
+
User.authenticate(@user.send(User.sorcery_config.username_attribute_names.first), 'secret').should be_true
|
|
80
79
|
end
|
|
81
80
|
|
|
82
81
|
it "authenticate should return false if credentials are bad" do
|
|
83
82
|
create_new_user
|
|
84
|
-
User.authenticate(@user.send(User.sorcery_config.
|
|
83
|
+
User.authenticate(@user.send(User.sorcery_config.username_attribute_names.first), 'wrong!').should be_false
|
|
85
84
|
end
|
|
86
85
|
|
|
87
86
|
specify { User.should respond_to(:encrypt) }
|
|
@@ -186,7 +185,7 @@ shared_examples_for "rails_3_core_model" do
|
|
|
186
185
|
it "should work with no password encryption" do
|
|
187
186
|
sorcery_model_property_set(:encryption_algorithm, :none)
|
|
188
187
|
create_new_user
|
|
189
|
-
User.authenticate(@user.send(User.sorcery_config.
|
|
188
|
+
User.authenticate(@user.send(User.sorcery_config.username_attribute_names.first), 'secret').should be_true
|
|
190
189
|
end
|
|
191
190
|
|
|
192
191
|
it "should work with custom password encryption" do
|
|
@@ -202,7 +201,7 @@ shared_examples_for "rails_3_core_model" do
|
|
|
202
201
|
sorcery_model_property_set(:encryption_algorithm, :custom)
|
|
203
202
|
sorcery_model_property_set(:custom_encryption_provider, MyCrypto)
|
|
204
203
|
create_new_user
|
|
205
|
-
User.authenticate(@user.send(User.sorcery_config.
|
|
204
|
+
User.authenticate(@user.send(User.sorcery_config.username_attribute_names.first), 'secret').should be_true
|
|
206
205
|
end
|
|
207
206
|
|
|
208
207
|
it "if encryption algo is aes256, it should set key to crypto provider" do
|
|
@@ -268,6 +267,35 @@ shared_examples_for "rails_3_core_model" do
|
|
|
268
267
|
end
|
|
269
268
|
|
|
270
269
|
end
|
|
270
|
+
|
|
271
|
+
describe User, "ORM adapter" do
|
|
272
|
+
before(:all) do
|
|
273
|
+
sorcery_reload!()
|
|
274
|
+
User.delete_all
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
before(:each) do
|
|
278
|
+
create_new_user
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
after(:each) do
|
|
282
|
+
User.delete_all
|
|
283
|
+
User.sorcery_config.reset!
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
it "find_by_username should work as expected" do
|
|
287
|
+
User.find_by_username("gizmo").should == @user
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
it "find_by_username should work as expected with multiple username attributes" do
|
|
291
|
+
sorcery_model_property_set(:username_attribute_names, [:username, :email])
|
|
292
|
+
User.find_by_username("gizmo").should == @user
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
it "find_by_email should work as expected" do
|
|
296
|
+
User.find_by_email("bla@bla.com").should == @user
|
|
297
|
+
end
|
|
298
|
+
end
|
|
271
299
|
end
|
|
272
300
|
|
|
273
301
|
shared_examples_for "external_user" do
|
|
@@ -54,7 +54,11 @@ describe "Crypto Providers wrappers" do
|
|
|
54
54
|
it "matches? returns false when no match" do
|
|
55
55
|
Sorcery::CryptoProviders::SHA1.matches?(@digest, 'Some Dude').should be_false
|
|
56
56
|
end
|
|
57
|
-
|
|
57
|
+
|
|
58
|
+
it "matches password encrypted using salt and join token from upstream" do
|
|
59
|
+
Sorcery::CryptoProviders::SHA1.join_token = "test"
|
|
60
|
+
Sorcery::CryptoProviders::SHA1.encrypt(['password', 'gq18WBnJYNh2arkC1kgH']).should == '894b5bf1643b8d0e1b2eaddb22426be7036dab70'
|
|
61
|
+
end
|
|
58
62
|
end
|
|
59
63
|
|
|
60
64
|
describe Sorcery::CryptoProviders::SHA256 do
|