Ejemplo n.º 1
0
 def test_it_works(self, db):
     user = UserFactory()
     now = time.time()
     self.configure_session(timestamp=now, user_id=user.pk)
     assert self.set_pw("my_awesome_new_pw") is None
     user.refresh_from_db()
     assert user.check_password("my_awesome_new_pw") is True
Ejemplo n.º 2
0
 def test_entire_reset_process_works(self):
     user = UserFactory(phone_number="5551234567")
     assert self.mutate_password_reset() == []
     assert self.mutate_password_reset_verification_code() == []
     assert self.mutate_password_reset_confirm() == []
     user.refresh_from_db()
     assert user.check_password("my_new_pw1234") is True
Ejemplo n.º 3
0
 def test_entire_reset_process_with_login_works(self):
     user = UserFactory(phone_number="5551234567")
     assert self.mutate_password_reset() == []
     assert self.mutate_password_reset_verification_code() == []
     assert self.mutate_password_reset_confirm_and_login() == {
         "errors": [],
         "session": {
             "phoneNumber": "5551234567"
         },
     }
     user.refresh_from_db()
     assert user.check_password("my_new_pw1234") is True
Ejemplo n.º 4
0
    def test_password_change(self, api_client):
        password = USER_PASSWORD
        new_password = "******"
        user = UserFactory(password=password)
        api_client.force_authenticate(user)

        data = {
            "old_password": "******",
            "new_password1": new_password,
            "new_password2": new_password,
        }

        response = api_client.post(self.password_change_url, data=data)
        assert response.status_code == status.HTTP_400_BAD_REQUEST

        data["old_password"] = password

        response = api_client.post(self.password_change_url, data=data)
        assert response.status_code == status.HTTP_200_OK

        assert user.check_password(new_password)