]> git.saurik.com Git - apt.git/blame - test/integration/skip-method-http-socks-client
Merge commit 'e2073b0276226b625897ef475f225bf8f508719e' as 'triehash'
[apt.git] / test / integration / skip-method-http-socks-client
CommitLineData
61db4824
DK
1#!/bin/sh
2set -e
3
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
6
7setupenvironment
8
9# We don't do a real proxy here, we just look how the implementation
10# reacts to certain responses from a "proxy" provided by socat
11# Checks HTTP, but requesting https instead will check HTTPS (curl) which
12# uses different error messages through – also: https://github.com/curl/curl/issues/944
13
14# FIXME: Not run automatically as it uses a hardcoded port (5555)
15
16msgtest 'Check that everything is installed' 'socat'
17if dpkg-checkbuilddeps -d 'socat' /dev/null >/dev/null 2>&1; then
18 msgpass
19else
20 msgskip "$(command dpkg -l socat)"
21 exit
22fi
23
24runclient() {
25 # this doesn't need to be an actually reachable webserver for this test
26 # in fact, its better if it isn't.
27 rm -f index.html
e40a4a3e 28 apthelper download-file "http://${2:-localhost:2903}/" index.html \
61db4824
DK
29 -o Acquire::http::Proxy="socks5h://${1}localhost:5555" \
30 -o Acquire::http::Timeout=2 -o Debug::Acquire::http=1 > client.output 2>&1 || true
31}
32runserver() {
33 socat -x tcp-listen:5555,reuseaddr \
34 system:"echo -n '$*' | xxd -r -p; echo 'HTTP/1.1 200 OK'; echo 'Content-Length: 5'; echo 'Connection: close'; echo; echo 'HTML'" \
35 > server.output 2>&1 &
36}
37PROXY="socks5h://localhost:5555"
38
39msgmsg 'SOCKS does not run'
40runclient
41testsuccess grep 'Could not connect to localhost:5555' client.output
42
43msgmsg 'SOCKS greets back with wrong version'
44runserver '04 00'
45runclient
46testsuccess grep 'greets back with wrong version: 4' client.output
47
48msgmsg 'SOCKS tries GSSAPI auth we have not advertised'
49runserver '05 01'
50runclient
51testsuccess grep 'greets back having not found a common authorization method: 1' client.output
52
53msgmsg 'SOCKS tries user&pass auth we have not advertised'
54runserver '05 02'
55runclient
56testsuccess grep 'pass auth, but we had not offered it' client.output
57
58msgmsg 'SOCKS user:pass wrong version'
59runserver '05 02' '05 00'
60runclient 'user:pass@'
61testsuccess grep 'auth status response with wrong version: 5' client.output
62
63msgmsg 'SOCKS user:pass wrong auth'
64runserver '05 02' '01 01'
65runclient 'user:pass@'
66testsuccess grep 'reported authorization failure: username or password incorrect? (1)' client.output
67
68msgmsg 'SOCKS user:pass request not granted no hostname'
69runserver '05 02' '01 00' '05 01 00 03 00 1f 90'
70runclient 'user:pass@'
e40a4a3e 71testsuccess grep 'could not connect to localhost (:8080) due to: general SOCKS server failure (1)' client.output
61db4824
DK
72
73msgmsg 'SOCKS user:pass request not granted with hostname'
74runserver '05 02' '01 00' '05 01 00 03 09 68 6f 73 74 6c 6f 63 61 6c 1f 90'
75runclient 'user:pass@'
e40a4a3e 76testsuccess grep 'could not connect to localhost (hostlocal:8080) due to: general SOCKS server failure (1)' client.output
61db4824
DK
77
78msgmsg 'SOCKS user:pass request not granted ipv4'
79runserver '05 02' '01 00' '05 04 00 01 ac 10 fe 01 1f 90'
80runclient 'user:pass@'
e40a4a3e 81testsuccess grep 'could not connect to localhost (172.16.254.1:8080) due to: Host unreachable (4)' client.output
61db4824
DK
82
83msgmsg 'SOCKS user:pass request not granted ipv6'
84runserver '05 02' '01 00' '05 12 00 04 20 01 0d b8 ac 10 fe 00 00 00 00 00 00 00 00 00 1f 90'
85runclient 'user:pass@'
e40a4a3e 86testsuccess grep 'could not connect to localhost (\[2001:0DB8:AC10:FE00:0000:0000:0000:0000\]:8080) due to: Unknown error (18)' client.output
61db4824
DK
87
88msgmsg 'SOCKS user:pass request granted ipv4'
89runserver '05 02' '01 00' '05 00 00 01 ac 10 fe 01 1f 90'
90runclient 'user:pass@'
e40a4a3e 91testequal "http: SOCKS proxy $PROXY connection established to localhost (172.16.254.1:8080)" head -n 1 client.output
61db4824
DK
92testfileequal index.html 'HTML'
93
94msgmsg 'SOCKS user:pass request granted ipv6'
95runserver '05 02' '01 00' '05 00 00 04 20 01 0d b8 ac 10 fe 00 00 00 00 00 00 00 00 00 1f 90'
96runclient 'user:pass@'
e40a4a3e 97testequal "http: SOCKS proxy $PROXY connection established to localhost ([2001:0DB8:AC10:FE00:0000:0000:0000:0000]:8080)" head -n 1 client.output
61db4824
DK
98testfileequal index.html 'HTML'
99
100msgmsg 'SOCKS no auth no hostname'
101runserver '05 00 05 00 00 03 00 1f 90'
102runclient
e40a4a3e 103testequal "http: SOCKS proxy $PROXY connection established to localhost (:8080)" head -n 1 client.output
61db4824
DK
104testfileequal index.html 'HTML'
105
106msgmsg 'SOCKS no auth with hostname'
107runserver '05 00 05 00 00 03 09 68 6f 73 74 6c 6f 63 61 6c 1f 90'
108runclient
e40a4a3e 109testequal "http: SOCKS proxy $PROXY connection established to localhost (hostlocal:8080)" head -n 1 client.output
61db4824
DK
110testfileequal index.html 'HTML'
111
112msgmsg 'SOCKS user-only request granted ipv4'
113runserver '05 02' '01 00' '05 00 00 01 ac 10 fe 01 1f 90'
114runclient 'apt@'
e40a4a3e 115testequal "http: SOCKS proxy $PROXY connection established to localhost (172.16.254.1:8080)" head -n 1 client.output
61db4824 116testfileequal index.html 'HTML'
e40a4a3e
DK
117
118msgmsg 'tor: SOCKS user:pass request not granted'
119runserver '05 02' '01 00' '05 04 00 01 00 00 00 00 00 00'
120runclient 'user:pass@'
121testsuccess grep 'could not connect to localhost (0.0.0.0:0) due to: Host unreachable (4)' client.output
122
123msgmsg 'tor: SOCKS user:pass request tll expired'
124runserver '05 02' '01 00' '05 06 00 01 00 00 00 00 00 00'
125runclient 'user:pass@'
126testsuccess grep 'could not connect to localhost (0.0.0.0:0) due to: TTL expired (6)' client.output
127
128msgmsg 'tor: SOCKS user:pass request service unreachable'
129runserver '05 02' '01 00' '05 06 00 01 00 00 00 00 00 00'
130runclient 'user:pass@' 'vwakviie2ienjx6t.onion'
131testsuccess grep 'could not connect to vwakviie2ienjx6t.onion (0.0.0.0:0) due to: Host unreachable (6)' client.output
132
133msgmsg 'tor: SOCKS user:pass request not granted onion'
134runserver '05 02' '01 00' '05 01 00 01 00 00 00 00 00 00'
135runclient 'user:pass@' 'vwakviie2ienjx6t.onion'
136testsuccess grep 'could not connect to vwakviie2ienjx6t.onion (0.0.0.0:0) due to: general SOCKS server failure (1)' client.output
137
138msgmsg 'tor: SOCKS user:pass request not granted subdomain'
139runserver '05 02' '01 00' '05 01 00 01 00 00 00 00 00 00'
140runclient 'user:pass@' 'ftp.vwakviie2ienjx6t.onion'
141testsuccess grep 'could not connect to ftp.vwakviie2ienjx6t.onion (0.0.0.0:0) due to: general SOCKS server failure (1)' client.output
142
143msgmsg 'tor: SOCKS user:pass request not granted too short'
144runserver '05 02' '01 00' '05 01 00 01 00 00 00 00 00 00'
145runclient 'user:pass@' 'wakviie2ienjx6t.onion'
146testsuccess grep 'could not connect to wakviie2ienjx6t.onion (0.0.0.0:0) due to: Invalid hostname: onion service name must be 16 characters long (1)' client.output
147
148msgmsg 'tor: SOCKS user:pass request not granted too long'
149runserver '05 02' '01 00' '05 01 00 01 00 00 00 00 00 00'
150runclient 'user:pass@' 'vwakviie2ienjx6t2.onion'
151testsuccess grep 'could not connect to vwakviie2ienjx6t2.onion (0.0.0.0:0) due to: Invalid hostname: onion service name must be 16 characters long (1)' client.output
152
153msgmsg 'tor: SOCKS user:pass request not granted too short subdomain'
154runserver '05 02' '01 00' '05 01 00 01 00 00 00 00 00 00'
155runclient 'user:pass@' 'a.akviie2ienjx6t.onion'
156testsuccess grep 'could not connect to a.akviie2ienjx6t.onion (0.0.0.0:0) due to: Invalid hostname: onion service name must be 16 characters long (1)' client.output
157
158msgmsg 'tor: SOCKS user:pass request not granted too short subdomains'
159runserver '05 02' '01 00' '05 01 00 01 00 00 00 00 00 00'
160runclient 'user:pass@' 'a.a.viie2ienjx6t.onion'
161testsuccess grep 'could not connect to a.a.viie2ienjx6t.onion (0.0.0.0:0) due to: Invalid hostname: onion service name must be 16 characters long (1)' client.output