sorcery 0.8.4 → 0.8.6
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.
- checksums.yaml +4 -4
- data/.gitignore +55 -0
- data/.travis.yml +69 -1
- data/CHANGELOG.md +248 -0
- data/Gemfile +16 -22
- data/Gemfile.rails4 +22 -0
- data/README.md +320 -0
- data/Rakefile +3 -79
- data/VERSION +1 -1
- data/gemfiles/active_record-rails41.gemfile +6 -0
- data/gemfiles/mongo_mapper-rails41.gemfile +8 -0
- data/gemfiles/mongoid-rails41.gemfile +11 -0
- data/lib/generators/sorcery/helpers.rb +40 -0
- data/lib/generators/sorcery/install_generator.rb +21 -17
- data/lib/generators/sorcery/templates/initializer.rb +1 -1
- data/lib/generators/sorcery/templates/migration/activity_logging.rb +2 -11
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +1 -7
- data/lib/generators/sorcery/templates/migration/core.rb +5 -8
- data/lib/generators/sorcery/templates/migration/external.rb +1 -5
- data/lib/generators/sorcery/templates/migration/remember_me.rb +2 -9
- data/lib/generators/sorcery/templates/migration/reset_password.rb +2 -10
- data/lib/generators/sorcery/templates/migration/user_activation.rb +2 -10
- data/lib/sorcery/controller/submodules/external.rb +39 -23
- data/lib/sorcery/controller/submodules/remember_me.rb +1 -1
- data/lib/sorcery/controller/submodules/session_timeout.rb +2 -2
- data/lib/sorcery/controller.rb +18 -11
- data/lib/sorcery/model/adapters/active_record.rb +7 -2
- data/lib/sorcery/model/adapters/datamapper.rb +123 -0
- data/lib/sorcery/model/adapters/mongo_mapper.rb +8 -4
- data/lib/sorcery/model/adapters/mongoid.rb +8 -8
- data/lib/sorcery/model/submodules/activity_logging.rb +24 -0
- data/lib/sorcery/model/submodules/brute_force_protection.rb +22 -8
- data/lib/sorcery/model/submodules/remember_me.rb +19 -4
- data/lib/sorcery/model/submodules/reset_password.rb +35 -14
- data/lib/sorcery/model/submodules/user_activation.rb +69 -24
- data/lib/sorcery/model.rb +111 -73
- data/lib/sorcery/protocols/oauth.rb +42 -0
- data/lib/sorcery/protocols/oauth2.rb +47 -0
- data/lib/sorcery/providers/base.rb +27 -0
- data/lib/sorcery/providers/facebook.rb +63 -0
- data/lib/sorcery/providers/github.rb +51 -0
- data/lib/sorcery/providers/google.rb +51 -0
- data/lib/sorcery/providers/linkedin.rb +66 -0
- data/lib/sorcery/providers/liveid.rb +53 -0
- data/lib/sorcery/providers/twitter.rb +59 -0
- data/lib/sorcery/providers/vk.rb +61 -0
- data/lib/sorcery/providers/xing.rb +64 -0
- data/lib/sorcery/test_helpers/internal/rails.rb +17 -6
- data/lib/sorcery/test_helpers/internal.rb +23 -6
- data/lib/sorcery/test_helpers/rails/controller.rb +17 -0
- data/lib/sorcery/test_helpers/rails/integration.rb +26 -0
- data/lib/sorcery/test_helpers/rails.rb +1 -10
- data/lib/sorcery.rb +20 -28
- data/sorcery.gemspec +21 -363
- data/spec/active_record/controller_activity_logging_spec.rb +29 -0
- data/spec/active_record/controller_brute_force_protection_spec.rb +158 -0
- data/spec/active_record/controller_http_basic_auth_spec.rb +65 -0
- data/spec/active_record/controller_oauth2_spec.rb +342 -0
- data/spec/{rails3/spec → active_record}/controller_oauth_spec.rb +69 -59
- data/spec/active_record/controller_remember_me_spec.rb +97 -0
- data/spec/active_record/controller_session_timeout_spec.rb +70 -0
- data/spec/active_record/controller_spec.rb +8 -0
- data/spec/{rails3/spec → active_record}/integration_spec.rb +3 -3
- data/spec/active_record/user_activation_spec.rb +18 -0
- data/spec/active_record/user_activity_logging_spec.rb +8 -0
- data/spec/{rails3/spec → active_record}/user_brute_force_protection_spec.rb +6 -5
- data/spec/{rails3/spec → active_record}/user_oauth_spec.rb +6 -5
- data/spec/{rails3/spec → active_record}/user_remember_me_spec.rb +5 -4
- data/spec/{rails3/spec → active_record}/user_reset_password_spec.rb +7 -7
- data/spec/active_record/user_spec.rb +37 -0
- data/spec/datamapper/controller_activity_logging_spec.rb +17 -0
- data/spec/datamapper/controller_spec.rb +8 -0
- data/spec/datamapper/user_activation_spec.rb +10 -0
- data/spec/datamapper/user_activity_logging_spec.rb +9 -0
- data/spec/datamapper/user_brute_force_protection_spec.rb +9 -0
- data/spec/datamapper/user_oauth_spec.rb +9 -0
- data/spec/datamapper/user_remember_me_spec.rb +8 -0
- data/spec/datamapper/user_reset_password_spec.rb +8 -0
- data/spec/datamapper/user_spec.rb +27 -0
- data/spec/mongo_mapper/controller_spec.rb +8 -0
- data/spec/mongo_mapper/user_activation_spec.rb +9 -0
- data/spec/mongo_mapper/user_activity_logging_spec.rb +8 -0
- data/spec/mongo_mapper/user_brute_force_protection_spec.rb +8 -0
- data/spec/mongo_mapper/user_oauth_spec.rb +8 -0
- data/spec/mongo_mapper/user_remember_me_spec.rb +8 -0
- data/spec/mongo_mapper/user_reset_password_spec.rb +8 -0
- data/spec/mongo_mapper/user_spec.rb +37 -0
- data/spec/mongoid/controller_activity_logging_spec.rb +16 -0
- data/spec/mongoid/controller_spec.rb +8 -0
- data/spec/mongoid/user_activation_spec.rb +9 -0
- data/spec/mongoid/user_activity_logging_spec.rb +8 -0
- data/spec/mongoid/user_brute_force_protection_spec.rb +8 -0
- data/spec/mongoid/user_oauth_spec.rb +8 -0
- data/spec/mongoid/user_remember_me_spec.rb +8 -0
- data/spec/mongoid/user_reset_password_spec.rb +8 -0
- data/spec/mongoid/user_spec.rb +38 -0
- data/spec/orm/active_record.rb +9 -0
- data/spec/orm/datamapper.rb +34 -0
- data/spec/orm/mongo_mapper.rb +11 -0
- data/spec/orm/mongoid.rb +18 -0
- data/spec/{rails3/app/models → rails_app/app/active_record}/user.rb +1 -2
- data/spec/rails_app/app/active_record/user_provider.rb +3 -0
- data/spec/rails_app/app/controllers/sorcery_controller.rb +224 -0
- data/spec/rails_app/app/datamapper/authentication.rb +8 -0
- data/spec/rails_app/app/datamapper/user.rb +7 -0
- data/spec/{rails3_mongoid/app/models → rails_app/app/mongoid}/user.rb +2 -0
- data/spec/{rails3_mongo_mapper → rails_app}/config/application.rb +13 -8
- data/spec/rails_app/config/boot.rb +4 -0
- data/spec/rails_app/config/database.yml +22 -0
- data/spec/{rails3_mongo_mapper → rails_app}/config/environments/test.rb +2 -0
- data/spec/{rails3_mongoid → rails_app}/config/initializers/session_store.rb +4 -0
- data/spec/rails_app/config/routes.rb +42 -0
- data/spec/{rails3_mongo_mapper → rails_app}/config.ru +1 -1
- data/spec/{rails3 → rails_app}/db/migrate/activation/20101224223622_add_activation_to_users.rb +3 -3
- data/spec/rails_app/db/migrate/external/20101224223628_create_authentications_and_user_providers.rb +22 -0
- data/spec/rails_app/log/development.log +1791 -0
- data/spec/shared_examples/controller_activity_logging_shared_examples.rb +125 -0
- data/spec/shared_examples/controller_oauth2_shared_examples.rb +32 -36
- data/spec/shared_examples/controller_oauth_shared_examples.rb +35 -28
- data/spec/shared_examples/controller_shared_examples.rb +203 -0
- data/spec/shared_examples/user_activation_shared_examples.rb +136 -97
- data/spec/shared_examples/user_activity_logging_shared_examples.rb +10 -10
- data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +14 -13
- data/spec/shared_examples/user_oauth_shared_examples.rb +23 -15
- data/spec/shared_examples/user_remember_me_shared_examples.rb +32 -23
- data/spec/shared_examples/user_reset_password_shared_examples.rb +162 -129
- data/spec/shared_examples/user_shared_examples.rb +265 -190
- data/spec/sorcery_crypto_providers_spec.rb +74 -72
- data/spec/spec_helper.rb +47 -4
- metadata +187 -368
- data/Gemfile.lock +0 -175
- data/README.rdoc +0 -261
- data/lib/sorcery/controller/submodules/external/protocols/oauth1.rb +0 -46
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +0 -49
- data/lib/sorcery/controller/submodules/external/providers/base.rb +0 -21
- data/lib/sorcery/controller/submodules/external/providers/facebook.rb +0 -98
- data/lib/sorcery/controller/submodules/external/providers/github.rb +0 -92
- data/lib/sorcery/controller/submodules/external/providers/google.rb +0 -91
- data/lib/sorcery/controller/submodules/external/providers/linkedin.rb +0 -102
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +0 -92
- data/lib/sorcery/controller/submodules/external/providers/twitter.rb +0 -93
- data/lib/sorcery/controller/submodules/external/providers/vk.rb +0 -100
- data/lib/sorcery/controller/submodules/external/providers/xing.rb +0 -97
- data/lib/sorcery/test_helpers.rb +0 -5
- data/spec/Gemfile +0 -12
- data/spec/Gemfile.lock +0 -129
- data/spec/README.md +0 -31
- data/spec/Rakefile +0 -12
- data/spec/rails3/.gitignore +0 -4
- data/spec/rails3/.rspec +0 -1
- data/spec/rails3/Gemfile +0 -15
- data/spec/rails3/Gemfile.lock +0 -162
- data/spec/rails3/README +0 -256
- data/spec/rails3/Rakefile +0 -11
- data/spec/rails3/app/controllers/application_controller.rb +0 -208
- data/spec/rails3/config/application.rb +0 -46
- data/spec/rails3/config/boot.rb +0 -13
- data/spec/rails3/config/database.yml +0 -27
- data/spec/rails3/config/environments/development.rb +0 -26
- data/spec/rails3/config/environments/in_memory.rb +0 -35
- data/spec/rails3/config/environments/production.rb +0 -49
- data/spec/rails3/config/environments/test.rb +0 -35
- data/spec/rails3/config/initializers/session_store.rb +0 -8
- data/spec/rails3/config/routes.rb +0 -59
- data/spec/rails3/config.ru +0 -4
- data/spec/rails3/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/rails3/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3/script/rails +0 -6
- data/spec/rails3/spec/controller_activity_logging_spec.rb +0 -130
- data/spec/rails3/spec/controller_brute_force_protection_spec.rb +0 -96
- data/spec/rails3/spec/controller_http_basic_auth_spec.rb +0 -50
- data/spec/rails3/spec/controller_oauth2_spec.rb +0 -380
- data/spec/rails3/spec/controller_remember_me_spec.rb +0 -96
- data/spec/rails3/spec/controller_session_timeout_spec.rb +0 -55
- data/spec/rails3/spec/controller_spec.rb +0 -182
- data/spec/rails3/spec/spec.opts +0 -2
- data/spec/rails3/spec/spec_helper.orig.rb +0 -27
- data/spec/rails3/spec/spec_helper.rb +0 -71
- data/spec/rails3/spec/user_activation_spec.rb +0 -16
- data/spec/rails3/spec/user_activity_logging_spec.rb +0 -8
- data/spec/rails3/spec/user_spec.rb +0 -36
- data/spec/rails3/vendor/plugins/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/.gitignore +0 -4
- data/spec/rails3_mongo_mapper/.rspec +0 -1
- data/spec/rails3_mongo_mapper/Gemfile +0 -16
- data/spec/rails3_mongo_mapper/Gemfile.lock +0 -156
- data/spec/rails3_mongo_mapper/Rakefile +0 -11
- data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +0 -122
- data/spec/rails3_mongo_mapper/app/helpers/application_helper.rb +0 -2
- data/spec/rails3_mongo_mapper/app/mailers/sorcery_mailer.rb +0 -25
- data/spec/rails3_mongo_mapper/app/views/layouts/application.html.erb +0 -14
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.html.erb +0 -17
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.text.erb +0 -9
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.text.erb +0 -9
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.html.erb +0 -16
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.text.erb +0 -8
- data/spec/rails3_mongo_mapper/config/boot.rb +0 -13
- data/spec/rails3_mongo_mapper/config/environment.rb +0 -5
- data/spec/rails3_mongo_mapper/config/environments/development.rb +0 -30
- data/spec/rails3_mongo_mapper/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongo_mapper/config/environments/production.rb +0 -49
- data/spec/rails3_mongo_mapper/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails3_mongo_mapper/config/initializers/inflections.rb +0 -10
- data/spec/rails3_mongo_mapper/config/initializers/mime_types.rb +0 -5
- data/spec/rails3_mongo_mapper/config/initializers/mongo.rb +0 -2
- data/spec/rails3_mongo_mapper/config/initializers/secret_token.rb +0 -7
- data/spec/rails3_mongo_mapper/config/initializers/session_store.rb +0 -8
- data/spec/rails3_mongo_mapper/config/locales/en.yml +0 -5
- data/spec/rails3_mongo_mapper/config/routes.rb +0 -59
- data/spec/rails3_mongo_mapper/db/schema.rb +0 -23
- data/spec/rails3_mongo_mapper/db/seeds.rb +0 -7
- data/spec/rails3_mongo_mapper/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/public/404.html +0 -26
- data/spec/rails3_mongo_mapper/public/422.html +0 -26
- data/spec/rails3_mongo_mapper/public/500.html +0 -26
- 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 +0 -2
- data/spec/rails3_mongo_mapper/public/javascripts/controls.js +0 -965
- data/spec/rails3_mongo_mapper/public/javascripts/dragdrop.js +0 -974
- data/spec/rails3_mongo_mapper/public/javascripts/effects.js +0 -1123
- data/spec/rails3_mongo_mapper/public/javascripts/prototype.js +0 -6001
- data/spec/rails3_mongo_mapper/public/javascripts/rails.js +0 -175
- data/spec/rails3_mongo_mapper/public/robots.txt +0 -5
- data/spec/rails3_mongo_mapper/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/script/rails +0 -6
- data/spec/rails3_mongo_mapper/spec/controller_spec.rb +0 -175
- data/spec/rails3_mongo_mapper/spec/spec.opts +0 -2
- data/spec/rails3_mongo_mapper/spec/spec_helper.orig.rb +0 -27
- data/spec/rails3_mongo_mapper/spec/spec_helper.rb +0 -55
- data/spec/rails3_mongo_mapper/spec/user_activation_spec.rb +0 -9
- data/spec/rails3_mongo_mapper/spec/user_activity_logging_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_brute_force_protection_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_oauth_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_remember_me_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_reset_password_spec.rb +0 -8
- data/spec/rails3_mongo_mapper/spec/user_spec.rb +0 -37
- data/spec/rails3_mongo_mapper/vendor/plugins/.gitkeep +0 -0
- data/spec/rails3_mongoid/.gitignore +0 -4
- data/spec/rails3_mongoid/.rspec +0 -1
- data/spec/rails3_mongoid/Gemfile +0 -15
- data/spec/rails3_mongoid/Gemfile.lock +0 -146
- data/spec/rails3_mongoid/Rakefile +0 -11
- data/spec/rails3_mongoid/app/controllers/application_controller.rb +0 -127
- data/spec/rails3_mongoid/app/helpers/application_helper.rb +0 -2
- data/spec/rails3_mongoid/app/mailers/sorcery_mailer.rb +0 -25
- data/spec/rails3_mongoid/app/views/layouts/application.html.erb +0 -14
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.html.erb +0 -17
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.text.erb +0 -9
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.html.erb +0 -17
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.text.erb +0 -9
- data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.html.erb +0 -16
- data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.text.erb +0 -8
- data/spec/rails3_mongoid/config/application.rb +0 -51
- data/spec/rails3_mongoid/config/boot.rb +0 -13
- data/spec/rails3_mongoid/config/environment.rb +0 -5
- data/spec/rails3_mongoid/config/environments/development.rb +0 -26
- data/spec/rails3_mongoid/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongoid/config/environments/production.rb +0 -49
- data/spec/rails3_mongoid/config/environments/test.rb +0 -35
- data/spec/rails3_mongoid/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails3_mongoid/config/initializers/inflections.rb +0 -10
- data/spec/rails3_mongoid/config/initializers/mime_types.rb +0 -5
- data/spec/rails3_mongoid/config/initializers/secret_token.rb +0 -7
- data/spec/rails3_mongoid/config/locales/en.yml +0 -5
- data/spec/rails3_mongoid/config/mongoid.yml +0 -7
- data/spec/rails3_mongoid/config/routes.rb +0 -59
- data/spec/rails3_mongoid/config.ru +0 -4
- data/spec/rails3_mongoid/db/schema.rb +0 -23
- data/spec/rails3_mongoid/db/seeds.rb +0 -7
- data/spec/rails3_mongoid/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongoid/public/404.html +0 -26
- data/spec/rails3_mongoid/public/422.html +0 -26
- data/spec/rails3_mongoid/public/500.html +0 -26
- data/spec/rails3_mongoid/public/favicon.ico +0 -0
- data/spec/rails3_mongoid/public/images/rails.png +0 -0
- data/spec/rails3_mongoid/public/javascripts/application.js +0 -2
- data/spec/rails3_mongoid/public/javascripts/controls.js +0 -965
- data/spec/rails3_mongoid/public/javascripts/dragdrop.js +0 -974
- data/spec/rails3_mongoid/public/javascripts/effects.js +0 -1123
- data/spec/rails3_mongoid/public/javascripts/prototype.js +0 -6001
- data/spec/rails3_mongoid/public/javascripts/rails.js +0 -175
- data/spec/rails3_mongoid/public/robots.txt +0 -5
- data/spec/rails3_mongoid/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongoid/script/rails +0 -6
- data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +0 -111
- data/spec/rails3_mongoid/spec/controller_spec.rb +0 -186
- data/spec/rails3_mongoid/spec/spec.opts +0 -2
- data/spec/rails3_mongoid/spec/spec_helper.orig.rb +0 -27
- data/spec/rails3_mongoid/spec/spec_helper.rb +0 -55
- data/spec/rails3_mongoid/spec/user_activation_spec.rb +0 -9
- data/spec/rails3_mongoid/spec/user_activity_logging_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_oauth_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_remember_me_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +0 -8
- data/spec/rails3_mongoid/spec/user_spec.rb +0 -38
- data/spec/rails3_mongoid/vendor/plugins/.gitkeep +0 -0
- /data/lib/sorcery/{controller/submodules/external/protocols → protocols}/certs/ca-bundle.crt +0 -0
- /data/spec/{rails3/app/models → rails_app/app/active_record}/authentication.rb +0 -0
- /data/spec/{rails3 → rails_app}/app/helpers/application_helper.rb +0 -0
- /data/spec/{rails3 → rails_app}/app/mailers/sorcery_mailer.rb +0 -0
- /data/spec/{rails3_mongo_mapper/app/models → rails_app/app/mongo_mapper}/authentication.rb +0 -0
- /data/spec/{rails3_mongo_mapper/app/models → rails_app/app/mongo_mapper}/user.rb +0 -0
- /data/spec/{rails3_mongoid/app/models → rails_app/app/mongoid}/authentication.rb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/application/index.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/layouts/application.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_email.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_email.text.erb +0 -0
- /data/spec/{rails3/app/views/sorcery_mailer/activation_success_email.html.erb → rails_app/app/views/sorcery_mailer/activation_needed_email.html.erb} +0 -0
- /data/spec/{rails3_mongo_mapper → rails_app}/app/views/sorcery_mailer/activation_success_email.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/activation_success_email.text.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/reset_password_email.html.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/reset_password_email.text.erb +0 -0
- /data/spec/{rails3 → rails_app}/app/views/sorcery_mailer/send_unlock_token_email.text.erb +0 -0
- /data/spec/{rails3 → rails_app}/config/environment.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/backtrace_silencers.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/inflections.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/mime_types.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/initializers/secret_token.rb +0 -0
- /data/spec/{rails3 → rails_app}/config/locales/en.yml +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/core/20101224223620_create_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/schema.rb +0 -0
- /data/spec/{rails3 → rails_app}/db/seeds.rb +0 -0
- /data/spec/{rails3 → rails_app}/public/404.html +0 -0
- /data/spec/{rails3 → rails_app}/public/422.html +0 -0
- /data/spec/{rails3 → rails_app}/public/500.html +0 -0
- /data/spec/{rails3 → rails_app}/public/favicon.ico +0 -0
- /data/spec/{rails3 → rails_app}/public/images/rails.png +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/application.js +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/controls.js +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/dragdrop.js +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/effects.js +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/prototype.js +0 -0
- /data/spec/{rails3 → rails_app}/public/javascripts/rails.js +0 -0
- /data/spec/{rails3 → rails_app}/public/robots.txt +0 -0
- /data/spec/{rails3/lib/tasks → rails_app/public/stylesheets}/.gitkeep +0 -0
|
@@ -1,320 +1,395 @@
|
|
|
1
1
|
shared_examples_for "rails_3_core_model" do
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
|
|
3
|
+
let(:user) { create_new_user }
|
|
4
|
+
let(:crypted_password) { user.send User.sorcery_config.crypted_password_attribute_name }
|
|
5
|
+
|
|
6
|
+
describe "loaded plugin configuration" do
|
|
7
|
+
|
|
8
|
+
after(:each) { User.sorcery_config.reset! }
|
|
9
|
+
|
|
10
|
+
it "enables configuration option 'username_attribute_names'" do
|
|
8
11
|
sorcery_model_property_set(:username_attribute_names, :email)
|
|
9
|
-
|
|
12
|
+
|
|
13
|
+
expect(User.sorcery_config.username_attribute_names).to eq [:email]
|
|
10
14
|
end
|
|
11
|
-
|
|
12
|
-
it "
|
|
15
|
+
|
|
16
|
+
it "enables configuration option 'password_attribute_name'" do
|
|
13
17
|
sorcery_model_property_set(:password_attribute_name, :mypassword)
|
|
14
|
-
|
|
18
|
+
|
|
19
|
+
expect(User.sorcery_config.password_attribute_name).to eq :mypassword
|
|
15
20
|
end
|
|
16
|
-
|
|
17
|
-
it "
|
|
21
|
+
|
|
22
|
+
it "enables configuration option 'email_attribute_name'" do
|
|
18
23
|
sorcery_model_property_set(:email_attribute_name, :my_email)
|
|
19
|
-
|
|
24
|
+
|
|
25
|
+
expect(User.sorcery_config.email_attribute_name).to eq :my_email
|
|
20
26
|
end
|
|
21
|
-
|
|
22
|
-
it "
|
|
27
|
+
|
|
28
|
+
it "enables configuration option 'crypted_password_attribute_name'" do
|
|
23
29
|
sorcery_model_property_set(:crypted_password_attribute_name, :password)
|
|
24
|
-
|
|
30
|
+
|
|
31
|
+
expect(User.sorcery_config.crypted_password_attribute_name).to eq :password
|
|
25
32
|
end
|
|
26
|
-
|
|
27
|
-
it "
|
|
33
|
+
|
|
34
|
+
it "enables configuration option 'salt_attribute_name'" do
|
|
28
35
|
sorcery_model_property_set(:salt_attribute_name, :my_salt)
|
|
29
|
-
|
|
36
|
+
|
|
37
|
+
expect(User.sorcery_config.salt_attribute_name).to eq :my_salt
|
|
30
38
|
end
|
|
31
|
-
|
|
32
|
-
it "
|
|
39
|
+
|
|
40
|
+
it "enables configuration option 'encryption_algorithm'" do
|
|
33
41
|
sorcery_model_property_set(:encryption_algorithm, :none)
|
|
34
|
-
|
|
42
|
+
|
|
43
|
+
expect(User.sorcery_config.encryption_algorithm).to eq :none
|
|
35
44
|
end
|
|
36
|
-
|
|
37
|
-
it "
|
|
45
|
+
|
|
46
|
+
it "enables configuration option 'encryption_key'" do
|
|
38
47
|
sorcery_model_property_set(:encryption_key, 'asdadas424234242')
|
|
39
|
-
|
|
48
|
+
|
|
49
|
+
expect(User.sorcery_config.encryption_key).to eq 'asdadas424234242'
|
|
40
50
|
end
|
|
41
|
-
|
|
42
|
-
it "
|
|
51
|
+
|
|
52
|
+
it "enables configuration option 'custom_encryption_provider'" do
|
|
43
53
|
sorcery_model_property_set(:encryption_algorithm, :custom)
|
|
44
54
|
sorcery_model_property_set(:custom_encryption_provider, Array)
|
|
45
|
-
|
|
55
|
+
|
|
56
|
+
expect(User.sorcery_config.custom_encryption_provider).to eq Array
|
|
46
57
|
end
|
|
47
|
-
|
|
48
|
-
it "
|
|
58
|
+
|
|
59
|
+
it "enables configuration option 'salt_join_token'" do
|
|
49
60
|
salt_join_token = "--%%*&-"
|
|
50
61
|
sorcery_model_property_set(:salt_join_token, salt_join_token)
|
|
51
|
-
|
|
62
|
+
|
|
63
|
+
expect(User.sorcery_config.salt_join_token).to eq salt_join_token
|
|
52
64
|
end
|
|
53
|
-
|
|
54
|
-
it "
|
|
65
|
+
|
|
66
|
+
it "enables configuration option 'stretches'" do
|
|
55
67
|
stretches = 15
|
|
56
68
|
sorcery_model_property_set(:stretches, stretches)
|
|
57
|
-
|
|
69
|
+
|
|
70
|
+
expect(User.sorcery_config.stretches).to eq stretches
|
|
58
71
|
end
|
|
59
72
|
end
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
before(:
|
|
64
|
-
|
|
73
|
+
|
|
74
|
+
describe "when activated with sorcery" do
|
|
75
|
+
before(:all) { sorcery_reload! }
|
|
76
|
+
before(:each) { User.delete_all }
|
|
77
|
+
|
|
78
|
+
it "does not add authenticate method to base class", active_record: true do
|
|
79
|
+
expect(ActiveRecord::Base).not_to respond_to(:authenticate) if defined?(ActiveRecord)
|
|
65
80
|
end
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
User.
|
|
81
|
+
|
|
82
|
+
it "responds to class method authenticate" do
|
|
83
|
+
expect(User).to respond_to :authenticate
|
|
69
84
|
end
|
|
70
|
-
|
|
71
|
-
it "
|
|
72
|
-
|
|
73
|
-
|
|
85
|
+
|
|
86
|
+
it "authenticate returns true if credentials are good" do
|
|
87
|
+
username = user.send(User.sorcery_config.username_attribute_names.first)
|
|
88
|
+
|
|
89
|
+
expect(User.authenticate username, 'secret').to be_truthy
|
|
74
90
|
end
|
|
75
|
-
|
|
76
|
-
it "authenticate
|
|
77
|
-
|
|
78
|
-
|
|
91
|
+
|
|
92
|
+
it "authenticate returns nil if credentials are bad" do
|
|
93
|
+
username = user.send(User.sorcery_config.username_attribute_names.first)
|
|
94
|
+
|
|
95
|
+
expect(User.authenticate username, 'wrong!').to be nil
|
|
79
96
|
end
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
|
|
98
|
+
context "with empty credentials" do
|
|
99
|
+
before do
|
|
100
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
after do
|
|
104
|
+
sorcery_reload!
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "don't downcase empty credentials" do
|
|
108
|
+
expect(User.authenticate(nil, 'wrong!')).to be_falsy
|
|
109
|
+
end
|
|
84
110
|
end
|
|
85
|
-
|
|
86
|
-
specify { User.
|
|
87
|
-
|
|
88
|
-
it "subclass
|
|
111
|
+
|
|
112
|
+
specify { expect(User).to respond_to(:encrypt) }
|
|
113
|
+
|
|
114
|
+
it "subclass inherits config if defined so" do
|
|
89
115
|
sorcery_reload!([],{:subclasses_inherit_config => true})
|
|
90
|
-
class Admin < User
|
|
91
|
-
|
|
92
|
-
Admin.sorcery_config.
|
|
93
|
-
Admin.sorcery_config.
|
|
116
|
+
class Admin < User; end
|
|
117
|
+
|
|
118
|
+
expect(Admin.sorcery_config).not_to be_nil
|
|
119
|
+
expect(Admin.sorcery_config).to eq User.sorcery_config
|
|
94
120
|
end
|
|
95
|
-
|
|
96
|
-
it "subclass
|
|
121
|
+
|
|
122
|
+
it "subclass does not inherit config if not defined so" do
|
|
97
123
|
sorcery_reload!([],{:subclasses_inherit_config => false})
|
|
98
|
-
class Admin2 < User
|
|
99
|
-
|
|
100
|
-
Admin2.sorcery_config.
|
|
124
|
+
class Admin2 < User; end
|
|
125
|
+
|
|
126
|
+
expect(Admin2.sorcery_config).to be_nil
|
|
101
127
|
end
|
|
102
128
|
end
|
|
103
|
-
|
|
104
|
-
# ----------------- REGISTRATION -----------------------
|
|
105
|
-
describe User, "registration" do
|
|
106
|
-
|
|
107
|
-
before(:all) do
|
|
108
|
-
sorcery_reload!()
|
|
109
|
-
end
|
|
110
129
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
130
|
+
|
|
131
|
+
describe "registration" do
|
|
132
|
+
|
|
133
|
+
before(:all) { sorcery_reload! }
|
|
134
|
+
before(:each) { User.delete_all }
|
|
135
|
+
|
|
136
|
+
it "by default, encryption_provider is not nil" do
|
|
137
|
+
expect(User.sorcery_config.encryption_provider).not_to be_nil
|
|
117
138
|
end
|
|
118
|
-
|
|
119
|
-
it "
|
|
120
|
-
|
|
121
|
-
User.sorcery_config.encryption_provider.matches?(@user.send(User.sorcery_config.crypted_password_attribute_name),'secret',@user.salt).should be_true
|
|
139
|
+
|
|
140
|
+
it "encrypts password when a new user is saved" do
|
|
141
|
+
expect(User.sorcery_config.encryption_provider.matches? crypted_password, 'secret', user.salt).to be true
|
|
122
142
|
end
|
|
123
143
|
|
|
124
|
-
it "
|
|
125
|
-
|
|
126
|
-
@user.password.should be_nil
|
|
144
|
+
it "clears the virtual password field if the encryption process worked" do
|
|
145
|
+
expect(user.password).to be_nil
|
|
127
146
|
end
|
|
128
|
-
|
|
129
|
-
it "
|
|
130
|
-
create_new_user
|
|
147
|
+
|
|
148
|
+
it "does not clear the virtual password field if save failed due to validity" do
|
|
131
149
|
User.class_eval do
|
|
132
|
-
validates_format_of :email, :with =>
|
|
150
|
+
validates_format_of :email, :with => /\A(.)+@(.)+\Z/, :if => Proc.new {|r| r.email}, :message => "is invalid"
|
|
133
151
|
end
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
152
|
+
|
|
153
|
+
user.password = 'blupush'
|
|
154
|
+
user.email = 'asd'
|
|
155
|
+
user.save
|
|
156
|
+
|
|
157
|
+
expect(user.password).not_to be_nil
|
|
138
158
|
end
|
|
139
|
-
|
|
140
|
-
it "
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
User.class_eval
|
|
145
|
-
validates_presence_of :username
|
|
146
|
-
end
|
|
159
|
+
|
|
160
|
+
it "does not clear the virtual password field if save failed due to exception" do
|
|
161
|
+
user.password = '4blupush'
|
|
162
|
+
user.username = nil
|
|
163
|
+
|
|
164
|
+
User.class_eval { validates_presence_of :username }
|
|
147
165
|
begin
|
|
148
|
-
|
|
166
|
+
if defined?(DataMapper) && user.class.ancestors.include?(DataMapper::Resource)
|
|
167
|
+
user.save
|
|
168
|
+
else
|
|
169
|
+
user.save! # triggers validation exception since username field is required.
|
|
170
|
+
end
|
|
149
171
|
rescue
|
|
150
172
|
end
|
|
151
|
-
|
|
173
|
+
|
|
174
|
+
expect(user.password).not_to be_nil
|
|
152
175
|
end
|
|
153
|
-
|
|
154
|
-
it "
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
176
|
+
|
|
177
|
+
it "does not encrypt the password twice when a user is updated" do
|
|
178
|
+
user.email = "blup@bla.com"
|
|
179
|
+
if defined?(DataMapper) && user.class.ancestors.include?(DataMapper::Resource)
|
|
180
|
+
user.save
|
|
181
|
+
else
|
|
182
|
+
user.save!
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
expect(User.sorcery_config.encryption_provider.matches? crypted_password, 'secret', user.salt).to be true
|
|
159
186
|
end
|
|
160
187
|
|
|
161
|
-
it "
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
188
|
+
it "replaces the crypted_password in case a new password is set" do
|
|
189
|
+
user.password = 'new_secret'
|
|
190
|
+
if defined?(DataMapper) && user.class.ancestors.include?(DataMapper::Resource)
|
|
191
|
+
user.save
|
|
192
|
+
else
|
|
193
|
+
user.save!
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
expect(User.sorcery_config.encryption_provider.matches? crypted_password, 'secret', user.salt).to be false
|
|
166
197
|
end
|
|
167
198
|
|
|
199
|
+
describe "when user has password_confirmation_defined" do
|
|
200
|
+
before(:all) do
|
|
201
|
+
User.class_eval { attr_accessor :password_confirmation }
|
|
202
|
+
if defined?(DataMapper)
|
|
203
|
+
DataMapper.finalize
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
after(:all) do
|
|
208
|
+
User.send(:remove_method, :password_confirmation)
|
|
209
|
+
User.send(:remove_method, :password_confirmation=)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it "clears the virtual password field if the encryption process worked" do
|
|
213
|
+
user = create_new_user(username: "u", password: "secret", password_confirmation: "secret", email: "email@example.com")
|
|
214
|
+
|
|
215
|
+
expect(user.password_confirmation).to be_nil
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
it "does not clear the virtual password field if save failed due to validity" do
|
|
219
|
+
User.class_eval do
|
|
220
|
+
validates_format_of :email, :with => /\A(.)+@(.)+\Z/
|
|
221
|
+
end
|
|
222
|
+
user = build_new_user(username: "u", password: "secret", password_confirmation: "secret", email: "asd")
|
|
223
|
+
user.save
|
|
224
|
+
|
|
225
|
+
expect(user.password_confirmation).not_to be_nil
|
|
226
|
+
end
|
|
227
|
+
end
|
|
168
228
|
end
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
describe User, "special encryption cases" do
|
|
229
|
+
|
|
230
|
+
describe "special encryption cases" do
|
|
172
231
|
before(:all) do
|
|
173
232
|
sorcery_reload!()
|
|
174
233
|
@text = "Some Text!"
|
|
175
234
|
end
|
|
176
|
-
|
|
235
|
+
|
|
177
236
|
before(:each) do
|
|
178
237
|
User.delete_all
|
|
179
238
|
end
|
|
180
|
-
|
|
239
|
+
|
|
181
240
|
after(:each) do
|
|
182
241
|
User.sorcery_config.reset!
|
|
183
242
|
end
|
|
184
|
-
|
|
185
|
-
it "
|
|
243
|
+
|
|
244
|
+
it "works with no password encryption" do
|
|
186
245
|
sorcery_model_property_set(:encryption_algorithm, :none)
|
|
187
|
-
|
|
188
|
-
|
|
246
|
+
username = user.send(User.sorcery_config.username_attribute_names.first)
|
|
247
|
+
|
|
248
|
+
expect(User.authenticate username, 'secret').to be_truthy
|
|
189
249
|
end
|
|
190
|
-
|
|
191
|
-
it "
|
|
250
|
+
|
|
251
|
+
it "works with custom password encryption" do
|
|
192
252
|
class MyCrypto
|
|
193
253
|
def self.encrypt(*tokens)
|
|
194
254
|
tokens.flatten.join('').gsub(/e/,'A')
|
|
195
255
|
end
|
|
196
|
-
|
|
256
|
+
|
|
197
257
|
def self.matches?(crypted,*tokens)
|
|
198
258
|
crypted == encrypt(*tokens)
|
|
199
259
|
end
|
|
200
260
|
end
|
|
201
261
|
sorcery_model_property_set(:encryption_algorithm, :custom)
|
|
202
262
|
sorcery_model_property_set(:custom_encryption_provider, MyCrypto)
|
|
203
|
-
|
|
204
|
-
|
|
263
|
+
|
|
264
|
+
username = user.send(User.sorcery_config.username_attribute_names.first)
|
|
265
|
+
|
|
266
|
+
expect(User.authenticate username, 'secret').to be_truthy
|
|
205
267
|
end
|
|
206
|
-
|
|
207
|
-
it "if encryption algo is aes256, it
|
|
268
|
+
|
|
269
|
+
it "if encryption algo is aes256, it sets key to crypto provider" do
|
|
208
270
|
sorcery_model_property_set(:encryption_algorithm, :aes256)
|
|
209
271
|
sorcery_model_property_set(:encryption_key, nil)
|
|
210
|
-
|
|
272
|
+
|
|
273
|
+
expect { User.encrypt @text }.to raise_error(ArgumentError)
|
|
274
|
+
|
|
211
275
|
sorcery_model_property_set(:encryption_key, "asd234dfs423fddsmndsflktsdf32343")
|
|
212
|
-
|
|
276
|
+
|
|
277
|
+
expect { User.encrypt @text }.not_to raise_error
|
|
213
278
|
end
|
|
214
|
-
|
|
215
|
-
it "if encryption algo is aes256, it
|
|
279
|
+
|
|
280
|
+
it "if encryption algo is aes256, it sets key to crypto provider, even if attributes are set in reverse" do
|
|
216
281
|
sorcery_model_property_set(:encryption_key, nil)
|
|
217
282
|
sorcery_model_property_set(:encryption_algorithm, :none)
|
|
218
283
|
sorcery_model_property_set(:encryption_key, "asd234dfs423fddsmndsflktsdf32343")
|
|
219
284
|
sorcery_model_property_set(:encryption_algorithm, :aes256)
|
|
220
|
-
|
|
285
|
+
|
|
286
|
+
expect { User.encrypt @text }.not_to raise_error
|
|
221
287
|
end
|
|
222
|
-
|
|
223
|
-
it "if encryption algo is md5 it
|
|
288
|
+
|
|
289
|
+
it "if encryption algo is md5 it works" do
|
|
224
290
|
sorcery_model_property_set(:encryption_algorithm, :md5)
|
|
225
|
-
|
|
291
|
+
|
|
292
|
+
expect(User.encrypt @text).to eq Sorcery::CryptoProviders::MD5.encrypt(@text)
|
|
226
293
|
end
|
|
227
|
-
|
|
228
|
-
it "if encryption algo is sha1 it
|
|
294
|
+
|
|
295
|
+
it "if encryption algo is sha1 it works" do
|
|
229
296
|
sorcery_model_property_set(:encryption_algorithm, :sha1)
|
|
230
|
-
|
|
297
|
+
|
|
298
|
+
expect(User.encrypt @text).to eq Sorcery::CryptoProviders::SHA1.encrypt(@text)
|
|
231
299
|
end
|
|
232
|
-
|
|
233
|
-
it "if encryption algo is sha256 it
|
|
300
|
+
|
|
301
|
+
it "if encryption algo is sha256 it works" do
|
|
234
302
|
sorcery_model_property_set(:encryption_algorithm, :sha256)
|
|
235
|
-
|
|
303
|
+
|
|
304
|
+
expect(User.encrypt @text).to eq Sorcery::CryptoProviders::SHA256.encrypt(@text)
|
|
236
305
|
end
|
|
237
|
-
|
|
238
|
-
it "if encryption algo is sha512 it
|
|
306
|
+
|
|
307
|
+
it "if encryption algo is sha512 it works" do
|
|
239
308
|
sorcery_model_property_set(:encryption_algorithm, :sha512)
|
|
240
|
-
|
|
309
|
+
|
|
310
|
+
expect(User.encrypt @text).to eq Sorcery::CryptoProviders::SHA512.encrypt(@text)
|
|
241
311
|
end
|
|
242
|
-
|
|
243
|
-
it "salt
|
|
312
|
+
|
|
313
|
+
it "salt is random for each user and saved in db" do
|
|
244
314
|
sorcery_model_property_set(:salt_attribute_name, :salt)
|
|
245
|
-
|
|
246
|
-
|
|
315
|
+
|
|
316
|
+
expect(user.salt).not_to be_nil
|
|
247
317
|
end
|
|
248
|
-
|
|
249
|
-
it "if salt is set
|
|
318
|
+
|
|
319
|
+
it "if salt is set uses it to encrypt" do
|
|
250
320
|
sorcery_model_property_set(:salt_attribute_name, :salt)
|
|
251
321
|
sorcery_model_property_set(:encryption_algorithm, :sha512)
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
322
|
+
|
|
323
|
+
expect(user.crypted_password).not_to eq Sorcery::CryptoProviders::SHA512.encrypt('secret')
|
|
324
|
+
expect(user.crypted_password).to eq Sorcery::CryptoProviders::SHA512.encrypt('secret',user.salt)
|
|
255
325
|
end
|
|
256
|
-
|
|
257
|
-
it "if salt_join_token is set
|
|
326
|
+
|
|
327
|
+
it "if salt_join_token is set uses it to encrypt" do
|
|
258
328
|
sorcery_model_property_set(:salt_attribute_name, :salt)
|
|
259
329
|
sorcery_model_property_set(:salt_join_token, "-@=>")
|
|
260
330
|
sorcery_model_property_set(:encryption_algorithm, :sha512)
|
|
261
|
-
|
|
262
|
-
|
|
331
|
+
|
|
332
|
+
expect(user.crypted_password).not_to eq Sorcery::CryptoProviders::SHA512.encrypt('secret')
|
|
333
|
+
|
|
263
334
|
Sorcery::CryptoProviders::SHA512.join_token = ""
|
|
264
|
-
|
|
335
|
+
|
|
336
|
+
expect(user.crypted_password).not_to eq Sorcery::CryptoProviders::SHA512.encrypt('secret',user.salt)
|
|
337
|
+
|
|
265
338
|
Sorcery::CryptoProviders::SHA512.join_token = User.sorcery_config.salt_join_token
|
|
266
|
-
|
|
339
|
+
|
|
340
|
+
expect(user.crypted_password).to eq Sorcery::CryptoProviders::SHA512.encrypt('secret',user.salt)
|
|
267
341
|
end
|
|
268
|
-
|
|
269
342
|
end
|
|
270
|
-
|
|
271
|
-
describe
|
|
343
|
+
|
|
344
|
+
describe "ORM adapter" do
|
|
272
345
|
before(:all) do
|
|
273
346
|
sorcery_reload!()
|
|
274
347
|
User.delete_all
|
|
275
348
|
end
|
|
276
|
-
|
|
277
|
-
before(:each)
|
|
278
|
-
create_new_user
|
|
279
|
-
end
|
|
349
|
+
|
|
350
|
+
before(:each) { user }
|
|
280
351
|
|
|
281
352
|
after(:each) do
|
|
282
353
|
User.delete_all
|
|
283
354
|
User.sorcery_config.reset!
|
|
284
355
|
end
|
|
285
356
|
|
|
286
|
-
|
|
287
|
-
|
|
357
|
+
|
|
358
|
+
it "find_by_username works as expected" do
|
|
359
|
+
sorcery_model_property_set(:username_attribute_names, [:username])
|
|
360
|
+
|
|
361
|
+
expect(User.find_by_username "gizmo").to eq user
|
|
288
362
|
end
|
|
289
363
|
|
|
290
|
-
it "find_by_username
|
|
364
|
+
it "find_by_username works as expected with multiple username attributes" do
|
|
291
365
|
sorcery_model_property_set(:username_attribute_names, [:username, :email])
|
|
292
|
-
|
|
366
|
+
|
|
367
|
+
expect(User.find_by_username "gizmo").to eq user
|
|
293
368
|
end
|
|
294
369
|
|
|
295
|
-
it "find_by_email
|
|
296
|
-
User.find_by_email
|
|
370
|
+
it "find_by_email works as expected" do
|
|
371
|
+
expect(User.find_by_email "bla@bla.com").to eq user
|
|
297
372
|
end
|
|
298
373
|
end
|
|
299
374
|
end
|
|
300
375
|
|
|
301
376
|
shared_examples_for "external_user" do
|
|
377
|
+
let(:user) { create_new_user }
|
|
378
|
+
let(:external_user) { create_new_external_user :twitter }
|
|
379
|
+
|
|
302
380
|
before(:each) do
|
|
303
381
|
User.delete_all
|
|
304
382
|
end
|
|
305
|
-
|
|
306
|
-
it "
|
|
307
|
-
|
|
308
|
-
@user.should respond_to(:external?)
|
|
383
|
+
|
|
384
|
+
it "responds to 'external?'" do
|
|
385
|
+
expect(user).to respond_to(:external?)
|
|
309
386
|
end
|
|
310
|
-
|
|
311
|
-
it "external?
|
|
312
|
-
|
|
313
|
-
@user.external?.should be_false
|
|
387
|
+
|
|
388
|
+
it "external? is false for regular users" do
|
|
389
|
+
expect(user.external?).to be false
|
|
314
390
|
end
|
|
315
|
-
|
|
316
|
-
it "external?
|
|
317
|
-
|
|
318
|
-
@user.external?.should be_true
|
|
391
|
+
|
|
392
|
+
it "external? is true for external users" do
|
|
393
|
+
expect(external_user.external?).to be true
|
|
319
394
|
end
|
|
320
|
-
end
|
|
395
|
+
end
|