Skip to content

Commit 47309c9

Browse files
authored
Merge pull request #754 from actions/Link-/add-proxy-integration-tests
Add proxy integration test
2 parents b7c566a + 02a8460 commit 47309c9

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

.github/workflows/test-proxy.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Test Proxy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- '**.md'
9+
pull_request:
10+
paths-ignore:
11+
- '**.md'
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
# End to end upload with proxy
18+
test-proxy-upload:
19+
runs-on: ubuntu-latest
20+
container:
21+
image: ubuntu:latest
22+
options: --cap-add=NET_ADMIN
23+
services:
24+
squid-proxy:
25+
image: ubuntu/squid:latest
26+
ports:
27+
- 3128:3128
28+
env:
29+
http_proxy: http://squid-proxy:3128
30+
https_proxy: http://squid-proxy:3128
31+
steps:
32+
- name: Wait for proxy to be ready
33+
shell: bash
34+
run: |
35+
echo "Waiting for squid proxy to be ready..."
36+
echo "Resolving squid-proxy hostname:"
37+
getent hosts squid-proxy || echo "DNS resolution failed"
38+
for i in $(seq 1 30); do
39+
if (echo > /dev/tcp/squid-proxy/3128) 2>/dev/null; then
40+
echo "Proxy is ready!"
41+
exit 0
42+
fi
43+
echo "Attempt $i: Proxy not ready, waiting..."
44+
sleep 2
45+
done
46+
echo "Proxy failed to become ready"
47+
exit 1
48+
env:
49+
http_proxy: ""
50+
https_proxy: ""
51+
- name: Install dependencies
52+
run: |
53+
apt-get update
54+
apt-get install -y iptables curl
55+
- name: Verify proxy is working
56+
run: |
57+
echo "Testing proxy connectivity..."
58+
curl -s -o /dev/null -w "%{http_code}" --proxy http://squid-proxy:3128 http://github.com || true
59+
echo "Proxy verification complete"
60+
- name: Block direct traffic (enforce proxy usage)
61+
run: |
62+
# Get the squid-proxy container IP
63+
PROXY_IP=$(getent hosts squid-proxy | awk '{ print $1 }')
64+
echo "Proxy IP: $PROXY_IP"
65+
66+
# Allow loopback traffic
67+
iptables -A OUTPUT -o lo -j ACCEPT
68+
69+
# Allow traffic to the proxy container
70+
iptables -A OUTPUT -d $PROXY_IP -j ACCEPT
71+
72+
# Allow established connections
73+
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
74+
75+
# Allow DNS (needed for initial resolution)
76+
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
77+
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
78+
79+
# Block all other outbound traffic (HTTP/HTTPS)
80+
iptables -A OUTPUT -p tcp --dport 80 -j REJECT
81+
iptables -A OUTPUT -p tcp --dport 443 -j REJECT
82+
83+
# Log the iptables rules for debugging
84+
iptables -L -v -n
85+
- name: Verify direct HTTPS is blocked
86+
run: |
87+
echo "Testing that direct HTTPS requests fail..."
88+
if curl --noproxy '*' -s --connect-timeout 5 https://github.com > /dev/null 2>&1; then
89+
echo "ERROR: Direct HTTPS request succeeded - blocking is not working!"
90+
exit 1
91+
else
92+
echo "SUCCESS: Direct HTTPS request was blocked as expected"
93+
fi
94+
95+
echo "Testing that HTTPS through proxy succeeds..."
96+
if curl --proxy http://squid-proxy:3128 -s --connect-timeout 10 https://github.com > /dev/null 2>&1; then
97+
echo "SUCCESS: HTTPS request through proxy succeeded"
98+
else
99+
echo "ERROR: HTTPS request through proxy failed!"
100+
exit 1
101+
fi
102+
- name: Checkout
103+
uses: actions/checkout@v4
104+
- name: Create artifact file
105+
run: |
106+
mkdir -p test-artifacts
107+
echo "Proxy test artifact - $GITHUB_RUN_ID" > test-artifacts/proxy-test.txt
108+
echo "Random data: $RANDOM $RANDOM $RANDOM" >> test-artifacts/proxy-test.txt
109+
cat test-artifacts/proxy-test.txt
110+
- name: Upload artifact through proxy
111+
uses: ./
112+
with:
113+
name: 'Proxy-Test-Artifact-${{ github.run_id }}'
114+
path: test-artifacts/proxy-test.txt

0 commit comments

Comments
 (0)