authlogic 2.0.1 → 2.1.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.
Files changed (82) hide show
  1. data/.gitignore +9 -0
  2. data/CHANGELOG.rdoc +99 -1
  3. data/{MIT-LICENSE → LICENSE} +1 -1
  4. data/README.rdoc +136 -159
  5. data/Rakefile +47 -19
  6. data/VERSION.yml +4 -0
  7. data/authlogic.gemspec +205 -0
  8. data/init.rb +1 -1
  9. data/lib/authlogic/acts_as_authentic/base.rb +31 -17
  10. data/lib/authlogic/acts_as_authentic/email.rb +47 -14
  11. data/lib/authlogic/acts_as_authentic/logged_in_status.rb +20 -14
  12. data/lib/authlogic/acts_as_authentic/login.rb +84 -8
  13. data/lib/authlogic/acts_as_authentic/password.rb +207 -88
  14. data/lib/authlogic/acts_as_authentic/perishable_token.rb +9 -4
  15. data/lib/authlogic/acts_as_authentic/persistence_token.rb +4 -2
  16. data/lib/authlogic/acts_as_authentic/restful_authentication.rb +5 -4
  17. data/lib/authlogic/acts_as_authentic/session_maintenance.rb +16 -4
  18. data/lib/authlogic/acts_as_authentic/single_access_token.rb +10 -3
  19. data/lib/authlogic/acts_as_authentic/validations_scope.rb +1 -1
  20. data/lib/authlogic/controller_adapters/abstract_adapter.rb +13 -1
  21. data/lib/authlogic/controller_adapters/rails_adapter.rb +1 -1
  22. data/lib/authlogic/crypto_providers/aes256.rb +2 -2
  23. data/lib/authlogic/crypto_providers/bcrypt.rb +3 -1
  24. data/lib/authlogic/crypto_providers/sha1.rb +2 -2
  25. data/lib/authlogic/i18n.rb +10 -1
  26. data/lib/authlogic/regex.rb +25 -0
  27. data/lib/authlogic/session/activation.rb +2 -0
  28. data/lib/authlogic/session/active_record_trickery.rb +13 -3
  29. data/lib/authlogic/session/brute_force_protection.rb +26 -11
  30. data/lib/authlogic/session/callbacks.rb +16 -6
  31. data/lib/authlogic/session/cookies.rb +15 -11
  32. data/lib/authlogic/session/existence.rb +4 -2
  33. data/lib/authlogic/session/foundation.rb +1 -1
  34. data/lib/authlogic/session/http_auth.rb +46 -11
  35. data/lib/authlogic/session/magic_columns.rb +25 -6
  36. data/lib/authlogic/session/magic_states.rb +4 -4
  37. data/lib/authlogic/session/params.rb +14 -9
  38. data/lib/authlogic/session/password.rb +86 -24
  39. data/lib/authlogic/session/priority_record.rb +1 -1
  40. data/lib/authlogic/session/session.rb +2 -2
  41. data/lib/authlogic/session/timeout.rb +1 -1
  42. data/lib/authlogic/session/validation.rb +9 -5
  43. data/lib/authlogic/test_case/mock_controller.rb +45 -0
  44. data/lib/authlogic/test_case/mock_cookie_jar.rb +14 -0
  45. data/lib/authlogic/test_case/mock_logger.rb +10 -0
  46. data/lib/authlogic/test_case/mock_request.rb +19 -0
  47. data/lib/authlogic/test_case/rails_request_adapter.rb +30 -0
  48. data/lib/authlogic/test_case.rb +114 -0
  49. data/lib/authlogic.rb +1 -1
  50. data/rails/init.rb +1 -0
  51. data/shoulda_macros/authlogic.rb +2 -1
  52. data/test/acts_as_authentic_test/base_test.rb +6 -0
  53. data/test/acts_as_authentic_test/email_test.rb +25 -7
  54. data/test/acts_as_authentic_test/login_test.rb +37 -7
  55. data/test/acts_as_authentic_test/magic_columns_test.rb +4 -4
  56. data/test/acts_as_authentic_test/password_test.rb +46 -44
  57. data/test/acts_as_authentic_test/perishable_token_test.rb +36 -2
  58. data/test/acts_as_authentic_test/restful_authentication_test.rb +40 -0
  59. data/test/acts_as_authentic_test/session_maintenance_test.rb +26 -18
  60. data/test/acts_as_authentic_test/single_access_test.rb +6 -1
  61. data/test/libs/affiliate.rb +7 -0
  62. data/test/libs/ldaper.rb +3 -0
  63. data/test/random_test.rb +2 -2
  64. data/test/session_test/activation_test.rb +1 -1
  65. data/test/session_test/active_record_trickery_test.rb +2 -1
  66. data/test/session_test/brute_force_protection_test.rb +34 -9
  67. data/test/session_test/cookies_test.rb +3 -3
  68. data/test/session_test/http_auth_test.rb +20 -8
  69. data/test/session_test/magic_columns_test.rb +7 -4
  70. data/test/session_test/magic_states_test.rb +3 -3
  71. data/test/session_test/params_test.rb +4 -4
  72. data/test/session_test/password_test.rb +8 -0
  73. data/test/session_test/session_test.rb +9 -9
  74. data/test/session_test/timeout_test.rb +10 -1
  75. data/test/test_helper.rb +43 -21
  76. metadata +38 -27
  77. data/Manifest.txt +0 -111
  78. data/lib/authlogic/testing/test_unit_helpers.rb +0 -39
  79. data/lib/authlogic/version.rb +0 -56
  80. data/test/libs/mock_controller.rb +0 -35
  81. data/test/libs/mock_cookie_jar.rb +0 -10
  82. data/test/libs/mock_request.rb +0 -5
@@ -31,7 +31,7 @@ module SessionTest
31
31
 
32
32
  ben.update_attribute(:active, false)
33
33
  assert !session.valid?
34
- assert session.errors.on_base.size > 0
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.on_base.size > 0
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.on_base.size > 0
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 @controller.session["user_credentials"]
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 @controller.session["user_credentials"]
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 @controller.session["user_credentials"] # should not persist since this is single access
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 @controller.session["user_credentials"]
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, @controller.session["user_credentials"]
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
- @controller.session["user_credentials_id"] = nil
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, @controller.session["user_credentials"]
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 @controller.session["user_credentials"].blank?
36
+ assert controller.session["user_credentials"].blank?
37
37
  assert session.save
38
- assert_equal ben.persistence_token, @controller.session["user_credentials"]
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, @controller.session["user_credentials"]
44
+ assert_equal ben.persistence_token, controller.session["user_credentials"]
45
45
  assert session = UserSession.find
46
46
  assert session.destroy
47
- assert @controller.session["user_credentials"].blank?
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 @controller.session["user_credentials"].blank?
53
+ assert controller.session["user_credentials"].blank?
54
54
  assert UserSession.find
55
- assert_equal ben.persistence_token, @controller.session["user_credentials"]
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 @controller.session["user_credentials_id"]
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 'active_record/fixtures'
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,15 +79,32 @@ 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__) + '/libs/mock_request'
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'
@@ -94,11 +121,6 @@ class ActiveSupport::TestCase
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
- @controller.http_user = user.login
114
- @controller.http_password = password_for(user)
135
+ controller.http_user = user.login
136
+ controller.http_password = password_for(user)
115
137
  end
116
138
  yield
117
- @controller.http_user = @controller.http_password = nil
139
+ controller.http_user = controller.http_password = nil
118
140
  end
119
141
 
120
142
  def set_cookie_for(user, id = nil)
121
- @controller.cookies["user_credentials"] = {:value => user.persistence_token, :expires => nil}
143
+ controller.cookies["user_credentials"] = {:value => user.persistence_token, :expires => nil}
122
144
  end
123
145
 
124
146
  def unset_cookie
125
- @controller.cookies["user_credentials"] = nil
147
+ controller.cookies["user_credentials"] = nil
126
148
  end
127
149
 
128
150
  def set_params_for(user, id = nil)
129
- @controller.params["user_credentials"] = user.single_access_token
151
+ controller.params["user_credentials"] = user.single_access_token
130
152
  end
131
153
 
132
154
  def unset_params
133
- @controller.params["user_credentials"] = nil
155
+ controller.params["user_credentials"] = nil
134
156
  end
135
157
 
136
158
  def set_request_content_type(type)
137
- @controller.request_content_type = type
159
+ controller.request_content_type = type
138
160
  end
139
161
 
140
162
  def unset_request_content_type
141
- @controller.request_content_type = nil
163
+ controller.request_content_type = nil
142
164
  end
143
165
 
144
166
  def set_session_for(user, id = nil)
145
- @controller.session["user_credentials"] = user.persistence_token
146
- @controller.session["user_credentials_id"] = user.id
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
- @controller.session["user_credentials"] = @controller.session["user_credentials_id"] = nil
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.1
4
+ version: 2.1.0
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-03-23 00:00:00 -04:00
12
+ date: 2009-06-27 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,32 +22,23 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
- - !ruby/object:Gem::Dependency
26
- name: hoe
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 1.11.0
34
- version:
35
- description: A clean, simple, and unobtrusive ruby authentication solution.
25
+ description:
36
26
  email: bjohnson@binarylogic.com
37
27
  executables: []
38
28
 
39
29
  extensions: []
40
30
 
41
31
  extra_rdoc_files:
42
- - Manifest.txt
43
- - CHANGELOG.rdoc
32
+ - LICENSE
44
33
  - README.rdoc
45
34
  files:
35
+ - .gitignore
46
36
  - CHANGELOG.rdoc
47
- - MIT-LICENSE
48
- - Manifest.txt
37
+ - LICENSE
49
38
  - README.rdoc
50
39
  - Rakefile
40
+ - VERSION.yml
41
+ - authlogic.gemspec
51
42
  - generators/session/session_generator.rb
52
43
  - generators/session/templates/session.rb
53
44
  - init.rb
@@ -76,6 +67,7 @@ files:
76
67
  - lib/authlogic/crypto_providers/sha512.rb
77
68
  - lib/authlogic/i18n.rb
78
69
  - lib/authlogic/random.rb
70
+ - lib/authlogic/regex.rb
79
71
  - lib/authlogic/session/activation.rb
80
72
  - lib/authlogic/session/active_record_trickery.rb
81
73
  - lib/authlogic/session/base.rb
@@ -99,8 +91,13 @@ files:
99
91
  - lib/authlogic/session/timeout.rb
100
92
  - lib/authlogic/session/unauthorized_record.rb
101
93
  - lib/authlogic/session/validation.rb
102
- - lib/authlogic/testing/test_unit_helpers.rb
103
- - lib/authlogic/version.rb
94
+ - lib/authlogic/test_case.rb
95
+ - lib/authlogic/test_case/mock_controller.rb
96
+ - lib/authlogic/test_case/mock_cookie_jar.rb
97
+ - lib/authlogic/test_case/mock_logger.rb
98
+ - lib/authlogic/test_case/mock_request.rb
99
+ - lib/authlogic/test_case/rails_request_adapter.rb
100
+ - rails/init.rb
104
101
  - shoulda_macros/authlogic.rb
105
102
  - test/acts_as_authentic_test/base_test.rb
106
103
  - test/acts_as_authentic_test/email_test.rb
@@ -110,6 +107,7 @@ files:
110
107
  - test/acts_as_authentic_test/password_test.rb
111
108
  - test/acts_as_authentic_test/perishable_token_test.rb
112
109
  - test/acts_as_authentic_test/persistence_token_test.rb
110
+ - test/acts_as_authentic_test/restful_authentication_test.rb
113
111
  - test/acts_as_authentic_test/session_maintenance_test.rb
114
112
  - test/acts_as_authentic_test/single_access_test.rb
115
113
  - test/authenticates_many_test.rb
@@ -121,12 +119,11 @@ files:
121
119
  - test/fixtures/employees.yml
122
120
  - test/fixtures/projects.yml
123
121
  - test/fixtures/users.yml
122
+ - test/libs/affiliate.rb
124
123
  - test/libs/company.rb
125
124
  - test/libs/employee.rb
126
125
  - test/libs/employee_session.rb
127
- - test/libs/mock_controller.rb
128
- - test/libs/mock_cookie_jar.rb
129
- - test/libs/mock_request.rb
126
+ - test/libs/ldaper.rb
130
127
  - test/libs/ordered_hash.rb
131
128
  - test/libs/project.rb
132
129
  - test/libs/user.rb
@@ -156,10 +153,11 @@ files:
156
153
  - test/test_helper.rb
157
154
  has_rdoc: true
158
155
  homepage: http://github.com/binarylogic/authlogic
159
- post_install_message: "Version 2.0 introduces some changes that break backwards compatibility. The big change is how acts_as_authentic accepts configuration options. Instead of a hash, it now accepts a block: acts_as_authentic { |c| c.my_config_option = my_value}. See the docs for more details."
156
+ licenses: []
157
+
158
+ post_install_message:
160
159
  rdoc_options:
161
- - --main
162
- - README.rdoc
160
+ - --charset=UTF-8
163
161
  require_paths:
164
162
  - lib
165
163
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -177,9 +175,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
175
  requirements: []
178
176
 
179
177
  rubyforge_project: authlogic
180
- rubygems_version: 1.3.1
178
+ rubygems_version: 1.3.4
181
179
  signing_key:
182
- specification_version: 2
180
+ specification_version: 3
183
181
  summary: A clean, simple, and unobtrusive ruby authentication solution.
184
182
  test_files:
185
183
  - test/acts_as_authentic_test/base_test.rb
@@ -190,12 +188,24 @@ test_files:
190
188
  - test/acts_as_authentic_test/password_test.rb
191
189
  - test/acts_as_authentic_test/perishable_token_test.rb
192
190
  - test/acts_as_authentic_test/persistence_token_test.rb
191
+ - test/acts_as_authentic_test/restful_authentication_test.rb
193
192
  - test/acts_as_authentic_test/session_maintenance_test.rb
194
193
  - test/acts_as_authentic_test/single_access_test.rb
194
+ - test/authenticates_many_test.rb
195
195
  - test/crypto_provider_test/aes256_test.rb
196
196
  - test/crypto_provider_test/bcrypt_test.rb
197
197
  - test/crypto_provider_test/sha1_test.rb
198
198
  - test/crypto_provider_test/sha512_test.rb
199
+ - test/libs/affiliate.rb
200
+ - test/libs/company.rb
201
+ - test/libs/employee.rb
202
+ - test/libs/employee_session.rb
203
+ - test/libs/ldaper.rb
204
+ - test/libs/ordered_hash.rb
205
+ - test/libs/project.rb
206
+ - test/libs/user.rb
207
+ - test/libs/user_session.rb
208
+ - test/random_test.rb
199
209
  - test/session_test/activation_test.rb
200
210
  - test/session_test/active_record_trickery_test.rb
201
211
  - test/session_test/brute_force_protection_test.rb
@@ -217,3 +227,4 @@ test_files:
217
227
  - test/session_test/timeout_test.rb
218
228
  - test/session_test/unauthorized_record_test.rb
219
229
  - test/session_test/validation_test.rb
230
+ - test/test_helper.rb
data/Manifest.txt DELETED
@@ -1,111 +0,0 @@
1
- CHANGELOG.rdoc
2
- MIT-LICENSE
3
- Manifest.txt
4
- README.rdoc
5
- Rakefile
6
- generators/session/session_generator.rb
7
- generators/session/templates/session.rb
8
- init.rb
9
- lib/authlogic.rb
10
- lib/authlogic/acts_as_authentic/base.rb
11
- lib/authlogic/acts_as_authentic/email.rb
12
- lib/authlogic/acts_as_authentic/logged_in_status.rb
13
- lib/authlogic/acts_as_authentic/login.rb
14
- lib/authlogic/acts_as_authentic/magic_columns.rb
15
- lib/authlogic/acts_as_authentic/password.rb
16
- lib/authlogic/acts_as_authentic/perishable_token.rb
17
- lib/authlogic/acts_as_authentic/persistence_token.rb
18
- lib/authlogic/acts_as_authentic/restful_authentication.rb
19
- lib/authlogic/acts_as_authentic/session_maintenance.rb
20
- lib/authlogic/acts_as_authentic/single_access_token.rb
21
- lib/authlogic/acts_as_authentic/validations_scope.rb
22
- lib/authlogic/authenticates_many/association.rb
23
- lib/authlogic/authenticates_many/base.rb
24
- lib/authlogic/controller_adapters/abstract_adapter.rb
25
- lib/authlogic/controller_adapters/merb_adapter.rb
26
- lib/authlogic/controller_adapters/rails_adapter.rb
27
- lib/authlogic/crypto_providers/aes256.rb
28
- lib/authlogic/crypto_providers/bcrypt.rb
29
- lib/authlogic/crypto_providers/md5.rb
30
- lib/authlogic/crypto_providers/sha1.rb
31
- lib/authlogic/crypto_providers/sha512.rb
32
- lib/authlogic/i18n.rb
33
- lib/authlogic/random.rb
34
- lib/authlogic/session/activation.rb
35
- lib/authlogic/session/active_record_trickery.rb
36
- lib/authlogic/session/base.rb
37
- lib/authlogic/session/brute_force_protection.rb
38
- lib/authlogic/session/callbacks.rb
39
- lib/authlogic/session/cookies.rb
40
- lib/authlogic/session/existence.rb
41
- lib/authlogic/session/foundation.rb
42
- lib/authlogic/session/http_auth.rb
43
- lib/authlogic/session/id.rb
44
- lib/authlogic/session/klass.rb
45
- lib/authlogic/session/magic_columns.rb
46
- lib/authlogic/session/magic_states.rb
47
- lib/authlogic/session/params.rb
48
- lib/authlogic/session/password.rb
49
- lib/authlogic/session/perishable_token.rb
50
- lib/authlogic/session/persistence.rb
51
- lib/authlogic/session/priority_record.rb
52
- lib/authlogic/session/scopes.rb
53
- lib/authlogic/session/session.rb
54
- lib/authlogic/session/timeout.rb
55
- lib/authlogic/session/unauthorized_record.rb
56
- lib/authlogic/session/validation.rb
57
- lib/authlogic/testing/test_unit_helpers.rb
58
- lib/authlogic/version.rb
59
- shoulda_macros/authlogic.rb
60
- test/acts_as_authentic_test/base_test.rb
61
- test/acts_as_authentic_test/email_test.rb
62
- test/acts_as_authentic_test/logged_in_status_test.rb
63
- test/acts_as_authentic_test/login_test.rb
64
- test/acts_as_authentic_test/magic_columns_test.rb
65
- test/acts_as_authentic_test/password_test.rb
66
- test/acts_as_authentic_test/perishable_token_test.rb
67
- test/acts_as_authentic_test/persistence_token_test.rb
68
- test/acts_as_authentic_test/session_maintenance_test.rb
69
- test/acts_as_authentic_test/single_access_test.rb
70
- test/authenticates_many_test.rb
71
- test/crypto_provider_test/aes256_test.rb
72
- test/crypto_provider_test/bcrypt_test.rb
73
- test/crypto_provider_test/sha1_test.rb
74
- test/crypto_provider_test/sha512_test.rb
75
- test/fixtures/companies.yml
76
- test/fixtures/employees.yml
77
- test/fixtures/projects.yml
78
- test/fixtures/users.yml
79
- test/libs/company.rb
80
- test/libs/employee.rb
81
- test/libs/employee_session.rb
82
- test/libs/mock_controller.rb
83
- test/libs/mock_cookie_jar.rb
84
- test/libs/mock_request.rb
85
- test/libs/ordered_hash.rb
86
- test/libs/project.rb
87
- test/libs/user.rb
88
- test/libs/user_session.rb
89
- test/random_test.rb
90
- test/session_test/activation_test.rb
91
- test/session_test/active_record_trickery_test.rb
92
- test/session_test/brute_force_protection_test.rb
93
- test/session_test/callbacks_test.rb
94
- test/session_test/cookies_test.rb
95
- test/session_test/credentials_test.rb
96
- test/session_test/existence_test.rb
97
- test/session_test/http_auth_test.rb
98
- test/session_test/id_test.rb
99
- test/session_test/klass_test.rb
100
- test/session_test/magic_columns_test.rb
101
- test/session_test/magic_states_test.rb
102
- test/session_test/params_test.rb
103
- test/session_test/password_test.rb
104
- test/session_test/perishability_test.rb
105
- test/session_test/persistence_test.rb
106
- test/session_test/scopes_test.rb
107
- test/session_test/session_test.rb
108
- test/session_test/timeout_test.rb
109
- test/session_test/unauthorized_record_test.rb
110
- test/session_test/validation_test.rb
111
- test/test_helper.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,56 +0,0 @@
1
- module Authlogic # :nodoc:
2
- # = Version
3
- #
4
- # A class for describing the current version of a library. The version
5
- # consists of three parts: the +major+ number, the +minor+ number, and the
6
- # +tiny+ (or +patch+) number.
7
- class Version
8
-
9
- include Comparable
10
-
11
- # A convenience method for instantiating a new Version instance with the
12
- # given +major+, +minor+, and +tiny+ components.
13
- def self.[](major, minor, tiny)
14
- new(major, minor, tiny)
15
- end
16
-
17
- attr_reader :major, :minor, :tiny
18
-
19
- # Create a new Version object with the given components.
20
- def initialize(major, minor, tiny)
21
- @major, @minor, @tiny = major, minor, tiny
22
- end
23
-
24
- # Compare this version to the given +version+ object.
25
- def <=>(version)
26
- to_i <=> version.to_i
27
- end
28
-
29
- # Converts this version object to a string, where each of the three
30
- # version components are joined by the '.' character. E.g., 2.0.0.
31
- def to_s
32
- @to_s ||= [@major, @minor, @tiny].join(".")
33
- end
34
-
35
- # Converts this version to a canonical integer that may be compared
36
- # against other version objects.
37
- def to_i
38
- @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny
39
- end
40
-
41
- def to_a
42
- [@major, @minor, @tiny]
43
- end
44
-
45
- MAJOR = 2
46
- MINOR = 0
47
- TINY = 1
48
-
49
- # The current version as a Version instance
50
- CURRENT = new(MAJOR, MINOR, TINY)
51
- # The current version as a String
52
- STRING = CURRENT.to_s
53
-
54
- end
55
-
56
- end
@@ -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
@@ -1,10 +0,0 @@
1
- class MockCookieJar < Hash
2
- def [](key)
3
- hash = super
4
- hash && hash[:value]
5
- end
6
-
7
- def delete(key, options = {})
8
- super(key)
9
- end
10
- end