Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/tests_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ jobs:
python-version: ["3.12"]
env:
FASTFUELS_API_KEY: ${{ secrets.FASTFUELS_API_KEY_V2 }}
FASTFUELS_CI_BYPASS: ${{ secrets.FASTFUELS_CI_BYPASS }}
steps:
- uses: actions/checkout@v4
- name: Install uv
Expand Down
10 changes: 8 additions & 2 deletions tests/v2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import json
import os
from contextlib import contextmanager
from datetime import datetime, timedelta, timezone

Expand All @@ -18,6 +19,10 @@
# job, so it stays pending (silvxlabs/FastFuels-API-v2#680)
SKIP_DISPATCH_HEADER = {"X-FastFuels-Skip-Dispatch": "1"}

# Cloud Armor exempts requests carrying this shared secret from its per-IP throttle
_ci_bypass = os.getenv("FASTFUELS_CI_BYPASS")
CI_HEADER = {"X-FastFuels-CI": _ci_bypass} if _ci_bypass else {}

# Client without SKIP_DISPATCH_HEADER, set by install_skip_dispatch_client
_real_client = None

Expand Down Expand Up @@ -82,13 +87,14 @@ def install_skip_dispatch_client() -> None:
"""Make the SDK send SKIP_DISPATCH_HEADER on every request by default.

Swaps the SDK's cached client for one carrying the header and keeps a
header-free client for ``real_dispatch_client``. Does nothing when no
API key is configured.
header-free client for ``real_dispatch_client``. Both carry CI_HEADER.
Does nothing when no API key is configured.
"""
global _real_client
api._client = None
_real_client = api.get_client()
if _real_client is not None:
_real_client = _real_client.with_headers(CI_HEADER)
api._client = _real_client.with_headers(SKIP_DISPATCH_HEADER)


Expand Down
Loading