authlogic 2.0.9 → 2.0.11

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of authlogic might be problematic. Click here for more details.

@@ -7,19 +7,13 @@ module Authlogic
7
7
  self.controller = controller
8
8
  end
9
9
 
10
- def request_method
11
- nil
12
- end
13
-
14
- def referer
15
- end
16
-
17
10
  def remote_ip
18
11
  (controller && controller.respond_to?(:env) && controller.env.is_a?(Hash) && controller.env['REMOTE_ADDR']) || "1.1.1.1"
19
12
  end
20
13
 
21
- def user_agent
22
- end
14
+ private
15
+ def method_missiing(*args, &block)
16
+ end
23
17
  end
24
18
  end
25
19
  end
@@ -41,7 +41,7 @@ module Authlogic # :nodoc:
41
41
 
42
42
  MAJOR = 2
43
43
  MINOR = 0
44
- TINY = 9
44
+ TINY = 11
45
45
 
46
46
  # The current version as a Version instance
47
47
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -4,8 +4,8 @@ module Authlogic
4
4
  def self.should_be_authentic
5
5
  klass = model_class
6
6
  should "acts as authentic" do
7
- assert klass.respond_to?(:password=)
8
- assert klass.respond_to?(:valid_password?)
7
+ assert klass.new.respond_to?(:password=)
8
+ assert klass.new.respond_to?(:valid_password?)
9
9
  end
10
10
  end
11
11
  end
@@ -73,6 +73,10 @@ module ActsAsAuthenticTest
73
73
  u.email = "a@a.com"
74
74
  assert !u.valid?
75
75
  assert !u.errors.on(:email)
76
+
77
+ u.email = "dakota.dux+1@gmail.com"
78
+ assert !u.valid?
79
+ assert !u.errors.on(:email)
76
80
  end
77
81
 
78
82
  def test_validates_uniqueness_of_email_field
@@ -33,7 +33,7 @@ module ActsAsAuthenticTest
33
33
  end
34
34
 
35
35
  def test_validates_format_of_login_field_options_config
36
- default = {:with => /\A\w[\w\.\-_@ ]+\z/, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}
36
+ default = {:with => /\A\w[\w\.+-_@ ]+\z/, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}
37
37
  assert_equal default, User.validates_format_of_login_field_options
38
38
  assert_equal default, Employee.validates_format_of_login_field_options
39
39
 
@@ -73,6 +73,10 @@ module ActsAsAuthenticTest
73
73
  u.login = "fdsfdsfdsfdsfs"
74
74
  assert !u.valid?
75
75
  assert !u.errors.on(:login)
76
+
77
+ u.login = "dakota.dux+1@gmail.com"
78
+ assert !u.valid?
79
+ assert !u.errors.on(:login)
76
80
  end
77
81
 
78
82
  def test_validates_uniqueness_of_login_field
@@ -32,6 +32,14 @@ module ActsAsAuthenticTest
32
32
  assert User.ignore_blank_passwords
33
33
  end
34
34
 
35
+ def test_check_passwords_against_database
36
+ assert User.check_passwords_against_database
37
+ User.check_passwords_against_database = false
38
+ assert !User.check_passwords_against_database
39
+ User.check_passwords_against_database true
40
+ assert User.check_passwords_against_database
41
+ end
42
+
35
43
  def test_validate_password_field_config
36
44
  assert User.validate_password_field
37
45
  assert Employee.validate_password_field
@@ -160,6 +168,26 @@ module ActsAsAuthenticTest
160
168
  transition_password_to(Authlogic::CryptoProviders::Sha512, ben, [Authlogic::CryptoProviders::Sha1, Authlogic::CryptoProviders::BCrypt])
161
169
  end
162
170
 
171
+ def test_checks_password_against_database
172
+ ben = users(:ben)
173
+ ben.password = "new pass"
174
+ assert !ben.valid_password?("new pass")
175
+ assert ben.valid_password?("benrocks")
176
+ end
177
+
178
+ def test_checks_password_against_database_and_always_fails_on_new_records
179
+ user = User.new
180
+ user.password = "new pass"
181
+ assert !user.valid_password?("new pass")
182
+ end
183
+
184
+ def test_checks_password_against_object
185
+ ben = users(:ben)
186
+ ben.password = "new pass"
187
+ assert ben.valid_password?("new pass", false)
188
+ assert !ben.valid_password?("benrocks", false)
189
+ end
190
+
163
191
  def test_reset_password
164
192
  ben = users(:ben)
165
193
  old_crypted_password = ben.crypted_password
@@ -2,6 +2,14 @@ require File.dirname(__FILE__) + '/../test_helper.rb'
2
2
 
3
3
  module ActsAsAuthenticTest
4
4
  class SessionMaintenanceTest < ActiveSupport::TestCase
5
+ def test_maintain_sessions_config
6
+ assert User.maintain_sessions
7
+ User.maintain_sessions = false
8
+ assert !User.maintain_sessions
9
+ User.maintain_sessions true
10
+ assert User.maintain_sessions
11
+ end
12
+
5
13
  def test_login_after_create
6
14
  assert User.create(:login => "awesome", :password => "saweet", :password_confirmation => "saweet", :email => "awesome@awesome.com")
7
15
  assert UserSession.find
@@ -35,5 +35,10 @@ module ActsAsAuthenticTest
35
35
 
36
36
  User.change_single_access_token_with_password = false
37
37
  end
38
+
39
+ def test_after_password_set_is_not_called
40
+ ldaper = Ldaper.new
41
+ assert ldaper.save
42
+ end
38
43
  end
39
44
  end
@@ -0,0 +1,7 @@
1
+ class Affiliate < ActiveRecord::Base
2
+ acts_as_authentic do |c|
3
+ c.crypted_password_field = :pw_hash
4
+ end
5
+
6
+ belongs_to :company
7
+ end
@@ -0,0 +1,3 @@
1
+ class Ldaper < ActiveRecord::Base
2
+ acts_as_authentic
3
+ end
@@ -2,14 +2,26 @@ require File.dirname(__FILE__) + '/../test_helper.rb'
2
2
 
3
3
  module SessionTest
4
4
  class HttpAuthTest < ActiveSupport::TestCase
5
- def test_persist_persist_by_http_auth
6
- ben = users(:ben)
7
- http_basic_auth_for { assert !UserSession.find }
8
- http_basic_auth_for(ben) do
9
- assert session = UserSession.find
10
- assert_equal ben, session.record
11
- assert_equal ben.login, session.login
12
- assert_equal "benrocks", session.send(:protected_password)
5
+ class ConfiTest < ActiveSupport::TestCase
6
+ def test_allow_http_basic_auth
7
+ UserSession.allow_http_basic_auth = false
8
+ assert_equal false, UserSession.allow_http_basic_auth
9
+
10
+ UserSession.allow_http_basic_auth true
11
+ assert_equal true, UserSession.allow_http_basic_auth
12
+ end
13
+ end
14
+
15
+ class InstanceMethodsTest < ActiveSupport::TestCase
16
+ def test_persist_persist_by_http_auth
17
+ ben = users(:ben)
18
+ http_basic_auth_for { assert !UserSession.find }
19
+ http_basic_auth_for(ben) do
20
+ assert session = UserSession.find
21
+ assert_equal ben, session.record
22
+ assert_equal ben.login, session.login
23
+ assert_equal "benrocks", session.send(:protected_password)
24
+ end
13
25
  end
14
26
  end
15
27
  end
@@ -79,6 +79,13 @@ ActiveRecord::Schema.define(:version => 1) do
79
79
  t.string :pw_salt
80
80
  t.string :persistence_token
81
81
  end
82
+
83
+ create_table :ldapers do |t|
84
+ t.datetime :created_at
85
+ t.datetime :updated_at
86
+ t.string :ldap_login
87
+ t.string :persistence_token
88
+ end
82
89
  end
83
90
 
84
91
  require File.dirname(__FILE__) + '/../lib/authlogic' unless defined?(Authlogic)
@@ -87,6 +94,7 @@ require File.dirname(__FILE__) + '/libs/project'
87
94
  require File.dirname(__FILE__) + '/libs/affiliate'
88
95
  require File.dirname(__FILE__) + '/libs/employee'
89
96
  require File.dirname(__FILE__) + '/libs/employee_session'
97
+ require File.dirname(__FILE__) + '/libs/ldaper'
90
98
  require File.dirname(__FILE__) + '/libs/user'
91
99
  require File.dirname(__FILE__) + '/libs/user_session'
92
100
  require File.dirname(__FILE__) + '/libs/company'
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.9
4
+ version: 2.0.11
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-04-11 00:00:00 -04:00
12
+ date: 2009-04-25 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -127,9 +127,11 @@ files:
127
127
  - test/fixtures/employees.yml
128
128
  - test/fixtures/projects.yml
129
129
  - test/fixtures/users.yml
130
+ - test/libs/affiliate.rb
130
131
  - test/libs/company.rb
131
132
  - test/libs/employee.rb
132
133
  - test/libs/employee_session.rb
134
+ - test/libs/ldaper.rb
133
135
  - test/libs/ordered_hash.rb
134
136
  - test/libs/project.rb
135
137
  - test/libs/user.rb