Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 13, 2025

The test file was using outdated header syntax that didn't match the current draft specification. This PR updates all test cases to use the proper structured field format defined in the latest draft.

Changes Made

Updated Header Syntax:

  • Before: limit=, remaining=, reset=, policy= (dictionary/simple values)
  • After: RateLimit-Policy: "name";q=quota;w=window and RateLimit: "name";r=remaining;t=time (structured field lists)

Example of the transformation:

# Old syntax
headers = dict(
    policy="10;w=1,50;w=60,1000;w=3600",
    limit="1000"
)

# New syntax 
headers = dict(
    **{"RateLimit-Policy": '"hourly";q=1000;w=3600,"daily";q=5000;w=86400'},
    **{"RateLimit": '"hourly";r=999;t=3540'}
)

New Test Coverage:

  • Basic policy and rate limit header parsing
  • Multiple policies in a single header
  • Partition key support with base64 encoding (pk=:base64data:)
  • Quota units for different measurement types (qu="content-bytes")
  • Policy lookup by name matching between headers
  • All parameter types: q (quota), w (window), r (remaining), t (time), pk (partition key), qu (quota unit)

Modernized Functions:

  • Replaced parse_fields() with parse_ratelimit_headers()
  • Updated find_quota_policy() to find_policy_by_name() for name-based lookups
  • Added comprehensive test runner with clear pass/fail reporting

All tests pass and the file now fully complies with the latest IETF draft specification for RateLimit headers.

Fixes #153.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Update test_ratelimit.py file to the syntax in the latest draft. Update test_ratelimit.py to use latest draft syntax with RateLimit-Policy and RateLimit headers Sep 13, 2025
@Copilot Copilot AI requested a review from darrelmiller September 13, 2025 23:21
Copilot finished work on behalf of darrelmiller September 13, 2025 23:21
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.

Update test_ratelimit.py file to the syntax in the latest draft.

2 participants