Fix release blockers and deployment build
deploy / deploy (push) Canceled after 0s

This commit is contained in:
Jens
2026-07-21 21:22:29 +02:00
parent b8091e59bd
commit a4eced8be5
64 changed files with 1011 additions and 675 deletions
+6 -1
View File
@@ -5,6 +5,7 @@ from django.utils import timezone
from apps.sources.models import Source, SourcePolicyReview
from apps.sources.services.policy import assess_url, create_policy_review, is_denied_domain
from apps.sources.services.robots import RobotsDecision
def test_platform_domains_are_denied_including_subdomains():
@@ -74,7 +75,11 @@ def test_policy_conflict_denies_even_when_allow_policy_set(db):
@pytest.mark.security
def test_trial_review_can_allow_fetch(db):
def test_trial_review_can_allow_fetch(db, monkeypatch):
monkeypatch.setattr(
"apps.sources.services.policy.assess_robots",
lambda *args, **kwargs: RobotsDecision(True, "Testrobots staan toegang toe"),
)
source = Source.objects.create(
name="Example jobs",
source_type=Source.Type.EMPLOYER,
+20 -3
View File
@@ -6,10 +6,24 @@ from django.utils import timezone
from apps.sources.models import Source, SourceRobotsCache
from apps.sources.services.robots import assess_robots
from apps.sources.services.url_security import ValidatedUrl
def _allow_test_dns(monkeypatch):
monkeypatch.setattr(
"apps.sources.services.robots.validate_public_url",
lambda url, **kwargs: ValidatedUrl(
url=url,
hostname="jobs.example.org",
port=443,
addresses=("93.184.216.34",),
),
)
@pytest.mark.security
def test_robots_uses_user_agent_matching_and_allows_default(db):
def test_robots_uses_user_agent_matching_and_allows_default(db, monkeypatch):
_allow_test_dns(monkeypatch)
source = Source.objects.create(
name="Example jobs",
source_type=Source.Type.EMPLOYER,
@@ -45,7 +59,8 @@ def test_robots_uses_user_agent_matching_and_allows_default(db):
@pytest.mark.security
def test_robots_cache_refreshes_after_ttl(db, settings):
def test_robots_cache_refreshes_after_ttl(db, settings, monkeypatch):
_allow_test_dns(monkeypatch)
source = Source.objects.create(
name="Example jobs",
source_type=Source.Type.EMPLOYER,
@@ -63,7 +78,9 @@ def test_robots_cache_refreshes_after_ttl(db, settings):
return httpx.Response(200, text="User-agent: *\nAllow: /")
client = httpx.Client(transport=httpx.MockTransport(handler))
assess_robots(source.base_url, source=source, user_agent="test-agent", client=client, now=timezone.now())
assess_robots(
source.base_url, source=source, user_agent="test-agent", client=client, now=timezone.now()
)
assert calls["count"] == 1
assess_robots(
source.base_url,