Skip to content

Commit 917dfe0

Browse files
Mossakaclaude
andcommitted
fix: use single-quoted bash -c in rate limit tests
The failing tests used bash -c "${script}" (double quotes), which caused bash to interpret inner double quotes in the curl commands, garbling the HTTP headers and JSON data. Switch to bash -c '${script}' (single quotes) and use escaped double quotes for JSON data, matching the pattern used by the passing tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 49c56fc commit 917dfe0

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

tests/integration/api-proxy-rate-limit.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ describe('API Proxy Rate Limiting', () => {
6161
// Set RPM=1, make 2 requests quickly — second should get 429 with Retry-After
6262
const script = [
6363
// First request consumes the limit
64-
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d '{"model":"test"}' > /dev/null`,
64+
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d "{\\"model\\":\\"test\\"}" > /dev/null`,
6565
// Second request should be rate limited — capture headers
66-
`curl -s -i -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d '{"model":"test"}'`,
66+
`curl -s -i -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d "{\\"model\\":\\"test\\"}"`,
6767
].join(' && ');
6868

6969
const result = await runner.runWithSudo(
70-
`bash -c "${script}"`,
70+
`bash -c '${script}'`,
7171
{
7272
allowDomains: ['api.anthropic.com'],
7373
enableApiProxy: true,
@@ -112,12 +112,12 @@ describe('API Proxy Rate Limiting', () => {
112112
test('should include X-RateLimit headers in 429 response', async () => {
113113
// Set low RPM to guarantee 429, then check for X-RateLimit-* headers
114114
const script = [
115-
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d '{"model":"test"}' > /dev/null`,
116-
`curl -s -i -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d '{"model":"test"}'`,
115+
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d "{\\"model\\":\\"test\\"}" > /dev/null`,
116+
`curl -s -i -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d "{\\"model\\":\\"test\\"}"`,
117117
].join(' && ');
118118

119119
const result = await runner.runWithSudo(
120-
`bash -c "${script}"`,
120+
`bash -c '${script}'`,
121121
{
122122
allowDomains: ['api.anthropic.com'],
123123
enableApiProxy: true,
@@ -172,13 +172,13 @@ describe('API Proxy Rate Limiting', () => {
172172
// Set a custom RPM and verify it appears in the health endpoint rate_limits
173173
const script = [
174174
// Make one request to create provider state in the limiter
175-
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d '{"model":"test"}' > /dev/null`,
175+
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d "{\\"model\\":\\"test\\"}" > /dev/null`,
176176
// Check health for rate limit config
177177
`curl -s http://${API_PROXY_IP}:10000/health`,
178178
].join(' && ');
179179

180180
const result = await runner.runWithSudo(
181-
`bash -c "${script}"`,
181+
`bash -c '${script}'`,
182182
{
183183
allowDomains: ['api.anthropic.com'],
184184
enableApiProxy: true,
@@ -203,15 +203,15 @@ describe('API Proxy Rate Limiting', () => {
203203
// Trigger rate limiting, then check /metrics for rate_limit_rejected_total
204204
const script = [
205205
// Make 3 rapid requests with RPM=1 to trigger at least one 429
206-
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d '{"model":"test"}' > /dev/null`,
207-
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d '{"model":"test"}' > /dev/null`,
208-
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d '{"model":"test"}' > /dev/null`,
206+
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d "{\\"model\\":\\"test\\"}" > /dev/null`,
207+
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d "{\\"model\\":\\"test\\"}" > /dev/null`,
208+
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d "{\\"model\\":\\"test\\"}" > /dev/null`,
209209
// Check metrics
210210
`curl -s http://${API_PROXY_IP}:10000/metrics`,
211211
].join(' && ');
212212

213213
const result = await runner.runWithSudo(
214-
`bash -c "${script}"`,
214+
`bash -c '${script}'`,
215215
{
216216
allowDomains: ['api.anthropic.com'],
217217
enableApiProxy: true,

0 commit comments

Comments
 (0)