Skip to content

test : added unit tests for ScanRateLimiter helpers in rate_limiter - #2328

Open
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#2323
Open

test : added unit tests for ScanRateLimiter helpers in rate_limiter#2328
tmdeveloper007 wants to merge 1 commit into
utksh1:mainfrom
tmdeveloper007:#2323

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Summary

Added 17 unit tests for helper functions in ScanRateLimiter from backend/secuscan/rate_limiter.py.

Changes Made

  • Created testing/backend/unit/test_rate_limiter_scan_rate_limiter.py with 17 tests
  • Tests cover:
    • _get_client_ip: proxy headers (X-Forwarded-For), direct clients, missing headers
    • _build_error_response: formatting of 429 JSON responses, retry-after headers, X-Request-ID
    • _check_burst_limit: burst window tracking, first-request initialization, limit enforcement
    • Rate limiter state isolation between test runs via mock cleanup

Impact

All 17 tests pass. The rate limiter module had zero unit test coverage before this PR.


This task is being handled by tmdeveloper007 as part of the GSSOC Auto-PR cron.

@utksh1

utksh1 commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Thanks for adding test coverage! This PR needs a rebase with main to pass CI. Please run:

git fetch upstream
git rebase upstream/main
git push --force-with-lease

Once rebased and CI passes, I'll merge immediately.

@utksh1 utksh1 added area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label labels Jul 30, 2026 — with ChatGPT Codex Connector
@tmdeveloper007

Copy link
Copy Markdown
Contributor Author

Thanks! I have rebased the branch on the latest upstream/main and pushed. The PR should now be up to date. Please re-review when you have a chance.

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the updated test submission. The coverage is focused and distinct from the duplicate PRs already closed. Backend scope is acceptable; merge remains subject to a current branch and the repository-required frontend security audit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend Backend API, database, or service work level:beginner 20 pts difficulty label for small beginner-friendly PRs type:testing Testing work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants