Upgrade passwords to the latest hashing scheme on login
This commit is contained in:
parent
15d29c646b
commit
b9daf06684
3 changed files with 28 additions and 1 deletions
|
@ -4,12 +4,14 @@ class PasswordHashTest < ActiveSupport::TestCase
|
|||
def test_md5_without_salt
|
||||
assert_equal true, PasswordHash.check("5f4dcc3b5aa765d61d8327deb882cf99", nil, "password")
|
||||
assert_equal false, PasswordHash.check("5f4dcc3b5aa765d61d8327deb882cf99", nil, "wrong")
|
||||
assert_equal true, PasswordHash.upgrade?("5f4dcc3b5aa765d61d8327deb882cf99", nil)
|
||||
end
|
||||
|
||||
def test_md5_with_salt
|
||||
assert_equal true, PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "salt", "password")
|
||||
assert_equal false, PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "salt", "wrong")
|
||||
assert_equal false, PasswordHash.check("67a1e09bb1f83f5007dc119c14d663aa", "wrong", "password")
|
||||
assert_equal true, PasswordHash.upgrade?("67a1e09bb1f83f5007dc119c14d663aa", "salt")
|
||||
end
|
||||
|
||||
def test_default
|
||||
|
@ -21,5 +23,7 @@ class PasswordHashTest < ActiveSupport::TestCase
|
|||
assert_equal false, PasswordHash.check(hash1, salt1, "wrong")
|
||||
assert_equal true, PasswordHash.check(hash2, salt2, "password")
|
||||
assert_equal false, PasswordHash.check(hash2, salt2, "wrong")
|
||||
assert_equal false, PasswordHash.upgrade?(hash1, salt1)
|
||||
assert_equal false, PasswordHash.upgrade?(hash2, salt2)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue