# Trouve-KA — tests de détection de pièges # Author: Simon-Pierre Boucher # Contact: contact@spboucher.ai from trouveka.crawler.traps import looks_like_trap def test_session_ids(): assert looks_like_trap("https://x.ca/p?PHPSESSID=abc123") assert looks_like_trap("https://x.ca/p?sid=9f8e7d") def test_too_many_params(): url = "https://x.ca/p?" + "&".join(f"f{i}={i}" for i in range(12)) assert looks_like_trap(url) def test_repeated_facet_param(): assert looks_like_trap("https://x.ca/s?f=a&f=b&f=c&f=d&f=e") def test_deep_paths_and_loops(): assert looks_like_trap("https://x.ca/" + "/".join(["seg"] * 15)) assert looks_like_trap("https://x.ca/a/b/a/b/a/b/a/b") def test_far_future_calendar(): assert looks_like_trap("https://x.ca/events/2085/05/17") assert not looks_like_trap("https://x.ca/nouvelles/2024/06/12") def test_excessive_pagination(): assert looks_like_trap("https://x.ca/liste?page=9999") assert not looks_like_trap("https://x.ca/liste?page=3") def test_normal_urls_pass(): assert not looks_like_trap("https://www.quebec.ca/services/permis?type=conduire") assert not looks_like_trap("https://ici.radio-canada.ca/nouvelle/2024/ceci-est-un-titre")