mirror of
https://github.com/heartcombo/devise.git
synced 2026-04-28 03:00:29 -04:00
moved password encryption out of Authenticatable to allow custom encryptions for people coming by with an existent users table
This commit is contained in:
@@ -6,7 +6,7 @@ class AuthenticatableTest < ActiveSupport::TestCase
|
||||
def encrypt_password(user, pepper=nil, stretches=1)
|
||||
user.class_eval { define_method(:stretches) { stretches } } if stretches
|
||||
user.password = '123456'
|
||||
::Digest::SHA1.hexdigest("--#{user.password_salt}--#{pepper}--123456--#{pepper}--")
|
||||
user.encryptor.digest('123456', { :salt => user.password_salt, :pepper => pepper })
|
||||
end
|
||||
|
||||
test 'should respond to password and password confirmation' do
|
||||
@@ -90,6 +90,19 @@ class AuthenticatableTest < ActiveSupport::TestCase
|
||||
Devise.stretches = default_stretches
|
||||
end
|
||||
end
|
||||
|
||||
test 'should fallback to Sha1 as default encryption' do
|
||||
user = create_user
|
||||
puts user.encrypted_password
|
||||
assert_equal user.encrypted_password, ::Devise::Models::Encryptors::Sha1.digest('123456', { :pepper => Devise.pepper, :salt => user.password_salt })
|
||||
end
|
||||
|
||||
test 'should act according to encryptor configuration' do
|
||||
Devise.encryptor = ::Devise::Models::Encryptors::Sha512
|
||||
user = create_user
|
||||
puts user.encrypted_password
|
||||
assert_equal user.encrypted_password, ::Devise::Models::Encryptors::Sha512.digest('123456', { :pepper => Devise.pepper, :salt => user.password_salt })
|
||||
end
|
||||
|
||||
test 'should test for a valid password' do
|
||||
user = create_user
|
||||
|
||||
Reference in New Issue
Block a user