def test_logs_out_inactive_users(self): user = User.objects.create_user( username="******", password="******", email="*****@*****.**", ) never_expire_password(user) self.client.login(username="******", password="******") resp = self.client.get('/home/') self.assertEqual(resp.status_code, 200) # check we are logged in user.is_active = False user.save() resp = self.client.get('/home/') self.assertRedirects(resp, self.login_url + "?next=/home/")
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()
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: with self.settings(MANDATORY_PASSWORD_CHANGE={"URL_NAME": "change_password"}): self.assertRedirects(self.client.get("/home/"), reverse("change_password")) never_expire_password(user) self.assertEqual(self.client.get("/home/").status_code, 200) finally: self.client.logout() user.delete()
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()
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: with self.settings( MANDATORY_PASSWORD_CHANGE={"URL_NAME": "change_password"}): self.assertRedirects( self.client.get("/home/"), reverse("change_password"), ) never_expire_password(user) self.assertEqual(self.client.get("/home/").status_code, 200) finally: self.client.logout() user.delete()