authlogic 2.0.0 → 2.0.14
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/CHANGELOG.rdoc +102 -2
- data/Manifest.txt +11 -4
- data/README.rdoc +129 -156
- data/Rakefile +2 -2
- data/init.rb +1 -1
- data/lib/authlogic/acts_as_authentic/base.rb +33 -12
- data/lib/authlogic/acts_as_authentic/email.rb +47 -14
- data/lib/authlogic/acts_as_authentic/logged_in_status.rb +20 -14
- data/lib/authlogic/acts_as_authentic/login.rb +84 -8
- data/lib/authlogic/acts_as_authentic/password.rb +216 -87
- data/lib/authlogic/acts_as_authentic/perishable_token.rb +3 -3
- data/lib/authlogic/acts_as_authentic/persistence_token.rb +4 -2
- data/lib/authlogic/acts_as_authentic/restful_authentication.rb +5 -4
- data/lib/authlogic/acts_as_authentic/session_maintenance.rb +17 -5
- data/lib/authlogic/acts_as_authentic/single_access_token.rb +10 -3
- data/lib/authlogic/acts_as_authentic/validations_scope.rb +2 -2
- data/lib/authlogic/controller_adapters/abstract_adapter.rb +13 -1
- data/lib/authlogic/controller_adapters/rails_adapter.rb +1 -1
- data/lib/authlogic/crypto_providers/aes256.rb +2 -2
- data/lib/authlogic/crypto_providers/bcrypt.rb +3 -1
- data/lib/authlogic/crypto_providers/sha1.rb +2 -2
- data/lib/authlogic/i18n.rb +10 -1
- data/lib/authlogic/regex.rb +25 -0
- data/lib/authlogic/session/activation.rb +2 -0
- data/lib/authlogic/session/active_record_trickery.rb +19 -3
- data/lib/authlogic/session/brute_force_protection.rb +26 -11
- data/lib/authlogic/session/callbacks.rb +15 -5
- data/lib/authlogic/session/cookies.rb +15 -11
- data/lib/authlogic/session/existence.rb +4 -2
- data/lib/authlogic/session/foundation.rb +1 -1
- data/lib/authlogic/session/http_auth.rb +46 -11
- data/lib/authlogic/session/magic_columns.rb +25 -6
- data/lib/authlogic/session/magic_states.rb +4 -4
- data/lib/authlogic/session/params.rb +14 -9
- data/lib/authlogic/session/password.rb +86 -24
- data/lib/authlogic/session/priority_record.rb +1 -1
- data/lib/authlogic/session/session.rb +2 -2
- data/lib/authlogic/session/timeout.rb +1 -1
- data/lib/authlogic/session/validation.rb +9 -5
- data/lib/authlogic/test_case/mock_controller.rb +45 -0
- data/lib/authlogic/test_case/mock_cookie_jar.rb +14 -0
- data/lib/authlogic/test_case/mock_logger.rb +10 -0
- data/lib/authlogic/test_case/mock_request.rb +19 -0
- data/lib/authlogic/test_case/rails_request_adapter.rb +30 -0
- data/lib/authlogic/test_case.rb +114 -0
- data/lib/authlogic/version.rb +1 -6
- data/lib/authlogic.rb +1 -0
- data/rails/init.rb +1 -0
- data/shoulda_macros/authlogic.rb +2 -1
- data/test/acts_as_authentic_test/base_test.rb +6 -0
- data/test/acts_as_authentic_test/email_test.rb +25 -7
- data/test/acts_as_authentic_test/login_test.rb +37 -7
- data/test/acts_as_authentic_test/magic_columns_test.rb +4 -4
- data/test/acts_as_authentic_test/password_test.rb +64 -40
- data/test/acts_as_authentic_test/perishable_token_test.rb +29 -1
- data/test/acts_as_authentic_test/restful_authentication_test.rb +40 -0
- data/test/acts_as_authentic_test/session_maintenance_test.rb +34 -18
- data/test/acts_as_authentic_test/single_access_test.rb +6 -1
- data/test/libs/affiliate.rb +7 -0
- data/test/libs/ldaper.rb +3 -0
- data/test/random_test.rb +2 -2
- data/test/session_test/activation_test.rb +1 -1
- data/test/session_test/active_record_trickery_test.rb +2 -1
- data/test/session_test/brute_force_protection_test.rb +34 -9
- data/test/session_test/cookies_test.rb +3 -3
- data/test/session_test/http_auth_test.rb +20 -8
- data/test/session_test/magic_columns_test.rb +7 -4
- data/test/session_test/magic_states_test.rb +3 -3
- data/test/session_test/params_test.rb +4 -4
- data/test/session_test/password_test.rb +8 -0
- data/test/session_test/session_test.rb +9 -9
- data/test/session_test/timeout_test.rb +10 -1
- data/test/test_helper.rb +46 -24
- metadata +22 -10
- data/lib/authlogic/testing/test_unit_helpers.rb +0 -39
- data/test/libs/mock_controller.rb +0 -35
- data/test/libs/mock_cookie_jar.rb +0 -10
- data/test/libs/mock_request.rb +0 -5
|
@@ -15,6 +15,8 @@ module SessionTest
|
|
|
15
15
|
class InstanceMethodsTest < ActiveSupport::TestCase
|
|
16
16
|
def test_after_persisting_set_last_request_at
|
|
17
17
|
ben = users(:ben)
|
|
18
|
+
assert UserSession.create(ben)
|
|
19
|
+
|
|
18
20
|
set_cookie_for(ben)
|
|
19
21
|
old_last_request_at = ben.last_request_at
|
|
20
22
|
assert UserSession.find
|
|
@@ -22,7 +24,7 @@ module SessionTest
|
|
|
22
24
|
assert ben.last_request_at != old_last_request_at
|
|
23
25
|
end
|
|
24
26
|
|
|
25
|
-
def
|
|
27
|
+
def test_valid_increase_failed_login_count
|
|
26
28
|
ben = users(:ben)
|
|
27
29
|
old_failed_login_count = ben.failed_login_count
|
|
28
30
|
assert !UserSession.create(:login => ben.login, :password => "wrong")
|
|
@@ -45,10 +47,11 @@ module SessionTest
|
|
|
45
47
|
old_last_login_ip = ben.last_login_ip
|
|
46
48
|
old_current_login_ip = ben.current_login_ip
|
|
47
49
|
|
|
48
|
-
assert UserSession.create(ben)
|
|
49
|
-
|
|
50
|
+
assert UserSession.create(:login => ben.login, :password => "benrocks")
|
|
51
|
+
|
|
52
|
+
ben.reload
|
|
50
53
|
assert_equal old_login_count + 1, ben.login_count
|
|
51
|
-
assert_equal
|
|
54
|
+
assert_equal 0, ben.failed_login_count
|
|
52
55
|
assert_equal old_current_login_at, ben.last_login_at
|
|
53
56
|
assert ben.current_login_at != old_current_login_at
|
|
54
57
|
assert_equal old_current_login_ip, ben.last_login_ip
|
|
@@ -31,7 +31,7 @@ module SessionTest
|
|
|
31
31
|
|
|
32
32
|
ben.update_attribute(:active, false)
|
|
33
33
|
assert !session.valid?
|
|
34
|
-
assert session.errors.
|
|
34
|
+
assert session.errors[:base].size > 0
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def test_validate_validate_magic_states_approved
|
|
@@ -42,7 +42,7 @@ module SessionTest
|
|
|
42
42
|
|
|
43
43
|
ben.update_attribute(:approved, false)
|
|
44
44
|
assert !session.valid?
|
|
45
|
-
assert session.errors.
|
|
45
|
+
assert session.errors[:base].size > 0
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def test_validate_validate_magic_states_confirmed
|
|
@@ -53,7 +53,7 @@ module SessionTest
|
|
|
53
53
|
|
|
54
54
|
ben.update_attribute(:confirmed, false)
|
|
55
55
|
assert !session.valid?
|
|
56
|
-
assert session.errors.
|
|
56
|
+
assert session.errors[:base].size > 0
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -31,22 +31,22 @@ module SessionTest
|
|
|
31
31
|
assert !session.persisting?
|
|
32
32
|
assert !session.unauthorized_record
|
|
33
33
|
assert !session.record
|
|
34
|
-
assert_nil
|
|
34
|
+
assert_nil controller.session["user_credentials"]
|
|
35
35
|
|
|
36
36
|
set_request_content_type("text/plain")
|
|
37
37
|
assert !session.persisting?
|
|
38
38
|
assert !session.unauthorized_record
|
|
39
|
-
assert_nil
|
|
39
|
+
assert_nil controller.session["user_credentials"]
|
|
40
40
|
|
|
41
41
|
set_request_content_type("application/atom+xml")
|
|
42
42
|
assert session.persisting?
|
|
43
43
|
assert_equal ben, session.record
|
|
44
|
-
assert_nil
|
|
44
|
+
assert_nil controller.session["user_credentials"] # should not persist since this is single access
|
|
45
45
|
|
|
46
46
|
set_request_content_type("application/rss+xml")
|
|
47
47
|
assert session.persisting?
|
|
48
48
|
assert_equal ben, session.unauthorized_record
|
|
49
|
-
assert_nil
|
|
49
|
+
assert_nil controller.session["user_credentials"]
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -19,6 +19,14 @@ module SessionTest
|
|
|
19
19
|
assert_equal "valid_password?", UserSession.verify_password_method
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def test_generalize_credentials_error_messages
|
|
23
|
+
UserSession.generalize_credentials_error_messages = true
|
|
24
|
+
assert UserSession.generalize_credentials_error_messages
|
|
25
|
+
|
|
26
|
+
UserSession.generalize_credentials_error_messages false
|
|
27
|
+
assert !UserSession.generalize_credentials_error_messages
|
|
28
|
+
end
|
|
29
|
+
|
|
22
30
|
def test_login_field
|
|
23
31
|
UserSession.configured_password_methods = false
|
|
24
32
|
UserSession.login_field = :saweet
|
|
@@ -18,41 +18,41 @@ module SessionTest
|
|
|
18
18
|
set_session_for(ben)
|
|
19
19
|
assert session = UserSession.find
|
|
20
20
|
assert_equal ben, session.record
|
|
21
|
-
assert_equal ben.persistence_token,
|
|
21
|
+
assert_equal ben.persistence_token, controller.session["user_credentials"]
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def test_persist_persist_by_session_with_token_only
|
|
25
25
|
ben = users(:ben)
|
|
26
26
|
set_session_for(ben)
|
|
27
|
-
|
|
27
|
+
controller.session["user_credentials_id"] = nil
|
|
28
28
|
assert session = UserSession.find
|
|
29
29
|
assert_equal ben, session.record
|
|
30
|
-
assert_equal ben.persistence_token,
|
|
30
|
+
assert_equal ben.persistence_token, controller.session["user_credentials"]
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def test_after_save_update_session
|
|
34
34
|
ben = users(:ben)
|
|
35
35
|
session = UserSession.new(ben)
|
|
36
|
-
assert
|
|
36
|
+
assert controller.session["user_credentials"].blank?
|
|
37
37
|
assert session.save
|
|
38
|
-
assert_equal ben.persistence_token,
|
|
38
|
+
assert_equal ben.persistence_token, controller.session["user_credentials"]
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def test_after_destroy_update_session
|
|
42
42
|
ben = users(:ben)
|
|
43
43
|
set_session_for(ben)
|
|
44
|
-
assert_equal ben.persistence_token,
|
|
44
|
+
assert_equal ben.persistence_token, controller.session["user_credentials"]
|
|
45
45
|
assert session = UserSession.find
|
|
46
46
|
assert session.destroy
|
|
47
|
-
assert
|
|
47
|
+
assert controller.session["user_credentials"].blank?
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def test_after_persisting_update_session
|
|
51
51
|
ben = users(:ben)
|
|
52
52
|
set_cookie_for(ben)
|
|
53
|
-
assert
|
|
53
|
+
assert controller.session["user_credentials"].blank?
|
|
54
54
|
assert UserSession.find
|
|
55
|
-
assert_equal ben.persistence_token,
|
|
55
|
+
assert_equal ben.persistence_token, controller.session["user_credentials"]
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
end
|
|
@@ -25,7 +25,7 @@ module SessionTest
|
|
|
25
25
|
assert session.stale?
|
|
26
26
|
assert_equal ben, session.stale_record
|
|
27
27
|
assert_nil session.record
|
|
28
|
-
assert_nil
|
|
28
|
+
assert_nil controller.session["user_credentials_id"]
|
|
29
29
|
|
|
30
30
|
set_session_for(ben)
|
|
31
31
|
|
|
@@ -38,6 +38,15 @@ module SessionTest
|
|
|
38
38
|
|
|
39
39
|
UserSession.logout_on_timeout = false
|
|
40
40
|
end
|
|
41
|
+
|
|
42
|
+
def test_successful_login
|
|
43
|
+
UserSession.logout_on_timeout = true
|
|
44
|
+
ben = users(:ben)
|
|
45
|
+
assert UserSession.create(:login => ben.login, :password => "benrocks")
|
|
46
|
+
assert session = UserSession.find
|
|
47
|
+
assert_equal ben, session.record
|
|
48
|
+
UserSession.logout_on_timeout = false
|
|
49
|
+
end
|
|
41
50
|
end
|
|
42
51
|
end
|
|
43
52
|
end
|
data/test/test_helper.rb
CHANGED
|
@@ -2,7 +2,17 @@ require "test/unit"
|
|
|
2
2
|
require "rubygems"
|
|
3
3
|
require "ruby-debug"
|
|
4
4
|
require "active_record"
|
|
5
|
-
require
|
|
5
|
+
require "active_record/fixtures"
|
|
6
|
+
|
|
7
|
+
# A temporary fix to bring active record errors up to speed with rails edge.
|
|
8
|
+
# I need to remove this once the new gem is released. This is only here so my tests pass.
|
|
9
|
+
class ActiveRecord::Errors
|
|
10
|
+
def [](key)
|
|
11
|
+
value = on(key)
|
|
12
|
+
value.is_a?(Array) ? value : [value].compact
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
6
16
|
|
|
7
17
|
ActiveRecord::Schema.verbose = false
|
|
8
18
|
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
|
|
@@ -69,36 +79,48 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
|
69
79
|
t.string :current_login_ip
|
|
70
80
|
t.string :last_login_ip
|
|
71
81
|
end
|
|
82
|
+
|
|
83
|
+
create_table :affiliates do |t|
|
|
84
|
+
t.datetime :created_at
|
|
85
|
+
t.datetime :updated_at
|
|
86
|
+
t.integer :company_id
|
|
87
|
+
t.string :username
|
|
88
|
+
t.string :pw_hash
|
|
89
|
+
t.string :pw_salt
|
|
90
|
+
t.string :persistence_token
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
create_table :ldapers do |t|
|
|
94
|
+
t.datetime :created_at
|
|
95
|
+
t.datetime :updated_at
|
|
96
|
+
t.string :ldap_login
|
|
97
|
+
t.string :persistence_token
|
|
98
|
+
end
|
|
72
99
|
end
|
|
73
100
|
|
|
74
101
|
require File.dirname(__FILE__) + '/../lib/authlogic' unless defined?(Authlogic)
|
|
75
|
-
require File.dirname(__FILE__) + '/
|
|
76
|
-
require File.dirname(__FILE__) + '/libs/mock_cookie_jar'
|
|
77
|
-
require File.dirname(__FILE__) + '/libs/mock_controller'
|
|
102
|
+
require File.dirname(__FILE__) + '/../lib/authlogic/test_case'
|
|
78
103
|
require File.dirname(__FILE__) + '/libs/project'
|
|
104
|
+
require File.dirname(__FILE__) + '/libs/affiliate'
|
|
79
105
|
require File.dirname(__FILE__) + '/libs/employee'
|
|
80
106
|
require File.dirname(__FILE__) + '/libs/employee_session'
|
|
107
|
+
require File.dirname(__FILE__) + '/libs/ldaper'
|
|
81
108
|
require File.dirname(__FILE__) + '/libs/user'
|
|
82
109
|
require File.dirname(__FILE__) + '/libs/user_session'
|
|
83
110
|
require File.dirname(__FILE__) + '/libs/company'
|
|
84
111
|
|
|
85
|
-
|
|
86
112
|
Authlogic::CryptoProviders::AES256.key = "myafdsfddddddddddddddddddddddddddddddddddddddddddddddd"
|
|
87
113
|
|
|
88
114
|
class ActiveSupport::TestCase
|
|
115
|
+
include ActiveRecord::TestFixtures
|
|
89
116
|
self.fixture_path = File.dirname(__FILE__) + "/fixtures"
|
|
90
|
-
self.use_transactional_fixtures =
|
|
117
|
+
self.use_transactional_fixtures = false
|
|
91
118
|
self.use_instantiated_fixtures = false
|
|
92
|
-
self.pre_loaded_fixtures =
|
|
119
|
+
self.pre_loaded_fixtures = false
|
|
93
120
|
fixtures :all
|
|
94
121
|
setup :activate_authlogic
|
|
95
122
|
|
|
96
123
|
private
|
|
97
|
-
def activate_authlogic
|
|
98
|
-
@controller = MockController.new
|
|
99
|
-
Authlogic::Session::Base.controller = @controller
|
|
100
|
-
end
|
|
101
|
-
|
|
102
124
|
def password_for(user)
|
|
103
125
|
case user
|
|
104
126
|
when users(:ben)
|
|
@@ -110,43 +132,43 @@ class ActiveSupport::TestCase
|
|
|
110
132
|
|
|
111
133
|
def http_basic_auth_for(user = nil, &block)
|
|
112
134
|
unless user.blank?
|
|
113
|
-
|
|
114
|
-
|
|
135
|
+
controller.http_user = user.login
|
|
136
|
+
controller.http_password = password_for(user)
|
|
115
137
|
end
|
|
116
138
|
yield
|
|
117
|
-
|
|
139
|
+
controller.http_user = controller.http_password = nil
|
|
118
140
|
end
|
|
119
141
|
|
|
120
142
|
def set_cookie_for(user, id = nil)
|
|
121
|
-
|
|
143
|
+
controller.cookies["user_credentials"] = {:value => user.persistence_token, :expires => nil}
|
|
122
144
|
end
|
|
123
145
|
|
|
124
146
|
def unset_cookie
|
|
125
|
-
|
|
147
|
+
controller.cookies["user_credentials"] = nil
|
|
126
148
|
end
|
|
127
149
|
|
|
128
150
|
def set_params_for(user, id = nil)
|
|
129
|
-
|
|
151
|
+
controller.params["user_credentials"] = user.single_access_token
|
|
130
152
|
end
|
|
131
153
|
|
|
132
154
|
def unset_params
|
|
133
|
-
|
|
155
|
+
controller.params["user_credentials"] = nil
|
|
134
156
|
end
|
|
135
157
|
|
|
136
158
|
def set_request_content_type(type)
|
|
137
|
-
|
|
159
|
+
controller.request_content_type = type
|
|
138
160
|
end
|
|
139
161
|
|
|
140
162
|
def unset_request_content_type
|
|
141
|
-
|
|
163
|
+
controller.request_content_type = nil
|
|
142
164
|
end
|
|
143
165
|
|
|
144
166
|
def set_session_for(user, id = nil)
|
|
145
|
-
|
|
146
|
-
|
|
167
|
+
controller.session["user_credentials"] = user.persistence_token
|
|
168
|
+
controller.session["user_credentials_id"] = user.id
|
|
147
169
|
end
|
|
148
170
|
|
|
149
171
|
def unset_session
|
|
150
|
-
|
|
172
|
+
controller.session["user_credentials"] = controller.session["user_credentials_id"] = nil
|
|
151
173
|
end
|
|
152
174
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: authlogic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Johnson of Binary Logic
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-06-13 00:00:00 -04:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -30,7 +30,7 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 2.0.0
|
|
34
34
|
version:
|
|
35
35
|
description: A clean, simple, and unobtrusive ruby authentication solution.
|
|
36
36
|
email: bjohnson@binarylogic.com
|
|
@@ -76,6 +76,7 @@ files:
|
|
|
76
76
|
- lib/authlogic/crypto_providers/sha512.rb
|
|
77
77
|
- lib/authlogic/i18n.rb
|
|
78
78
|
- lib/authlogic/random.rb
|
|
79
|
+
- lib/authlogic/regex.rb
|
|
79
80
|
- lib/authlogic/session/activation.rb
|
|
80
81
|
- lib/authlogic/session/active_record_trickery.rb
|
|
81
82
|
- lib/authlogic/session/base.rb
|
|
@@ -99,8 +100,14 @@ files:
|
|
|
99
100
|
- lib/authlogic/session/timeout.rb
|
|
100
101
|
- lib/authlogic/session/unauthorized_record.rb
|
|
101
102
|
- lib/authlogic/session/validation.rb
|
|
102
|
-
- lib/authlogic/
|
|
103
|
+
- lib/authlogic/test_case.rb
|
|
104
|
+
- lib/authlogic/test_case/mock_controller.rb
|
|
105
|
+
- lib/authlogic/test_case/mock_cookie_jar.rb
|
|
106
|
+
- lib/authlogic/test_case/mock_logger.rb
|
|
107
|
+
- lib/authlogic/test_case/mock_request.rb
|
|
108
|
+
- lib/authlogic/test_case/rails_request_adapter.rb
|
|
103
109
|
- lib/authlogic/version.rb
|
|
110
|
+
- rails/init.rb
|
|
104
111
|
- shoulda_macros/authlogic.rb
|
|
105
112
|
- test/acts_as_authentic_test/base_test.rb
|
|
106
113
|
- test/acts_as_authentic_test/email_test.rb
|
|
@@ -110,6 +117,7 @@ files:
|
|
|
110
117
|
- test/acts_as_authentic_test/password_test.rb
|
|
111
118
|
- test/acts_as_authentic_test/perishable_token_test.rb
|
|
112
119
|
- test/acts_as_authentic_test/persistence_token_test.rb
|
|
120
|
+
- test/acts_as_authentic_test/restful_authentication_test.rb
|
|
113
121
|
- test/acts_as_authentic_test/session_maintenance_test.rb
|
|
114
122
|
- test/acts_as_authentic_test/single_access_test.rb
|
|
115
123
|
- test/authenticates_many_test.rb
|
|
@@ -121,12 +129,11 @@ files:
|
|
|
121
129
|
- test/fixtures/employees.yml
|
|
122
130
|
- test/fixtures/projects.yml
|
|
123
131
|
- test/fixtures/users.yml
|
|
132
|
+
- test/libs/affiliate.rb
|
|
124
133
|
- test/libs/company.rb
|
|
125
134
|
- test/libs/employee.rb
|
|
126
135
|
- test/libs/employee_session.rb
|
|
127
|
-
- test/libs/
|
|
128
|
-
- test/libs/mock_cookie_jar.rb
|
|
129
|
-
- test/libs/mock_request.rb
|
|
136
|
+
- test/libs/ldaper.rb
|
|
130
137
|
- test/libs/ordered_hash.rb
|
|
131
138
|
- test/libs/project.rb
|
|
132
139
|
- test/libs/user.rb
|
|
@@ -156,7 +163,9 @@ files:
|
|
|
156
163
|
- test/test_helper.rb
|
|
157
164
|
has_rdoc: true
|
|
158
165
|
homepage: http://github.com/binarylogic/authlogic
|
|
159
|
-
|
|
166
|
+
licenses: []
|
|
167
|
+
|
|
168
|
+
post_install_message:
|
|
160
169
|
rdoc_options:
|
|
161
170
|
- --main
|
|
162
171
|
- README.rdoc
|
|
@@ -177,11 +186,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
177
186
|
requirements: []
|
|
178
187
|
|
|
179
188
|
rubyforge_project: authlogic
|
|
180
|
-
rubygems_version: 1.3.
|
|
189
|
+
rubygems_version: 1.3.4
|
|
181
190
|
signing_key:
|
|
182
|
-
specification_version:
|
|
191
|
+
specification_version: 3
|
|
183
192
|
summary: A clean, simple, and unobtrusive ruby authentication solution.
|
|
184
193
|
test_files:
|
|
194
|
+
- test/authenticates_many_test.rb
|
|
195
|
+
- test/random_test.rb
|
|
185
196
|
- test/acts_as_authentic_test/base_test.rb
|
|
186
197
|
- test/acts_as_authentic_test/email_test.rb
|
|
187
198
|
- test/acts_as_authentic_test/logged_in_status_test.rb
|
|
@@ -190,6 +201,7 @@ test_files:
|
|
|
190
201
|
- test/acts_as_authentic_test/password_test.rb
|
|
191
202
|
- test/acts_as_authentic_test/perishable_token_test.rb
|
|
192
203
|
- test/acts_as_authentic_test/persistence_token_test.rb
|
|
204
|
+
- test/acts_as_authentic_test/restful_authentication_test.rb
|
|
193
205
|
- test/acts_as_authentic_test/session_maintenance_test.rb
|
|
194
206
|
- test/acts_as_authentic_test/single_access_test.rb
|
|
195
207
|
- test/crypto_provider_test/aes256_test.rb
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
module Authlogic
|
|
2
|
-
# Various utilities to help with testing. Keep in mind, Authlogic is thoroughly tested for you, the only thing you should be
|
|
3
|
-
# testing is code you write, such as code in your controller.
|
|
4
|
-
module Testing
|
|
5
|
-
# Provides useful methods for testing in Test::Unit, lets you log records in, etc. Just include this in your test_helper filter:
|
|
6
|
-
#
|
|
7
|
-
# require "authlogic/testing/test_unit_helpers"
|
|
8
|
-
#
|
|
9
|
-
# Then you will have the methods below to use in your tests.
|
|
10
|
-
module TestUnitHelpers
|
|
11
|
-
private
|
|
12
|
-
def session_class(record) # :nodoc:
|
|
13
|
-
record.class.acts_as_authentic_config[:session_class].constantize
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# Sets the session for a record. This way when you execute a request in your test, session values will be present.
|
|
17
|
-
def set_session_for(record)
|
|
18
|
-
session_class = session_class(record)
|
|
19
|
-
@request.session[session_class.session_key] = record.send(record.class.acts_as_authentic_config[:persistence_token_field])
|
|
20
|
-
@request.session["#{session_class.session_key}_id"] = record.id
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Sets the cookie for a record. This way when you execute a request in your test, cookie values will be present.
|
|
24
|
-
def set_cookie_for(record)
|
|
25
|
-
session_class = session_class(record)
|
|
26
|
-
@request.cookies[session_class.cookie_key] = record.send(record.class.acts_as_authentic_config[:persistence_token_field])
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Sets the HTTP_AUTHORIZATION header for basic HTTP auth. This way when you execute a request in your test that is trying to authenticate
|
|
30
|
-
# with HTTP basic auth, the neccessary headers will be present.
|
|
31
|
-
def set_http_auth_for(username, password)
|
|
32
|
-
session_class = session_class(record)
|
|
33
|
-
@request.env['HTTP_AUTHORIZATION'] = @controller.encode_credentials(username, password)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
Test::Unit::TestCase.send(:include, Authlogic::Testing::TestUnitHelpers)
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
class MockController < Authlogic::ControllerAdapters::AbstractAdapter
|
|
2
|
-
attr_accessor :http_user, :http_password
|
|
3
|
-
attr_writer :request_content_type
|
|
4
|
-
|
|
5
|
-
def initialize
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def authenticate_with_http_basic(&block)
|
|
9
|
-
yield http_user, http_password
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def cookies
|
|
13
|
-
@cookies ||= MockCookieJar.new
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def cookie_domain
|
|
17
|
-
nil
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def params
|
|
21
|
-
@params ||= {}
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def request
|
|
25
|
-
@request ||= MockRequest.new
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def request_content_type
|
|
29
|
-
@request_content_type ||= "text/html"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def session
|
|
33
|
-
@session ||= {}
|
|
34
|
-
end
|
|
35
|
-
end
|