Skip to content

Commit cc407ac

Browse files
CopilotMossaka
andcommitted
test: add iptables to child NAT tests and add HTTP_PROXY fallback test
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
1 parent 04f242b commit cc407ac

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

tests/integration/docker-egress.test.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ describe('Docker Container Egress Tests', () => {
352352
// This test verifies that child containers have NAT rules applied via docker-wrapper.sh
353353
// Even if an application ignores HTTP_PROXY env vars, traffic is still redirected to Squid
354354
const result = await runner.runWithSudo(
355-
`docker run --rm alpine:latest sh -c 'apk add --no-cache curl >/dev/null 2>&1 && unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy && curl -f https://example.com --max-time 10'`,
355+
`docker run --rm alpine:latest sh -c 'apk add --no-cache curl iptables >/dev/null 2>&1 && unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy && curl -f https://example.com --max-time 10'`,
356356
{
357357
allowDomains: ['github.com'],
358358
logLevel: 'warn',
@@ -367,7 +367,7 @@ describe('Docker Container Egress Tests', () => {
367367
test('Container: NAT rules applied - allows whitelisted domains even when proxy env vars are ignored', async () => {
368368
// Verify that allowed domains still work even when proxy env vars are unset
369369
const result = await runner.runWithSudo(
370-
`docker run --rm alpine:latest sh -c 'apk add --no-cache curl >/dev/null 2>&1 && unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy && curl -fsS https://api.github.com/zen --max-time 30'`,
370+
`docker run --rm alpine:latest sh -c 'apk add --no-cache curl iptables >/dev/null 2>&1 && unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy && curl -fsS https://api.github.com/zen --max-time 30'`,
371371
{
372372
allowDomains: ['api.github.com'],
373373
logLevel: 'warn',
@@ -382,7 +382,7 @@ describe('Docker Container Egress Tests', () => {
382382
test('Container: wget --no-proxy blocked by NAT rules', async () => {
383383
// wget --no-proxy explicitly ignores proxy settings, but NAT rules should still work
384384
const result = await runner.runWithSudo(
385-
`docker run --rm alpine:latest sh -c 'apk add --no-cache wget >/dev/null 2>&1 && wget --no-proxy -q -O- https://example.com --timeout=10'`,
385+
`docker run --rm alpine:latest sh -c 'apk add --no-cache wget iptables >/dev/null 2>&1 && wget --no-proxy -q -O- https://example.com --timeout=10'`,
386386
{
387387
allowDomains: ['github.com'],
388388
logLevel: 'warn',
@@ -410,5 +410,20 @@ describe('Docker Container Egress Tests', () => {
410410
expect(result.stdout).toContain('DNAT');
411411
expect(result.stdout).toContain('172.30.0.10:3128');
412412
}, 180000);
413+
414+
test('Container: Images without iptables still work via HTTP_PROXY', async () => {
415+
// Containers without iptables should still be able to access allowed domains via HTTP_PROXY
416+
const result = await runner.runWithSudo(
417+
'docker run --rm curlimages/curl:latest -fsS https://api.github.com/zen',
418+
{
419+
allowDomains: ['api.github.com'],
420+
logLevel: 'warn',
421+
timeout: 30000,
422+
}
423+
);
424+
425+
// Should succeed via HTTP_PROXY (NAT rules won't apply without iptables)
426+
expect(result).toSucceed();
427+
}, 120000);
413428
});
414429
});

0 commit comments

Comments
 (0)