def post(self, request):
        serializer = self.InputSerializer(data=request.data)
        serializer.is_valid(raise_exception=True)

        user_password_reset(**serializer.validated_data)

        return Response(status=status.HTTP_201_CREATED)
Exemple #2
0
    def test_token_is_none(self, user_password_reset_check_mock):
        password = fake.password()
        user = user_create(
            first_name=fake.first_name(),
            last_name=fake.last_name(),
            password=password,
            email=fake.email()
        )

        # Obtain token and user
        user_password_reset(email=user.email)

        # Code no valid in check
        with self.assertRaises(ValidationError):
            self.service(token=None, password=password)
Exemple #3
0
    def test_token_valid_with_vulnerable_password(self, user_password_reset_check_mock):
        user = user_create(
            first_name=fake.first_name(),
            last_name=fake.last_name(),
            password=fake.password(),
            email=fake.email()
        )
        # Obtain token and user
        _, token = user_password_reset(email=user.email)

        # Token valid with invalid password
        password_vulnerable = fake.password(length=5, digits=False)
        with self.assertRaises(ValidationError):
            self.service(token=token, password=password_vulnerable)
Exemple #4
0
    def test_valid_token_password_and_call_service(self, user_password_reset_check_email_send_mock):
        user = user_create(
            first_name=fake.first_name(),
            last_name=fake.last_name(),
            password=fake.password(),
            email=fake.email()
        )
        # Obtain token and user
        _, token = user_password_reset(email=user.email)

        # Token valid with invalid password
        password_vulnerable = fake.password(length=5, digits=False)
        self.service(token=token, password=fake.password())

        user_password_reset_check_email_send_mock.assert_called()