authlogic 3.4.3 → 3.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,24 +6,24 @@ module SessionTest
6
6
  def test_last_request_at_threshold_config
7
7
  UserSession.last_request_at_threshold = 2.minutes
8
8
  assert_equal 2.minutes, UserSession.last_request_at_threshold
9
-
9
+
10
10
  UserSession.last_request_at_threshold 0
11
11
  assert_equal 0, UserSession.last_request_at_threshold
12
12
  end
13
13
  end
14
-
14
+
15
15
  class InstanceMethodsTest < ActiveSupport::TestCase
16
16
  def test_after_persisting_set_last_request_at
17
17
  ben = users(:ben)
18
18
  assert !UserSession.create(ben).new_session?
19
-
19
+
20
20
  set_cookie_for(ben)
21
21
  old_last_request_at = ben.last_request_at
22
22
  assert UserSession.find
23
23
  ben.reload
24
24
  assert ben.last_request_at != old_last_request_at
25
25
  end
26
-
26
+
27
27
  def test_valid_increase_failed_login_count
28
28
  ben = users(:ben)
29
29
  old_failed_login_count = ben.failed_login_count
@@ -31,32 +31,32 @@ module SessionTest
31
31
  ben.reload
32
32
  assert_equal old_failed_login_count + 1, ben.failed_login_count
33
33
  end
34
-
34
+
35
35
  def test_before_save_update_info
36
- ben = users(:ben)
37
-
36
+ aaron = users(:aaron)
37
+
38
38
  # increase failed login count
39
- assert UserSession.create(:login => ben.login, :password => "wrong").new_session?
40
- ben.reload
41
-
39
+ assert UserSession.create(:login => aaron.login, :password => "wrong").new_session?
40
+ aaron.reload
41
+
42
42
  # grab old values
43
- old_login_count = ben.login_count
44
- old_failed_login_count = ben.failed_login_count
45
- old_last_login_at = ben.last_login_at
46
- old_current_login_at = ben.current_login_at
47
- old_last_login_ip = ben.last_login_ip
48
- old_current_login_ip = ben.current_login_ip
49
-
50
- assert !UserSession.create(:login => ben.login, :password => "benrocks").new_session?
51
-
52
- ben.reload
53
- assert_equal old_login_count + 1, ben.login_count
54
- assert_equal 0, ben.failed_login_count
55
- assert_equal old_current_login_at, ben.last_login_at
56
- assert ben.current_login_at != old_current_login_at
57
- assert_equal old_current_login_ip, ben.last_login_ip
58
- assert_equal "1.1.1.1", ben.current_login_ip
43
+ old_login_count = aaron.login_count
44
+ old_failed_login_count = aaron.failed_login_count
45
+ old_last_login_at = aaron.last_login_at
46
+ old_current_login_at = aaron.current_login_at
47
+ old_last_login_ip = aaron.last_login_ip
48
+ old_current_login_ip = aaron.current_login_ip
49
+
50
+ assert UserSession.create(:login => aaron.login, :password => "aaronrocks").valid?
51
+
52
+ aaron.reload
53
+ assert_equal old_login_count + 1, aaron.login_count
54
+ assert_equal 0, aaron.failed_login_count
55
+ assert_equal old_current_login_at, aaron.last_login_at
56
+ assert aaron.current_login_at != old_current_login_at
57
+ assert_equal old_current_login_ip, aaron.last_login_ip
58
+ assert_equal "1.1.1.1", aaron.current_login_ip
59
59
  end
60
60
  end
61
61
  end
62
- end
62
+ end
@@ -6,26 +6,26 @@ module SessionTest
6
6
  def test_find_by_login_method
7
7
  UserSession.find_by_login_method = "my_login_method"
8
8
  assert_equal "my_login_method", UserSession.find_by_login_method
9
-
9
+
10
10
  UserSession.find_by_login_method "find_by_login"
11
11
  assert_equal "find_by_login", UserSession.find_by_login_method
12
12
  end
13
-
13
+
14
14
  def test_verify_password_method
15
15
  UserSession.verify_password_method = "my_login_method"
16
16
  assert_equal "my_login_method", UserSession.verify_password_method
17
-
17
+
18
18
  UserSession.verify_password_method "valid_password?"
19
19
  assert_equal "valid_password?", UserSession.verify_password_method
20
20
  end
21
-
21
+
22
22
  def test_generalize_credentials_error_mesages_set_to_false
23
23
  UserSession.generalize_credentials_error_messages false
24
24
  assert !UserSession.generalize_credentials_error_messages
25
25
  session = UserSession.create(:login => users(:ben).login, :password => "invalud-password")
26
26
  assert_equal ["Password is not valid"], session.errors.full_messages
27
27
  end
28
-
28
+
29
29
  def test_generalize_credentials_error_messages_set_to_true
30
30
  UserSession.generalize_credentials_error_messages true
31
31
  assert UserSession.generalize_credentials_error_messages
@@ -40,34 +40,34 @@ module SessionTest
40
40
  assert_equal ["Custom Error Message"], session.errors.full_messages
41
41
  end
42
42
 
43
-
43
+
44
44
  def test_login_field
45
45
  UserSession.configured_password_methods = false
46
46
  UserSession.login_field = :saweet
47
47
  assert_equal :saweet, UserSession.login_field
48
48
  session = UserSession.new
49
49
  assert session.respond_to?(:saweet)
50
-
50
+
51
51
  UserSession.login_field :login
52
52
  assert_equal :login, UserSession.login_field
53
53
  session = UserSession.new
54
54
  assert session.respond_to?(:login)
55
55
  end
56
-
56
+
57
57
  def test_password_field
58
58
  UserSession.configured_password_methods = false
59
59
  UserSession.password_field = :saweet
60
60
  assert_equal :saweet, UserSession.password_field
61
61
  session = UserSession.new
62
62
  assert session.respond_to?(:saweet)
63
-
63
+
64
64
  UserSession.password_field :password
65
65
  assert_equal :password, UserSession.password_field
66
66
  session = UserSession.new
67
67
  assert session.respond_to?(:password)
68
68
  end
69
69
  end
70
-
70
+
71
71
  class InstanceMethodsTest < ActiveSupport::TestCase
72
72
  def test_init
73
73
  session = UserSession.new
@@ -77,7 +77,7 @@ module SessionTest
77
77
  assert session.respond_to?(:password=)
78
78
  assert session.respond_to?(:protected_password, true)
79
79
  end
80
-
80
+
81
81
  def test_credentials
82
82
  session = UserSession.new
83
83
  session.credentials = {:login => "login", :password => "pass"}
@@ -86,15 +86,15 @@ module SessionTest
86
86
  assert_equal "pass", session.send(:protected_password)
87
87
  assert_equal({:password => "<protected>", :login => "login"}, session.credentials)
88
88
  end
89
-
89
+
90
90
  def test_credentials_are_params_safe
91
91
  session = UserSession.new
92
92
  assert_nothing_raised { session.credentials = {:hacker_method => "error!"} }
93
93
  end
94
-
94
+
95
95
  def test_save_with_credentials
96
- ben = users(:ben)
97
- session = UserSession.new(:login => ben.login, :password => "benrocks")
96
+ aaron = users(:aaron)
97
+ session = UserSession.new(:login => aaron.login, :password => "aaronrocks")
98
98
  assert session.save
99
99
  assert !session.new_session?
100
100
  assert_equal 1, session.record.login_count
@@ -3,29 +3,29 @@ require 'test_helper'
3
3
  module SessionTest
4
4
  class PersistenceTest < ActiveSupport::TestCase
5
5
  def test_find
6
- ben = users(:ben)
6
+ aaron = users(:aaron)
7
7
  assert !UserSession.find
8
- http_basic_auth_for(ben) { assert UserSession.find }
9
- set_cookie_for(ben)
8
+ http_basic_auth_for(aaron) { assert UserSession.find }
9
+ set_cookie_for(aaron)
10
10
  assert UserSession.find
11
11
  unset_cookie
12
- set_session_for(ben)
12
+ set_session_for(aaron)
13
13
  session = UserSession.find
14
14
  assert session
15
15
  end
16
-
16
+
17
17
  def test_persisting
18
18
  # tested thoroughly in test_find
19
19
  end
20
20
 
21
21
  def test_should_set_remember_me_on_the_next_request
22
- ben = users(:ben)
23
- session = UserSession.new(ben)
22
+ aaron = users(:aaron)
23
+ session = UserSession.new(aaron)
24
24
  session.remember_me = true
25
25
  assert !UserSession.remember_me
26
26
  assert session.save
27
27
  assert session.remember_me?
28
- session = UserSession.find(ben)
28
+ session = UserSession.find(aaron)
29
29
  assert session.remember_me?
30
30
  end
31
31
  end
data/test/test_helper.rb CHANGED
@@ -99,16 +99,16 @@ ActiveRecord::Schema.define(:version => 1) do
99
99
  end
100
100
  end
101
101
 
102
- require File.dirname(__FILE__) + '/../lib/authlogic' unless defined?(Authlogic)
103
- require File.dirname(__FILE__) + '/../lib/authlogic/test_case'
104
- require File.dirname(__FILE__) + '/libs/project'
105
- require File.dirname(__FILE__) + '/libs/affiliate'
106
- require File.dirname(__FILE__) + '/libs/employee'
107
- require File.dirname(__FILE__) + '/libs/employee_session'
108
- require File.dirname(__FILE__) + '/libs/ldaper'
109
- require File.dirname(__FILE__) + '/libs/user'
110
- require File.dirname(__FILE__) + '/libs/user_session'
111
- require File.dirname(__FILE__) + '/libs/company'
102
+ require_relative '../lib/authlogic' unless defined?(Authlogic)
103
+ require_relative '../lib/authlogic/test_case'
104
+ require_relative 'libs/project'
105
+ require_relative 'libs/affiliate'
106
+ require_relative 'libs/employee'
107
+ require_relative 'libs/employee_session'
108
+ require_relative 'libs/ldaper'
109
+ require_relative 'libs/user'
110
+ require_relative 'libs/user_session'
111
+ require_relative 'libs/company'
112
112
 
113
113
  Authlogic::CryptoProviders::AES256.key = "myafdsfddddddddddddddddddddddddddddddddddddddddddddddd"
114
114
 
@@ -120,14 +120,37 @@ class ActiveSupport::TestCase
120
120
  self.pre_loaded_fixtures = false
121
121
  fixtures :all
122
122
  setup :activate_authlogic
123
+ setup :config_setup
124
+ teardown :config_teardown
125
+ teardown { Timecop.return } # for tests that need to freeze the time
126
+
123
127
 
124
128
  private
129
+ # Many of the tests change Authlogic config for the test models. Some tests
130
+ # were not resetting the config after tests, which didn't surface as broken
131
+ # tests until Rails 4.1 was added for testing. This ensures that all the
132
+ # models start tests with their original config.
133
+ def config_setup
134
+ [Project, Affiliate, Employee, EmployeeSession, Ldaper, User, UserSession, Company].each do |model|
135
+ model.class_attribute :original_acts_as_authentic_config unless model.respond_to?(:original_acts_as_authentic_config)
136
+ model.original_acts_as_authentic_config = model.acts_as_authentic_config
137
+ end
138
+ end
139
+
140
+ def config_teardown
141
+ [Project, Affiliate, Employee, EmployeeSession, Ldaper, User, UserSession, Company].each do |model|
142
+ model.acts_as_authentic_config = model.original_acts_as_authentic_config
143
+ end
144
+ end
145
+
125
146
  def password_for(user)
126
147
  case user
127
148
  when users(:ben)
128
149
  "benrocks"
129
150
  when users(:zack)
130
151
  "zackrocks"
152
+ when users(:aaron)
153
+ "aaronrocks"
131
154
  end
132
155
  end
133
156
 
metadata CHANGED
@@ -1,99 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authlogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.3
4
+ version: 3.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-08 00:00:00.000000000 Z
11
+ date: 2014-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
- requirement: !ruby/object:Gem::Requirement
15
+ version_requirements: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.2'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
20
+ requirement: !ruby/object:Gem::Requirement
23
21
  requirements:
24
- - - ">="
22
+ - - '>='
25
23
  - !ruby/object:Gem::Version
26
24
  version: '3.2'
25
+ prerelease: false
26
+ type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
- requirement: !ruby/object:Gem::Requirement
29
+ version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.2'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
34
+ requirement: !ruby/object:Gem::Requirement
37
35
  requirements:
38
- - - ">="
36
+ - - '>='
39
37
  - !ruby/object:Gem::Version
40
38
  version: '3.2'
39
+ prerelease: false
40
+ type: :runtime
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: request_store
43
- requirement: !ruby/object:Gem::Requirement
43
+ version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
51
49
  requirements:
52
- - - "~>"
50
+ - - ~>
53
51
  - !ruby/object:Gem::Version
54
52
  version: '1.0'
53
+ prerelease: false
54
+ type: :runtime
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: scrypt
57
- requirement: !ruby/object:Gem::Requirement
57
+ version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.2'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
62
+ requirement: !ruby/object:Gem::Requirement
65
63
  requirements:
66
- - - "~>"
64
+ - - ~>
67
65
  - !ruby/object:Gem::Version
68
66
  version: '1.2'
67
+ prerelease: false
68
+ type: :runtime
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bcrypt
71
- requirement: !ruby/object:Gem::Requirement
71
+ version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '3.1'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
76
+ requirement: !ruby/object:Gem::Requirement
79
77
  requirements:
80
- - - "~>"
78
+ - - ~>
81
79
  - !ruby/object:Gem::Version
82
80
  version: '3.1'
81
+ prerelease: false
82
+ type: :development
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: timecop
85
- requirement: !ruby/object:Gem::Requirement
85
+ version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0.7'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
90
+ requirement: !ruby/object:Gem::Requirement
93
91
  requirements:
94
- - - "~>"
92
+ - - ~>
95
93
  - !ruby/object:Gem::Version
96
94
  version: '0.7'
95
+ prerelease: false
96
+ type: :development
97
97
  description: A clean, simple, and unobtrusive ruby authentication solution.
98
98
  email:
99
99
  - bjohnson@binarylogic.com
@@ -101,8 +101,8 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - ".gitignore"
105
- - ".travis.yml"
104
+ - .gitignore
105
+ - .travis.yml
106
106
  - CHANGELOG.md
107
107
  - CONTRIBUTING.md
108
108
  - Gemfile
@@ -125,6 +125,7 @@ files:
125
125
  - lib/authlogic/acts_as_authentic/validations_scope.rb
126
126
  - lib/authlogic/authenticates_many/association.rb
127
127
  - lib/authlogic/authenticates_many/base.rb
128
+ - lib/authlogic/config.rb
128
129
  - lib/authlogic/controller_adapters/abstract_adapter.rb
129
130
  - lib/authlogic/controller_adapters/rack_adapter.rb
130
131
  - lib/authlogic/controller_adapters/rails_adapter.rb
@@ -183,6 +184,7 @@ files:
183
184
  - test/acts_as_authentic_test/session_maintenance_test.rb
184
185
  - test/acts_as_authentic_test/single_access_test.rb
185
186
  - test/authenticates_many_test.rb
187
+ - test/config_test.rb
186
188
  - test/crypto_provider_test/aes256_test.rb
187
189
  - test/crypto_provider_test/bcrypt_test.rb
188
190
  - test/crypto_provider_test/scrypt_test.rb
@@ -196,6 +198,7 @@ files:
196
198
  - test/gemfiles/Gemfile.rails-3.2.x
197
199
  - test/gemfiles/Gemfile.rails-4.0.x
198
200
  - test/gemfiles/Gemfile.rails-4.1.x
201
+ - test/gemfiles/Gemfile.rails-4.2.x
199
202
  - test/i18n/lol.yml
200
203
  - test/i18n_test.rb
201
204
  - test/libs/affiliate.rb
@@ -203,7 +206,6 @@ files:
203
206
  - test/libs/employee.rb
204
207
  - test/libs/employee_session.rb
205
208
  - test/libs/ldaper.rb
206
- - test/libs/ordered_hash.rb
207
209
  - test/libs/project.rb
208
210
  - test/libs/user.rb
209
211
  - test/libs/user_session.rb
@@ -215,6 +217,7 @@ files:
215
217
  - test/session_test/cookies_test.rb
216
218
  - test/session_test/credentials_test.rb
217
219
  - test/session_test/existence_test.rb
220
+ - test/session_test/foundation_test.rb
218
221
  - test/session_test/http_auth_test.rb
219
222
  - test/session_test/id_test.rb
220
223
  - test/session_test/klass_test.rb
@@ -234,24 +237,24 @@ homepage: http://github.com/binarylogic/authlogic
234
237
  licenses:
235
238
  - MIT
236
239
  metadata: {}
237
- post_install_message:
240
+ post_install_message:
238
241
  rdoc_options: []
239
242
  require_paths:
240
243
  - lib
241
244
  required_ruby_version: !ruby/object:Gem::Requirement
242
245
  requirements:
243
- - - ">="
246
+ - - '>='
244
247
  - !ruby/object:Gem::Version
245
248
  version: '0'
246
249
  required_rubygems_version: !ruby/object:Gem::Requirement
247
250
  requirements:
248
- - - ">="
251
+ - - '>='
249
252
  - !ruby/object:Gem::Version
250
253
  version: '0'
251
254
  requirements: []
252
- rubyforge_project:
253
- rubygems_version: 2.2.2
254
- signing_key:
255
+ rubyforge_project:
256
+ rubygems_version: 2.1.9
257
+ signing_key:
255
258
  specification_version: 4
256
259
  summary: A clean, simple, and unobtrusive ruby authentication solution.
257
260
  test_files:
@@ -267,6 +270,7 @@ test_files:
267
270
  - test/acts_as_authentic_test/session_maintenance_test.rb
268
271
  - test/acts_as_authentic_test/single_access_test.rb
269
272
  - test/authenticates_many_test.rb
273
+ - test/config_test.rb
270
274
  - test/crypto_provider_test/aes256_test.rb
271
275
  - test/crypto_provider_test/bcrypt_test.rb
272
276
  - test/crypto_provider_test/scrypt_test.rb
@@ -280,6 +284,7 @@ test_files:
280
284
  - test/gemfiles/Gemfile.rails-3.2.x
281
285
  - test/gemfiles/Gemfile.rails-4.0.x
282
286
  - test/gemfiles/Gemfile.rails-4.1.x
287
+ - test/gemfiles/Gemfile.rails-4.2.x
283
288
  - test/i18n/lol.yml
284
289
  - test/i18n_test.rb
285
290
  - test/libs/affiliate.rb
@@ -287,7 +292,6 @@ test_files:
287
292
  - test/libs/employee.rb
288
293
  - test/libs/employee_session.rb
289
294
  - test/libs/ldaper.rb
290
- - test/libs/ordered_hash.rb
291
295
  - test/libs/project.rb
292
296
  - test/libs/user.rb
293
297
  - test/libs/user_session.rb
@@ -299,6 +303,7 @@ test_files:
299
303
  - test/session_test/cookies_test.rb
300
304
  - test/session_test/credentials_test.rb
301
305
  - test/session_test/existence_test.rb
306
+ - test/session_test/foundation_test.rb
302
307
  - test/session_test/http_auth_test.rb
303
308
  - test/session_test/id_test.rb
304
309
  - test/session_test/klass_test.rb