test: add Python SDK unit tests for input_processor (SSRF, URL validation)#1139
Merged
homanp merged 1 commit intoMar 23, 2026
Merged
Conversation
…tion) Add comprehensive mock-based unit tests for the Python SDK's input_processor module, covering: - URL string detection (_is_url_string) - MIME type helper functions (image, text, PDF detection) - MIME type inference from URL extensions - Private IP / SSRF protection (_is_private_ip, _validate_url) - Vision model detection (is_vision_model) - process_input integration tests with mocked network calls These tests mirror the TypeScript SDK's ssrf-protection.test.ts coverage. All network calls are mocked so tests run fully offline. Addresses superagent-ai#1111
|
@frankentini is attempting to deploy a commit to the Superagent Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
|
@frankentini thanks for the PR, is it ready?! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The TypeScript SDK has comprehensive SSRF protection tests (
ssrf-protection.test.ts) but the Python SDK'sinput_processor.pymodule has no dedicated unit tests. This module handles URL validation, private IP blocking, content type detection, and input routing -- all security-critical functionality.Solution
Add
test_input_processor.pywith 30+ mock-based unit tests covering:_is_url_stringfor http/https/plain text/empty stringsgethostbynameprocess_inputintegration -- plain text passthrough, URL delegation, bytes detection (PDF magic bytes, PNG/JPEG headers, text fallback)All network calls are mocked (
unittest.mock), so tests run fully offline.Testing
Tests use
pytest+pytest-asynciowith the project's existingasyncio_mode = "auto"config. No new dependencies required.Partially addresses #1111