Beispiel #1
0
 def test_raises_improperly_configured(self):
     change = MandatoryPasswordChangeMiddleware()
     self.assertRaises(
         ImproperlyConfigured,
         change.load_setting,
         'MANDATORY_PASSWORD_CHANGE',
         {'EXEMPT_URLS': []},
     )
Beispiel #2
0
 def test_require_password_change(self):
     """
     A brand-new user should have an already-expired password, and therefore
     be redirected to the password change form on any request.
     """
     user = User.objects.create_user(username="******",
                                     password="******",
                                     email="*****@*****.**")
     self.client.login(username="******", password="******")
     try:
         self.assertRedirects(
             self.client.get("/home/"),
             MandatoryPasswordChangeMiddleware().password_change_url)
         never_expire_password(user)
         self.assertEqual(self.client.get("/home/").status_code, 200)
     finally:
         self.client.logout()
         user.delete()