'Assert when passwords must be reset'

@patch.dict('django.conf.settings.ADVANCED_SECURITY_CONFIG', {'MIN_DAYS_FOR_STAFF_ACCOUNTS_PASSWORD_RESETS': 1})
@patch.dict('django.conf.settings.ADVANCED_SECURITY_CONFIG', {'MIN_DAYS_FOR_STUDENT_ACCOUNTS_PASSWORD_RESETS': 5})
def test_forced_password_change(self):

    student = self._user_factory_with_history()
    staff = self._user_factory_with_history(is_staff=True)
    grandfathered_student = self._user_factory_with_history(set_initial_history=False)
    self.assertFalse(PasswordHistory.should_user_reset_password_now(student))
    self.assertFalse(PasswordHistory.should_user_reset_password_now(staff))
    self.assertFalse(PasswordHistory.should_user_reset_password_now(grandfathered_student))
    staff_reset_time = (timezone.now() + timedelta(days=1))
    with freeze_time(staff_reset_time):
        self.assertFalse(PasswordHistory.should_user_reset_password_now(student))
        self.assertFalse(PasswordHistory.should_user_reset_password_now(grandfathered_student))
        self.assertTrue(PasswordHistory.should_user_reset_password_now(staff))
        self._change_password(staff, 'Different')
        self.assertFalse(PasswordHistory.should_user_reset_password_now(staff))
    student_reset_time = (timezone.now() + timedelta(days=5))
    with freeze_time(student_reset_time):
        self.assertTrue(PasswordHistory.should_user_reset_password_now(student))
        self.assertTrue(PasswordHistory.should_user_reset_password_now(grandfathered_student))
        self.assertTrue(PasswordHistory.should_user_reset_password_now(staff))
        self._change_password(student, 'Different')
        self.assertFalse(PasswordHistory.should_user_reset_password_now(student))
        self._change_password(grandfathered_student, 'Different')
        self.assertFalse(PasswordHistory.should_user_reset_password_now(grandfathered_student))
        self._change_password(staff, 'Different')
        self.assertFalse(PasswordHistory.should_user_reset_password_now(staff))
