sorcery 0.8.1 → 0.9.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.
- checksums.yaml +7 -0
- data/.gitignore +56 -0
- data/.travis.yml +130 -1
- data/CHANGELOG.md +270 -0
- data/Gemfile +18 -23
- data/README.md +371 -0
- data/Rakefile +3 -78
- data/gemfiles/active_record-rails40.gemfile +7 -0
- data/gemfiles/active_record-rails41.gemfile +7 -0
- data/gemfiles/mongo_mapper-rails40.gemfile +9 -0
- data/gemfiles/mongo_mapper-rails41.gemfile +9 -0
- data/gemfiles/mongoid-rails40.gemfile +9 -0
- data/gemfiles/mongoid-rails41.gemfile +9 -0
- data/gemfiles/mongoid3-rails32.gemfile +9 -0
- data/lib/generators/sorcery/USAGE +1 -1
- data/lib/generators/sorcery/helpers.rb +40 -0
- data/lib/generators/sorcery/install_generator.rb +38 -20
- data/lib/generators/sorcery/templates/initializer.rb +51 -15
- data/lib/generators/sorcery/templates/migration/activity_logging.rb +3 -10
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +3 -7
- data/lib/generators/sorcery/templates/migration/core.rb +5 -8
- data/lib/generators/sorcery/templates/migration/external.rb +3 -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/adapters/active_record_adapter.rb +120 -0
- data/lib/sorcery/adapters/base_adapter.rb +30 -0
- data/lib/sorcery/adapters/data_mapper_adapter.rb +176 -0
- data/lib/sorcery/adapters/mongo_mapper_adapter.rb +110 -0
- data/lib/sorcery/adapters/mongoid_adapter.rb +97 -0
- data/lib/sorcery/controller/config.rb +65 -0
- data/lib/sorcery/controller/submodules/activity_logging.rb +27 -21
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +6 -6
- data/lib/sorcery/controller/submodules/external.rb +107 -75
- data/lib/sorcery/controller/submodules/remember_me.rb +5 -5
- data/lib/sorcery/controller/submodules/session_timeout.rb +11 -7
- data/lib/sorcery/controller.rb +27 -76
- data/lib/sorcery/model/config.rb +96 -0
- data/lib/sorcery/model/submodules/activity_logging.rb +32 -12
- data/lib/sorcery/model/submodules/brute_force_protection.rb +36 -36
- data/lib/sorcery/model/submodules/external.rb +53 -9
- data/lib/sorcery/model/submodules/remember_me.rb +15 -19
- data/lib/sorcery/model/submodules/reset_password.rb +36 -33
- data/lib/sorcery/model/submodules/user_activation.rb +51 -48
- data/lib/sorcery/model/temporary_token.rb +4 -4
- data/lib/sorcery/model.rb +81 -175
- data/lib/sorcery/protocols/oauth.rb +42 -0
- data/lib/sorcery/protocols/oauth2.rb +47 -0
- data/lib/sorcery/providers/base.rb +38 -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/heroku.rb +57 -0
- data/lib/sorcery/providers/jira.rb +77 -0
- data/lib/sorcery/providers/linkedin.rb +66 -0
- data/lib/sorcery/providers/liveid.rb +53 -0
- data/lib/sorcery/providers/salesforce.rb +50 -0
- data/lib/sorcery/providers/twitter.rb +59 -0
- data/lib/sorcery/providers/vk.rb +63 -0
- data/lib/sorcery/providers/xing.rb +64 -0
- data/lib/sorcery/railties/tasks.rake +1 -7
- data/lib/sorcery/test_helpers/internal/rails.rb +17 -6
- data/lib/sorcery/test_helpers/internal.rb +27 -6
- data/lib/sorcery/test_helpers/rails/controller.rb +21 -0
- data/lib/sorcery/test_helpers/rails/integration.rb +26 -0
- data/lib/sorcery/version.rb +3 -0
- data/lib/sorcery.rb +83 -57
- data/sorcery.gemspec +24 -363
- data/spec/active_record/user_activation_spec.rb +18 -0
- data/spec/active_record/user_activity_logging_spec.rb +17 -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/controllers/controller_activity_logging_spec.rb +124 -0
- data/spec/controllers/controller_brute_force_protection_spec.rb +43 -0
- data/spec/controllers/controller_http_basic_auth_spec.rb +68 -0
- data/spec/controllers/controller_oauth2_spec.rb +414 -0
- data/spec/controllers/controller_oauth_spec.rb +240 -0
- data/spec/controllers/controller_remember_me_spec.rb +117 -0
- data/spec/controllers/controller_session_timeout_spec.rb +80 -0
- data/spec/controllers/controller_spec.rb +218 -0
- data/spec/data_mapper/user_activation_spec.rb +10 -0
- data/spec/data_mapper/user_activity_logging_spec.rb +14 -0
- data/spec/data_mapper/user_brute_force_protection_spec.rb +9 -0
- data/spec/data_mapper/user_oauth_spec.rb +9 -0
- data/spec/data_mapper/user_remember_me_spec.rb +8 -0
- data/spec/data_mapper/user_reset_password_spec.rb +8 -0
- data/spec/data_mapper/user_spec.rb +27 -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/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 +51 -0
- data/spec/orm/active_record.rb +21 -0
- data/spec/orm/data_mapper.rb +48 -0
- data/spec/orm/mongo_mapper.rb +10 -0
- data/spec/orm/mongoid.rb +22 -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 +285 -0
- data/spec/rails_app/app/data_mapper/authentication.rb +8 -0
- data/spec/rails_app/app/data_mapper/user.rb +7 -0
- data/spec/{rails3_mongo_mapper/app/models → rails_app/app/mongo_mapper}/user.rb +2 -0
- data/spec/{rails3_mongoid/app/models → rails_app/app/mongoid}/user.rb +2 -0
- data/spec/rails_app/app/views/sorcery_mailer/send_unlock_token_email.text.erb +1 -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 +51 -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/{rails3 → rails_app}/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +2 -0
- data/spec/{rails3 → rails_app}/db/migrate/core/20101224223620_create_users.rb +2 -2
- 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/user_activation_shared_examples.rb +137 -98
- data/spec/shared_examples/user_activity_logging_shared_examples.rb +86 -13
- data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +140 -21
- data/spec/shared_examples/user_oauth_shared_examples.rb +21 -16
- data/spec/shared_examples/user_remember_me_shared_examples.rb +36 -24
- data/spec/shared_examples/user_reset_password_shared_examples.rb +163 -130
- data/spec/shared_examples/user_shared_examples.rb +355 -193
- data/spec/sorcery_crypto_providers_spec.rb +74 -72
- data/spec/spec_helper.rb +32 -4
- metadata +258 -425
- data/Gemfile.lock +0 -192
- data/README.rdoc +0 -261
- data/VERSION +0 -1
- data/lib/sorcery/controller/submodules/external/protocols/oauth1.rb +0 -35
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +0 -45
- data/lib/sorcery/controller/submodules/external/providers/facebook.rb +0 -97
- data/lib/sorcery/controller/submodules/external/providers/github.rb +0 -91
- data/lib/sorcery/controller/submodules/external/providers/google.rb +0 -90
- data/lib/sorcery/controller/submodules/external/providers/linkedin.rb +0 -101
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +0 -91
- data/lib/sorcery/controller/submodules/external/providers/twitter.rb +0 -92
- data/lib/sorcery/controller/submodules/external/providers/vk.rb +0 -99
- data/lib/sorcery/model/adapters/active_record.rb +0 -49
- data/lib/sorcery/model/adapters/mongo_mapper.rb +0 -56
- data/lib/sorcery/model/adapters/mongoid.rb +0 -88
- data/lib/sorcery/test_helpers/rails.rb +0 -16
- 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/app/views/sorcery_mailer/send_unlock_token_email.text.erb +0 -1
- 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/lib/tasks/.gitkeep +0 -0
- data/spec/rails3/public/404.html +0 -26
- data/spec/rails3/public/422.html +0 -26
- data/spec/rails3/public/500.html +0 -26
- data/spec/rails3/public/favicon.ico +0 -0
- data/spec/rails3/public/images/rails.png +0 -0
- data/spec/rails3/public/javascripts/application.js +0 -2
- data/spec/rails3/public/javascripts/controls.js +0 -965
- data/spec/rails3/public/javascripts/dragdrop.js +0 -974
- data/spec/rails3/public/javascripts/effects.js +0 -1123
- data/spec/rails3/public/javascripts/prototype.js +0 -6001
- data/spec/rails3/public/javascripts/rails.js +0 -175
- data/spec/rails3/public/robots.txt +0 -5
- 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 -115
- data/spec/rails3/spec/controller_brute_force_protection_spec.rb +0 -88
- 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_oauth_spec.rb +0 -206
- 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 -177
- data/spec/rails3/spec/integration_spec.rb +0 -23
- 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 -170
- 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 -105
- data/spec/rails3_mongoid/spec/controller_spec.rb +0 -181
- 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/spec/shared_examples/controller_oauth2_shared_examples.rb +0 -56
- data/spec/shared_examples/controller_oauth_shared_examples.rb +0 -55
- /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_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}/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/brute_force_protection/20101224223626_add_brute_force_protection_to_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
|
@@ -1,380 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/controller_oauth2_shared_examples')
|
|
3
|
-
|
|
4
|
-
def stub_all_oauth2_requests!
|
|
5
|
-
auth_code = OAuth2::Strategy::AuthCode.any_instance
|
|
6
|
-
access_token = mock(OAuth2::AccessToken)
|
|
7
|
-
access_token.stub(:token_param=)
|
|
8
|
-
response = mock(OAuth2::Response)
|
|
9
|
-
response.stub(:body).and_return({
|
|
10
|
-
"id"=>"123",
|
|
11
|
-
"name"=>"Noam Ben Ari",
|
|
12
|
-
"first_name"=>"Noam",
|
|
13
|
-
"last_name"=>"Ben Ari",
|
|
14
|
-
"link"=>"http://www.facebook.com/nbenari1",
|
|
15
|
-
"hometown"=>{"id"=>"110619208966868", "name"=>"Haifa, Israel"},
|
|
16
|
-
"location"=>{"id"=>"106906559341067", "name"=>"Pardes Hanah, Hefa, Israel"},
|
|
17
|
-
"bio"=>"I'm a new daddy, and enjoying it!",
|
|
18
|
-
"gender"=>"male",
|
|
19
|
-
"email"=>"nbenari@gmail.com",
|
|
20
|
-
"timezone"=>2,
|
|
21
|
-
"locale"=>"en_US",
|
|
22
|
-
"languages"=>[{"id"=>"108405449189952", "name"=>"Hebrew"}, {"id"=>"106059522759137", "name"=>"English"}, {"id"=>"112624162082677", "name"=>"Russian"}],
|
|
23
|
-
"verified"=>true,
|
|
24
|
-
"updated_time"=>"2011-02-16T20:59:38+0000"}.to_json)
|
|
25
|
-
access_token.stub(:get).and_return(response)
|
|
26
|
-
auth_code.stub(:get_token).and_return(access_token)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def set_external_property
|
|
30
|
-
sorcery_controller_property_set(:external_providers, [:facebook, :github, :google, :liveid])
|
|
31
|
-
sorcery_controller_external_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
|
|
32
|
-
sorcery_controller_external_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
33
|
-
sorcery_controller_external_property_set(:facebook, :callback_url, "http://blabla.com")
|
|
34
|
-
sorcery_controller_external_property_set(:github, :key, "eYVNBjBDi33aa9GkA3w")
|
|
35
|
-
sorcery_controller_external_property_set(:github, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
36
|
-
sorcery_controller_external_property_set(:github, :callback_url, "http://blabla.com")
|
|
37
|
-
sorcery_controller_external_property_set(:google, :key, "eYVNBjBDi33aa9GkA3w")
|
|
38
|
-
sorcery_controller_external_property_set(:google, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
39
|
-
sorcery_controller_external_property_set(:google, :callback_url, "http://blabla.com")
|
|
40
|
-
sorcery_controller_external_property_set(:liveid, :key, "eYVNBjBDi33aa9GkA3w")
|
|
41
|
-
sorcery_controller_external_property_set(:liveid, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
42
|
-
sorcery_controller_external_property_set(:liveid, :callback_url, "http://blabla.com")
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
describe ApplicationController do
|
|
46
|
-
before(:all) do
|
|
47
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
|
|
48
|
-
sorcery_reload!([:external])
|
|
49
|
-
set_external_property
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
after(:all) do
|
|
53
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
54
|
-
end
|
|
55
|
-
# ----------------- OAuth -----------------------
|
|
56
|
-
describe ApplicationController, "with OAuth features" do
|
|
57
|
-
|
|
58
|
-
before(:each) do
|
|
59
|
-
stub_all_oauth2_requests!
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
after(:each) do
|
|
63
|
-
User.delete_all
|
|
64
|
-
Authentication.delete_all
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
context "when callback_url begin with /" do
|
|
68
|
-
before do
|
|
69
|
-
sorcery_controller_external_property_set(:facebook, :callback_url, "/oauth/twitter/callback")
|
|
70
|
-
end
|
|
71
|
-
it "login_at redirects correctly" do
|
|
72
|
-
create_new_user
|
|
73
|
-
get :login_at_test2
|
|
74
|
-
response.should be_a_redirect
|
|
75
|
-
response.should redirect_to("https://graph.facebook.com/oauth/authorize?response_type=code&client_id=#{::Sorcery::Controller::Config.facebook.key}&redirect_uri=http%3A%2F%2Ftest.host%2Foauth%2Ftwitter%2Fcallback&scope=email%2Coffline_access&display=page")
|
|
76
|
-
end
|
|
77
|
-
after do
|
|
78
|
-
sorcery_controller_external_property_set(:facebook, :callback_url, "http://blabla.com")
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
context "when callback_url begin with http://" do
|
|
83
|
-
it "login_at redirects correctly" do
|
|
84
|
-
create_new_user
|
|
85
|
-
get :login_at_test2
|
|
86
|
-
response.should be_a_redirect
|
|
87
|
-
response.should redirect_to("https://graph.facebook.com/oauth/authorize?response_type=code&client_id=#{::Sorcery::Controller::Config.facebook.key}&redirect_uri=http%3A%2F%2Fblabla.com&scope=email%2Coffline_access&display=page")
|
|
88
|
-
end
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "'login_from' logins if user exists" do
|
|
92
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
93
|
-
create_new_external_user(:facebook)
|
|
94
|
-
get :test_login_from2
|
|
95
|
-
flash[:notice].should == "Success!"
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it "'login_from' fails if user doesn't exist" do
|
|
99
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
100
|
-
create_new_user
|
|
101
|
-
get :test_login_from2
|
|
102
|
-
flash[:alert].should == "Failed!"
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
it "on successful login_from the user should be redirected to the url he originally wanted" do
|
|
106
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
107
|
-
create_new_external_user(:facebook)
|
|
108
|
-
get :test_return_to_with_external2, {}, :return_to_url => "fuu"
|
|
109
|
-
response.should redirect_to("fuu")
|
|
110
|
-
flash[:notice].should == "Success!"
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# provider: github
|
|
114
|
-
it "login_at redirects correctly (github)" do
|
|
115
|
-
create_new_user
|
|
116
|
-
get :login_at_test3
|
|
117
|
-
response.should be_a_redirect
|
|
118
|
-
response.should redirect_to("https://github.com/login/oauth/authorize?response_type=code&client_id=#{::Sorcery::Controller::Config.github.key}&redirect_uri=http%3A%2F%2Fblabla.com&scope&display")
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
it "'login_from' logins if user exists (github)" do
|
|
122
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
123
|
-
create_new_external_user(:github)
|
|
124
|
-
get :test_login_from3
|
|
125
|
-
flash[:notice].should == "Success!"
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
it "'login_from' fails if user doesn't exist (github)" do
|
|
129
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
130
|
-
create_new_user
|
|
131
|
-
get :test_login_from3
|
|
132
|
-
flash[:alert].should == "Failed!"
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it "on successful login_from the user should be redirected to the url he originally wanted (github)" do
|
|
136
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
137
|
-
create_new_external_user(:github)
|
|
138
|
-
get :test_return_to_with_external3, {}, :return_to_url => "fuu"
|
|
139
|
-
response.should redirect_to("fuu")
|
|
140
|
-
flash[:notice].should == "Success!"
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
# provider: google
|
|
144
|
-
it "login_at redirects correctly (google)" do
|
|
145
|
-
create_new_user
|
|
146
|
-
get :login_at_test4
|
|
147
|
-
response.should be_a_redirect
|
|
148
|
-
response.should redirect_to("https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=#{::Sorcery::Controller::Config.google.key}&redirect_uri=http%3A%2F%2Fblabla.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile&display")
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
it "'login_from' logins if user exists (google)" do
|
|
152
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
153
|
-
create_new_external_user(:google)
|
|
154
|
-
get :test_login_from4
|
|
155
|
-
flash[:notice].should == "Success!"
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it "'login_from' fails if user doesn't exist (google)" do
|
|
159
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
160
|
-
create_new_user
|
|
161
|
-
get :test_login_from4
|
|
162
|
-
flash[:alert].should == "Failed!"
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
it "on successful login_from the user should be redirected to the url he originally wanted (google)" do
|
|
166
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
167
|
-
create_new_external_user(:google)
|
|
168
|
-
get :test_return_to_with_external4, {}, :return_to_url => "fuu"
|
|
169
|
-
response.should redirect_to("fuu")
|
|
170
|
-
flash[:notice].should == "Success!"
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
# provider: liveid
|
|
174
|
-
it "login_at redirects correctly (liveid)" do
|
|
175
|
-
create_new_user
|
|
176
|
-
get :login_at_test5
|
|
177
|
-
response.should be_a_redirect
|
|
178
|
-
response.should redirect_to("https://oauth.live.com/authorize?response_type=code&client_id=#{::Sorcery::Controller::Config.liveid.key}&redirect_uri=http%3A%2F%2Fblabla.com&scope=wl.basic+wl.emails+wl.offline_access&display")
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
it "'login_from' logins if user exists (liveid)" do
|
|
182
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
183
|
-
create_new_external_user(:liveid)
|
|
184
|
-
get :test_login_from5
|
|
185
|
-
flash[:notice].should == "Success!"
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
it "'login_from' fails if user doesn't exist (liveid)" do
|
|
189
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
190
|
-
create_new_user
|
|
191
|
-
get :test_login_from5
|
|
192
|
-
flash[:alert].should == "Failed!"
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
it "on successful login_from the user should be redirected to the url he originally wanted (liveid)" do
|
|
196
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
197
|
-
create_new_external_user(:liveid)
|
|
198
|
-
get :test_return_to_with_external5, {}, :return_to_url => "fuu"
|
|
199
|
-
response.should redirect_to("fuu")
|
|
200
|
-
flash[:notice].should == "Success!"
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
describe ApplicationController do
|
|
207
|
-
it_behaves_like "oauth2_controller"
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
describe ApplicationController, "OAuth with User Activation features" do
|
|
211
|
-
before(:all) do
|
|
212
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activation")
|
|
213
|
-
sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
|
|
214
|
-
sorcery_controller_property_set(:external_providers, [:facebook, :github, :google, :liveid])
|
|
215
|
-
sorcery_controller_external_property_set(:facebook, :key, "eYVNBjBDi33aa9GkA3w")
|
|
216
|
-
sorcery_controller_external_property_set(:facebook, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
217
|
-
sorcery_controller_external_property_set(:facebook, :callback_url, "http://blabla.com")
|
|
218
|
-
sorcery_controller_external_property_set(:github, :key, "eYVNBjBDi33aa9GkA3w")
|
|
219
|
-
sorcery_controller_external_property_set(:github, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
220
|
-
sorcery_controller_external_property_set(:github, :callback_url, "http://blabla.com")
|
|
221
|
-
sorcery_controller_external_property_set(:google, :key, "eYVNBjBDi33aa9GkA3w")
|
|
222
|
-
sorcery_controller_external_property_set(:google, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
223
|
-
sorcery_controller_external_property_set(:google, :callback_url, "http://blabla.com")
|
|
224
|
-
sorcery_controller_external_property_set(:liveid, :key, "eYVNBjBDi33aa9GkA3w")
|
|
225
|
-
sorcery_controller_external_property_set(:liveid, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
226
|
-
sorcery_controller_external_property_set(:liveid, :callback_url, "http://blabla.com")
|
|
227
|
-
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
after(:all) do
|
|
231
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/activation")
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
after(:each) do
|
|
235
|
-
User.delete_all
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
it "should not send activation email to external users" do
|
|
239
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
240
|
-
create_new_external_user(:facebook)
|
|
241
|
-
ActionMailer::Base.deliveries.size.should == old_size
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
it "should not send external users an activation success email" do
|
|
245
|
-
sorcery_model_property_set(:activation_success_email_method_name, nil)
|
|
246
|
-
create_new_external_user(:facebook)
|
|
247
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
248
|
-
@user.activate!
|
|
249
|
-
ActionMailer::Base.deliveries.size.should == old_size
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
# provider: github
|
|
253
|
-
it "should not send activation email to external users (github)" do
|
|
254
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
255
|
-
create_new_external_user(:github)
|
|
256
|
-
ActionMailer::Base.deliveries.size.should == old_size
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
it "should not send external users an activation success email (github)" do
|
|
260
|
-
sorcery_model_property_set(:activation_success_email_method_name, nil)
|
|
261
|
-
create_new_external_user(:github)
|
|
262
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
263
|
-
@user.activate!
|
|
264
|
-
ActionMailer::Base.deliveries.size.should == old_size
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
# provider: google
|
|
268
|
-
it "should not send activation email to external users (google)" do
|
|
269
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
270
|
-
create_new_external_user(:google)
|
|
271
|
-
ActionMailer::Base.deliveries.size.should == old_size
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
it "should not send external users an activation success email (google)" do
|
|
275
|
-
sorcery_model_property_set(:activation_success_email_method_name, nil)
|
|
276
|
-
create_new_external_user(:google)
|
|
277
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
278
|
-
@user.activate!
|
|
279
|
-
ActionMailer::Base.deliveries.size.should == old_size
|
|
280
|
-
end
|
|
281
|
-
|
|
282
|
-
# provider: liveid
|
|
283
|
-
it "should not send activation email to external users (liveid)" do
|
|
284
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
285
|
-
create_new_external_user(:liveid)
|
|
286
|
-
ActionMailer::Base.deliveries.size.should == old_size
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
it "should not send external users an activation success email (liveid)" do
|
|
290
|
-
sorcery_model_property_set(:activation_success_email_method_name, nil)
|
|
291
|
-
create_new_external_user(:liveid)
|
|
292
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
293
|
-
@user.activate!
|
|
294
|
-
ActionMailer::Base.deliveries.size.should == old_size
|
|
295
|
-
end
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
describe ApplicationController, "OAuth with user activation features" do
|
|
299
|
-
before(:all) do
|
|
300
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
|
|
301
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activity_logging")
|
|
302
|
-
sorcery_reload!([:activity_logging, :external])
|
|
303
|
-
end
|
|
304
|
-
|
|
305
|
-
after(:all) do
|
|
306
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
307
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/activity_logging")
|
|
308
|
-
end
|
|
309
|
-
|
|
310
|
-
%w(facebook github google liveid).each.with_index(2) do |provider, index|
|
|
311
|
-
context "when #{provider}" do
|
|
312
|
-
before(:each) do
|
|
313
|
-
User.delete_all
|
|
314
|
-
Authentication.delete_all
|
|
315
|
-
sorcery_controller_property_set(:register_login_time, true)
|
|
316
|
-
stub_all_oauth2_requests!
|
|
317
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
318
|
-
create_new_external_user(provider.to_sym)
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
it "should register login time" do
|
|
322
|
-
now = Time.now.in_time_zone
|
|
323
|
-
get "test_login_from#{index}".to_sym
|
|
324
|
-
User.last.last_login_at.should_not be_nil
|
|
325
|
-
User.last.last_login_at.to_s(:db).should >= now.to_s(:db)
|
|
326
|
-
User.last.last_login_at.to_s(:db).should <= (now+2).to_s(:db)
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
it "should not register login time if configured so" do
|
|
330
|
-
sorcery_controller_property_set(:register_login_time, false)
|
|
331
|
-
now = Time.now.in_time_zone
|
|
332
|
-
get "test_login_from#{index}".to_sym
|
|
333
|
-
User.last.last_login_at.should be_nil
|
|
334
|
-
end
|
|
335
|
-
end
|
|
336
|
-
end
|
|
337
|
-
end
|
|
338
|
-
|
|
339
|
-
describe ApplicationController, "OAuth with session timeout features" do
|
|
340
|
-
before(:all) do
|
|
341
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
|
|
342
|
-
sorcery_reload!([:session_timeout, :external])
|
|
343
|
-
end
|
|
344
|
-
|
|
345
|
-
after(:all) do
|
|
346
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
%w(facebook github google liveid).each.with_index(2) do |provider, index|
|
|
350
|
-
context "when #{provider}" do
|
|
351
|
-
before(:each) do
|
|
352
|
-
User.delete_all
|
|
353
|
-
Authentication.delete_all
|
|
354
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
355
|
-
sorcery_controller_property_set(:session_timeout,0.5)
|
|
356
|
-
stub_all_oauth2_requests!
|
|
357
|
-
create_new_external_user(provider.to_sym)
|
|
358
|
-
end
|
|
359
|
-
|
|
360
|
-
after(:each) do
|
|
361
|
-
Timecop.return
|
|
362
|
-
end
|
|
363
|
-
|
|
364
|
-
it "should not reset session before session timeout" do
|
|
365
|
-
get "test_login_from#{index}".to_sym
|
|
366
|
-
session[:user_id].should_not be_nil
|
|
367
|
-
flash[:notice].should == "Success!"
|
|
368
|
-
end
|
|
369
|
-
|
|
370
|
-
it "should reset session after session timeout" do
|
|
371
|
-
get "test_login_from#{index}".to_sym
|
|
372
|
-
Timecop.travel(Time.now.in_time_zone+0.6)
|
|
373
|
-
get :test_should_be_logged_in
|
|
374
|
-
session[:user_id].should be_nil
|
|
375
|
-
response.should be_a_redirect
|
|
376
|
-
end
|
|
377
|
-
end
|
|
378
|
-
end
|
|
379
|
-
end
|
|
380
|
-
end
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/controller_oauth_shared_examples')
|
|
3
|
-
require 'ostruct'
|
|
4
|
-
|
|
5
|
-
def stub_all_oauth_requests!
|
|
6
|
-
@consumer = OAuth::Consumer.new("key","secret", :site => "http://myapi.com")
|
|
7
|
-
OAuth::Consumer.stub!(:new).and_return(@consumer)
|
|
8
|
-
|
|
9
|
-
@req_token = OAuth::RequestToken.new(@consumer)
|
|
10
|
-
@consumer.stub!(:get_request_token).and_return(@req_token)
|
|
11
|
-
@acc_token = OAuth::AccessToken.new(@consumer)
|
|
12
|
-
@req_token.stub!(:get_access_token).and_return(@acc_token)
|
|
13
|
-
session[:request_token] = @req_token.token
|
|
14
|
-
session[:request_token_secret] = @req_token.secret
|
|
15
|
-
OAuth::RequestToken.stub!(:new).and_return(@req_token)
|
|
16
|
-
response = OpenStruct.new()
|
|
17
|
-
response.body = {"following"=>false, "listed_count"=>0, "profile_link_color"=>"0084B4", "profile_image_url"=>"http://a1.twimg.com/profile_images/536178575/noamb_normal.jpg", "description"=>"Programmer/Heavy Metal Fan/New Father", "status"=>{"text"=>"coming soon to sorcery gem: twitter and facebook authentication support.", "truncated"=>false, "favorited"=>false, "source"=>"web", "geo"=>nil, "in_reply_to_screen_name"=>nil, "in_reply_to_user_id"=>nil, "in_reply_to_status_id_str"=>nil, "created_at"=>"Sun Mar 06 23:01:12 +0000 2011", "contributors"=>nil, "place"=>nil, "retweeted"=>false, "in_reply_to_status_id"=>nil, "in_reply_to_user_id_str"=>nil, "coordinates"=>nil, "retweet_count"=>0, "id"=>44533012284706816, "id_str"=>"44533012284706816"}, "show_all_inline_media"=>false, "geo_enabled"=>true, "profile_sidebar_border_color"=>"a8c7f7", "url"=>nil, "followers_count"=>10, "screen_name"=>"nbenari", "profile_use_background_image"=>true, "location"=>"Israel", "statuses_count"=>25, "profile_background_color"=>"022330", "lang"=>"en", "verified"=>false, "notifications"=>false, "profile_background_image_url"=>"http://a3.twimg.com/profile_background_images/104087198/04042010339.jpg", "favourites_count"=>5, "created_at"=>"Fri Nov 20 21:58:19 +0000 2009", "is_translator"=>false, "contributors_enabled"=>false, "protected"=>false, "follow_request_sent"=>false, "time_zone"=>"Greenland", "profile_text_color"=>"333333", "name"=>"Noam Ben Ari", "friends_count"=>10, "profile_sidebar_fill_color"=>"C0DFEC", "id"=>123, "id_str"=>"91434812", "profile_background_tile"=>false, "utc_offset"=>-10800}.to_json
|
|
18
|
-
@acc_token.stub!(:get).and_return(response)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
describe ApplicationController do
|
|
22
|
-
before(:all) do
|
|
23
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
|
|
24
|
-
sorcery_reload!([:external])
|
|
25
|
-
sorcery_controller_property_set(:external_providers, [:twitter])
|
|
26
|
-
sorcery_controller_external_property_set(:twitter, :key, "eYVNBjBDi33aa9GkA3w")
|
|
27
|
-
sorcery_controller_external_property_set(:twitter, :secret, "XpbeSdCoaKSmQGSeokz5qcUATClRW5u08QWNfv71N8")
|
|
28
|
-
sorcery_controller_external_property_set(:twitter, :callback_url, "http://blabla.com")
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
after(:all) do
|
|
32
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
33
|
-
end
|
|
34
|
-
# ----------------- OAuth -----------------------
|
|
35
|
-
describe ApplicationController, "'using external API to login'" do
|
|
36
|
-
|
|
37
|
-
before(:each) do
|
|
38
|
-
stub_all_oauth_requests!
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
after(:each) do
|
|
42
|
-
User.delete_all
|
|
43
|
-
Authentication.delete_all
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context "when callback_url begin with /" do
|
|
47
|
-
before do
|
|
48
|
-
sorcery_controller_external_property_set(:twitter, :callback_url, "/oauth/twitter/callback")
|
|
49
|
-
end
|
|
50
|
-
it "login_at redirects correctly" do
|
|
51
|
-
create_new_user
|
|
52
|
-
get :login_at_test
|
|
53
|
-
response.should be_a_redirect
|
|
54
|
-
response.should redirect_to("http://myapi.com/oauth/authorize?oauth_callback=http%3A%2F%2Ftest.host%2Foauth%2Ftwitter%2Fcallback&oauth_token=")
|
|
55
|
-
end
|
|
56
|
-
after do
|
|
57
|
-
sorcery_controller_external_property_set(:twitter, :callback_url, "http://blabla.com")
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
context "when callback_url begin with http://" do
|
|
62
|
-
it "login_at redirects correctly" do
|
|
63
|
-
create_new_user
|
|
64
|
-
get :login_at_test
|
|
65
|
-
response.should be_a_redirect
|
|
66
|
-
response.should redirect_to("http://myapi.com/oauth/authorize?oauth_callback=http%3A%2F%2Fblabla.com&oauth_token=")
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "logins if user exists" do
|
|
71
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
72
|
-
create_new_external_user(:twitter)
|
|
73
|
-
get :test_login_from, :oauth_verifier => "blablaRERASDFcxvSDFA"
|
|
74
|
-
flash[:notice].should == "Success!"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "'login_from' fails if user doesn't exist" do
|
|
78
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
79
|
-
create_new_user
|
|
80
|
-
get :test_login_from, :oauth_verifier => "blablaRERASDFcxvSDFA"
|
|
81
|
-
flash[:alert].should == "Failed!"
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it "on successful 'login_from' the user should be redirected to the url he originally wanted" do
|
|
85
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
86
|
-
create_new_external_user(:twitter)
|
|
87
|
-
get :test_return_to_with_external, {}, :return_to_url => "fuu"
|
|
88
|
-
response.should redirect_to("fuu")
|
|
89
|
-
flash[:notice].should == "Success!"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
describe ApplicationController do
|
|
95
|
-
it_behaves_like "oauth_controller"
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
describe ApplicationController, "using OAuth with User Activation features" do
|
|
99
|
-
before(:all) do
|
|
100
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activation")
|
|
101
|
-
sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
after(:all) do
|
|
105
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/activation")
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
after(:each) do
|
|
109
|
-
User.delete_all
|
|
110
|
-
Authentication.delete_all
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
it "should not send activation email to external users" do
|
|
114
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
115
|
-
create_new_external_user(:twitter)
|
|
116
|
-
ActionMailer::Base.deliveries.size.should == old_size
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it "should not send external users an activation success email" do
|
|
120
|
-
sorcery_model_property_set(:activation_success_email_method_name, nil)
|
|
121
|
-
create_new_external_user(:twitter)
|
|
122
|
-
old_size = ActionMailer::Base.deliveries.size
|
|
123
|
-
@user.activate!
|
|
124
|
-
ActionMailer::Base.deliveries.size.should == old_size
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
describe ApplicationController, "OAuth with user activation features" do
|
|
129
|
-
before(:all) do
|
|
130
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
|
|
131
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activity_logging")
|
|
132
|
-
sorcery_reload!([:activity_logging, :external])
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
after(:all) do
|
|
136
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
137
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/activity_logging")
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
context "when twitter" do
|
|
141
|
-
before(:each) do
|
|
142
|
-
User.delete_all
|
|
143
|
-
Authentication.delete_all
|
|
144
|
-
sorcery_controller_property_set(:register_login_time, true)
|
|
145
|
-
stub_all_oauth_requests!
|
|
146
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
147
|
-
create_new_external_user(:twitter)
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
it "should register login time" do
|
|
151
|
-
now = Time.now.in_time_zone
|
|
152
|
-
get :test_login_from
|
|
153
|
-
User.last.last_login_at.should_not be_nil
|
|
154
|
-
User.last.last_login_at.to_s(:db).should >= now.to_s(:db)
|
|
155
|
-
User.last.last_login_at.to_s(:db).should <= (now+2).to_s(:db)
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it "should not register login time if configured so" do
|
|
159
|
-
sorcery_controller_property_set(:register_login_time, false)
|
|
160
|
-
now = Time.now.in_time_zone
|
|
161
|
-
get :test_login_from
|
|
162
|
-
User.last.last_login_at.should be_nil
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
describe ApplicationController, "OAuth with session timeout features" do
|
|
168
|
-
before(:all) do
|
|
169
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/external")
|
|
170
|
-
sorcery_reload!([:session_timeout, :external])
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
after(:all) do
|
|
174
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
context "when twitter" do
|
|
178
|
-
before(:each) do
|
|
179
|
-
User.delete_all
|
|
180
|
-
Authentication.delete_all
|
|
181
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
182
|
-
sorcery_controller_property_set(:session_timeout,0.5)
|
|
183
|
-
stub_all_oauth_requests!
|
|
184
|
-
create_new_external_user(:twitter)
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
after(:each) do
|
|
188
|
-
Timecop.return
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
it "should not reset session before session timeout" do
|
|
192
|
-
get :test_login_from
|
|
193
|
-
session[:user_id].should_not be_nil
|
|
194
|
-
flash[:notice].should == "Success!"
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
it "should reset session after session timeout" do
|
|
198
|
-
get :test_login_from
|
|
199
|
-
Timecop.travel(Time.now.in_time_zone+0.6)
|
|
200
|
-
get :test_should_be_logged_in
|
|
201
|
-
session[:user_id].should be_nil
|
|
202
|
-
response.should be_a_redirect
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
end
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
-
|
|
3
|
-
describe ApplicationController do
|
|
4
|
-
|
|
5
|
-
# ----------------- REMEMBER ME -----------------------
|
|
6
|
-
describe ApplicationController, "with remember me features" do
|
|
7
|
-
|
|
8
|
-
before(:all) do
|
|
9
|
-
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/remember_me")
|
|
10
|
-
sorcery_reload!([:remember_me])
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
before(:each) do
|
|
14
|
-
create_new_user
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
after(:all) do
|
|
18
|
-
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/remember_me")
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
after(:each) do
|
|
22
|
-
session = nil
|
|
23
|
-
cookies = nil
|
|
24
|
-
User.delete_all
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "should set cookie on remember_me!" do
|
|
28
|
-
post :test_login_with_remember, :username => 'gizmo', :password => 'secret'
|
|
29
|
-
@request.cookies.merge!(cookies)
|
|
30
|
-
cookies = ActionDispatch::Cookies::CookieJar.build(@request)
|
|
31
|
-
cookies.signed["remember_me_token"].should == assigns[:current_user].remember_me_token
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should clear cookie on forget_me!" do
|
|
35
|
-
cookies["remember_me_token"] == {:value => 'asd54234dsfsd43534', :expires => 3600}
|
|
36
|
-
get :test_logout
|
|
37
|
-
cookies["remember_me_token"].should be_nil
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it "login(username,password,remember_me) should login and remember" do
|
|
41
|
-
post :test_login_with_remember_in_login, :username => 'gizmo', :password => 'secret', :remember => "1"
|
|
42
|
-
@request.cookies.merge!(cookies)
|
|
43
|
-
cookies = ActionDispatch::Cookies::CookieJar.build(@request)
|
|
44
|
-
cookies.signed["remember_me_token"].should_not be_nil
|
|
45
|
-
cookies.signed["remember_me_token"].should == assigns[:user].remember_me_token
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "logout should also forget_me!" do
|
|
49
|
-
session[:user_id] = @user.id
|
|
50
|
-
get :test_logout_with_remember
|
|
51
|
-
cookies["remember_me_token"].should be_nil
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
it "should login_from_cookie" do
|
|
55
|
-
session[:user_id] = @user.id
|
|
56
|
-
subject.remember_me!
|
|
57
|
-
subject.instance_eval do
|
|
58
|
-
@current_user = nil
|
|
59
|
-
end
|
|
60
|
-
session[:user_id] = nil
|
|
61
|
-
get :test_login_from_cookie
|
|
62
|
-
assigns[:current_user].should == @user
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it "should not remember_me! when not asked to, even if third parameter is used" do
|
|
66
|
-
post :test_login_with_remember_in_login, :username => 'gizmo', :password => 'secret', :remember => "0"
|
|
67
|
-
cookies["remember_me_token"].should be_nil
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "should not remember_me! when not asked to" do
|
|
71
|
-
post :test_login, :username => 'gizmo', :password => 'secret'
|
|
72
|
-
cookies["remember_me_token"].should be_nil
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# --- login_user(user) ---
|
|
76
|
-
specify { should respond_to(:auto_login) }
|
|
77
|
-
|
|
78
|
-
it "auto_login(user) should login a user instance without remembering" do
|
|
79
|
-
create_new_user
|
|
80
|
-
session[:user_id] = nil
|
|
81
|
-
subject.auto_login(@user)
|
|
82
|
-
get :test_login_from_cookie
|
|
83
|
-
assigns[:current_user].should == @user
|
|
84
|
-
cookies["remember_me_token"].should be_nil
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it "auto_login(user, true) should login a user instance with remembering" do
|
|
88
|
-
create_new_user
|
|
89
|
-
session[:user_id] = nil
|
|
90
|
-
subject.auto_login(@user, true)
|
|
91
|
-
get :test_login_from_cookie
|
|
92
|
-
assigns[:current_user].should == @user
|
|
93
|
-
cookies["remember_me_token"].should_not be_nil
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|