]> git.saurik.com Git - apt.git/blame - test/integration/test-apt-helper
format multiline errors properly in acquire progress
[apt.git] / test / integration / test-apt-helper
CommitLineData
c1409d1b
MV
1#!/bin/sh
2set -e
3
3abb6a6a
DK
4TESTDIR="$(readlink -f "$(dirname "$0")")"
5. "$TESTDIR/framework"
c1409d1b
MV
6
7setupenvironment
43acd019 8configarchitecture 'i386'
c1409d1b
MV
9
10changetohttpswebserver
11
6c0765c0
DK
12echo 'foo' > aptarchive/foo
13echo 'bar' > aptarchive/foo2
14
c6ee61ea 15test_apt_helper_download() {
6c0765c0 16 msgmsg 'Test with' "$1"
c1409d1b 17
63d60998 18 msgtest 'apt-file download-file' 'md5sum'
6c0765c0 19 testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo2' 'MD5Sum:d3b07384d113edec49eaa6238ad5ff00'
63d60998
DK
20 testfileequal ./downloaded/foo2 'foo'
21
22 msgtest 'apt-file download-file' 'sha1'
6c0765c0 23 testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo1' 'SHA1:f1d2d2f924e986ac86fdf7b36c94bcdf32beec15'
fec55559 24 testfileequal ./downloaded/foo1 'foo'
c1409d1b 25
63d60998 26 msgtest 'apt-file download-file' 'sha256'
6c0765c0 27 testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo3' 'SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c'
fec55559 28 testfileequal ./downloaded/foo3 'foo'
c1409d1b 29
63d60998 30 msgtest 'apt-file download-file' 'no-hash'
6c0765c0 31 testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo4'
fec55559 32 testfileequal ./downloaded/foo4 'foo'
63d60998
DK
33
34 msgtest 'apt-file download-file' 'wrong md5sum'
6c0765c0
DK
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
6c0765c0 37E: Download Failed"
fec55559 38 testfileequal ./downloaded/foo5.FAILED 'foo'
92e8c1ff 39
63d60998 40 msgtest 'apt-file download-file' 'wrong sha256'
6c0765c0
DK
41 testfailure --nomsg apthelper -qq download-file "${1}/foo" './downloaded/foo6' 'SHA256:aabbcc'
42 testfileequal rootdir/tmp/testfailure.output "E: Failed to fetch ${1}/foo Hash Sum mismatch
6c0765c0
DK
43E: Download Failed"
44 testfileequal './downloaded/foo6.FAILED' 'foo'
63d60998
DK
45
46 msgtest 'apt-file download-file' 'sha256 sha1'
6c0765c0
DK
47 testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo8' 'SHA256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c' \
48 "${1}/foo2" './downloaded/foo7' 'SHA1:e242ed3bffccdf271b7fbaf34ed72d089537b42f'
49 testfileequal './downloaded/foo8' 'foo'
50 testfileequal './downloaded/foo7' 'bar'
63d60998
DK
51
52 msgtest 'apt-file download-file' 'md5sum sha1'
6c0765c0
DK
53 testsuccess --nomsg apthelper download-file "${1}/foo" './downloaded/foo9' 'MD5Sum:d3b07384d113edec49eaa6238ad5ff00' \
54 "${1}/foo2" './downloaded/foo10' 'SHA1:e242ed3bffccdf271b7fbaf34ed72d089537b42f'
55 testfileequal './downloaded/foo9' 'foo'
56 testfileequal './downloaded/foo10' 'bar'
c6ee61ea
MV
57}
58
59test_apt_helper_detect_proxy() {
60 # no proxy
25b86db1 61 testsuccessequal "Using proxy '' for URL 'http://example.com/'" apthelper auto-detect-proxy http://example.com/
c6ee61ea
MV
62
63
64 # http auto detect proxy script
65 cat > apt-proxy-detect <<'EOF'
66#!/bin/sh -e
67echo "http://some-proxy"
68EOF
69 chmod 755 apt-proxy-detect
70 echo "Acquire::http::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir/etc/apt/apt.conf.d/02proxy-detect
081c9d44 71
25b86db1 72 testsuccessequal "Using proxy 'http://some-proxy' for URL 'http://www.example.com/'" apthelper auto-detect-proxy http://www.example.com
c6ee61ea
MV
73
74
75 # https auto detect proxy script
76 cat > apt-proxy-detect <<'EOF'
77#!/bin/sh -e
78echo "https://https-proxy"
79EOF
80 chmod 755 apt-proxy-detect
81 echo "Acquire::https::Proxy-Auto-Detect \"$(pwd)/apt-proxy-detect\";" > rootdir/etc/apt/apt.conf.d/02proxy-detect
c6ee61ea 82
25b86db1 83 testsuccessequal "Using proxy 'https://https-proxy' for URL 'https://ssl.example.com/'" apthelper auto-detect-proxy https://ssl.example.com
c6ee61ea
MV
84}
85
6c0765c0
DK
86test_apt_helper_download "http://localhost:${APTHTTPPORT}"
87test_apt_helper_download "https://localhost:${APTHTTPSPORT}"
c6ee61ea
MV
88test_apt_helper_detect_proxy
89
081c9d44 90# test failure modes
25b86db1
DK
91testfailureequal 'E: Invalid operation download' apthelper download
92testfailureequal 'E: Must specify at least one pair url/filename' apthelper download-file
6c0765c0 93testfailureequal 'E: Must specify at least one pair url/filename' apthelper download-file 'http://example.org/'
25b86db1 94testfailureequal 'E: Need one URL as argument' apthelper auto-detect-proxy
7414af7f 95testfailureequal 'E: Must specify at least one SRV record' apthelper srv-lookup
87d6947d
DK
96testfailureequal 'E: GetSrvRec failed for localhost' apthelper -q=1 srv-lookup 'localhost'
97testfailureequal "E: GetSrvRec failed for localhost:${APTHTTPPORT}" apthelper -q=1 srv-lookup "localhost:${APTHTTPPORT}"
98testfailureequal "E: GetSrvRec failed for localhost:${APTHTTPSPORT}" apthelper -q=1 srv-lookup "localhost:${APTHTTPSPORT}"