sorcery 0.5.21 → 0.6.1
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/Gemfile +2 -2
- data/Gemfile.lock +96 -81
- data/README.rdoc +9 -1
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/sorcery/controller/submodules/activity_logging.rb +11 -7
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +8 -5
- data/lib/sorcery/controller/submodules/external.rb +11 -6
- data/lib/sorcery/controller/submodules/http_basic_auth.rb +11 -6
- data/lib/sorcery/controller/submodules/remember_me.rb +14 -5
- data/lib/sorcery/controller/submodules/session_timeout.rb +3 -1
- data/lib/sorcery/controller.rb +12 -9
- data/lib/sorcery/crypto_providers/aes256.rb +8 -5
- data/lib/sorcery/crypto_providers/bcrypt.rb +12 -6
- data/lib/sorcery/crypto_providers/sha256.rb +2 -1
- data/lib/sorcery/crypto_providers/sha512.rb +2 -1
- data/lib/sorcery/initializers/initializer.rb +125 -36
- data/lib/sorcery/model/adapters/active_record.rb +2 -2
- data/lib/sorcery/model/adapters/mongoid.rb +4 -4
- data/lib/sorcery/model/submodules/activity_logging.rb +7 -6
- data/lib/sorcery/model/submodules/brute_force_protection.rb +10 -6
- data/lib/sorcery/model/submodules/external.rb +4 -2
- data/lib/sorcery/model/submodules/remember_me.rb +4 -3
- data/lib/sorcery/model/submodules/reset_password.rb +16 -8
- data/lib/sorcery/model/submodules/user_activation.rb +23 -10
- data/lib/sorcery/model/temporary_token.rb +3 -2
- data/lib/sorcery/model.rb +58 -26
- data/lib/sorcery/test_helpers/internal/rails.rb +6 -2
- data/lib/sorcery/test_helpers/internal/sinatra.rb +1 -1
- data/lib/sorcery/test_helpers/internal/sinatra_modular.rb +1 -1
- data/lib/sorcery/test_helpers/internal.rb +2 -1
- data/sorcery.gemspec +41 -23
- data/spec/Gemfile +2 -2
- data/spec/Gemfile.lock +33 -32
- data/spec/rails3/Gemfile.lock +7 -7
- data/spec/rails3/spec/controller_oauth2_spec.rb +4 -25
- data/spec/rails3/spec/controller_oauth_spec.rb +3 -24
- data/spec/rails3/spec/controller_spec.rb +2 -2
- data/spec/rails3/spec/user_activation_spec.rb +2 -168
- data/spec/rails3/spec/user_activity_logging_spec.rb +2 -30
- data/spec/rails3/spec/user_brute_force_protection_spec.rb +2 -35
- data/spec/rails3/spec/user_oauth_spec.rb +2 -26
- data/spec/rails3/spec/user_remember_me_spec.rb +2 -45
- data/spec/rails3/spec/user_reset_password_spec.rb +3 -168
- data/spec/rails3/spec/user_spec.rb +3 -283
- data/spec/rails3_mongoid/Gemfile.lock +7 -7
- data/spec/rails3_mongoid/app/models/authentication.rb +3 -3
- data/spec/rails3_mongoid/spec/user_activation_spec.rb +2 -171
- data/spec/rails3_mongoid/spec/user_activity_logging_spec.rb +2 -25
- data/spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb +2 -35
- data/spec/rails3_mongoid/spec/user_oauth_spec.rb +2 -28
- data/spec/rails3_mongoid/spec/user_remember_me_spec.rb +2 -45
- data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +2 -176
- data/spec/rails3_mongoid/spec/user_spec.rb +3 -285
- data/spec/shared_examples/controller_oauth2_shared_examples.rb +37 -0
- data/spec/shared_examples/controller_oauth_shared_examples.rb +37 -0
- data/spec/shared_examples/user_activation_shared_examples.rb +173 -0
- data/spec/shared_examples/user_activity_logging_shared_examples.rb +27 -0
- data/spec/shared_examples/user_brute_force_protection_shared_examples.rb +37 -0
- data/spec/shared_examples/user_oauth_shared_examples.rb +31 -0
- data/spec/shared_examples/user_remember_me_shared_examples.rb +47 -0
- data/spec/shared_examples/user_reset_password_shared_examples.rb +177 -0
- data/spec/shared_examples/user_shared_examples.rb +292 -0
- data/spec/sinatra/Gemfile.lock +7 -7
- data/spec/sinatra/spec/controller_oauth2_spec.rb +3 -24
- data/spec/sinatra/spec/controller_oauth_spec.rb +3 -24
- data/spec/sinatra/spec/controller_spec.rb +2 -2
- data/spec/sinatra_modular/Gemfile.lock +7 -7
- data/spec/sinatra_modular/spec_modular/controller_oauth2_spec.rb +3 -24
- data/spec/sinatra_modular/spec_modular/controller_oauth_spec.rb +3 -24
- data/spec/sinatra_modular/spec_modular/controller_spec.rb +2 -2
- metadata +28 -12
|
@@ -4,7 +4,11 @@ module Sorcery
|
|
|
4
4
|
module Rails
|
|
5
5
|
include ::Sorcery::TestHelpers::Rails
|
|
6
6
|
|
|
7
|
-
SUBMODUELS_AUTO_ADDED_CONTROLLER_FILTERS = [
|
|
7
|
+
SUBMODUELS_AUTO_ADDED_CONTROLLER_FILTERS = [
|
|
8
|
+
:register_last_activity_time_to_db,
|
|
9
|
+
:deny_banned_user,
|
|
10
|
+
:validate_session
|
|
11
|
+
]
|
|
8
12
|
|
|
9
13
|
def sorcery_reload!(submodules = [], options = {})
|
|
10
14
|
reload_user_class
|
|
@@ -22,7 +26,7 @@ module Sorcery
|
|
|
22
26
|
::Sorcery::Controller::Config.submodules = submodules
|
|
23
27
|
::Sorcery::Controller::Config.user_class = nil
|
|
24
28
|
ActionController::Base.send(:include,::Sorcery::Controller)
|
|
25
|
-
::Sorcery::Controller::Config.user_class = User
|
|
29
|
+
::Sorcery::Controller::Config.user_class = "User"
|
|
26
30
|
|
|
27
31
|
::Sorcery::Controller::Config.user_config do |user|
|
|
28
32
|
options.each do |property,value|
|
|
@@ -51,7 +51,7 @@ module Sorcery
|
|
|
51
51
|
::Sorcery::Controller::Config.user_class = nil
|
|
52
52
|
::Sinatra::Application.send(:include, Sorcery::Controller::Adapters::Sinatra)
|
|
53
53
|
::Sinatra::Application.send(:include, Sorcery::Controller)
|
|
54
|
-
::Sorcery::Controller::Config.user_class = User
|
|
54
|
+
::Sorcery::Controller::Config.user_class = "User"
|
|
55
55
|
|
|
56
56
|
::Sorcery::Controller::Config.user_config do |user|
|
|
57
57
|
options.each do |property, value|
|
|
@@ -51,7 +51,7 @@ module Sorcery
|
|
|
51
51
|
::Sorcery::Controller::Config.user_class = nil
|
|
52
52
|
::Sinatra::Base.send(:include, Sorcery::Controller::Adapters::Sinatra)
|
|
53
53
|
::Sinatra::Base.send(:include, Sorcery::Controller)
|
|
54
|
-
::Sorcery::Controller::Config.user_class = User
|
|
54
|
+
::Sorcery::Controller::Config.user_class = "User"
|
|
55
55
|
|
|
56
56
|
::Sorcery::Controller::Config.user_config do |user|
|
|
57
57
|
options.each do |property, value|
|
|
@@ -15,7 +15,8 @@ module Sorcery
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# a patch to fix a bug in testing that happens when you 'destroy' a session twice.
|
|
18
|
-
# After the first destroy, the session is an ordinary hash, and then when destroy
|
|
18
|
+
# After the first destroy, the session is an ordinary hash, and then when destroy
|
|
19
|
+
# is called again there's an exception.
|
|
19
20
|
class ::Hash
|
|
20
21
|
def destroy
|
|
21
22
|
clear
|
data/sorcery.gemspec
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
|
-
s.name =
|
|
8
|
-
s.version = "0.
|
|
7
|
+
s.name = "sorcery"
|
|
8
|
+
s.version = "0.6.1"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Noam Ben Ari"]
|
|
12
|
-
s.date =
|
|
13
|
-
s.description =
|
|
14
|
-
s.email =
|
|
12
|
+
s.date = "2011-09-02"
|
|
13
|
+
s.description = "Provides common authentication needs such as signing in/out, activating by email and resetting password."
|
|
14
|
+
s.email = "nbenari@gmail.com"
|
|
15
15
|
s.extra_rdoc_files = [
|
|
16
16
|
"LICENSE.txt",
|
|
17
17
|
"README.rdoc"
|
|
@@ -218,6 +218,15 @@ Gem::Specification.new do |s|
|
|
|
218
218
|
"spec/rails3_mongoid/spec/user_reset_password_spec.rb",
|
|
219
219
|
"spec/rails3_mongoid/spec/user_spec.rb",
|
|
220
220
|
"spec/rails3_mongoid/vendor/plugins/.gitkeep",
|
|
221
|
+
"spec/shared_examples/controller_oauth2_shared_examples.rb",
|
|
222
|
+
"spec/shared_examples/controller_oauth_shared_examples.rb",
|
|
223
|
+
"spec/shared_examples/user_activation_shared_examples.rb",
|
|
224
|
+
"spec/shared_examples/user_activity_logging_shared_examples.rb",
|
|
225
|
+
"spec/shared_examples/user_brute_force_protection_shared_examples.rb",
|
|
226
|
+
"spec/shared_examples/user_oauth_shared_examples.rb",
|
|
227
|
+
"spec/shared_examples/user_remember_me_shared_examples.rb",
|
|
228
|
+
"spec/shared_examples/user_reset_password_shared_examples.rb",
|
|
229
|
+
"spec/shared_examples/user_shared_examples.rb",
|
|
221
230
|
"spec/sinatra/Gemfile",
|
|
222
231
|
"spec/sinatra/Gemfile.lock",
|
|
223
232
|
"spec/sinatra/Rakefile",
|
|
@@ -276,11 +285,11 @@ Gem::Specification.new do |s|
|
|
|
276
285
|
"spec/spec.opts",
|
|
277
286
|
"spec/spec_helper.rb"
|
|
278
287
|
]
|
|
279
|
-
s.homepage =
|
|
288
|
+
s.homepage = "http://github.com/NoamB/sorcery"
|
|
280
289
|
s.licenses = ["MIT"]
|
|
281
290
|
s.require_paths = ["lib"]
|
|
282
|
-
s.rubygems_version =
|
|
283
|
-
s.summary =
|
|
291
|
+
s.rubygems_version = "1.8.10"
|
|
292
|
+
s.summary = "Magical authentication for Rails 3 applications"
|
|
284
293
|
s.test_files = [
|
|
285
294
|
"spec/rails3/app/controllers/application_controller.rb",
|
|
286
295
|
"spec/rails3/app/helpers/application_helper.rb",
|
|
@@ -355,6 +364,15 @@ Gem::Specification.new do |s|
|
|
|
355
364
|
"spec/rails3_mongoid/spec/user_remember_me_spec.rb",
|
|
356
365
|
"spec/rails3_mongoid/spec/user_reset_password_spec.rb",
|
|
357
366
|
"spec/rails3_mongoid/spec/user_spec.rb",
|
|
367
|
+
"spec/shared_examples/controller_oauth2_shared_examples.rb",
|
|
368
|
+
"spec/shared_examples/controller_oauth_shared_examples.rb",
|
|
369
|
+
"spec/shared_examples/user_activation_shared_examples.rb",
|
|
370
|
+
"spec/shared_examples/user_activity_logging_shared_examples.rb",
|
|
371
|
+
"spec/shared_examples/user_brute_force_protection_shared_examples.rb",
|
|
372
|
+
"spec/shared_examples/user_oauth_shared_examples.rb",
|
|
373
|
+
"spec/shared_examples/user_remember_me_shared_examples.rb",
|
|
374
|
+
"spec/shared_examples/user_reset_password_shared_examples.rb",
|
|
375
|
+
"spec/shared_examples/user_shared_examples.rb",
|
|
358
376
|
"spec/sinatra/authentication.rb",
|
|
359
377
|
"spec/sinatra/db/migrate/activation/20101224223622_add_activation_to_users.rb",
|
|
360
378
|
"spec/sinatra/db/migrate/activity_logging/20101224223624_add_activity_logging_to_users.rb",
|
|
@@ -407,8 +425,8 @@ Gem::Specification.new do |s|
|
|
|
407
425
|
s.specification_version = 3
|
|
408
426
|
|
|
409
427
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
410
|
-
s.add_runtime_dependency(%q<oauth>, ["
|
|
411
|
-
s.add_runtime_dependency(%q<oauth2>, ["
|
|
428
|
+
s.add_runtime_dependency(%q<oauth>, ["~> 0.4.4"])
|
|
429
|
+
s.add_runtime_dependency(%q<oauth2>, ["~> 0.4.1"])
|
|
412
430
|
s.add_development_dependency(%q<rails>, [">= 3.0.0"])
|
|
413
431
|
s.add_development_dependency(%q<json>, [">= 1.5.1"])
|
|
414
432
|
s.add_development_dependency(%q<mongoid>, ["~> 2.0"])
|
|
@@ -422,12 +440,12 @@ Gem::Specification.new do |s|
|
|
|
422
440
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
423
441
|
s.add_development_dependency(%q<simplecov>, [">= 0.3.8"])
|
|
424
442
|
s.add_development_dependency(%q<timecop>, [">= 0"])
|
|
425
|
-
s.add_runtime_dependency(%q<bcrypt-ruby>, ["~>
|
|
426
|
-
s.add_runtime_dependency(%q<oauth>, ["
|
|
427
|
-
s.add_runtime_dependency(%q<oauth2>, ["
|
|
443
|
+
s.add_runtime_dependency(%q<bcrypt-ruby>, ["~> 3.0.0"])
|
|
444
|
+
s.add_runtime_dependency(%q<oauth>, ["~> 0.4.4"])
|
|
445
|
+
s.add_runtime_dependency(%q<oauth2>, ["~> 0.4.1"])
|
|
428
446
|
else
|
|
429
|
-
s.add_dependency(%q<oauth>, ["
|
|
430
|
-
s.add_dependency(%q<oauth2>, ["
|
|
447
|
+
s.add_dependency(%q<oauth>, ["~> 0.4.4"])
|
|
448
|
+
s.add_dependency(%q<oauth2>, ["~> 0.4.1"])
|
|
431
449
|
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
|
432
450
|
s.add_dependency(%q<json>, [">= 1.5.1"])
|
|
433
451
|
s.add_dependency(%q<mongoid>, ["~> 2.0"])
|
|
@@ -441,13 +459,13 @@ Gem::Specification.new do |s|
|
|
|
441
459
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
442
460
|
s.add_dependency(%q<simplecov>, [">= 0.3.8"])
|
|
443
461
|
s.add_dependency(%q<timecop>, [">= 0"])
|
|
444
|
-
s.add_dependency(%q<bcrypt-ruby>, ["~>
|
|
445
|
-
s.add_dependency(%q<oauth>, ["
|
|
446
|
-
s.add_dependency(%q<oauth2>, ["
|
|
462
|
+
s.add_dependency(%q<bcrypt-ruby>, ["~> 3.0.0"])
|
|
463
|
+
s.add_dependency(%q<oauth>, ["~> 0.4.4"])
|
|
464
|
+
s.add_dependency(%q<oauth2>, ["~> 0.4.1"])
|
|
447
465
|
end
|
|
448
466
|
else
|
|
449
|
-
s.add_dependency(%q<oauth>, ["
|
|
450
|
-
s.add_dependency(%q<oauth2>, ["
|
|
467
|
+
s.add_dependency(%q<oauth>, ["~> 0.4.4"])
|
|
468
|
+
s.add_dependency(%q<oauth2>, ["~> 0.4.1"])
|
|
451
469
|
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
|
452
470
|
s.add_dependency(%q<json>, [">= 1.5.1"])
|
|
453
471
|
s.add_dependency(%q<mongoid>, ["~> 2.0"])
|
|
@@ -461,9 +479,9 @@ Gem::Specification.new do |s|
|
|
|
461
479
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
|
462
480
|
s.add_dependency(%q<simplecov>, [">= 0.3.8"])
|
|
463
481
|
s.add_dependency(%q<timecop>, [">= 0"])
|
|
464
|
-
s.add_dependency(%q<bcrypt-ruby>, ["~>
|
|
465
|
-
s.add_dependency(%q<oauth>, ["
|
|
466
|
-
s.add_dependency(%q<oauth2>, ["
|
|
482
|
+
s.add_dependency(%q<bcrypt-ruby>, ["~> 3.0.0"])
|
|
483
|
+
s.add_dependency(%q<oauth>, ["~> 0.4.4"])
|
|
484
|
+
s.add_dependency(%q<oauth2>, ["~> 0.4.1"])
|
|
467
485
|
end
|
|
468
486
|
end
|
|
469
487
|
|
data/spec/Gemfile
CHANGED
|
@@ -3,8 +3,8 @@ source 'http://rubygems.org'
|
|
|
3
3
|
gem "rails", '3.0.3'
|
|
4
4
|
gem 'bcrypt-ruby', :require => 'bcrypt'
|
|
5
5
|
gem "sorcery", '>= 0.1.0', :path => '../'
|
|
6
|
-
gem 'oauth', "
|
|
7
|
-
gem 'oauth2', "
|
|
6
|
+
gem 'oauth', "~> 0.4.4"
|
|
7
|
+
gem 'oauth2', "~> 0.4.1"
|
|
8
8
|
group :development do
|
|
9
9
|
gem "rspec", "~> 2.5.0"
|
|
10
10
|
gem 'ruby-debug19'
|
data/spec/Gemfile.lock
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../
|
|
3
3
|
specs:
|
|
4
|
-
sorcery (0.
|
|
5
|
-
bcrypt-ruby (~>
|
|
4
|
+
sorcery (0.6.0)
|
|
5
|
+
bcrypt-ruby (~> 3.0.0)
|
|
6
6
|
oauth (>= 0.4.4)
|
|
7
7
|
oauth (>= 0.4.4)
|
|
8
8
|
oauth2 (>= 0.1.1)
|
|
@@ -38,39 +38,39 @@ GEM
|
|
|
38
38
|
activemodel (= 3.0.3)
|
|
39
39
|
activesupport (= 3.0.3)
|
|
40
40
|
activesupport (3.0.3)
|
|
41
|
-
addressable (2.2.
|
|
41
|
+
addressable (2.2.6)
|
|
42
42
|
archive-tar-minitar (0.5.2)
|
|
43
|
-
arel (2.0.
|
|
44
|
-
bcrypt-ruby (
|
|
43
|
+
arel (2.0.10)
|
|
44
|
+
bcrypt-ruby (3.0.0)
|
|
45
45
|
builder (2.1.2)
|
|
46
|
-
columnize (0.3.
|
|
47
|
-
diff-lcs (1.1.
|
|
46
|
+
columnize (0.3.4)
|
|
47
|
+
diff-lcs (1.1.3)
|
|
48
48
|
erubis (2.6.6)
|
|
49
49
|
abstract (>= 1.0.0)
|
|
50
|
-
faraday (0.
|
|
50
|
+
faraday (0.6.1)
|
|
51
51
|
addressable (~> 2.2.4)
|
|
52
52
|
multipart-post (~> 1.1.0)
|
|
53
53
|
rack (< 2, >= 1.1.0)
|
|
54
|
-
i18n (0.
|
|
55
|
-
linecache19 (0.5.
|
|
54
|
+
i18n (0.6.0)
|
|
55
|
+
linecache19 (0.5.12)
|
|
56
56
|
ruby_core_source (>= 0.1.4)
|
|
57
|
-
mail (2.2.
|
|
57
|
+
mail (2.2.19)
|
|
58
58
|
activesupport (>= 2.3.6)
|
|
59
59
|
i18n (>= 0.4.0)
|
|
60
60
|
mime-types (~> 1.16)
|
|
61
61
|
treetop (~> 1.4.8)
|
|
62
62
|
mime-types (1.16)
|
|
63
|
-
multi_json (
|
|
64
|
-
multipart-post (1.1.
|
|
65
|
-
oauth (0.4.
|
|
66
|
-
oauth2 (0.
|
|
67
|
-
faraday (~> 0.
|
|
68
|
-
multi_json (
|
|
69
|
-
polyglot (0.3.
|
|
70
|
-
rack (1.2.
|
|
71
|
-
rack-mount (0.6.
|
|
63
|
+
multi_json (1.0.3)
|
|
64
|
+
multipart-post (1.1.3)
|
|
65
|
+
oauth (0.4.5)
|
|
66
|
+
oauth2 (0.4.1)
|
|
67
|
+
faraday (~> 0.6.1)
|
|
68
|
+
multi_json (>= 0.0.5)
|
|
69
|
+
polyglot (0.3.2)
|
|
70
|
+
rack (1.2.3)
|
|
71
|
+
rack-mount (0.6.14)
|
|
72
72
|
rack (>= 1.0.0)
|
|
73
|
-
rack-test (0.5.
|
|
73
|
+
rack-test (0.5.7)
|
|
74
74
|
rack (>= 1.0)
|
|
75
75
|
rails (3.0.3)
|
|
76
76
|
actionmailer (= 3.0.3)
|
|
@@ -85,16 +85,16 @@ GEM
|
|
|
85
85
|
activesupport (= 3.0.3)
|
|
86
86
|
rake (>= 0.8.7)
|
|
87
87
|
thor (~> 0.14.4)
|
|
88
|
-
rake (0.
|
|
88
|
+
rake (0.9.2)
|
|
89
89
|
rspec (2.5.0)
|
|
90
90
|
rspec-core (~> 2.5.0)
|
|
91
91
|
rspec-expectations (~> 2.5.0)
|
|
92
92
|
rspec-mocks (~> 2.5.0)
|
|
93
|
-
rspec-core (2.5.
|
|
93
|
+
rspec-core (2.5.2)
|
|
94
94
|
rspec-expectations (2.5.0)
|
|
95
95
|
diff-lcs (~> 1.1.2)
|
|
96
96
|
rspec-mocks (2.5.0)
|
|
97
|
-
ruby-debug-base19 (0.11.
|
|
97
|
+
ruby-debug-base19 (0.11.25)
|
|
98
98
|
columnize (>= 0.3.1)
|
|
99
99
|
linecache19 (>= 0.5.11)
|
|
100
100
|
ruby_core_source (>= 0.1.4)
|
|
@@ -102,23 +102,24 @@ GEM
|
|
|
102
102
|
columnize (>= 0.3.1)
|
|
103
103
|
linecache19 (>= 0.5.11)
|
|
104
104
|
ruby-debug-base19 (>= 0.11.19)
|
|
105
|
-
ruby_core_source (0.1.
|
|
105
|
+
ruby_core_source (0.1.5)
|
|
106
106
|
archive-tar-minitar (>= 0.5.2)
|
|
107
|
-
simplecov (0.
|
|
108
|
-
simplecov-html (
|
|
109
|
-
simplecov-html (0.
|
|
107
|
+
simplecov (0.4.2)
|
|
108
|
+
simplecov-html (~> 0.4.4)
|
|
109
|
+
simplecov-html (0.4.5)
|
|
110
110
|
thor (0.14.6)
|
|
111
|
-
treetop (1.4.
|
|
111
|
+
treetop (1.4.10)
|
|
112
|
+
polyglot
|
|
112
113
|
polyglot (>= 0.3.1)
|
|
113
|
-
tzinfo (0.3.
|
|
114
|
+
tzinfo (0.3.29)
|
|
114
115
|
|
|
115
116
|
PLATFORMS
|
|
116
117
|
ruby
|
|
117
118
|
|
|
118
119
|
DEPENDENCIES
|
|
119
120
|
bcrypt-ruby
|
|
120
|
-
oauth (
|
|
121
|
-
oauth2 (
|
|
121
|
+
oauth (~> 0.4.4)
|
|
122
|
+
oauth2 (~> 0.4.1)
|
|
122
123
|
rails (= 3.0.3)
|
|
123
124
|
rspec (~> 2.5.0)
|
|
124
125
|
ruby-debug19
|
data/spec/rails3/Gemfile.lock
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: ../../../
|
|
3
3
|
specs:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
bcrypt-ruby (~> 2.1.4)
|
|
4
|
+
sorcery (0.6.0)
|
|
5
|
+
bcrypt-ruby (~> 3.0.0)
|
|
7
6
|
oauth (>= 0.4.4)
|
|
8
7
|
oauth (>= 0.4.4)
|
|
9
8
|
oauth2 (>= 0.1.1)
|
|
@@ -39,10 +38,10 @@ GEM
|
|
|
39
38
|
activemodel (= 3.0.3)
|
|
40
39
|
activesupport (= 3.0.3)
|
|
41
40
|
activesupport (3.0.3)
|
|
42
|
-
addressable (2.2.
|
|
41
|
+
addressable (2.2.6)
|
|
43
42
|
archive-tar-minitar (0.5.2)
|
|
44
43
|
arel (2.0.6)
|
|
45
|
-
bcrypt-ruby (
|
|
44
|
+
bcrypt-ruby (3.0.0)
|
|
46
45
|
builder (2.1.2)
|
|
47
46
|
columnize (0.3.2)
|
|
48
47
|
diff-lcs (1.1.2)
|
|
@@ -61,8 +60,9 @@ GEM
|
|
|
61
60
|
mime-types (~> 1.16)
|
|
62
61
|
treetop (~> 1.4.8)
|
|
63
62
|
mime-types (1.16)
|
|
64
|
-
multi_json (1.0.
|
|
65
|
-
multipart-post (1.1.
|
|
63
|
+
multi_json (1.0.3)
|
|
64
|
+
multipart-post (1.1.3)
|
|
65
|
+
oauth (0.4.5)
|
|
66
66
|
oauth2 (0.4.1)
|
|
67
67
|
faraday (~> 0.6.1)
|
|
68
68
|
multi_json (>= 0.0.5)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/controller_oauth2_shared_examples')
|
|
2
3
|
|
|
3
4
|
def stub_all_oauth2_requests!
|
|
4
5
|
@client = OAuth2::Client.new("key","secret", :site => "http://myapi.com")
|
|
5
6
|
OAuth2::Client.stub!(:new).and_return(@client)
|
|
6
|
-
@acc_token = OAuth2::AccessToken.new(@client, "
|
|
7
|
+
@acc_token = OAuth2::AccessToken.new(@client, "asd", {})
|
|
7
8
|
@webby = @client.web_server
|
|
8
9
|
OAuth2::Strategy::WebServer.stub!(:new).and_return(@webby)
|
|
9
10
|
@webby.stub!(:get_access_token).and_return(@acc_token)
|
|
@@ -58,30 +59,8 @@ describe ApplicationController do
|
|
|
58
59
|
end
|
|
59
60
|
end
|
|
60
61
|
|
|
61
|
-
describe ApplicationController
|
|
62
|
-
|
|
63
|
-
stub_all_oauth2_requests!
|
|
64
|
-
User.delete_all
|
|
65
|
-
Authentication.delete_all
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "should create a new user" do
|
|
69
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
70
|
-
sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "name"})
|
|
71
|
-
lambda do
|
|
72
|
-
get :test_create_from_provider, :provider => "facebook"
|
|
73
|
-
end.should change(User, :count).by(1)
|
|
74
|
-
User.first.username.should == "Noam Ben Ari"
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "should support nested attributes" do
|
|
78
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
79
|
-
sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "hometown/name"})
|
|
80
|
-
lambda do
|
|
81
|
-
get :test_create_from_provider, :provider => "facebook"
|
|
82
|
-
end.should change(User, :count).by(1)
|
|
83
|
-
User.first.username.should == "Haifa, Israel"
|
|
84
|
-
end
|
|
62
|
+
describe ApplicationController do
|
|
63
|
+
it_behaves_like "oauth2_controller"
|
|
85
64
|
end
|
|
86
65
|
|
|
87
66
|
describe ApplicationController, "OAuth with User Activation features" do
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/controller_oauth_shared_examples')
|
|
2
3
|
require 'ostruct'
|
|
3
4
|
|
|
4
5
|
def stub_all_oauth_requests!
|
|
@@ -64,30 +65,8 @@ describe ApplicationController do
|
|
|
64
65
|
end
|
|
65
66
|
end
|
|
66
67
|
|
|
67
|
-
describe ApplicationController
|
|
68
|
-
|
|
69
|
-
stub_all_oauth_requests!
|
|
70
|
-
User.delete_all
|
|
71
|
-
Authentication.delete_all
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "should create a new user" do
|
|
75
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
76
|
-
sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
|
|
77
|
-
lambda do
|
|
78
|
-
get :test_create_from_provider, :provider => "twitter"
|
|
79
|
-
end.should change(User, :count).by(1)
|
|
80
|
-
User.first.username.should == "nbenari"
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "should support nested attributes" do
|
|
84
|
-
sorcery_model_property_set(:authentications_class, Authentication)
|
|
85
|
-
sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "status/text"})
|
|
86
|
-
lambda do
|
|
87
|
-
get :test_create_from_provider, :provider => "twitter"
|
|
88
|
-
end.should change(User, :count).by(1)
|
|
89
|
-
User.first.username.should == "coming soon to sorcery gem: twitter and facebook authentication support."
|
|
90
|
-
end
|
|
68
|
+
describe ApplicationController do
|
|
69
|
+
it_behaves_like "oauth_controller"
|
|
91
70
|
end
|
|
92
71
|
|
|
93
72
|
describe ApplicationController, "using OAuth with User Activation features" do
|
|
@@ -14,8 +14,8 @@ describe ApplicationController do
|
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "should enable configuration option 'user_class'" do
|
|
17
|
-
sorcery_controller_property_set(:user_class, TestUser)
|
|
18
|
-
Sorcery::Controller::Config.user_class.should
|
|
17
|
+
sorcery_controller_property_set(:user_class, "TestUser")
|
|
18
|
+
Sorcery::Controller::Config.user_class.should == "TestUser"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "should enable configuration option 'not_authenticated_action'" do
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/../app/mailers/sorcery_mailer')
|
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/user_activation_shared_examples')
|
|
3
4
|
|
|
4
5
|
describe "User with activation submodule" do
|
|
5
6
|
before(:all) do
|
|
@@ -10,173 +11,6 @@ describe "User with activation submodule" do
|
|
|
10
11
|
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/activation")
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
describe User, "loaded plugin configuration" do
|
|
15
|
-
before(:all) do
|
|
16
|
-
sorcery_reload!([:user_activation], :user_activation_mailer => ::SorceryMailer)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
after(:each) do
|
|
20
|
-
User.sorcery_config.reset!
|
|
21
|
-
sorcery_reload!([:user_activation], :user_activation_mailer => ::SorceryMailer)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "should enable configuration option 'activation_state_attribute_name'" do
|
|
25
|
-
sorcery_model_property_set(:activation_state_attribute_name, :status)
|
|
26
|
-
User.sorcery_config.activation_state_attribute_name.should equal(:status)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "should enable configuration option 'activation_token_attribute_name'" do
|
|
30
|
-
sorcery_model_property_set(:activation_token_attribute_name, :code)
|
|
31
|
-
User.sorcery_config.activation_token_attribute_name.should equal(:code)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
it "should enable configuration option 'user_activation_mailer'" do
|
|
35
|
-
sorcery_model_property_set(:user_activation_mailer, TestMailer)
|
|
36
|
-
User.sorcery_config.user_activation_mailer.should equal(TestMailer)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "should enable configuration option 'activation_needed_email_method_name'" do
|
|
40
|
-
sorcery_model_property_set(:activation_needed_email_method_name, :my_activation_email)
|
|
41
|
-
User.sorcery_config.activation_needed_email_method_name.should equal(:my_activation_email)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "should enable configuration option 'activation_success_email_method_name'" do
|
|
45
|
-
sorcery_model_property_set(:activation_success_email_method_name, :my_activation_email)
|
|
46
|
-
User.sorcery_config.activation_success_email_method_name.should equal(:my_activation_email)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "if mailer is nil on activation, throw exception!" do
|
|
50
|
-
expect{sorcery_reload!([:user_activation])}.to raise_error(ArgumentError)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
# ----------------- ACTIVATION PROCESS -----------------------
|
|
55
|
-
describe User, "activation process" do
|
|
56
|
-
before(:all) do
|
|
57
|
-
sorcery_reload!([:user_activation], :user_activation_mailer => ::SorceryMailer)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
before(:each) do
|
|
61
|
-
create_new_user
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "should initialize user state to 'pending'" do
|
|
65
|
-
@user.activation_state.should == "pending"
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
specify { @user.should respond_to(:activate!) }
|
|
69
|
-
|
|
70
|
-
it "should clear activation code and change state to 'active' on activation" do
|
|
71
|
-
activation_token = @user.activation_token
|
|
72
|
-
@user.activate!
|
|
73
|
-
@user2 = User.find(@user.id) # go to db to make sure it was saved and not just in memory
|
|
74
|
-
@user2.activation_token.should be_nil
|
|
75
|
-
@user2.activation_state.should == "active"
|
|
76
|
-
User.find_by_activation_token(activation_token).should be_nil
|
|
77
|
-
end
|
|
78
|
-
|
|
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
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
describe User, "prevent non-active login feature" do
|
|
122
|
-
before(:all) do
|
|
123
|
-
sorcery_reload!([:user_activation], :user_activation_mailer => ::SorceryMailer)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it "should not allow a non-active user to authenticate" do
|
|
127
|
-
create_new_user
|
|
128
|
-
User.authenticate(@user.username,'secret').should be_false
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it "should allow a non-active user to authenticate if configured so" do
|
|
132
|
-
create_new_user
|
|
133
|
-
sorcery_model_property_set(:prevent_non_active_users_to_login, false)
|
|
134
|
-
User.authenticate(@user.username,'secret').should be_true
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
describe User, "load_from_activation_token" do
|
|
139
|
-
before(:all) do
|
|
140
|
-
sorcery_reload!([:user_activation], :user_activation_mailer => ::SorceryMailer)
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
after(:each) do
|
|
144
|
-
Timecop.return
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
it "load_from_activation_token should return user when token is found" do
|
|
148
|
-
create_new_user
|
|
149
|
-
User.load_from_activation_token(@user.activation_token).should == @user
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
it "load_from_activation_token should NOT return user when token is NOT found" do
|
|
153
|
-
create_new_user
|
|
154
|
-
User.load_from_activation_token("a").should == nil
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
it "load_from_activation_token should return user when token is found and not expired" do
|
|
158
|
-
sorcery_model_property_set(:activation_token_expiration_period, 500)
|
|
159
|
-
create_new_user
|
|
160
|
-
User.load_from_activation_token(@user.activation_token).should == @user
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
it "load_from_activation_token should NOT return user when token is found and expired" do
|
|
164
|
-
sorcery_model_property_set(:activation_token_expiration_period, 0.1)
|
|
165
|
-
create_new_user
|
|
166
|
-
Timecop.travel(Time.now+0.5)
|
|
167
|
-
User.load_from_activation_token(@user.activation_token).should == nil
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
it "load_from_activation_token should return nil if token is blank" do
|
|
171
|
-
User.load_from_activation_token(nil).should == nil
|
|
172
|
-
User.load_from_activation_token("").should == nil
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
it "load_from_activation_token should always be valid if expiration period is nil" do
|
|
176
|
-
sorcery_model_property_set(:activation_token_expiration_period, nil)
|
|
177
|
-
create_new_user
|
|
178
|
-
User.load_from_activation_token(@user.activation_token).should == @user
|
|
179
|
-
end
|
|
180
|
-
end
|
|
14
|
+
it_behaves_like "rails_3_activation_model"
|
|
181
15
|
|
|
182
16
|
end
|
|
@@ -1,36 +1,8 @@
|
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../shared_examples/user_activity_logging_shared_examples')
|
|
2
3
|
|
|
3
4
|
describe "User with activity logging submodule" do
|
|
4
|
-
before(:all) do
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
after(:all) do
|
|
8
|
-
end
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
describe User, "loaded plugin configuration" do
|
|
12
|
-
before(:all) do
|
|
13
|
-
sorcery_reload!([:activity_logging])
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
after(:each) do
|
|
17
|
-
User.sorcery_config.reset!
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "should allow configuration option 'last_login_at_attribute_name'" do
|
|
21
|
-
sorcery_model_property_set(:last_login_at_attribute_name, :login_time)
|
|
22
|
-
User.sorcery_config.last_login_at_attribute_name.should equal(:login_time)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it "should allow configuration option 'last_logout_at_attribute_name'" do
|
|
26
|
-
sorcery_model_property_set(:last_logout_at_attribute_name, :logout_time)
|
|
27
|
-
User.sorcery_config.last_logout_at_attribute_name.should equal(:logout_time)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "should allow configuration option 'last_activity_at_attribute_name'" do
|
|
31
|
-
sorcery_model_property_set(:last_activity_at_attribute_name, :activity_time)
|
|
32
|
-
User.sorcery_config.last_activity_at_attribute_name.should equal(:activity_time)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
6
|
+
it_behaves_like "rails_3_activity_logging_model"
|
|
35
7
|
|
|
36
8
|
end
|