mirror of
https://github.com/soxoj/maigret.git
synced 2026-09-22 17:54:55 +02:00
* fix: don't treat refused or self-redirected responses as not-found 401 and 429 fell through to the checkType branch, where any non-2xx code means the username is free, so blocked and rate-limited requests were reported as confirmed absences; they now return errors, Vercel's Security Checkpoint joins the bot-protection markers, and a self-redirect that carries Set-Cookie is retried once instead of read as an absence. * Fix site checks: 16 sites, 3 fixed, 12 disabled, 1 dead deleted * docs: note that the joyreactor self-redirect is intermittent
46 lines
1.0 KiB
Python
46 lines
1.0 KiB
Python
"""
|
|
Unit tests for error page detection helpers.
|
|
"""
|
|
|
|
from maigret.error_detection import detect_error_page
|
|
from maigret.errors import CheckError
|
|
|
|
|
|
def test_site_specific_error():
|
|
err = detect_error_page(
|
|
"this page is blocked",
|
|
200,
|
|
{"blocked": "Blocked by site"},
|
|
ignore_403=False,
|
|
)
|
|
|
|
assert isinstance(err, CheckError)
|
|
assert err.type == "Site-specific"
|
|
|
|
|
|
def test_http_403():
|
|
err = detect_error_page("x", 403, {}, ignore_403=False)
|
|
|
|
assert err.type == "Access denied"
|
|
|
|
|
|
def test_http_500():
|
|
err = detect_error_page("x", 500, {}, ignore_403=False)
|
|
|
|
assert err.type == "Server"
|
|
|
|
|
|
def test_no_error():
|
|
assert detect_error_page("ok", 200, {}, ignore_403=False) is None
|
|
|
|
|
|
def test_http_429_is_rate_limit():
|
|
err = detect_error_page("x", 429, {}, ignore_403=False)
|
|
|
|
assert err.type == "Rate limited"
|
|
|
|
|
|
def test_ignore_linkedin_999_status():
|
|
# 999 stays a pass-through on purpose, see detect_error_page.
|
|
assert detect_error_page("", 999, {}, ignore_403=False) is None
|