Skip to content

🧪 test: add comprehensive unit test suite for image_utils module - #109

Merged
chottokun merged 2 commits into
mainfrom
test/add-image-utils-tests-571073663461290150
Oct 12, 2026
Merged

chottokun merged 2 commits into
mainfrom
test/add-image-utils-tests-571073663461290150

Conversation

@chottokun

Copy link
Copy Markdown
Owner

Add comprehensive unit test coverage for src/app/image_utils.py in src/tests/test_image_utils.py.

🎯 What

Addresses the missing test file for src/app/image_utils.py.

📊 Coverage

  • SSRF Defense Functions: resolve_safe_url_async and is_safe_url_async across valid public IPs, private/loopback/link-local IP addresses, invalid schemes/hostnames, and socket resolution errors (gaierror, ValueError, TypeError).
  • Safe Network Backend: SafeNetworkBackend connection parameter overrides (connect_tcp, connect_unix_socket, and sleep).
  • Image Conversion Helper: _decode_and_convert_image with valid image bytes and corrupted byte streams.
  • Base64 Decoding: Success cases, payloads exceeding 15MB MAX_FILE_SIZE, and corrupted Base64 strings.
  • URL Download & Redirects: Happy path downloads, SSRF blocked URLs, file size limit enforcement during chunked streaming, valid safe redirects, missing Location header handling, and max redirect limits (MAX_REDIRECTS).
  • Configuration Limits: Verification of MAX_IMAGE_PIXELS (20M pixels) decompression bomb protection.

✨ Result

Added 29 unit test cases achieving high test coverage for image_utils.py and ensuring no regressions across existing multimodal test suites.


PR created automatically by Jules for task 571073663461290150 started by @chottokun

Added dedicated unit test file `src/tests/test_image_utils.py` to cover SSRF defenses, safe network backend, Base64 image decoding, image stream downloading, redirects, file size limits, and decompression bomb protection.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chottokun
chottokun merged commit 06b3013 into main Oct 12, 2026
2 checks passed
@chottokun
chottokun deleted the test/add-image-utils-tests-571073663461290150 branch October 12, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant