-
Notifications
You must be signed in to change notification settings - Fork 2
Writing tests to break the server #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gwbischof
wants to merge
33
commits into
main
Choose a base branch
from
more_tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 24 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
55586c4
Add server bug tests that expose JSON parsing crashes and validation …
gwbischof f83d6b8
Add comprehensive edge case tests with timeout protection to discover…
gwbischof b19a691
Uncomment hanging WebSocket tests and add timeout protection to preve…
gwbischof a512d08
Add TODO comments to identify tests that expose server crashes or han…
gwbischof 1453d46
Refine test_server_bugs.py to focus on 12 actionable server bugs incl…
gwbischof ad14419
Remove pytest.raises patterns and add 8 new bug tests to expand test …
gwbischof 48326f4
Remove 2 passing tests that show correct server behavior to focus tes…
gwbischof bfc56e0
Reorganize bug tests into 5 focused test files grouped by server func…
gwbischof 9c9dc74
Fix server crash by adding JSON parsing error handling to /close endp…
gwbischof cb53697
Add configurable resource limits to prevent memory exhaustion and DoS…
gwbischof f212ec8
Remove Redis manipulation tests that bypass API validation to focus o…
gwbischof 5b346e1
Add test references to server code fixes for better traceability betw…
gwbischof 0b402f4
Improve JSON error handling to only catch JSON-specific exceptions fo…
gwbischof a7a9e17
Sanitize JSON error messages to prevent leaking implementation detail…
gwbischof 7f82c1f
makeing some progress
gwbischof 8cadb32
Remove untested WebSocket frame size limits to follow test-driven dev…
gwbischof 95bbdc7
moving along
gwbischof 7112820
ruff
gwbischof a319113
cleanup
gwbischof c66f737
don't use the middleware because it is only needed for the upload end…
gwbischof a9c7025
Add payload size validation and JSON error handling to prevent server…
gwbischof 90ae9ff
Replace manual JSON parsing with Pydantic model for cleaner validation
gwbischof 0eb0c3b
clean up
gwbischof 28eea12
touch ups
gwbischof 6211736
remove the close_connection body
gwbischof f189940
make close_connection a delete endpoint
gwbischof d95f65d
add close connection tests
gwbischof 7c0a96c
test websocket connection to non-existant node
gwbischof 8212b36
return 404 if node not streamable
gwbischof f662241
clean up the test
gwbischof ea431da
touch ups
gwbischof 57c94be
touch ups
gwbischof cd31947
touch up
gwbischof File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| """ | ||
| Tests for JSON parsing error handling bugs in server endpoints. | ||
| """ | ||
|
|
||
|
|
||
| def test_json_parsing_errors_in_close_endpoint(client): | ||
gwbischof marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """Server should handle JSON parsing errors in /close endpoint gracefully.""" | ||
| response = client.post("/upload") | ||
| assert response.status_code == 200 | ||
| node_id = response.json()["node_id"] | ||
|
|
||
| # Test 1: Malformed JSON content should not crash | ||
| response = client.post( | ||
| f"/close/{node_id}", | ||
| content=b"invalid json {{{", | ||
| headers={"Content-Type": "application/json"}, | ||
| ) | ||
| assert response.status_code == 422 # Pydantic returns 422 for validation errors | ||
| assert "detail" in response.json() | ||
|
|
||
| # Test 2: Missing JSON body should not crash | ||
| response = client.post(f"/close/{node_id}") | ||
| assert response.status_code == 422 # Pydantic returns 422 for validation errors | ||
| assert "detail" in response.json() | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| """ | ||
| Tests for large data handling and resource limit bugs. | ||
| """ | ||
|
|
||
|
|
||
| def test_large_data_resource_limits(client): | ||
| """Server should handle large data with proper resource limits.""" | ||
|
|
||
| # Test: Huge payload (20MB) - should be rejected as too large | ||
| response = client.post("/upload") | ||
| assert response.status_code == 200 | ||
| node_id = response.json()["node_id"] | ||
|
|
||
| huge_payload = b"\x00" * (20 * 1024 * 1024) # 20MB (exceeds 16MB limit) | ||
| response = client.post( | ||
| f"/upload/{node_id}", | ||
| content=huge_payload, | ||
| headers={"Content-Type": "application/octet-stream"}, | ||
| ) | ||
| # Should be rejected with 413 Payload Too Large due to size limits | ||
| assert response.status_code == 413 | ||
| assert "Payload too large" in response.json()["detail"] |
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.
Uh oh!
There was an error while loading. Please reload this page.