Sha256: 4d1d5677c23871265f3454d23699cdfe4a038613f5552c1bc3dcc9c21f7f9687
Contents?: true
Size: 1.4 KB
Versions: 62
Compression:
Stored size: 1.4 KB
Contents
require 'test_helper' module Workarea class User class RecentPasswordTest < TestCase def test_clean user = create_user passwords = [] (Workarea.config.password_history_length + 1).times do passwords << RecentPassword.create!( user: user, password: SecureRandom.hex ) end RecentPassword.clean(user) assert_equal( Workarea.config.password_history_length, user.recent_passwords.length ) assert_raise(Mongoid::Errors::DocumentNotFound) { passwords.last.reload } end def test_save_password_digest password = 'Password!1' cost = if ActiveModel::SecurePassword.min_cost BCrypt::Engine::MIN_COST else BCrypt::Engine.cost end password_digest = BCrypt::Password.create(password, cost: cost).to_s user = User.new( email: 'admin@othersite.com', password_digest: password_digest ) assert_nil(user.password) refute_nil(user.password_digest) assert_equal(password_digest, user.password_digest) assert(user.save!) refute_empty(user.recent_passwords) refute_nil(user.recent_passwords.first.password_digest) assert_equal(password_digest, user.recent_passwords.first.password_digest) end end end end
Version data entries
62 entries across 62 versions & 1 rubygems
Version | Path |
---|---|
workarea-core-3.4.13 | test/models/workarea/user/recent_password_test.rb |
workarea-core-3.4.12 | test/models/workarea/user/recent_password_test.rb |