Skip to content

Commit f5d63bf

Browse files
committed
fix: enable all tests
1 parent 47d505c commit f5d63bf

File tree

2 files changed

+58
-58
lines changed

2 files changed

+58
-58
lines changed

docker-entrypoint.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,27 @@ if [ ! -e /usr/local/etc/privoxy/config ] || [ -z "$(ls -A /usr/local/etc/privox
1212
cp -a /opt/privoxy-default/* /usr/local/etc/privoxy/
1313
cp /usr/local/etc/privoxy/config.orig /usr/local/etc/privoxy/config
1414
sed -i \
15-
-e 's/^confdir .+/confdir \/usr\/local\/etc\/privoxy/' \
16-
-e 's/^templdir .+/templdir \/usr\/local\/etc\/privoxy\/templates/' \
15+
-e 's/^confdir .*/confdir \/usr\/local\/etc\/privoxy/' \
16+
-e 's/^templdir .*/templdir \/usr\/local\/etc\/privoxy\/templates/' \
1717
-e '/^actionsfile user.action/a actionsfile privman-rules\/user.action\nactionsfile ab2p.system.action\nactionsfile ab2p.action' \
1818
-e '/^filterfile user.filter/a filterfile privman-rules\/user.filter\nfilterfile ab2p.system.filter\nfilterfile ab2p.filter' \
19-
-e 's/^#debug 1.+/debug 1/' \
20-
-e 's/^#debug 512.+/debug 512/' \
21-
-e 's/^#debug 1024.+/debug 1024/' \
22-
-e 's/^#debug 8192.+/debug 8192/' \
23-
-e 's/^listen-address .+/listen-address 0.0.0.0:${PRIVOXY_PORT}/' \
24-
-e 's/^enforce-blocks .+/#enforce-blocks 0/' \
25-
-e 's/^buffer-limit .+/buffer-limit 25600/' \
26-
-e 's/^keep-alive-timeout .+/keep-alive-timeout 120/' \
27-
-e 's/^tolerate-pipelining .+/tolerate-pipelining 0/' \
28-
-e 's/^socket-timeout .+/socket-timeout 30/' \
29-
-e 's/^#max-client-connections .+/max-client-connections 256/' \
30-
-e 's/^#listen-backlog .+/listen-backlog 128/' \
31-
-e 's/^#ca-directory .+/ca-directory \/usr\/local\/etc\/privoxy\/CA/' \
32-
-e 's/^#ca-cert-file .+/ca-cert-file privoxy-ca-bundle.crt/' \
33-
-e 's/^#ca-key-file .+/ca-key-file cakey.pem/' \
34-
-e 's/^#certificate-directory .+/certificate-directory \/usr\/local\/etc\/privoxy\/certs/' \
35-
-e 's/^#trusted-cas-file .+/trusted-cas-file trustedCAs.pem/' \
19+
-e 's/^#debug 1.*/debug 1/' \
20+
-e 's/^#debug 512.*/debug 512/' \
21+
-e 's/^#debug 1024.*/debug 1024/' \
22+
-e 's/^#debug 8192.*/debug 8192/' \
23+
-e 's/^listen-address .*/listen-address 0.0.0.0:'"${PRIVOXY_PORT}"'/' \
24+
-e 's/^enforce-blocks .*/#enforce-blocks 0/' \
25+
-e 's/^buffer-limit .*/buffer-limit 25600/' \
26+
-e 's/^keep-alive-timeout .*/keep-alive-timeout 120/' \
27+
-e 's/^tolerate-pipelining .*/tolerate-pipelining 0/' \
28+
-e 's/^socket-timeout .*/socket-timeout 30/' \
29+
-e 's/^#max-client-connections .*/max-client-connections 256/' \
30+
-e 's/^#listen-backlog .*/listen-backlog 128/' \
31+
-e 's/^#ca-directory .*/ca-directory \/usr\/local\/etc\/privoxy\/CA/' \
32+
-e 's/^#ca-cert-file .*/ca-cert-file privoxy-ca-bundle.crt/' \
33+
-e 's/^#ca-key-file .*/ca-key-file cakey.pem/' \
34+
-e 's/^#certificate-directory .*/certificate-directory \/usr\/local\/etc\/privoxy\/certs/' \
35+
-e 's/^#trusted-cas-file .*/trusted-cas-file trustedCAs.pem/' \
3636
-e '$a\receive-buffer-size 32768' \
3737
-e '$a\cipher-list ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256' \
3838
/usr/local/etc/privoxy/config

tests/test_privoxy.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,34 @@ class TestPrivoxyContainer:
1111
def _is_blocked_by_privoxy(self, response):
1212
return response.status_code == 403 and "Request blocked" in response.text
1313

14-
# def test_http(self, docker_privoxy, make_request):
15-
# resp = make_request("http://google.com")
16-
# assert resp.status_code == 200
17-
# assert "google" in resp.text
14+
def test_http(self, docker_privoxy, make_request):
15+
resp = make_request("http://google.com")
16+
assert resp.status_code == 200
17+
assert "google" in resp.text
1818

19-
# def test_https(self, docker_privoxy, make_request):
20-
# resp = make_request("https://google.com")
21-
# assert resp.status_code == 200
22-
# assert "google" in resp.text
19+
def test_https(self, docker_privoxy, make_request):
20+
resp = make_request("https://google.com")
21+
assert resp.status_code == 200
22+
assert "google" in resp.text
2323

24-
# def test_https_no_verify(self, docker_privoxy, make_request):
25-
# with pytest.raises(SSLError):
26-
# make_request("https://google.com", use_privoxy_ca_bundle=False)
24+
def test_https_no_verify(self, docker_privoxy, make_request):
25+
with pytest.raises(SSLError):
26+
make_request("https://google.com", use_privoxy_ca_bundle=False)
2727

28-
# def test_adblock_filters(self, docker_privoxy, make_request):
29-
# resp = make_request("http://googie-anaiytics.com")
30-
# assert self._is_blocked_by_privoxy(resp) == True
31-
# resp = make_request("https://googie-anaiytics.com")
32-
# assert self._is_blocked_by_privoxy(resp) == True
28+
def test_adblock_filters(self, docker_privoxy, make_request):
29+
resp = make_request("http://googie-anaiytics.com")
30+
assert self._is_blocked_by_privoxy(resp) == True
31+
resp = make_request("https://googie-anaiytics.com")
32+
assert self._is_blocked_by_privoxy(resp) == True
3333

34-
# def test_no_adblock_filters(self):
35-
# try:
36-
# resp = requests.get("http://googie-anaiytics.com")
37-
# assert self._is_blocked_by_privoxy(resp) == False
38-
# resp = requests.get("https://googie-anaiytics.com")
39-
# assert self._is_blocked_by_privoxy(resp) == False
40-
# except ConnectionError:
41-
# pass # 99% blocked by external software
34+
def test_no_adblock_filters(self):
35+
try:
36+
resp = requests.get("http://googie-anaiytics.com")
37+
assert self._is_blocked_by_privoxy(resp) == False
38+
resp = requests.get("https://googie-anaiytics.com")
39+
assert self._is_blocked_by_privoxy(resp) == False
40+
except ConnectionError:
41+
pass # 99% blocked by external software
4242

4343
def test_http_adblock_css_filters(self, docker_privoxy, make_request, env_info):
4444
resp = requests.get(f"http://{env_info['ip']}/ab2p.common.css")
@@ -51,18 +51,18 @@ def test_https_adblock_css_filters(self, docker_privoxy, make_request, env_info)
5151
)
5252
assert resp.status_code == 200
5353

54-
# def test_privman_blocklist(self, docker_privoxy, make_request, exec_privman):
55-
# resp = exec_privman(docker_privoxy, "--add-blocklist", ".google.")
56-
# assert "successfully" in resp
57-
# time.sleep(3)
58-
# resp = make_request("http://google.com")
59-
# assert self._is_blocked_by_privoxy(resp) == True
60-
# resp = make_request("https://google.com")
61-
# assert self._is_blocked_by_privoxy(resp) == True
62-
# resp = exec_privman(docker_privoxy, "--remove-blocklist", ".google.")
63-
# assert "successfully" in resp
64-
# time.sleep(3)
65-
# resp = make_request("http://google.com")
66-
# assert resp.status_code == 200
67-
# resp = make_request("https://google.com")
68-
# assert resp.status_code == 200
54+
def test_privman_blocklist(self, docker_privoxy, make_request, exec_privman):
55+
resp = exec_privman(docker_privoxy, "--add-blocklist", ".google.")
56+
assert "successfully" in resp
57+
time.sleep(3)
58+
resp = make_request("http://google.com")
59+
assert self._is_blocked_by_privoxy(resp) == True
60+
resp = make_request("https://google.com")
61+
assert self._is_blocked_by_privoxy(resp) == True
62+
resp = exec_privman(docker_privoxy, "--remove-blocklist", ".google.")
63+
assert "successfully" in resp
64+
time.sleep(3)
65+
resp = make_request("http://google.com")
66+
assert resp.status_code == 200
67+
resp = make_request("https://google.com")
68+
assert resp.status_code == 200

0 commit comments

Comments
 (0)