This commit is contained in:
@@ -6,8 +6,8 @@ from apps.sources.services.fetcher import (
|
||||
ContentRejectedError,
|
||||
FetchError,
|
||||
FetchTimeoutError,
|
||||
RateLimitedError,
|
||||
PolicyBlockedError,
|
||||
RateLimitedError,
|
||||
fetch_url,
|
||||
)
|
||||
from apps.sources.services.url_security import ValidatedUrl
|
||||
@@ -79,7 +79,9 @@ def test_fetcher_rejects_dns_rebinding(monkeypatch):
|
||||
|
||||
def validate(url: str, **kwargs):
|
||||
if "/final" in url:
|
||||
return ValidatedUrl(url=url, hostname="example.org", port=443, addresses=("198.51.100.12",))
|
||||
return ValidatedUrl(
|
||||
url=url, hostname="example.org", port=443, addresses=("198.51.100.12",)
|
||||
)
|
||||
return ValidatedUrl(url=url, hostname="example.org", port=443, addresses=("93.184.216.34",))
|
||||
|
||||
monkeypatch.setattr("apps.sources.services.fetcher.validate_public_url", validate)
|
||||
@@ -133,7 +135,9 @@ def test_fetcher_rejects_policy_content_size_and_http(monkeypatch):
|
||||
client.close()
|
||||
|
||||
client = httpx.Client(
|
||||
transport=httpx.MockTransport(lambda request: (_ for _ in ()).throw(httpx.TimeoutException("timeout")))
|
||||
transport=httpx.MockTransport(
|
||||
lambda request: (_ for _ in ()).throw(httpx.TimeoutException("timeout"))
|
||||
)
|
||||
)
|
||||
with pytest.raises(FetchTimeoutError):
|
||||
fetch_url("https://example.org/slow", client=client)
|
||||
|
||||
Reference in New Issue
Block a user