Guest User

Untitled

a guest
Jan 25th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. context "password requires change after certain time" do
  2. before :each do
  3. @password = "about_time"
  4. @salt = "not_a_rhyme"
  5.  
  6. @user = mock_model(User)
  7.  
  8. archived_passwords = mock
  9.  
  10. most_recent_archived_pw = mock_model(ArchivedPassword,
  11. :password => PasswordHelper::hash(@password, @salt),
  12. :salt => @salt,
  13. :created_at => Time.now - 90.days)
  14.  
  15. @policy = Factory.build(:password_policy_basic)
  16. @policy.user = @user
  17. @policy.change_time = 90
  18.  
  19. @user.should_receive(:archived_passwords).and_return(archived_passwords)
  20.  
  21. archived_passwords.should_receive(:previous).with(1).
  22. and_return([most_recent_archived_pw])
  23. end
  24.  
  25. it 'should prevent passwords that match the expired password' do
  26. @policy.allows_password(@password).should be_false
  27. end
  28.  
  29. end
Add Comment
Please, Sign In to add comment