Skip to content

Commit 0485845

Browse files
Mossakaclaude
andcommitted
fix: fill empty test body and use mktemp for paths
- Add actual X-RateLimit header assertions to the empty "should include X-RateLimit headers in responses" test - Replace fixed /tmp/auth-* paths with mktemp -d to avoid conflicts between parallel test runs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 917dfe0 commit 0485845

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,19 @@ describe('API Proxy Rate Limiting', () => {
8787
}, 180000);
8888

8989
test('should include X-RateLimit headers in responses', async () => {
90-
// Make a single request and check for rate limit headers
90+
// Use RPM=1 and make 2 requests — the second triggers 429 which always has rate limit headers
91+
const script = [
92+
`curl -s -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d "{\\"model\\":\\"test\\"}" > /dev/null`,
93+
`curl -s -i -X POST http://${API_PROXY_IP}:10001/v1/messages -H "Content-Type: application/json" -d "{\\"model\\":\\"test\\"}"`,
94+
].join(' && ');
95+
9196
const result = await runner.runWithSudo(
92-
`bash -c "curl -s -i -X POST http://${API_PROXY_IP}:10001/v1/messages -H 'Content-Type: application/json' -d '{\"model\":\"test\"}'"`,
97+
`bash -c '${script}'`,
9398
{
9499
allowDomains: ['api.anthropic.com'],
95100
enableApiProxy: true,
96101
buildLocal: true,
102+
rateLimitRpm: 1,
97103
logLevel: 'debug',
98104
timeout: 120000,
99105
env: {
@@ -103,10 +109,10 @@ describe('API Proxy Rate Limiting', () => {
103109
);
104110

105111
expect(result).toSucceed();
106-
// Even non-429 responses from rate-limited requests should have rate limit headers.
107-
// When rate limit IS triggered (429), headers are always present.
108-
// For a single request at default limits, we might get the upstream response
109-
// which won't have these headers. So use a low RPM and make 2 requests.
112+
const lower = result.stdout.toLowerCase();
113+
expect(lower).toContain('x-ratelimit-limit');
114+
expect(lower).toContain('x-ratelimit-remaining');
115+
expect(lower).toContain('x-ratelimit-reset');
110116
}, 180000);
111117

112118
test('should include X-RateLimit headers in 429 response', async () => {

tests/integration/git-operations.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe('Git Operations', () => {
162162

163163
const result = await runner.runWithSudo(
164164
withGitAuth(
165-
`git clone --depth 1 https://github.com/${TEST_REPO}.git /tmp/auth-clone && ls /tmp/auth-clone`
165+
`TMPDIR=$(mktemp -d) && git clone --depth 1 https://github.com/${TEST_REPO}.git $TMPDIR/repo && ls $TMPDIR/repo`
166166
),
167167
{
168168
allowDomains: ['github.com'],
@@ -183,8 +183,8 @@ describe('Git Operations', () => {
183183

184184
const result = await runner.runWithSudo(
185185
withGitAuth(
186-
`git clone --depth 1 https://github.com/${TEST_REPO}.git /tmp/auth-fetch && ` +
187-
`cd /tmp/auth-fetch && git fetch origin`
186+
`TMPDIR=$(mktemp -d) && git clone --depth 1 https://github.com/${TEST_REPO}.git $TMPDIR/repo && ` +
187+
`cd $TMPDIR/repo && git fetch origin`
188188
),
189189
{
190190
allowDomains: ['github.com'],
@@ -207,8 +207,8 @@ describe('Git Operations', () => {
207207
// Clone, create branch, commit, push, then delete the remote branch
208208
const result = await runner.runWithSudo(
209209
withGitAuth(
210-
`git clone --depth 1 https://github.com/${TEST_REPO}.git /tmp/auth-push && ` +
211-
`cd /tmp/auth-push && ` +
210+
`TMPDIR=$(mktemp -d) && git clone --depth 1 https://github.com/${TEST_REPO}.git $TMPDIR/repo && ` +
211+
`cd $TMPDIR/repo && ` +
212212
`git checkout -b ${branchName} && ` +
213213
`echo "awf-test-$(date +%s)" > awf-test-file.txt && ` +
214214
`git add awf-test-file.txt && ` +

0 commit comments

Comments
 (0)