You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by "onlyarnav (via GitHub)" <gi...@apache.org> on 2026/07/31 08:54:45 UTC
[PR] test(bitbucket): add test coverage for defensive pagination and redirect guards [magpie]
onlyarnav opened a new pull request, #1047:
URL: https://github.com/apache/magpie/pull/1047
### Summary
Adds unit test cases in `tools/bitbucket/tests/test_bitbucket.py` for three defensive guards in the Bitbucket bridge to prevent regressions or accidental removal during future refactoring:
1. **Redirect Scheme Downgrade Guard**:
- `test_same_host_redirect_handler_rejects_scheme_downgrade`: Asserts `SameHostRedirectHandler` refuses `https → http` redirects on the same host and raises `BitbucketError` ("refusing to forward credentials").
2. **Data Center Non-advancing Cursor Guard**:
- `test_datacenter_get_pull_request_commits_stops_on_non_advancing_next_page_start`: Asserts `datacenter.get_pull_request_commits` terminates its pagination loop when `nextPageStart` is non-advancing (`<= start`), preventing infinite loops.
3. **Cloud Repeated Pagination URL Guard**:
- `test_cloud_get_pull_request_commits_rejects_repeated_next_url`: Asserts `cloud.get_pull_request_commits` rejects repeated next URLs and raises `BitbucketError` ("pagination returned a repeated URL").
### Negative Control Verification
Each test was verified by temporarily disabling its guard in source code:
- Disabling scheme validation in `_origin()` caused `test_same_host_redirect_handler_rejects_scheme_downgrade` to fail (`DID NOT RAISE BitbucketError`).
- Removing `if next_start <= start: break` from `datacenter.py` caused `test_datacenter_get_pull_request_commits_stops_on_non_advancing_next_page_start` to fail (`StopIteration`).
- Removing `if next_url in seen_urls:` from `cloud.py` caused `test_cloud_get_pull_request_commits_rejects_repeated_next_url` to fail (`StopIteration`).
### Test Suite Status
All 101 unit tests in `tools/bitbucket` pass cleanly (`uv run --directory tools/bitbucket pytest`).
## fixes: #1007
Generated using Claude Code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(bitbucket): add test coverage for defensive pagination and redirect guards [magpie]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #1047:
URL: https://github.com/apache/magpie/pull/1047
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org