sorcery 0.6.1 → 0.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +2 -0
- data/Gemfile +2 -23
- data/Gemfile.lock +105 -77
- data/README.rdoc +32 -59
- data/Rakefile +29 -1
- data/VERSION +1 -1
- data/lib/generators/sorcery/USAGE +22 -0
- data/lib/generators/sorcery/install_generator.rb +77 -0
- data/lib/generators/sorcery/templates/initializer.rb +406 -0
- data/lib/generators/sorcery/templates/migration/activity_logging.rb +17 -0
- data/lib/generators/sorcery/templates/migration/brute_force_protection.rb +13 -0
- data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/core.rb +3 -3
- data/lib/generators/{sorcery_migration/templates → sorcery/templates/migration}/external.rb +1 -1
- data/lib/generators/sorcery/templates/migration/remember_me.rb +15 -0
- data/lib/generators/sorcery/templates/migration/reset_password.rb +17 -0
- data/lib/generators/sorcery/templates/migration/user_activation.rb +17 -0
- data/lib/sorcery/controller/submodules/activity_logging.rb +24 -10
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +3 -2
- data/lib/sorcery/controller/submodules/external/protocols/certs/ca-bundle.crt +5182 -0
- data/lib/sorcery/controller/submodules/external/protocols/oauth2.rb +28 -9
- data/lib/sorcery/controller/submodules/external/providers/facebook.rb +12 -4
- data/lib/sorcery/controller/submodules/external/providers/github.rb +89 -0
- data/lib/sorcery/controller/submodules/external/providers/google.rb +90 -0
- data/lib/sorcery/controller/submodules/external/providers/liveid.rb +91 -0
- data/lib/sorcery/controller/submodules/external/providers/twitter.rb +8 -2
- data/lib/sorcery/controller/submodules/external.rb +17 -4
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +1 -1
- data/lib/sorcery/controller/submodules/remember_me.rb +26 -15
- data/lib/sorcery/controller/submodules/session_timeout.rb +4 -4
- data/lib/sorcery/controller.rb +61 -38
- data/lib/sorcery/crypto_providers/aes256.rb +7 -3
- data/lib/sorcery/engine.rb +1 -0
- data/lib/sorcery/model/adapters/active_record.rb +17 -1
- data/lib/sorcery/model/adapters/mongo_mapper.rb +54 -0
- data/lib/sorcery/model/adapters/mongoid.rb +22 -4
- data/lib/sorcery/model/submodules/activity_logging.rb +4 -4
- data/lib/sorcery/model/submodules/brute_force_protection.rb +53 -14
- data/lib/sorcery/model/submodules/remember_me.rb +10 -3
- data/lib/sorcery/model/submodules/reset_password.rb +26 -11
- data/lib/sorcery/model/submodules/user_activation.rb +28 -10
- data/lib/sorcery/model/temporary_token.rb +8 -1
- data/lib/sorcery/model.rb +51 -19
- data/lib/sorcery/test_helpers/internal/rails.rb +1 -1
- data/lib/sorcery/test_helpers/rails.rb +2 -2
- data/lib/sorcery.rb +8 -7
- data/sorcery.gemspec +110 -223
- data/spec/Gemfile +1 -1
- data/spec/Gemfile.lock +26 -26
- data/spec/README.md +31 -0
- data/spec/rails3/Gemfile +5 -3
- data/spec/rails3/Gemfile.lock +74 -48
- data/spec/rails3/app/controllers/application_controller.rb +70 -23
- data/spec/rails3/app/mailers/sorcery_mailer.rb +7 -0
- data/spec/rails3/app/views/application/index.html.erb +17 -0
- data/spec/rails3/app/views/sorcery_mailer/send_unlock_token_email.text.erb +1 -0
- data/spec/rails3/config/environments/in_memory.rb +35 -0
- data/spec/rails3/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +2 -0
- data/spec/rails3/spec/controller_activity_logging_spec.rb +33 -3
- data/spec/rails3/spec/controller_brute_force_protection_spec.rb +25 -3
- data/spec/rails3/spec/controller_oauth2_spec.rb +170 -25
- data/spec/rails3/spec/controller_remember_me_spec.rb +37 -6
- data/spec/rails3/spec/controller_session_timeout_spec.rb +4 -4
- data/spec/rails3/spec/controller_spec.rb +60 -2
- data/spec/rails3/spec/integration_spec.rb +23 -0
- data/spec/rails3/spec/spec_helper.rb +6 -5
- data/spec/rails3_mongo_mapper/.gitignore +4 -0
- data/spec/rails3_mongo_mapper/.rspec +1 -0
- data/spec/{sinatra_modular → rails3_mongo_mapper}/Gemfile +6 -5
- data/spec/rails3_mongo_mapper/Gemfile.lock +154 -0
- data/spec/{sinatra → rails3_mongo_mapper}/Rakefile +3 -3
- data/spec/rails3_mongo_mapper/app/controllers/application_controller.rb +108 -0
- data/spec/rails3_mongo_mapper/app/helpers/application_helper.rb +2 -0
- data/spec/rails3_mongo_mapper/app/models/authentication.rb +6 -0
- data/spec/rails3_mongo_mapper/app/models/user.rb +5 -0
- data/spec/rails3_mongo_mapper/app/views/layouts/application.html.erb +14 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.html.erb +17 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_email.text.erb +9 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.html.erb +17 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/activation_success_email.text.erb +9 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.html.erb +16 -0
- data/spec/rails3_mongo_mapper/app/views/sorcery_mailer/reset_password_email.text.erb +8 -0
- data/spec/rails3_mongo_mapper/config/application.rb +51 -0
- data/spec/rails3_mongo_mapper/config/boot.rb +13 -0
- data/spec/rails3_mongo_mapper/config/environment.rb +5 -0
- data/spec/rails3_mongo_mapper/config/environments/development.rb +30 -0
- data/spec/rails3_mongo_mapper/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongo_mapper/config/environments/production.rb +49 -0
- data/spec/rails3_mongo_mapper/config/environments/test.rb +35 -0
- data/spec/rails3_mongo_mapper/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails3_mongo_mapper/config/initializers/inflections.rb +10 -0
- data/spec/rails3_mongo_mapper/config/initializers/mime_types.rb +5 -0
- data/spec/rails3_mongo_mapper/config/initializers/mongo.rb +2 -0
- data/spec/rails3_mongo_mapper/config/initializers/secret_token.rb +7 -0
- data/spec/rails3_mongo_mapper/config/initializers/session_store.rb +8 -0
- data/spec/rails3_mongo_mapper/config/locales/en.yml +5 -0
- data/spec/rails3_mongo_mapper/config/routes.rb +59 -0
- data/spec/rails3_mongo_mapper/config.ru +4 -0
- data/spec/rails3_mongo_mapper/db/schema.rb +23 -0
- data/spec/rails3_mongo_mapper/db/seeds.rb +7 -0
- data/spec/rails3_mongo_mapper/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/public/404.html +26 -0
- data/spec/rails3_mongo_mapper/public/422.html +26 -0
- data/spec/rails3_mongo_mapper/public/500.html +26 -0
- data/spec/rails3_mongo_mapper/public/favicon.ico +0 -0
- data/spec/rails3_mongo_mapper/public/images/rails.png +0 -0
- data/spec/rails3_mongo_mapper/public/javascripts/application.js +2 -0
- data/spec/rails3_mongo_mapper/public/javascripts/controls.js +965 -0
- data/spec/rails3_mongo_mapper/public/javascripts/dragdrop.js +974 -0
- data/spec/rails3_mongo_mapper/public/javascripts/effects.js +1123 -0
- data/spec/rails3_mongo_mapper/public/javascripts/prototype.js +6001 -0
- data/spec/rails3_mongo_mapper/public/javascripts/rails.js +175 -0
- data/spec/rails3_mongo_mapper/public/robots.txt +5 -0
- data/spec/rails3_mongo_mapper/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongo_mapper/script/rails +6 -0
- data/spec/rails3_mongo_mapper/spec/controller_spec.rb +163 -0
- data/spec/rails3_mongo_mapper/spec/spec_helper.orig.rb +27 -0
- data/spec/rails3_mongo_mapper/spec/spec_helper.rb +55 -0
- data/spec/rails3_mongo_mapper/spec/user_activation_spec.rb +9 -0
- data/spec/rails3_mongo_mapper/spec/user_activity_logging_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_brute_force_protection_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_oauth_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_remember_me_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_reset_password_spec.rb +8 -0
- data/spec/rails3_mongo_mapper/spec/user_spec.rb +37 -0
- data/spec/rails3_mongo_mapper/vendor/plugins/.gitkeep +0 -0
- data/spec/rails3_mongoid/Gemfile +2 -1
- data/spec/rails3_mongoid/Gemfile.lock +46 -45
- data/spec/rails3_mongoid/app/controllers/application_controller.rb +5 -0
- data/spec/rails3_mongoid/config/mongoid.yml +1 -1
- data/spec/rails3_mongoid/script/rails +0 -0
- data/spec/rails3_mongoid/spec/controller_activity_logging_spec.rb +105 -0
- data/spec/rails3_mongoid/spec/controller_spec.rb +174 -0
- data/spec/rails3_mongoid/spec/user_spec.rb +1 -0
- data/spec/shared_examples/user_activation_shared_examples.rb +72 -42
- data/spec/shared_examples/user_remember_me_shared_examples.rb +2 -1
- data/spec/shared_examples/user_reset_password_shared_examples.rb +81 -28
- data/spec/shared_examples/user_shared_examples.rb +36 -8
- data/spec/sorcery_crypto_providers_spec.rb +5 -1
- metadata +239 -346
- data/lib/generators/sorcery_migration/sorcery_migration_generator.rb +0 -24
- data/lib/generators/sorcery_migration/templates/activity_logging.rb +0 -17
- data/lib/generators/sorcery_migration/templates/brute_force_protection.rb +0 -11
- data/lib/generators/sorcery_migration/templates/remember_me.rb +0 -15
- data/lib/generators/sorcery_migration/templates/reset_password.rb +0 -13
- data/lib/generators/sorcery_migration/templates/user_activation.rb +0 -17
- data/lib/sorcery/controller/adapters/sinatra.rb +0 -104
- data/lib/sorcery/initializers/initializer.rb +0 -178
- data/lib/sorcery/sinatra.rb +0 -4
- data/lib/sorcery/test_helpers/internal/sinatra.rb +0 -74
- data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +0 -74
- data/lib/sorcery/test_helpers/sinatra.rb +0 -88
- data/spec/rails3/Rakefile.unused +0 -7
- data/spec/rails3/public/index.html +0 -239
- data/spec/sinatra/Gemfile +0 -15
- data/spec/sinatra/Gemfile.lock +0 -117
- data/spec/sinatra/authentication.rb +0 -3
- data/spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
- data/spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
- data/spec/sinatra/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
- data/spec/sinatra/db/migrate/core/20101224223620_create_users.rb +0 -16
- data/spec/sinatra/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/sinatra/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
- data/spec/sinatra/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
- data/spec/sinatra/filters.rb +0 -27
- data/spec/sinatra/modular.rb +0 -157
- data/spec/sinatra/myapp.rb +0 -133
- data/spec/sinatra/spec/controller_activity_logging_spec.rb +0 -85
- data/spec/sinatra/spec/controller_brute_force_protection_spec.rb +0 -70
- data/spec/sinatra/spec/controller_http_basic_auth_spec.rb +0 -53
- data/spec/sinatra/spec/controller_oauth2_spec.rb +0 -99
- data/spec/sinatra/spec/controller_oauth_spec.rb +0 -100
- data/spec/sinatra/spec/controller_remember_me_spec.rb +0 -64
- data/spec/sinatra/spec/controller_session_timeout_spec.rb +0 -57
- data/spec/sinatra/spec/controller_spec.rb +0 -120
- data/spec/sinatra/spec/spec_helper.rb +0 -45
- data/spec/sinatra/user.rb +0 -6
- data/spec/sinatra/views/test_login.erb +0 -4
- data/spec/sinatra_modular/Gemfile.lock +0 -117
- data/spec/sinatra_modular/Rakefile +0 -11
- data/spec/sinatra_modular/authentication.rb +0 -3
- data/spec/sinatra_modular/db/migrate/activation/20101224223622_add_activation_to_users.rb +0 -17
- data/spec/sinatra_modular/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb +0 -17
- data/spec/sinatra_modular/db/migrate/brute_force_protection/20101224223626_add_brute_force_protection_to_users.rb +0 -11
- data/spec/sinatra_modular/db/migrate/core/20101224223620_create_users.rb +0 -16
- data/spec/sinatra_modular/db/migrate/external/20101224223628_create_authentications.rb +0 -14
- data/spec/sinatra_modular/db/migrate/remember_me/20101224223623_add_remember_me_token_to_users.rb +0 -15
- data/spec/sinatra_modular/db/migrate/reset_password/20101224223622_add_reset_password_to_users.rb +0 -13
- data/spec/sinatra_modular/filters.rb +0 -27
- data/spec/sinatra_modular/modular.rb +0 -157
- data/spec/sinatra_modular/myapp.rb +0 -133
- data/spec/sinatra_modular/sorcery_mailer.rb +0 -25
- data/spec/sinatra_modular/spec_modular/controller_activity_logging_spec.rb +0 -85
- data/spec/sinatra_modular/spec_modular/controller_brute_force_protection_spec.rb +0 -70
- data/spec/sinatra_modular/spec_modular/controller_http_basic_auth_spec.rb +0 -53
- data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +0 -99
- data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +0 -100
- data/spec/sinatra_modular/spec_modular/controller_remember_me_spec.rb +0 -64
- data/spec/sinatra_modular/spec_modular/controller_session_timeout_spec.rb +0 -57
- data/spec/sinatra_modular/spec_modular/controller_spec.rb +0 -116
- data/spec/sinatra_modular/spec_modular/spec.opts +0 -2
- data/spec/sinatra_modular/spec_modular/spec_helper.rb +0 -51
- data/spec/sinatra_modular/user.rb +0 -6
- data/spec/sinatra_modular/views/test_login.erb +0 -4
- /data/spec/{sinatra → rails3_mongo_mapper/app/mailers}/sorcery_mailer.rb +0 -0
- /data/spec/{sinatra → rails3_mongo_mapper}/spec/spec.opts +0 -0
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
PATH
|
|
2
|
-
remote:
|
|
2
|
+
remote: ../../
|
|
3
3
|
specs:
|
|
4
|
-
sorcery (0.
|
|
4
|
+
sorcery (0.7.8)
|
|
5
5
|
bcrypt-ruby (~> 3.0.0)
|
|
6
|
-
|
|
7
|
-
oauth (
|
|
8
|
-
oauth2 (
|
|
9
|
-
oauth2 (>= 0.1.1)
|
|
6
|
+
bundler (>= 1.1.0)
|
|
7
|
+
oauth (~> 0.4.4)
|
|
8
|
+
oauth2 (~> 0.5.1)
|
|
10
9
|
|
|
11
10
|
GEM
|
|
12
11
|
remote: http://rubygems.org/
|
|
@@ -38,48 +37,48 @@ GEM
|
|
|
38
37
|
activemodel (= 3.0.3)
|
|
39
38
|
activesupport (= 3.0.3)
|
|
40
39
|
activesupport (3.0.3)
|
|
41
|
-
addressable (2.2.
|
|
40
|
+
addressable (2.2.7)
|
|
42
41
|
archive-tar-minitar (0.5.2)
|
|
43
|
-
arel (2.0.
|
|
44
|
-
bcrypt-ruby (3.0.
|
|
45
|
-
bson (1.
|
|
46
|
-
bson_ext (1.
|
|
42
|
+
arel (2.0.10)
|
|
43
|
+
bcrypt-ruby (3.0.1)
|
|
44
|
+
bson (1.6.0)
|
|
45
|
+
bson_ext (1.6.0)
|
|
46
|
+
bson (= 1.6.0)
|
|
47
47
|
builder (2.1.2)
|
|
48
|
-
columnize (0.3.
|
|
49
|
-
diff-lcs (1.1.
|
|
48
|
+
columnize (0.3.6)
|
|
49
|
+
diff-lcs (1.1.3)
|
|
50
50
|
erubis (2.6.6)
|
|
51
51
|
abstract (>= 1.0.0)
|
|
52
|
-
faraday (0.6
|
|
53
|
-
addressable (~> 2.2
|
|
54
|
-
multipart-post (~> 1.1
|
|
55
|
-
rack (
|
|
56
|
-
i18n (0.
|
|
57
|
-
linecache19 (0.5.
|
|
52
|
+
faraday (0.7.6)
|
|
53
|
+
addressable (~> 2.2)
|
|
54
|
+
multipart-post (~> 1.1)
|
|
55
|
+
rack (~> 1.1)
|
|
56
|
+
i18n (0.6.0)
|
|
57
|
+
linecache19 (0.5.12)
|
|
58
58
|
ruby_core_source (>= 0.1.4)
|
|
59
|
-
mail (2.2.
|
|
59
|
+
mail (2.2.19)
|
|
60
60
|
activesupport (>= 2.3.6)
|
|
61
61
|
i18n (>= 0.4.0)
|
|
62
62
|
mime-types (~> 1.16)
|
|
63
63
|
treetop (~> 1.4.8)
|
|
64
|
-
mime-types (1.
|
|
65
|
-
mongo (1.
|
|
66
|
-
bson (
|
|
67
|
-
mongoid (2.
|
|
68
|
-
activemodel (~> 3.0)
|
|
64
|
+
mime-types (1.17.2)
|
|
65
|
+
mongo (1.6.0)
|
|
66
|
+
bson (= 1.6.0)
|
|
67
|
+
mongoid (2.2.6)
|
|
68
|
+
activemodel (~> 3.0.0)
|
|
69
69
|
mongo (~> 1.3)
|
|
70
70
|
tzinfo (~> 0.3.22)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
multipart-post (1.1.3)
|
|
71
|
+
multi_json (1.1.0)
|
|
72
|
+
multipart-post (1.1.5)
|
|
74
73
|
oauth (0.4.5)
|
|
75
|
-
oauth2 (0.
|
|
76
|
-
faraday (~> 0.
|
|
77
|
-
multi_json (
|
|
78
|
-
polyglot (0.3.
|
|
79
|
-
rack (1.2.
|
|
80
|
-
rack-mount (0.6.
|
|
74
|
+
oauth2 (0.5.2)
|
|
75
|
+
faraday (~> 0.7)
|
|
76
|
+
multi_json (~> 1.0)
|
|
77
|
+
polyglot (0.3.3)
|
|
78
|
+
rack (1.2.5)
|
|
79
|
+
rack-mount (0.6.14)
|
|
81
80
|
rack (>= 1.0.0)
|
|
82
|
-
rack-test (0.5.
|
|
81
|
+
rack-test (0.5.7)
|
|
83
82
|
rack (>= 1.0)
|
|
84
83
|
rails (3.0.3)
|
|
85
84
|
actionmailer (= 3.0.3)
|
|
@@ -94,12 +93,12 @@ GEM
|
|
|
94
93
|
activesupport (= 3.0.3)
|
|
95
94
|
rake (>= 0.8.7)
|
|
96
95
|
thor (~> 0.14.4)
|
|
97
|
-
rake (0.
|
|
96
|
+
rake (0.9.2.2)
|
|
98
97
|
rspec (2.5.0)
|
|
99
98
|
rspec-core (~> 2.5.0)
|
|
100
99
|
rspec-expectations (~> 2.5.0)
|
|
101
100
|
rspec-mocks (~> 2.5.0)
|
|
102
|
-
rspec-core (2.5.
|
|
101
|
+
rspec-core (2.5.2)
|
|
103
102
|
rspec-expectations (2.5.0)
|
|
104
103
|
diff-lcs (~> 1.1.2)
|
|
105
104
|
rspec-mocks (2.5.0)
|
|
@@ -108,7 +107,7 @@ GEM
|
|
|
108
107
|
activesupport (~> 3.0)
|
|
109
108
|
railties (~> 3.0)
|
|
110
109
|
rspec (~> 2.5.0)
|
|
111
|
-
ruby-debug-base19 (0.11.
|
|
110
|
+
ruby-debug-base19 (0.11.25)
|
|
112
111
|
columnize (>= 0.3.1)
|
|
113
112
|
linecache19 (>= 0.5.11)
|
|
114
113
|
ruby_core_source (>= 0.1.4)
|
|
@@ -116,22 +115,24 @@ GEM
|
|
|
116
115
|
columnize (>= 0.3.1)
|
|
117
116
|
linecache19 (>= 0.5.11)
|
|
118
117
|
ruby-debug-base19 (>= 0.11.19)
|
|
119
|
-
ruby_core_source (0.1.
|
|
118
|
+
ruby_core_source (0.1.5)
|
|
120
119
|
archive-tar-minitar (>= 0.5.2)
|
|
121
|
-
simplecov (0.
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
simplecov (0.6.1)
|
|
121
|
+
multi_json (~> 1.0)
|
|
122
|
+
simplecov-html (~> 0.5.3)
|
|
123
|
+
simplecov-html (0.5.3)
|
|
124
124
|
thor (0.14.6)
|
|
125
125
|
timecop (0.3.5)
|
|
126
|
-
treetop (1.4.
|
|
126
|
+
treetop (1.4.10)
|
|
127
|
+
polyglot
|
|
127
128
|
polyglot (>= 0.3.1)
|
|
128
|
-
tzinfo (0.3.
|
|
129
|
-
will_paginate (3.0.pre2)
|
|
129
|
+
tzinfo (0.3.31)
|
|
130
130
|
|
|
131
131
|
PLATFORMS
|
|
132
132
|
ruby
|
|
133
133
|
|
|
134
134
|
DEPENDENCIES
|
|
135
|
+
bcrypt-ruby (~> 3.0.0)
|
|
135
136
|
bson_ext (~> 1.3)
|
|
136
137
|
mongoid (~> 2.0)
|
|
137
138
|
rails (= 3.0.3)
|
|
@@ -16,6 +16,11 @@ class ApplicationController < ActionController::Base
|
|
|
16
16
|
render :nothing => true
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def some_action_making_a_non_persisted_change_to_the_user
|
|
20
|
+
current_user.username = "to_be_ignored"
|
|
21
|
+
render :nothing => true
|
|
22
|
+
end
|
|
23
|
+
|
|
19
24
|
def test_login
|
|
20
25
|
@user = login(params[:username], params[:password])
|
|
21
26
|
render :text => ""
|
|
File without changes
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe ApplicationController do
|
|
4
|
+
|
|
5
|
+
# ----------------- ACTIVITY LOGGING -----------------------
|
|
6
|
+
describe ApplicationController, "with activity logging features" do
|
|
7
|
+
before(:all) do
|
|
8
|
+
sorcery_reload!([:activity_logging])
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
before(:each) do
|
|
12
|
+
create_new_user
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
after(:each) do
|
|
16
|
+
User.delete_all
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
specify { subject.should respond_to(:current_users) }
|
|
20
|
+
|
|
21
|
+
it "'current_users' should be empty when no users are logged in" do
|
|
22
|
+
subject.current_users.size.should == 0
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should log login time on login" do
|
|
26
|
+
now = Time.now.utc
|
|
27
|
+
login_user
|
|
28
|
+
@user.last_login_at.should_not be_nil
|
|
29
|
+
@user.last_login_at.utc.to_s.should >= now.utc.to_s
|
|
30
|
+
@user.last_login_at.utc.to_s.should <= (now.utc+2).to_s
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should log logout time on logout" do
|
|
34
|
+
login_user
|
|
35
|
+
now = Time.now.utc
|
|
36
|
+
logout_user
|
|
37
|
+
User.first.last_logout_at.utc.should_not be_nil
|
|
38
|
+
User.first.last_logout_at.utc.to_s.should >= now.utc.to_s
|
|
39
|
+
User.first.last_logout_at.utc.to_s.should <= (now.utc+2).to_s
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should log last activity time when logged in" do
|
|
43
|
+
login_user
|
|
44
|
+
now = Time.now.utc
|
|
45
|
+
get :some_action
|
|
46
|
+
User.first.last_activity_at.utc.should >= now.utc
|
|
47
|
+
User.first.last_activity_at.utc.should <= (now.utc+2)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should update nothing but activity fields" do
|
|
51
|
+
original_user_name = User.first.username
|
|
52
|
+
login_user
|
|
53
|
+
get :some_action_making_a_non_persisted_change_to_the_user
|
|
54
|
+
User.first.username.should == original_user_name
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "'current_users' should hold the user object when 1 user is logged in" do
|
|
58
|
+
login_user
|
|
59
|
+
get :some_action
|
|
60
|
+
subject.current_users.size.should == 1
|
|
61
|
+
subject.current_users[0].should == @user
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "'current_users' should show all current_users, whether they have logged out before or not." do
|
|
65
|
+
user1 = create_new_user({:username => 'gizmo1', :email => "bla1@bla.com", :password => 'secret1'})
|
|
66
|
+
login_user(user1)
|
|
67
|
+
get :some_action
|
|
68
|
+
clear_user_without_logout
|
|
69
|
+
user2 = create_new_user({:username => 'gizmo2', :email => "bla2@bla.com", :password => 'secret2'})
|
|
70
|
+
login_user(user2)
|
|
71
|
+
get :some_action
|
|
72
|
+
clear_user_without_logout
|
|
73
|
+
user3 = create_new_user({:username => 'gizmo3', :email => "bla3@bla.com", :password => 'secret3'})
|
|
74
|
+
login_user(user3)
|
|
75
|
+
get :some_action
|
|
76
|
+
subject.current_users.size.should == 3
|
|
77
|
+
subject.current_users[0].should == user1
|
|
78
|
+
subject.current_users[1].should == user2
|
|
79
|
+
subject.current_users[2].should == user3
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "should not register login time if configured so" do
|
|
83
|
+
sorcery_controller_property_set(:register_login_time, false)
|
|
84
|
+
now = Time.now.in_time_zone
|
|
85
|
+
login_user
|
|
86
|
+
@user.last_login_at.should be_nil
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "should not register logout time if configured so" do
|
|
90
|
+
sorcery_controller_property_set(:register_logout_time, false)
|
|
91
|
+
now = Time.now.in_time_zone
|
|
92
|
+
login_user
|
|
93
|
+
logout_user
|
|
94
|
+
@user.last_logout_at.should be_nil
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should not register last activity time if configured so" do
|
|
98
|
+
sorcery_controller_property_set(:register_last_activity_time, false)
|
|
99
|
+
now = Time.now.in_time_zone
|
|
100
|
+
login_user
|
|
101
|
+
get :some_action
|
|
102
|
+
@user.last_activity_at.should be_nil
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe ApplicationController do
|
|
4
|
+
|
|
5
|
+
# ----------------- PLUGIN CONFIGURATION -----------------------
|
|
6
|
+
describe ApplicationController, "plugin configuration" do
|
|
7
|
+
before(:all) do
|
|
8
|
+
sorcery_reload!
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
after(:each) do
|
|
12
|
+
Sorcery::Controller::Config.reset!
|
|
13
|
+
sorcery_reload!
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should enable configuration option 'user_class'" do
|
|
17
|
+
sorcery_controller_property_set(:user_class, "TestUser")
|
|
18
|
+
Sorcery::Controller::Config.user_class.should == "TestUser"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should enable configuration option 'not_authenticated_action'" do
|
|
22
|
+
sorcery_controller_property_set(:not_authenticated_action, :my_action)
|
|
23
|
+
Sorcery::Controller::Config.not_authenticated_action.should equal(:my_action)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# ----------------- PLUGIN ACTIVATED -----------------------
|
|
29
|
+
describe ApplicationController, "when activated with sorcery" do
|
|
30
|
+
before(:all) do
|
|
31
|
+
sorcery_reload!
|
|
32
|
+
User.delete_all
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
before(:each) do
|
|
36
|
+
create_new_user
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
after(:each) do
|
|
40
|
+
Sorcery::Controller::Config.reset!
|
|
41
|
+
sorcery_reload!
|
|
42
|
+
User.delete_all
|
|
43
|
+
sorcery_controller_property_set(:user_class, User)
|
|
44
|
+
sorcery_model_property_set(:username_attribute_names, [:username, :email])
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
specify { should respond_to(:login) }
|
|
48
|
+
|
|
49
|
+
specify { should respond_to(:logout) }
|
|
50
|
+
|
|
51
|
+
specify { should respond_to(:logged_in?) }
|
|
52
|
+
|
|
53
|
+
specify { should respond_to(:current_user) }
|
|
54
|
+
|
|
55
|
+
it "login(username,password) should return the user when success and set the session with user.id" do
|
|
56
|
+
get :test_login, :username => 'gizmo', :password => 'secret'
|
|
57
|
+
assigns[:user].should == @user
|
|
58
|
+
session[:user_id].should == @user.id
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "login(email,password) should return the user when success and set the session with user.id" do
|
|
62
|
+
get :test_login, :username => 'bla@bla.com', :password => 'secret'
|
|
63
|
+
assigns[:user].should == @user
|
|
64
|
+
session[:user_id].should == @user.id
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "login(username,password) should return nil and not set the session when failure" do
|
|
68
|
+
get :test_login, :username => 'gizmo', :password => 'opensesame!'
|
|
69
|
+
assigns[:user].should be_nil
|
|
70
|
+
session[:user_id].should be_nil
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "login(username,password) should return nil and not set the session when upper case username" do
|
|
74
|
+
get :test_login, :username => 'GIZMO', :password => 'secret'
|
|
75
|
+
assigns[:user].should be_nil
|
|
76
|
+
session[:user_id].should be_nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it "login(username,password) should return the user and set the session with user.id when upper case username and config is downcase before authenticating" do
|
|
80
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
|
81
|
+
get :test_login, :username => 'GIZMO', :password => 'secret'
|
|
82
|
+
assigns[:user].should == @user
|
|
83
|
+
session[:user_id].should == @user.id
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "login(username,password) should return nil and not set the session when user was created with upper case username, config is default, and log in username is lower case" do
|
|
87
|
+
create_new_user({:username => 'GIZMO1', :email => "bla1@bla.com", :password => 'secret1'})
|
|
88
|
+
get :test_login, :username => 'gizmo1', :password => 'secret1'
|
|
89
|
+
assigns[:user].should be_nil
|
|
90
|
+
session[:user_id].should be_nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "login(username,password) should return the user and set the session with user.id when user was created with upper case username and config is downcase before authenticating" do
|
|
94
|
+
sorcery_model_property_set(:downcase_username_before_authenticating, true)
|
|
95
|
+
create_new_user({:username => 'GIZMO1', :email => "bla1@bla.com", :password => 'secret1'})
|
|
96
|
+
get :test_login, :username => 'gizmo1', :password => 'secret1'
|
|
97
|
+
assigns[:user].should == @user
|
|
98
|
+
session[:user_id].should == @user.id
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "logout should clear the session" do
|
|
102
|
+
cookies[:remember_me_token] = nil
|
|
103
|
+
session[:user_id] = @user.id
|
|
104
|
+
get :test_logout
|
|
105
|
+
session[:user_id].should be_nil
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "logged_in? should return true if logged in" do
|
|
109
|
+
session[:user_id] = @user.id
|
|
110
|
+
subject.logged_in?.should be_true
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "logged_in? should return false if not logged in" do
|
|
114
|
+
session[:user_id] = nil
|
|
115
|
+
subject.logged_in?.should be_false
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it "current_user should return the user instance if logged in" do
|
|
119
|
+
create_new_user
|
|
120
|
+
session[:user_id] = @user.id
|
|
121
|
+
subject.current_user.should == @user
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "current_user should return false if not logged in" do
|
|
125
|
+
session[:user_id] = nil
|
|
126
|
+
subject.current_user.should == false
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
specify { should respond_to(:require_login) }
|
|
130
|
+
|
|
131
|
+
it "should call the configured 'not_authenticated_action' when session[:user_id] isn't found" do
|
|
132
|
+
# If someone passes in a bogus user_id than no big deal, but if a user is deleted
|
|
133
|
+
# and there is still an active session out there for him this causes problems.
|
|
134
|
+
user = User.create(:email => 'test@example.com', :password => 'password')
|
|
135
|
+
session[:user_id] = user.id
|
|
136
|
+
user.destroy
|
|
137
|
+
sorcery_controller_property_set(:not_authenticated_action, :test_not_authenticated_action)
|
|
138
|
+
get :test_logout
|
|
139
|
+
response.body.should == "test_not_authenticated_action"
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "should call the configured 'not_authenticated_action' when authenticate before_filter fails" do
|
|
143
|
+
session[:user_id] = nil
|
|
144
|
+
sorcery_controller_property_set(:not_authenticated_action, :test_not_authenticated_action)
|
|
145
|
+
get :test_logout
|
|
146
|
+
response.body.should == "test_not_authenticated_action"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it "require_login before_filter should save the url that the user originally wanted" do
|
|
150
|
+
get :some_action
|
|
151
|
+
session[:return_to_url].should == "http://test.host/application/some_action"
|
|
152
|
+
response.should redirect_to("http://test.host/")
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "on successful login the user should be redirected to the url he originally wanted" do
|
|
156
|
+
session[:return_to_url] = "http://test.host/some_action"
|
|
157
|
+
post :test_return_to, :username => 'gizmo', :password => 'secret'
|
|
158
|
+
response.should redirect_to("http://test.host/some_action")
|
|
159
|
+
flash[:notice].should == "haha!"
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
# --- login_user(user) ---
|
|
164
|
+
specify { should respond_to(:auto_login) }
|
|
165
|
+
|
|
166
|
+
it "auto_login(user) should login a user instance" do
|
|
167
|
+
create_new_user
|
|
168
|
+
session[:user_id] = nil
|
|
169
|
+
subject.auto_login(@user)
|
|
170
|
+
subject.logged_in?.should be_true
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
end
|
|
@@ -34,9 +34,18 @@ shared_examples_for "rails_3_activation_model" do
|
|
|
34
34
|
sorcery_model_property_set(:activation_success_email_method_name, :my_activation_email)
|
|
35
35
|
User.sorcery_config.activation_success_email_method_name.should equal(:my_activation_email)
|
|
36
36
|
end
|
|
37
|
+
|
|
38
|
+
it "should enable configuration option 'activation_mailer_disabled'" do
|
|
39
|
+
sorcery_model_property_set(:activation_mailer_disabled, :my_activation_mailer_disabled)
|
|
40
|
+
User.sorcery_config.activation_mailer_disabled.should equal(:my_activation_mailer_disabled)
|
|
41
|
+
end
|
|
37
42
|
|
|
38
|
-
it "if mailer is nil
|
|
39
|
-
expect{sorcery_reload!([:user_activation])}.to raise_error(ArgumentError)
|
|
43
|
+
it "if mailer is nil and mailer is enabled, throw exception!" do
|
|
44
|
+
expect{sorcery_reload!([:user_activation], :activation_mailer_disabled => false)}.to raise_error(ArgumentError)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "if mailer is disabled and mailer is nil, do NOT throw exception" do
|
|
48
|
+
expect{sorcery_reload!([:user_activation], :activation_mailer_disabled => true)}.to_not raise_error
|
|
40
49
|
end
|
|
41
50
|
end
|
|
42
51
|
|
|
@@ -64,46 +73,67 @@ shared_examples_for "rails_3_activation_model" do
|
|
|
64
73
|
@user2.activation_state.should == "active"
|
|
65
74
|
User.find_by_activation_token(activation_token).should be_nil
|
|
66
75
|
end
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
context "mailer is enabled" do
|
|
79
|
+
it "should send the user an activation email" do
|
|
80
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
81
|
+
create_new_user
|
|
82
|
+
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "subsequent saves do not send activation email" do
|
|
86
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
87
|
+
@user.username = "Shauli"
|
|
88
|
+
@user.save!
|
|
89
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should send the user an activation success email on successful activation" do
|
|
93
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
94
|
+
@user.activate!
|
|
95
|
+
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "subsequent saves do not send activation success email" do
|
|
99
|
+
@user.activate!
|
|
100
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
101
|
+
@user.username = "Shauli"
|
|
102
|
+
@user.save!
|
|
103
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "activation needed email is optional" do
|
|
107
|
+
sorcery_model_property_set(:activation_needed_email_method_name, nil)
|
|
108
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
109
|
+
create_new_user
|
|
110
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it "activation success email is optional" do
|
|
114
|
+
sorcery_model_property_set(:activation_success_email_method_name, nil)
|
|
115
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
116
|
+
@user.activate!
|
|
117
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
118
|
+
end
|
|
100
119
|
end
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
120
|
+
|
|
121
|
+
context "mailer has been disabled" do
|
|
122
|
+
before(:each) do
|
|
123
|
+
sorcery_reload!([:user_activation], :activation_mailer_disabled => true, :user_activation_mailer => ::SorceryMailer)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it "should not send the user an activation email" do
|
|
127
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
128
|
+
create_new_user
|
|
129
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it "should not send the user an activation success email on successful activation" do
|
|
133
|
+
old_size = ActionMailer::Base.deliveries.size
|
|
134
|
+
@user.activate!
|
|
135
|
+
ActionMailer::Base.deliveries.size.should == old_size
|
|
136
|
+
end
|
|
107
137
|
end
|
|
108
138
|
end
|
|
109
139
|
|
|
@@ -155,7 +185,7 @@ shared_examples_for "rails_3_activation_model" do
|
|
|
155
185
|
it "load_from_activation_token should NOT return user when token is found and expired" do
|
|
156
186
|
sorcery_model_property_set(:activation_token_expiration_period, 0.1)
|
|
157
187
|
create_new_user
|
|
158
|
-
Timecop.travel(Time.now+0.5)
|
|
188
|
+
Timecop.travel(Time.now.in_time_zone+0.5)
|
|
159
189
|
User.load_from_activation_token(@user.activation_token).should == nil
|
|
160
190
|
end
|
|
161
191
|
|
|
@@ -30,10 +30,11 @@ shared_examples_for "rails_3_remember_me_model" do
|
|
|
30
30
|
@user.remember_me_token.should_not be_nil
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
# FIXME: assert on line 37 sometimes fails by a second
|
|
33
34
|
it "should set an expiration based on 'remember_me_for' attribute" do
|
|
34
35
|
sorcery_model_property_set(:remember_me_for, 2 * 60 * 60 * 24)
|
|
35
36
|
@user.remember_me!
|
|
36
|
-
@user.remember_me_token_expires_at.utc.to_s.should == (Time.now + 2 * 60 * 60 * 24).utc.to_s
|
|
37
|
+
@user.remember_me_token_expires_at.utc.to_s.should == (Time.now.in_time_zone + 2 * 60 * 60 * 24).utc.to_s
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
it "should delete the token and expiration on 'forget_me!'" do
|