Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02a8460

Browse filesBrowse files
authored
Add proxy integration test
1 parent b7c566a commit 02a8460
Copy full SHA for 02a8460

1 file changed

+114Lines changed: 114 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/test-proxy.yml‎

Copy file name to clipboard
+114Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.