4 TESTDIR
=$(readlink -f $(dirname $0))
8 configarchitecture
'i386'
10 changetohttpswebserver
12 echo 'foo' > aptarchive
/foo
13 echo 'bar' > aptarchive
/foo2
15 test_apt_helper_download
() {
16 msgmsg
'Test with' "$1"
18 msgtest
'apt-file download-file' 'md5sum'
19 testsuccess
--nomsg apthelper download
-file "${1}/foo" './downloaded/foo2' 'MD5Sum:d3b07384d113edec49eaa6238ad5ff00'
20 testfileequal .
/downloaded
/foo2
'foo'
22 msgtest
'apt-file download-file' 'sha1'
23 testsuccess
--nomsg apthelper download
-file "${1}/foo" './downloaded/foo1' 'SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15'
24 testfileequal .
/downloaded
/foo1
'foo'
26 msgtest
'apt-file download-file' 'sha256'
27 testsuccess
--nomsg apthelper download
-file "${1}/foo" './downloaded/foo3' 'SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c'
28 testfileequal .
/downloaded
/foo3
'foo'
30 msgtest
'apt-file download-file' 'no-hash'
31 testsuccess
--nomsg apthelper download
-file "${1}/foo" './downloaded/foo4'
32 testfileequal .
/downloaded
/foo4
'foo'
34 msgtest
'apt-file download-file' 'wrong md5sum'
35 testfailure
--nomsg apthelper
-qq download
-file "${1}/foo" './downloaded/foo5' 'MD5Sum:aabbcc'
36 testfileequal rootdir
/tmp
/testfailure.output
"E: Failed to fetch ${1}/foo Hash Sum mismatch
39 testfileequal .
/downloaded
/foo5.FAILED
'foo'
41 msgtest
'apt-file download-file' 'wrong sha256'
42 testfailure
--nomsg apthelper
-qq download
-file "${1}/foo" './downloaded/foo6' 'SHA256:aabbcc'
43 testfileequal rootdir
/tmp
/testfailure.output
"E: Failed to fetch ${1}/foo Hash Sum mismatch
46 testfileequal
'./downloaded/foo6.FAILED' 'foo'
48 msgtest
'apt-file download-file' 'sha256 sha1'
49 testsuccess
--nomsg apthelper download
-file "${1}/foo" './downloaded/foo8' 'SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c' \
50 "${1}/foo2" './downloaded/foo7' 'SHA1:e242ed3bffccdf271b7fbaf34ed72d089537b42f'
51 testfileequal
'./downloaded/foo8' 'foo'
52 testfileequal
'./downloaded/foo7' 'bar'
54 msgtest
'apt-file download-file' 'md5sum sha1'
55 testsuccess
--nomsg apthelper download
-file "${1}/foo" './downloaded/foo9' 'MD5Sum:d3b07384d113edec49eaa6238ad5ff00' \
56 "${1}/foo2" './downloaded/foo10' 'SHA1:e242ed3bffccdf271b7fbaf34ed72d089537b42f'
57 testfileequal
'./downloaded/foo9' 'foo'
58 testfileequal
'./downloaded/foo10' 'bar'
61 test_apt_helper_detect_proxy
() {
63 testsuccessequal
"Using proxy '' for URL 'http://example.com/'" apthelper auto
-detect-proxy http
://example.com
/
66 # http auto detect proxy script
67 cat > apt
-proxy-detect <<'EOF'
69 echo "http://some-proxy"
71 chmod 755 apt
-proxy-detect
72 echo "Acquire::http::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir
/etc
/apt
/apt.conf.d
/02proxy
-detect
74 testsuccessequal
"Using proxy 'http://some-proxy' for URL 'http://www.example.com/'" apthelper auto
-detect-proxy http
://www.example.com
77 # https auto detect proxy script
78 cat > apt
-proxy-detect <<'EOF'
80 echo "https://https-proxy"
82 chmod 755 apt
-proxy-detect
83 echo "Acquire::https::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir
/etc
/apt
/apt.conf.d
/02proxy
-detect
85 testsuccessequal
"Using proxy 'https://https-proxy' for URL 'https://ssl.example.com/'" apthelper auto
-detect-proxy https
://ssl.example.com
88 test_apt_helper_download
"http://localhost:${APTHTTPPORT}"
89 test_apt_helper_download
"https://localhost:${APTHTTPSPORT}"
90 test_apt_helper_detect_proxy
93 testfailureequal
'E: Invalid operation download' apthelper download
94 testfailureequal
'E: Must specify at least one pair url/filename' apthelper download
-file
95 testfailureequal
'E: Must specify at least one pair url/filename' apthelper download
-file 'http://example.org/'
96 testfailureequal
'E: Need one URL as argument' apthelper auto
-detect-proxy
97 testfailureequal
'E: Must specify at least one SRV record' apthelper srv
-lookup
98 testfailureequal
'E: GetSrvRec failed for localhost' apthelper
-q=1 srv
-lookup 'localhost'
99 testfailureequal
"E: GetSrvRec failed for localhost:${APTHTTPPORT}" apthelper
-q=1 srv
-lookup "localhost:${APTHTTPPORT}"
100 testfailureequal
"E: GetSrvRec failed for localhost:${APTHTTPSPORT}" apthelper
-q=1 srv
-lookup "localhost:${APTHTTPSPORT}"