'Goes through the password reset flows to make sure the various password reuse policies are enforced'

@patch.dict('django.conf.settings.ADVANCED_SECURITY_CONFIG', {'MIN_DIFFERENT_STAFF_PASSWORDS_BEFORE_REUSE': 2})
def test_staff_password_reset_reuse(self):

    (staff_email, _) = self._setup_user(is_staff=True)
    user = User.objects.get(email=staff_email)
    err_msg = 'You    are    re-using    a    password    that    you    have    used    recently.    You    must    have    2    distinct    passwords'
    success_msg = 'Your    Password    Reset    is    Complete'
    token = default_token_generator.make_token(user)
    uidb36 = int_to_base36(user.id)
    resp = self.client.post('/password_reset_confirm/{0}-{1}/'.format(uidb36, token), {'new_password1': 'foo', 'new_password2': 'foo'}, follow=True)
    self.assertPasswordResetError(resp, err_msg)
    user = User.objects.get(email=staff_email)
    token = default_token_generator.make_token(user)
    uidb36 = int_to_base36(user.id)
    resp = self.client.post('/password_reset_confirm/{0}-{1}/'.format(uidb36, token), {'new_password1': 'bar', 'new_password2': 'bar'}, follow=True)
    self.assertIn(success_msg, resp.content)
    user = User.objects.get(email=staff_email)
    token = default_token_generator.make_token(user)
    uidb36 = int_to_base36(user.id)
    resp = self.client.post('/password_reset_confirm/{0}-{1}/'.format(uidb36, token), {'new_password1': 'foo', 'new_password2': 'foo'}, follow=True)
    self.assertPasswordResetError(resp, err_msg)
    user = User.objects.get(email=staff_email)
    token = default_token_generator.make_token(user)
    uidb36 = int_to_base36(user.id)
    resp = self.client.post('/password_reset_confirm/{0}-{1}/'.format(uidb36, token), {'new_password1': 'baz', 'new_password2': 'baz'}, follow=True)
    self.assertIn(success_msg, resp.content)
    user = User.objects.get(email=staff_email)
    token = default_token_generator.make_token(user)
    uidb36 = int_to_base36(user.id)
    resp = self.client.post('/password_reset_confirm/{0}-{1}/'.format(uidb36, token), {'new_password1': 'foo', 'new_password2': 'foo'}, follow=True)
    self.assertIn(success_msg, resp.content)
