diff --git a/pyproject.toml b/pyproject.toml index 2fd1f631..e223d985 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ "playwright==1.55.0", "PyYAML==6.0.2", "python-dateutil==2.9.0.post0", - "requests==2.32.5", + "httpx==0.28.1", "retrying==1.4.2", "shodan==1.31.0", "slowapi==0.1.9", @@ -53,7 +53,6 @@ dev = [ "types-chardet==5.0.4.6", "types-python-dateutil==2.9.0.20250822", "types-PyYAML==6.0.12.20250516", - "types-requests==2.32.4.20250809", "ruff==0.12.11", "types-ujson==5.10.0.20250822", "wheel==0.45.1", diff --git a/tests/discovery/test_certspotter.py b/tests/discovery/test_certspotter.py index efd9b5ee..0e47e83f 100644 --- a/tests/discovery/test_certspotter.py +++ b/tests/discovery/test_certspotter.py @@ -4,7 +4,7 @@ import os from typing import Optional import pytest -import requests +import httpx from _pytest.mark.structures import MarkDecorator from theHarvester.discovery import certspottersearch @@ -27,7 +27,7 @@ class TestCertspotterSearch(object): async def test_api(self) -> None: base_url = f"https://api.certspotter.com/v1/issuances?domain={TestCertspotter.domain()}&expand=dns_names" headers = {"User-Agent": Core.get_user_agent()} - request = requests.get(base_url, headers=headers) + request = httpx.get(base_url, headers=headers) assert request.status_code == 200 async def test_search(self) -> None: diff --git a/tests/discovery/test_githubcode.py b/tests/discovery/test_githubcode.py index 10099694..8bde5af0 100644 --- a/tests/discovery/test_githubcode.py +++ b/tests/discovery/test_githubcode.py @@ -1,7 +1,7 @@ from unittest.mock import MagicMock import pytest from _pytest.mark.structures import MarkDecorator -from requests import Response +from httpx import Response from theHarvester.discovery import githubcode from theHarvester.discovery.constants import MissingKey from theHarvester.lib.core import Core @@ -11,12 +11,11 @@ pytestmark: MarkDecorator = pytest.mark.asyncio class TestSearchGithubCode: class OkResponse: - response = Response() + response = Response(status_code=200) # Mocking the json method properly def __init__(self): - self.response = Response() - self.response.status_code = 200 + self.response = Response(status_code=200) object.__setattr__( self.response, "json", @@ -31,25 +30,18 @@ class TestSearchGithubCode: ) class FailureResponse: - response = Response() - def __init__(self): - self.response = Response() - self.response.status_code = 401 + self.response = Response(status_code=401) object.__setattr__(self.response, "json", MagicMock(return_value={})) class RetryResponse: def __init__(self): - self.response = Response() - self.response.status_code = 403 + self.response = Response(status_code=403) object.__setattr__(self.response, "json", MagicMock(return_value={})) class MalformedResponse: - response = Response() - def __init__(self): - self.response = Response() - self.response.status_code = 200 + self.response = Response(status_code=200) object.__setattr__( self.response, "json", diff --git a/tests/discovery/test_otx.py b/tests/discovery/test_otx.py index 037aef3e..7a181248 100644 --- a/tests/discovery/test_otx.py +++ b/tests/discovery/test_otx.py @@ -2,9 +2,8 @@ # coding=utf-8 import os from typing import Optional - +import httpx import pytest -import requests from _pytest.mark.structures import MarkDecorator from theHarvester.discovery import otxsearch @@ -24,7 +23,7 @@ class TestOtx(object): async def test_api(self) -> None: base_url = f"https://otx.alienvault.com/api/v1/indicators/domain/{TestOtx.domain()}/passive_dns" headers = {"User-Agent": Core.get_user_agent()} - request = requests.get(base_url, headers=headers) + request = httpx.get(base_url, headers=headers) assert request.status_code == 200 async def test_search(self) -> None: diff --git a/theHarvester/lib/api/api_example.py b/theHarvester/lib/api/api_example.py index 1dbc532d..758ad062 100644 --- a/theHarvester/lib/api/api_example.py +++ b/theHarvester/lib/api/api_example.py @@ -31,7 +31,7 @@ async def fetch(session, url): async def main() -> None: """ Just a simple example of how to interact with the rest api - you can use requests instead of aiohttp or whatever you best see fit + you can use httpx instead of aiohttp or whatever you best see fit """ url = 'http://127.0.0.1:5000' domain = 'netflix.com'