Skip to content

TestRedirectRevalidation urllib3 tests fail when urllib3 is not installed #1681

@brendancol

Description

@brendancol

Describe the bug

Since #1668 (commit 919d827), CI on main has been red. The four test_urllib3_* tests in xrspatial/geotiff/tests/test_ssrf_hardening_1664.py::TestRedirectRevalidation raise ModuleNotFoundError: No module named 'urllib3' on every OS / Python combo:

```
FAILED xrspatial/geotiff/tests/test_ssrf_hardening_1664.py::TestRedirectRevalidation::test_urllib3_redirect_to_private_rejected
FAILED xrspatial/geotiff/tests/test_ssrf_hardening_1664.py::TestRedirectRevalidation::test_urllib3_redirect_to_public_followed
FAILED xrspatial/geotiff/tests/test_ssrf_hardening_1664.py::TestRedirectRevalidation::test_urllib3_redirect_chain_capped
FAILED xrspatial/geotiff/tests/test_ssrf_hardening_1664.py::TestRedirectRevalidation::test_urllib3_relative_location_resolved
===== 4 failed, 4683 passed, 999 skipped =====
```

urllib3 is an optional runtime dependency (_HTTPSource falls back to stdlib urllib.request when urllib3 is missing — see _reader.py:615-617). The test class mocks urllib3's PoolManager API and calls src.read_range(...), which calls _urllib3_timeout() at _reader.py:640. That helper does a lazy import urllib3 and blows up when the package isn't installed.

Expected behavior

The four test_urllib3_* tests are specifically exercising the urllib3 path. They should skip cleanly when urllib3 is not installed.

Suggested fix

Add pytest.importorskip("urllib3") at the top of the TestRedirectRevalidation class. The stdlib-fallback path can be tested separately if needed.

Impact

Currently blocks CI on every PR that branches from main. PRs #1675-#1680 all hit this same wall.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginput-validationInput validation and error messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions