From 0d6493a9a54c5eb413aafaf4bfc19ae3b93ea63d Mon Sep 17 00:00:00 2001 From: Vasiliy Ermolovich Date: Sun, 6 Oct 2013 14:19:08 +0300 Subject: [PATCH] proper hash comparing in Devise.bcrypt test --- test/devise_test.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/devise_test.rb b/test/devise_test.rb index 1a5f7149..27f46811 100644 --- a/test/devise_test.rb +++ b/test/devise_test.rb @@ -15,10 +15,11 @@ class DeviseTest < ActiveSupport::TestCase password = "super secret" klass = Struct.new(:pepper, :stretches).new("blahblah", 2) hash = Devise.bcrypt(klass, password) - assert_equal hash, Devise.bcrypt(klass, password) + assert_equal ::BCrypt::Password.create(hash), hash klass = Struct.new(:pepper, :stretches).new("bla", 2) - assert_not_equal hash, Devise.bcrypt(klass, password) + hash = Devise.bcrypt(klass, password) + assert_not_equal ::BCrypt::Password.new(hash), hash end test 'model options can be configured through Devise' do @@ -69,7 +70,7 @@ class DeviseTest < ActiveSupport::TestCase Devise::ALL.delete(:kivi) Devise::CONTROLLERS.delete(:kivi) end - + test 'should complain when comparing empty or different sized passes' do [nil, ""].each do |empty| assert_not Devise.secure_compare(empty, "something")