sorcery 0.4.1 → 0.5.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.
- data/Gemfile +5 -2
- data/Gemfile.lock +12 -0
- data/README.rdoc +12 -7
- data/VERSION +1 -1
- data/lib/sorcery/controller/submodules/brute_force_protection.rb +1 -1
- data/lib/sorcery/crypto_providers/bcrypt.rb +2 -4
- data/lib/sorcery/crypto_providers/common.rb +2 -2
- data/lib/sorcery/engine.rb +0 -4
- data/lib/sorcery/initializers/initializer.rb +2 -0
- data/lib/sorcery/model/adapters/active_record.rb +28 -0
- data/lib/sorcery/model/adapters/mongoid.rb +59 -0
- data/lib/sorcery/model/submodules/activity_logging.rb +12 -3
- data/lib/sorcery/model/submodules/brute_force_protection.rb +6 -1
- data/lib/sorcery/model/submodules/external.rb +1 -0
- data/lib/sorcery/model/submodules/remember_me.rb +15 -1
- data/lib/sorcery/model/submodules/reset_password.rb +10 -3
- data/lib/sorcery/model/submodules/user_activation.rb +11 -1
- data/lib/sorcery/model/temporary_token.rb +1 -1
- data/lib/sorcery/model.rb +34 -6
- data/lib/sorcery/sinatra.rb +0 -1
- data/lib/sorcery/test_helpers/internal/rails.rb +52 -0
- data/lib/sorcery/test_helpers/internal/sinatra.rb +74 -0
- data/lib/sorcery/test_helpers/internal.rb +56 -0
- data/lib/sorcery/test_helpers/rails.rb +5 -43
- data/lib/sorcery/test_helpers/sinatra.rb +62 -102
- data/lib/sorcery/test_helpers.rb +0 -47
- data/lib/sorcery.rb +29 -1
- data/sorcery.gemspec +110 -10
- data/spec/Gemfile +1 -1
- data/spec/Gemfile.lock +12 -4
- data/spec/rails3/Gemfile +1 -1
- data/spec/rails3/Gemfile.lock +6 -6
- data/spec/rails3/spec/controller_activity_logging_spec.rb +2 -4
- data/spec/rails3/spec/controller_oauth_spec.rb +3 -3
- data/spec/rails3/spec/controller_session_timeout_spec.rb +20 -19
- data/spec/rails3/spec/controller_spec.rb +6 -16
- data/spec/rails3/spec/spec_helper.rb +2 -2
- data/spec/rails3/spec/user_activation_spec.rb +2 -12
- data/spec/rails3/spec/user_brute_force_protection_spec.rb +2 -30
- data/spec/rails3/spec/user_remember_me_spec.rb +3 -11
- data/spec/rails3/spec/user_reset_password_spec.rb +14 -15
- data/spec/rails3/spec/user_spec.rb +18 -3
- data/spec/rails3_mongoid/.gitignore +4 -0
- data/spec/rails3_mongoid/.rspec +1 -0
- data/spec/rails3_mongoid/Gemfile +14 -0
- data/spec/rails3_mongoid/Gemfile.lock +146 -0
- data/spec/rails3_mongoid/Rakefile +11 -0
- data/spec/rails3_mongoid/app/controllers/application_controller.rb +108 -0
- data/spec/rails3_mongoid/app/helpers/application_helper.rb +2 -0
- data/spec/rails3_mongoid/app/mailers/sorcery_mailer.rb +25 -0
- data/spec/rails3_mongoid/app/models/authentication.rb +7 -0
- data/spec/rails3_mongoid/app/models/user.rb +5 -0
- data/spec/rails3_mongoid/app/views/layouts/application.html.erb +14 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.html.erb +17 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_email.text.erb +9 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.html.erb +17 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/activation_success_email.text.erb +9 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.html.erb +16 -0
- data/spec/rails3_mongoid/app/views/sorcery_mailer/reset_password_email.text.erb +8 -0
- data/spec/rails3_mongoid/config/application.rb +51 -0
- data/spec/rails3_mongoid/config/boot.rb +13 -0
- data/spec/rails3_mongoid/config/environment.rb +5 -0
- data/spec/rails3_mongoid/config/environments/development.rb +26 -0
- data/spec/rails3_mongoid/config/environments/in_memory.rb +0 -0
- data/spec/rails3_mongoid/config/environments/production.rb +49 -0
- data/spec/rails3_mongoid/config/environments/test.rb +35 -0
- data/spec/rails3_mongoid/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails3_mongoid/config/initializers/inflections.rb +10 -0
- data/spec/rails3_mongoid/config/initializers/mime_types.rb +5 -0
- data/spec/rails3_mongoid/config/initializers/secret_token.rb +7 -0
- data/spec/rails3_mongoid/config/initializers/session_store.rb +8 -0
- data/spec/rails3_mongoid/config/locales/en.yml +5 -0
- data/spec/rails3_mongoid/config/mongoid.yml +7 -0
- data/spec/rails3_mongoid/config/routes.rb +59 -0
- data/spec/rails3_mongoid/config.ru +4 -0
- data/spec/rails3_mongoid/db/schema.rb +23 -0
- data/spec/rails3_mongoid/db/seeds.rb +7 -0
- data/spec/rails3_mongoid/lib/tasks/.gitkeep +0 -0
- data/spec/rails3_mongoid/public/404.html +26 -0
- data/spec/rails3_mongoid/public/422.html +26 -0
- data/spec/rails3_mongoid/public/500.html +26 -0
- 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 +2 -0
- data/spec/rails3_mongoid/public/javascripts/controls.js +965 -0
- data/spec/rails3_mongoid/public/javascripts/dragdrop.js +974 -0
- data/spec/rails3_mongoid/public/javascripts/effects.js +1123 -0
- data/spec/rails3_mongoid/public/javascripts/prototype.js +6001 -0
- data/spec/rails3_mongoid/public/javascripts/rails.js +175 -0
- data/spec/rails3_mongoid/public/robots.txt +5 -0
- data/spec/rails3_mongoid/public/stylesheets/.gitkeep +0 -0
- data/spec/rails3_mongoid/script/rails +6 -0
- data/spec/rails3_mongoid/spec/spec.opts +2 -0
- data/spec/rails3_mongoid/spec/spec_helper.orig.rb +27 -0
- data/spec/rails3_mongoid/spec/spec_helper.rb +55 -0
- data/spec/rails3_mongoid/spec/user_activation_spec.rb +178 -0
- data/spec/rails3_mongoid/spec/user_activity_logging_spec.rb +31 -0
- data/spec/rails3_mongoid/spec/user_brute_force_protection_spec.rb +41 -0
- data/spec/rails3_mongoid/spec/user_oauth_spec.rb +34 -0
- data/spec/rails3_mongoid/spec/user_remember_me_spec.rb +51 -0
- data/spec/rails3_mongoid/spec/user_reset_password_spec.rb +174 -0
- data/spec/rails3_mongoid/spec/user_spec.rb +329 -0
- data/spec/rails3_mongoid/vendor/plugins/.gitkeep +0 -0
- data/spec/sinatra/Gemfile +1 -1
- data/spec/sinatra/Gemfile.lock +6 -6
- data/spec/sinatra/spec/controller_session_timeout_spec.rb +23 -22
- data/spec/sinatra/spec/spec_helper.rb +2 -2
- metadata +153 -37
- data/spec/untitled folder +0 -18
data/spec/Gemfile
CHANGED
data/spec/Gemfile.lock
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
|
-
remote:
|
|
2
|
+
remote: ../
|
|
3
3
|
specs:
|
|
4
|
-
sorcery (0.
|
|
4
|
+
sorcery (0.5.0)
|
|
5
|
+
bcrypt-ruby (~> 2.1.4)
|
|
6
|
+
json (>= 1.5.1)
|
|
7
|
+
oauth (>= 0.4.4)
|
|
8
|
+
oauth (>= 0.4.4)
|
|
9
|
+
oauth2 (>= 0.1.1)
|
|
10
|
+
oauth2 (>= 0.1.1)
|
|
11
|
+
rails (>= 3.0.0)
|
|
5
12
|
|
|
6
13
|
GEM
|
|
7
14
|
remote: http://rubygems.org/
|
|
@@ -36,7 +43,7 @@ GEM
|
|
|
36
43
|
addressable (2.2.4)
|
|
37
44
|
archive-tar-minitar (0.5.2)
|
|
38
45
|
arel (2.0.6)
|
|
39
|
-
bcrypt-ruby (2.1.
|
|
46
|
+
bcrypt-ruby (2.1.4)
|
|
40
47
|
builder (2.1.2)
|
|
41
48
|
columnize (0.3.2)
|
|
42
49
|
diff-lcs (1.1.2)
|
|
@@ -47,6 +54,7 @@ GEM
|
|
|
47
54
|
multipart-post (~> 1.1.0)
|
|
48
55
|
rack (< 2, >= 1.1.0)
|
|
49
56
|
i18n (0.5.0)
|
|
57
|
+
json (1.5.1)
|
|
50
58
|
linecache19 (0.5.11)
|
|
51
59
|
ruby_core_source (>= 0.1.4)
|
|
52
60
|
mail (2.2.13)
|
|
@@ -118,4 +126,4 @@ DEPENDENCIES
|
|
|
118
126
|
rspec (~> 2.5.0)
|
|
119
127
|
ruby-debug19
|
|
120
128
|
simplecov (>= 0.3.8)
|
|
121
|
-
sorcery (
|
|
129
|
+
sorcery (>= 0.1.0)!
|
data/spec/rails3/Gemfile
CHANGED
data/spec/rails3/Gemfile.lock
CHANGED
|
@@ -2,7 +2,7 @@ PATH
|
|
|
2
2
|
remote: ../../../
|
|
3
3
|
specs:
|
|
4
4
|
oauth (0.4.4)
|
|
5
|
-
sorcery (0.
|
|
5
|
+
sorcery (0.5.0)
|
|
6
6
|
bcrypt-ruby (~> 2.1.4)
|
|
7
7
|
json (>= 1.5.1)
|
|
8
8
|
oauth (>= 0.4.4)
|
|
@@ -64,11 +64,11 @@ GEM
|
|
|
64
64
|
mime-types (~> 1.16)
|
|
65
65
|
treetop (~> 1.4.8)
|
|
66
66
|
mime-types (1.16)
|
|
67
|
-
multi_json (
|
|
67
|
+
multi_json (1.0.1)
|
|
68
68
|
multipart-post (1.1.0)
|
|
69
|
-
oauth2 (0.4.
|
|
70
|
-
faraday (~> 0.6.
|
|
71
|
-
multi_json (
|
|
69
|
+
oauth2 (0.4.1)
|
|
70
|
+
faraday (~> 0.6.1)
|
|
71
|
+
multi_json (>= 0.0.5)
|
|
72
72
|
polyglot (0.3.1)
|
|
73
73
|
rack (1.2.1)
|
|
74
74
|
rack-mount (0.6.13)
|
|
@@ -131,6 +131,6 @@ DEPENDENCIES
|
|
|
131
131
|
rspec-rails (~> 2.5.0)
|
|
132
132
|
ruby-debug19
|
|
133
133
|
simplecov (>= 0.3.8)
|
|
134
|
-
sorcery (
|
|
134
|
+
sorcery (>= 0.1.0)!
|
|
135
135
|
sqlite3-ruby
|
|
136
136
|
timecop
|
|
@@ -22,10 +22,8 @@ describe ApplicationController do
|
|
|
22
22
|
after(:each) do
|
|
23
23
|
User.delete_all
|
|
24
24
|
end
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
subject.should respond_to(:current_users)
|
|
28
|
-
end
|
|
25
|
+
|
|
26
|
+
specify { subject.should respond_to(:current_users) }
|
|
29
27
|
|
|
30
28
|
it "'current_users' should be empty when no users are logged in" do
|
|
31
29
|
subject.current_users.size.should == 0
|
|
@@ -31,7 +31,7 @@ describe ApplicationController do
|
|
|
31
31
|
ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate/external")
|
|
32
32
|
end
|
|
33
33
|
# ----------------- OAuth -----------------------
|
|
34
|
-
describe ApplicationController, "'
|
|
34
|
+
describe ApplicationController, "'using external API to login'" do
|
|
35
35
|
|
|
36
36
|
before(:each) do
|
|
37
37
|
stub_all_oauth_requests!
|
|
@@ -64,7 +64,7 @@ describe ApplicationController do
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
describe ApplicationController, "'create_from'" do
|
|
67
|
+
describe ApplicationController, "using 'create_from'" do
|
|
68
68
|
before(:each) do
|
|
69
69
|
stub_all_oauth_requests!
|
|
70
70
|
User.delete_all
|
|
@@ -90,7 +90,7 @@ describe ApplicationController do
|
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
describe ApplicationController, "OAuth with User Activation features" do
|
|
93
|
+
describe ApplicationController, "using OAuth with User Activation features" do
|
|
94
94
|
before(:all) do
|
|
95
95
|
ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate/activation")
|
|
96
96
|
sorcery_reload!([:user_activation,:external], :user_activation_mailer => ::SorceryMailer)
|
|
@@ -29,26 +29,27 @@ describe ApplicationController do
|
|
|
29
29
|
response.should be_a_redirect
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
context "with 'session_timeout_from_last_action'" do
|
|
33
|
+
it "should not logout if there was activity" do
|
|
34
|
+
sorcery_controller_property_set(:session_timeout_from_last_action, true)
|
|
35
|
+
get :test_login, :username => 'gizmo', :password => 'secret'
|
|
36
|
+
Timecop.travel(Time.now+0.3)
|
|
37
|
+
get :test_should_be_logged_in
|
|
38
|
+
session[:user_id].should_not be_nil
|
|
39
|
+
Timecop.travel(Time.now+0.3)
|
|
40
|
+
get :test_should_be_logged_in
|
|
41
|
+
session[:user_id].should_not be_nil
|
|
42
|
+
response.should be_a_success
|
|
43
|
+
end
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
it "with 'session_timeout_from_last_action' should logout if there was no activity" do
|
|
46
|
+
sorcery_controller_property_set(:session_timeout_from_last_action, true)
|
|
47
|
+
get :test_login, :username => 'gizmo', :password => 'secret'
|
|
48
|
+
Timecop.travel(Time.now+0.6)
|
|
49
|
+
get :test_should_be_logged_in
|
|
50
|
+
session[:user_id].should be_nil
|
|
51
|
+
response.should be_a_redirect
|
|
52
|
+
end
|
|
51
53
|
end
|
|
52
|
-
|
|
53
54
|
end
|
|
54
55
|
end
|
|
@@ -37,21 +37,13 @@ describe ApplicationController do
|
|
|
37
37
|
sorcery_controller_property_set(:user_class, User)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
it "should respond to the instance method logout" do
|
|
45
|
-
should respond_to(:logout)
|
|
46
|
-
end
|
|
40
|
+
specify { should respond_to(:login) }
|
|
41
|
+
|
|
42
|
+
specify { should respond_to(:logout) }
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
should respond_to(:logged_in?)
|
|
50
|
-
end
|
|
44
|
+
specify { should respond_to(:logged_in?) }
|
|
51
45
|
|
|
52
|
-
|
|
53
|
-
should respond_to(:current_user)
|
|
54
|
-
end
|
|
46
|
+
specify { should respond_to(:current_user) }
|
|
55
47
|
|
|
56
48
|
it "login(username,password) should return the user when success and set the session with user.id" do
|
|
57
49
|
get :test_login, :username => 'gizmo', :password => 'secret'
|
|
@@ -93,9 +85,7 @@ describe ApplicationController do
|
|
|
93
85
|
subject.current_user.should == false
|
|
94
86
|
end
|
|
95
87
|
|
|
96
|
-
|
|
97
|
-
should respond_to(:require_login)
|
|
98
|
-
end
|
|
88
|
+
specify { should respond_to(:require_login) }
|
|
99
89
|
|
|
100
90
|
it "should call the configured 'not_authenticated_action' when authenticate before_filter fails" do
|
|
101
91
|
session[:user_id] = nil
|
|
@@ -57,23 +57,17 @@ describe "User with activation submodule" do
|
|
|
57
57
|
sorcery_reload!([:user_activation], :user_activation_mailer => ::SorceryMailer)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
before(:each) do
|
|
61
61
|
create_new_user
|
|
62
|
-
@user.activation_token.should_not be_nil
|
|
63
62
|
end
|
|
64
63
|
|
|
65
64
|
it "should initialize user state to 'pending'" do
|
|
66
|
-
create_new_user
|
|
67
65
|
@user.activation_state.should == "pending"
|
|
68
66
|
end
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
create_new_user
|
|
72
|
-
@user.should respond_to(:activate!)
|
|
73
|
-
end
|
|
68
|
+
specify { @user.should respond_to(:activate!) }
|
|
74
69
|
|
|
75
70
|
it "should clear activation code and change state to 'active' on activation" do
|
|
76
|
-
create_new_user
|
|
77
71
|
activation_token = @user.activation_token
|
|
78
72
|
@user.activate!
|
|
79
73
|
@user2 = User.find(@user.id) # go to db to make sure it was saved and not just in memory
|
|
@@ -89,7 +83,6 @@ describe "User with activation submodule" do
|
|
|
89
83
|
end
|
|
90
84
|
|
|
91
85
|
it "subsequent saves do not send activation email" do
|
|
92
|
-
create_new_user
|
|
93
86
|
old_size = ActionMailer::Base.deliveries.size
|
|
94
87
|
@user.username = "Shauli"
|
|
95
88
|
@user.save!
|
|
@@ -97,14 +90,12 @@ describe "User with activation submodule" do
|
|
|
97
90
|
end
|
|
98
91
|
|
|
99
92
|
it "should send the user an activation success email on successful activation" do
|
|
100
|
-
create_new_user
|
|
101
93
|
old_size = ActionMailer::Base.deliveries.size
|
|
102
94
|
@user.activate!
|
|
103
95
|
ActionMailer::Base.deliveries.size.should == old_size + 1
|
|
104
96
|
end
|
|
105
97
|
|
|
106
98
|
it "subsequent saves do not send activation success email" do
|
|
107
|
-
create_new_user
|
|
108
99
|
@user.activate!
|
|
109
100
|
old_size = ActionMailer::Base.deliveries.size
|
|
110
101
|
@user.username = "Shauli"
|
|
@@ -121,7 +112,6 @@ describe "User with activation submodule" do
|
|
|
121
112
|
|
|
122
113
|
it "activation success email is optional" do
|
|
123
114
|
sorcery_model_property_set(:activation_success_email_method_name, nil)
|
|
124
|
-
create_new_user
|
|
125
115
|
old_size = ActionMailer::Base.deliveries.size
|
|
126
116
|
@user.activate!
|
|
127
117
|
ActionMailer::Base.deliveries.size.should == old_size
|
|
@@ -21,13 +21,8 @@ describe "User with brute_force_protection submodule" do
|
|
|
21
21
|
User.sorcery_config.reset!
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "should respond to 'lock_expires_at'" do
|
|
29
|
-
@user.should respond_to(:failed_logins_count)
|
|
30
|
-
end
|
|
24
|
+
specify { @user.should respond_to(:failed_logins_count) }
|
|
25
|
+
specify { @user.should respond_to(:lock_expires_at) }
|
|
31
26
|
|
|
32
27
|
it "should enable configuration option 'failed_logins_count_attribute_name'" do
|
|
33
28
|
sorcery_model_property_set(:failed_logins_count_attribute_name, :my_count)
|
|
@@ -49,28 +44,5 @@ describe "User with brute_force_protection submodule" do
|
|
|
49
44
|
User.sorcery_config.login_lock_time_period.should == 2.hours
|
|
50
45
|
end
|
|
51
46
|
end
|
|
52
|
-
|
|
53
|
-
# ----------------- PLUGIN ACTIVATED -----------------------
|
|
54
|
-
describe User, "when activated with sorcery" do
|
|
55
|
-
|
|
56
|
-
before(:all) do
|
|
57
|
-
sorcery_reload!([:brute_force_protection])
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
before(:each) do
|
|
61
|
-
User.delete_all
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# it "should increment failed_logins_count on a failed login" do
|
|
65
|
-
# create_new_user
|
|
66
|
-
#
|
|
67
|
-
# end
|
|
68
|
-
#
|
|
69
|
-
# it "should set lock expiry (effectively lock user) when failed_logins_count reaches max within max period" do
|
|
70
|
-
# create_new_user
|
|
71
|
-
# @user.lock_expires_at.should == Time.now.utc + 30
|
|
72
|
-
# end
|
|
73
|
-
|
|
74
|
-
end
|
|
75
47
|
|
|
76
48
|
end
|
|
@@ -13,6 +13,7 @@ describe "User with remember_me submodule" do
|
|
|
13
13
|
describe User, "loaded plugin configuration" do
|
|
14
14
|
before(:all) do
|
|
15
15
|
sorcery_reload!([:remember_me])
|
|
16
|
+
create_new_user
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
after(:each) do
|
|
@@ -29,32 +30,23 @@ describe "User with remember_me submodule" do
|
|
|
29
30
|
User.sorcery_config.remember_me_token_expires_at_attribute_name.should equal(:my_expires)
|
|
30
31
|
end
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
create_new_user
|
|
34
|
-
@user.should respond_to(:remember_me!)
|
|
35
|
-
end
|
|
33
|
+
specify { @user.should respond_to(:remember_me!) }
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
create_new_user
|
|
39
|
-
@user.should respond_to(:forget_me!)
|
|
40
|
-
end
|
|
35
|
+
specify { @user.should respond_to(:forget_me!) }
|
|
41
36
|
|
|
42
37
|
it "should generate a new token on 'remember_me!'" do
|
|
43
|
-
create_new_user
|
|
44
38
|
@user.remember_me_token.should be_nil
|
|
45
39
|
@user.remember_me!
|
|
46
40
|
@user.remember_me_token.should_not be_nil
|
|
47
41
|
end
|
|
48
42
|
|
|
49
43
|
it "should set an expiration based on 'remember_me_for' attribute" do
|
|
50
|
-
create_new_user
|
|
51
44
|
sorcery_model_property_set(:remember_me_for, 2 * 60 * 60 * 24)
|
|
52
45
|
@user.remember_me!
|
|
53
46
|
@user.remember_me_token_expires_at.to_s.should == (Time.now + 2 * 60 * 60 * 24).utc.to_s
|
|
54
47
|
end
|
|
55
48
|
|
|
56
49
|
it "should delete the token and expiration on 'forget_me!'" do
|
|
57
|
-
create_new_user
|
|
58
50
|
@user.remember_me!
|
|
59
51
|
@user.remember_me_token.should_not be_nil
|
|
60
52
|
@user.forget_me!
|
|
@@ -20,21 +20,20 @@ describe "User with reset_password submodule" do
|
|
|
20
20
|
User.sorcery_config.reset!
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@user.should respond_to(:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
User.should respond_to(:load_from_reset_password_token)
|
|
23
|
+
context "API" do
|
|
24
|
+
before(:all) do
|
|
25
|
+
create_new_user
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
specify { @user.should respond_to(:deliver_reset_password_instructions!) }
|
|
29
|
+
|
|
30
|
+
specify { @user.should respond_to(:change_password!) }
|
|
31
|
+
|
|
32
|
+
it "should respond to .load_from_reset_password_token" do
|
|
33
|
+
User.should respond_to(:load_from_reset_password_token)
|
|
34
|
+
end
|
|
36
35
|
end
|
|
37
|
-
|
|
36
|
+
|
|
38
37
|
it "should allow configuration option 'reset_password_token_attribute_name'" do
|
|
39
38
|
sorcery_model_property_set(:reset_password_token_attribute_name, :my_code)
|
|
40
39
|
User.sorcery_config.reset_password_token_attribute_name.should equal(:my_code)
|
|
@@ -147,7 +146,7 @@ describe "User with reset_password submodule" do
|
|
|
147
146
|
create_new_user
|
|
148
147
|
@user.deliver_reset_password_instructions!
|
|
149
148
|
@user.reset_password_token.should_not be_nil
|
|
150
|
-
@user.
|
|
149
|
+
@user.change_password!("blabulsdf")
|
|
151
150
|
@user.save!
|
|
152
151
|
@user.reset_password_token.should be_nil
|
|
153
152
|
end
|
|
@@ -9,6 +9,9 @@ describe "User with no submodules (core)" do
|
|
|
9
9
|
describe User, "when app has plugin loaded" do
|
|
10
10
|
it "should respond to the plugin activation class method" do
|
|
11
11
|
ActiveRecord::Base.should respond_to(:authenticates_with_sorcery!)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "User should respond_to .authenticates_with_sorcery!" do
|
|
12
15
|
User.should respond_to(:authenticates_with_sorcery!)
|
|
13
16
|
end
|
|
14
17
|
end
|
|
@@ -109,8 +112,21 @@ describe "User with no submodules (core)" do
|
|
|
109
112
|
User.authenticate(@user.send(User.sorcery_config.username_attribute_name), 'wrong!').should be_false
|
|
110
113
|
end
|
|
111
114
|
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
specify { User.should respond_to(:encrypt) }
|
|
116
|
+
|
|
117
|
+
it "subclass should inherit config if defined so" do
|
|
118
|
+
sorcery_reload!([],{:subclasses_inherit_config => true})
|
|
119
|
+
class Admin < User
|
|
120
|
+
end
|
|
121
|
+
Admin.sorcery_config.should_not be_nil
|
|
122
|
+
Admin.sorcery_config.should == User.sorcery_config
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "subclass should not inherit config if not defined so" do
|
|
126
|
+
sorcery_reload!([],{:subclasses_inherit_config => false})
|
|
127
|
+
class Admin2 < User
|
|
128
|
+
end
|
|
129
|
+
Admin2.sorcery_config.should be_nil
|
|
114
130
|
end
|
|
115
131
|
end
|
|
116
132
|
|
|
@@ -307,5 +323,4 @@ describe "User with no submodules (core)" do
|
|
|
307
323
|
@user.external?.should be_true
|
|
308
324
|
end
|
|
309
325
|
end
|
|
310
|
-
|
|
311
326
|
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--colour
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
source 'http://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem 'rails', '3.0.3'
|
|
4
|
+
gem "sorcery", '>= 0.1.0', :path => '../../../'
|
|
5
|
+
gem "mongoid", "~> 2.0"
|
|
6
|
+
gem "bson_ext", "~> 1.3"
|
|
7
|
+
|
|
8
|
+
group :development, :test do
|
|
9
|
+
gem "rspec", "~> 2.5.0"
|
|
10
|
+
gem 'rspec-rails', "~> 2.5.0"
|
|
11
|
+
gem 'ruby-debug19'
|
|
12
|
+
gem 'simplecov', '>= 0.3.8', :require => false # Will install simplecov-html as a dependency
|
|
13
|
+
gem 'timecop'
|
|
14
|
+
end
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../../../
|
|
3
|
+
specs:
|
|
4
|
+
oauth (0.4.4)
|
|
5
|
+
sorcery (0.5.0)
|
|
6
|
+
bcrypt-ruby (~> 2.1.4)
|
|
7
|
+
json (>= 1.5.1)
|
|
8
|
+
oauth (>= 0.4.4)
|
|
9
|
+
oauth (>= 0.4.4)
|
|
10
|
+
oauth2 (>= 0.1.1)
|
|
11
|
+
oauth2 (>= 0.1.1)
|
|
12
|
+
rails (>= 3.0.0)
|
|
13
|
+
|
|
14
|
+
GEM
|
|
15
|
+
remote: http://rubygems.org/
|
|
16
|
+
specs:
|
|
17
|
+
abstract (1.0.0)
|
|
18
|
+
actionmailer (3.0.3)
|
|
19
|
+
actionpack (= 3.0.3)
|
|
20
|
+
mail (~> 2.2.9)
|
|
21
|
+
actionpack (3.0.3)
|
|
22
|
+
activemodel (= 3.0.3)
|
|
23
|
+
activesupport (= 3.0.3)
|
|
24
|
+
builder (~> 2.1.2)
|
|
25
|
+
erubis (~> 2.6.6)
|
|
26
|
+
i18n (~> 0.4)
|
|
27
|
+
rack (~> 1.2.1)
|
|
28
|
+
rack-mount (~> 0.6.13)
|
|
29
|
+
rack-test (~> 0.5.6)
|
|
30
|
+
tzinfo (~> 0.3.23)
|
|
31
|
+
activemodel (3.0.3)
|
|
32
|
+
activesupport (= 3.0.3)
|
|
33
|
+
builder (~> 2.1.2)
|
|
34
|
+
i18n (~> 0.4)
|
|
35
|
+
activerecord (3.0.3)
|
|
36
|
+
activemodel (= 3.0.3)
|
|
37
|
+
activesupport (= 3.0.3)
|
|
38
|
+
arel (~> 2.0.2)
|
|
39
|
+
tzinfo (~> 0.3.23)
|
|
40
|
+
activeresource (3.0.3)
|
|
41
|
+
activemodel (= 3.0.3)
|
|
42
|
+
activesupport (= 3.0.3)
|
|
43
|
+
activesupport (3.0.3)
|
|
44
|
+
addressable (2.2.5)
|
|
45
|
+
archive-tar-minitar (0.5.2)
|
|
46
|
+
arel (2.0.6)
|
|
47
|
+
bcrypt-ruby (2.1.4)
|
|
48
|
+
bson (1.3.0)
|
|
49
|
+
bson_ext (1.3.0)
|
|
50
|
+
builder (2.1.2)
|
|
51
|
+
columnize (0.3.2)
|
|
52
|
+
diff-lcs (1.1.2)
|
|
53
|
+
erubis (2.6.6)
|
|
54
|
+
abstract (>= 1.0.0)
|
|
55
|
+
faraday (0.6.1)
|
|
56
|
+
addressable (~> 2.2.4)
|
|
57
|
+
multipart-post (~> 1.1.0)
|
|
58
|
+
rack (< 2, >= 1.1.0)
|
|
59
|
+
i18n (0.5.0)
|
|
60
|
+
json (1.5.1)
|
|
61
|
+
linecache19 (0.5.11)
|
|
62
|
+
ruby_core_source (>= 0.1.4)
|
|
63
|
+
mail (2.2.13)
|
|
64
|
+
activesupport (>= 2.3.6)
|
|
65
|
+
i18n (>= 0.4.0)
|
|
66
|
+
mime-types (~> 1.16)
|
|
67
|
+
treetop (~> 1.4.8)
|
|
68
|
+
mime-types (1.16)
|
|
69
|
+
mongo (1.3.0)
|
|
70
|
+
bson (>= 1.3.0)
|
|
71
|
+
mongoid (2.0.1)
|
|
72
|
+
activemodel (~> 3.0)
|
|
73
|
+
mongo (~> 1.3)
|
|
74
|
+
tzinfo (~> 0.3.22)
|
|
75
|
+
will_paginate (~> 3.0.pre)
|
|
76
|
+
multi_json (1.0.1)
|
|
77
|
+
multipart-post (1.1.0)
|
|
78
|
+
oauth2 (0.4.1)
|
|
79
|
+
faraday (~> 0.6.1)
|
|
80
|
+
multi_json (>= 0.0.5)
|
|
81
|
+
polyglot (0.3.1)
|
|
82
|
+
rack (1.2.1)
|
|
83
|
+
rack-mount (0.6.13)
|
|
84
|
+
rack (>= 1.0.0)
|
|
85
|
+
rack-test (0.5.6)
|
|
86
|
+
rack (>= 1.0)
|
|
87
|
+
rails (3.0.3)
|
|
88
|
+
actionmailer (= 3.0.3)
|
|
89
|
+
actionpack (= 3.0.3)
|
|
90
|
+
activerecord (= 3.0.3)
|
|
91
|
+
activeresource (= 3.0.3)
|
|
92
|
+
activesupport (= 3.0.3)
|
|
93
|
+
bundler (~> 1.0)
|
|
94
|
+
railties (= 3.0.3)
|
|
95
|
+
railties (3.0.3)
|
|
96
|
+
actionpack (= 3.0.3)
|
|
97
|
+
activesupport (= 3.0.3)
|
|
98
|
+
rake (>= 0.8.7)
|
|
99
|
+
thor (~> 0.14.4)
|
|
100
|
+
rake (0.8.7)
|
|
101
|
+
rspec (2.5.0)
|
|
102
|
+
rspec-core (~> 2.5.0)
|
|
103
|
+
rspec-expectations (~> 2.5.0)
|
|
104
|
+
rspec-mocks (~> 2.5.0)
|
|
105
|
+
rspec-core (2.5.1)
|
|
106
|
+
rspec-expectations (2.5.0)
|
|
107
|
+
diff-lcs (~> 1.1.2)
|
|
108
|
+
rspec-mocks (2.5.0)
|
|
109
|
+
rspec-rails (2.5.0)
|
|
110
|
+
actionpack (~> 3.0)
|
|
111
|
+
activesupport (~> 3.0)
|
|
112
|
+
railties (~> 3.0)
|
|
113
|
+
rspec (~> 2.5.0)
|
|
114
|
+
ruby-debug-base19 (0.11.24)
|
|
115
|
+
columnize (>= 0.3.1)
|
|
116
|
+
linecache19 (>= 0.5.11)
|
|
117
|
+
ruby_core_source (>= 0.1.4)
|
|
118
|
+
ruby-debug19 (0.11.6)
|
|
119
|
+
columnize (>= 0.3.1)
|
|
120
|
+
linecache19 (>= 0.5.11)
|
|
121
|
+
ruby-debug-base19 (>= 0.11.19)
|
|
122
|
+
ruby_core_source (0.1.4)
|
|
123
|
+
archive-tar-minitar (>= 0.5.2)
|
|
124
|
+
simplecov (0.3.9)
|
|
125
|
+
simplecov-html (>= 0.3.7)
|
|
126
|
+
simplecov-html (0.3.9)
|
|
127
|
+
thor (0.14.6)
|
|
128
|
+
timecop (0.3.5)
|
|
129
|
+
treetop (1.4.9)
|
|
130
|
+
polyglot (>= 0.3.1)
|
|
131
|
+
tzinfo (0.3.23)
|
|
132
|
+
will_paginate (3.0.pre2)
|
|
133
|
+
|
|
134
|
+
PLATFORMS
|
|
135
|
+
ruby
|
|
136
|
+
|
|
137
|
+
DEPENDENCIES
|
|
138
|
+
bson_ext (~> 1.3)
|
|
139
|
+
mongoid (~> 2.0)
|
|
140
|
+
rails (= 3.0.3)
|
|
141
|
+
rspec (~> 2.5.0)
|
|
142
|
+
rspec-rails (~> 2.5.0)
|
|
143
|
+
ruby-debug19
|
|
144
|
+
simplecov (>= 0.3.8)
|
|
145
|
+
sorcery (>= 0.1.0)!
|
|
146
|
+
timecop
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rspec/core/rake_task'
|
|
3
|
+
|
|
4
|
+
desc 'Default: Run all specs for a specific rails version.'
|
|
5
|
+
task :default => :spec
|
|
6
|
+
|
|
7
|
+
desc "Run all specs for a specific rails version"
|
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
9
|
+
t.pattern = '**/*_spec.rb'
|
|
10
|
+
t.rspec_opts = ["--options #{File.dirname(__FILE__)}/spec/spec.opts"]
|
|
11
|
+
end
|