usage-meter-poll: the serve test asks a loopback fake, never the provider (finding serve-test-asks-real-provider)

serve_config is the public wrapper over a crate-private serve_config_with
that takes the usage client; the test runs it in-process against a fake and
asserts the fake received GET /api/oauth/usage with the bearer. The endpoint
is not a document field or env, so whoever writes the config cannot redirect
the token. The subprocess test that reached api.anthropic.com is deleted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-01 03:17:08 +01:00
commit 8fb8b5a71d
2 changed files with 105 additions and 2 deletions

View file

@ -393,14 +393,15 @@ fn unix_ms() -> u64 {
/// Starts the poll thread. It reads the token afresh at each poll, writes
/// only to `cell`, and logs one line to stderr when its state changes.
pub fn start(
pub(crate) fn start(
cell: Arc<QuotaCell>,
tokens: Box<dyn TokenSource>,
client: UsageClient,
) -> std::io::Result<std::thread::JoinHandle<()>> {
let poller = Poller::new(
cell,
tokens,
UsageClient::production(),
client,
Box::new(|line| eprintln!("claude-connector: {line}")),
);
std::thread::Builder::new()