summaryrefslogtreecommitdiff
path: root/test/integration/test-apt-https-transient
blob: 9fd70942fe31a4e288049ea1cf1fa78702d3d567 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
set -e

TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"

setupenvironment
configarchitecture "i386"

# Disable sandbox to avoid W: down below
echo 'APT::Sandbox::User "root";' > rootdir/etc/apt/apt.conf.d/no-acquire-sandbox

echo 'alright' > aptarchive/working
changetohttpswebserver

msgtest 'download of a file works via' 'http'
testsuccess --nomsg downloadfile "http://localhost:${APTHTTPPORT}/working" httpsfile
testfileequal httpsfile 'alright'
rm -f httpfile httpsfile

msgtest 'download of a file works via' 'https'
testsuccess --nomsg downloadfile "https://localhost:${APTHTTPSPORT}/working" httpfile
testfileequal httpfile 'alright'
rm -f httpfile httpsfile

# Speak wrong protocols (https on http port and vice versa). We check that they can be retried.
msgtest 'protocol negotiation error is transient for' 'https'
testfailure --nomsg apthelper download-file "https://localhost:${APTHTTPPORT}/working" httpfile -oAcquire::https::Timeout=1 -oAcquire::Retries=1
cp -a rootdir/tmp/testfailure.output httpsonhttp.output
# the error details produced seem a bit too internal to hardcode them here:
#  SSL connection failed: error:00000000:lib(0)::reason(0) / Connection reset by peer
testsuccess grep "^Ign:1 https://localhost:${APTHTTPPORT}/working$" httpsonhttp.output
testsuccess grep "^Err:1 https://localhost:${APTHTTPPORT}/working$" httpsonhttp.output

# Speak wrong protocols (https on http port and vice versa)
msgtest 'protocol negotiation error is transient for' 'http'
testfailureequal --nomsg "Ign:1 http://localhost:${APTHTTPSPORT}/working
  Connection failed
Err:1 http://localhost:${APTHTTPSPORT}/working
  Connection failed
E: Failed to fetch http://localhost:${APTHTTPSPORT}/working  Connection failed
E: Download Failed" apthelper download-file "http://localhost:${APTHTTPSPORT}/working" httpfile -oAcquire::https::Timeout=1 -oAcquire::Retries=1