authlogic 2.0.4 → 2.0.5

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.

@@ -1,3 +1,8 @@
1
+ == 2.0.5 released 2009-3-30
2
+
3
+ * Stub out authenticate_with_http_basic for TestCase::Controller adapter.
4
+ * Added second parameter for add_acts_as_authentic module to specify the position: append or prepend.
5
+
1
6
  == 2.0.4 released 2009-3-28
2
7
 
3
8
  * Added validates_uniqueness_of_login_field_options and validates_uniqueness_of_email_field_options configuration options
@@ -58,6 +58,7 @@ lib/authlogic/test_case.rb
58
58
  lib/authlogic/test_case/controller_adapter.rb
59
59
  lib/authlogic/test_case/mock_controller.rb
60
60
  lib/authlogic/test_case/mock_cookie_jar.rb
61
+ lib/authlogic/test_case/mock_logger.rb
61
62
  lib/authlogic/test_case/mock_request.rb
62
63
  lib/authlogic/version.rb
63
64
  shoulda_macros/authlogic.rb
data/Rakefile CHANGED
@@ -15,7 +15,6 @@ Hoe.new("Authlogic", Authlogic::Version::STRING) do |p|
15
15
  p.readme_file = "README.rdoc"
16
16
  p.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc"]
17
17
  p.remote_rdoc_dir = ''
18
- p.test_globs = ["test/*/test_*.rb", "test/*/*_test.rb"]
18
+ p.test_globs = ["test/*/test_*.rb", "test/*_test.rb", "test/*/*_test.rb"]
19
19
  p.extra_deps = %w(activesupport)
20
- p.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."
21
20
  end
@@ -41,9 +41,14 @@ module Authlogic
41
41
  # nothing to do with Authlogic.
42
42
  #
43
43
  # That being said, this is your tool for extending Authlogic and "hooking" into the acts_as_authentic call.
44
- def add_acts_as_authentic_module(mod)
44
+ def add_acts_as_authentic_module(mod, action = :append)
45
45
  modules = acts_as_authentic_modules
46
- modules << mod
46
+ case action
47
+ when :append
48
+ modules << mod
49
+ when :prepend
50
+ modules = [mod] + modules
51
+ end
47
52
  modules.uniq!
48
53
  write_inheritable_attribute(:acts_as_authentic_modules, modules)
49
54
  end
@@ -62,8 +67,7 @@ module Authlogic
62
67
 
63
68
  def config(key, value, default_value = nil, read_value = nil)
64
69
  if value == read_value
65
- return read_inheritable_attribute(key) if inheritable_attributes.include?(key)
66
- write_inheritable_attribute(key, default_value)
70
+ inheritable_attributes.include?(key) ? read_inheritable_attribute(key) : default_value
67
71
  else
68
72
  write_inheritable_attribute(key, value)
69
73
  end
@@ -73,6 +77,7 @@ module Authlogic
73
77
  columns_to_check.each { |column_name| return column_name.to_sym if column_names.include?(column_name.to_s) }
74
78
  columns_to_check.first ? columns_to_check.first.to_sym : nil
75
79
  end
80
+
76
81
  end
77
82
  end
78
83
  end
@@ -54,7 +54,7 @@ module Authlogic
54
54
  # * <tt>Default:</tt> {:minimum => 4, :if => "#{password_salt_field}_changed?".to_sym}
55
55
  # * <tt>Accepts:</tt> Hash of options accepted by validates_confirmation_of
56
56
  def validates_confirmation_of_password_field_options(value = nil)
57
- config(:validates_confirmation_of_password_field_options, value, {:minimum => 4, :if => (password_salt_field ? "#{password_salt_field}_changed?".to_sym : nil)})
57
+ config(:validates_confirmation_of_password_field_options, value, {:minimum => 4, :if => :require_password?})
58
58
  end
59
59
  alias_method :validates_confirmation_of_password_field_options=, :validates_confirmation_of_password_field_options
60
60
 
@@ -140,6 +140,7 @@ module Authlogic
140
140
  @password = pass
141
141
  send("#{password_salt_field}=", Authlogic::Random.friendly_token) if password_salt_field
142
142
  send("#{crypted_password_field}=", crypto_provider.encrypt(*encrypt_arguments(@password, act_like_restful_authentication? ? :restful_authentication : nil)))
143
+ @password_changed = true
143
144
  after_password_set
144
145
  end
145
146
 
@@ -201,7 +202,11 @@ module Authlogic
201
202
  end
202
203
 
203
204
  def require_password?
204
- new_record? || (password_salt_field && send("#{password_salt_field}_changed?")) || send(crypted_password_field).blank?
205
+ new_record? || password_changed? || send(crypted_password_field).blank?
206
+ end
207
+
208
+ def password_changed?
209
+ @password_changed == true
205
210
  end
206
211
 
207
212
  def crypted_password_field
@@ -4,7 +4,7 @@ module Authlogic
4
4
  # provides. Similar to how ActiveRecord has an adapter for MySQL, PostgreSQL, SQLite, etc.
5
5
  class RailsAdapter < AbstractAdapter
6
6
  def authenticate_with_http_basic(&block)
7
- controller.authenticate_with_http_basic(&block)
7
+ yield [nil, nil]
8
8
  end
9
9
 
10
10
  def cookies
@@ -1,7 +1,8 @@
1
- require "authlogic/test_case/controller_adapter"
2
- require "authlogic/test_case/mock_cookie_jar"
3
- require "authlogic/test_case/mock_request"
4
- require "authlogic/test_case/mock_controller"
1
+ require File.dirname(__FILE__) + "/test_case/controller_adapter"
2
+ require File.dirname(__FILE__) + "/test_case/mock_cookie_jar"
3
+ require File.dirname(__FILE__) + "/test_case/mock_controller"
4
+ require File.dirname(__FILE__) + "/test_case/mock_logger"
5
+ require File.dirname(__FILE__) + "/test_case/mock_request"
5
6
 
6
7
  module Authlogic
7
8
  # This is a collection of methods and classes that help you easily test Authlogic. In fact, I use these same tools
@@ -20,6 +20,10 @@ module Authlogic
20
20
  def cookie_domain
21
21
  nil
22
22
  end
23
+
24
+ def logger
25
+ @logger ||= MockLogger.new
26
+ end
23
27
 
24
28
  def params
25
29
  @params ||= {}
@@ -0,0 +1,10 @@
1
+ module Authlogic
2
+ module TestCase
3
+ # Simple class to replace real loggers, so that we can raise any errors being logged.
4
+ class MockLogger
5
+ def error(message)
6
+ raise message
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,6 +1,10 @@
1
1
  module Authlogic
2
2
  module TestCase
3
3
  class MockRequest # :nodoc:
4
+ def request_method
5
+ nil
6
+ end
7
+
4
8
  def remote_ip
5
9
  "1.1.1.1"
6
10
  end
@@ -41,7 +41,7 @@ module Authlogic # :nodoc:
41
41
 
42
42
  MAJOR = 2
43
43
  MINOR = 0
44
- TINY = 4
44
+ TINY = 5
45
45
 
46
46
  # The current version as a Version instance
47
47
  CURRENT = new(MAJOR, MINOR, TINY)
@@ -44,7 +44,7 @@ module ActsAsAuthenticTest
44
44
  end
45
45
 
46
46
  def test_validates_confirmation_of_password_field_options_config
47
- default = {:minimum => 4, :if => "#{User.password_salt_field}_changed?".to_sym}
47
+ default = {:minimum => 4, :if => :require_password?}
48
48
  assert_equal default, User.validates_confirmation_of_password_field_options
49
49
  assert_equal default, Employee.validates_confirmation_of_password_field_options
50
50
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
3
  class RandomTest < ActiveSupport::TestCase
4
4
  def test_random_tokens_have_consisten_length
@@ -36,7 +36,7 @@ class RandomTest < ActiveSupport::TestCase
36
36
  def reload_authlogic_with_sec_random!(secure_random, enabled = true)
37
37
  silence_warnings do
38
38
  secure_random.parent.const_set(secure_random.name.sub("#{secure_random.parent}::", ''), enabled ? secure_random : nil)
39
- load(File.dirname(__FILE__) + '/../../lib/authlogic/random.rb')
39
+ load(File.dirname(__FILE__) + '/../lib/authlogic/random.rb')
40
40
  end
41
41
  end
42
42
 
@@ -2,7 +2,7 @@ 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
6
 
7
7
  ActiveRecord::Schema.verbose = false
8
8
  ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
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
4
+ version: 2.0.5
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-28 00:00:00 -04:00
12
+ date: 2009-03-30 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -103,6 +103,7 @@ files:
103
103
  - lib/authlogic/test_case/controller_adapter.rb
104
104
  - lib/authlogic/test_case/mock_controller.rb
105
105
  - lib/authlogic/test_case/mock_cookie_jar.rb
106
+ - lib/authlogic/test_case/mock_logger.rb
106
107
  - lib/authlogic/test_case/mock_request.rb
107
108
  - lib/authlogic/version.rb
108
109
  - shoulda_macros/authlogic.rb
@@ -158,7 +159,7 @@ files:
158
159
  - test/test_helper.rb
159
160
  has_rdoc: true
160
161
  homepage: http://github.com/binarylogic/authlogic
161
- 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."
162
+ post_install_message:
162
163
  rdoc_options:
163
164
  - --main
164
165
  - README.rdoc
@@ -184,6 +185,8 @@ signing_key:
184
185
  specification_version: 2
185
186
  summary: A clean, simple, and unobtrusive ruby authentication solution.
186
187
  test_files:
188
+ - test/authenticates_many_test.rb
189
+ - test/random_test.rb
187
190
  - test/acts_as_authentic_test/base_test.rb
188
191
  - test/acts_as_authentic_test/email_test.rb
189
192
  - test/acts_as_authentic_test/logged_in_status_test.rb