]> git.saurik.com Git - apt.git/blame - test/integration/test-ubuntu-bug-346386-apt-get-update-paywall
merged lp:~mvo/apt/hash-order
[apt.git] / test / integration / test-ubuntu-bug-346386-apt-get-update-paywall
CommitLineData
da3ebfe7
MV
1#!/bin/sh
2set -e
3
549b4939
MV
4ensure_n_canary_strings_in_dir() {
5 DIR=$1
6 CANARY_STRING=$2
7 EXPECTED_N=$3
8
721b05b8 9 msgtest "Testing for $EXPECTED_N canary strings '$CANARY_STRING' in in" "$DIR"
549b4939
MV
10
11 N=$(grep "$CANARY_STRING" $DIR/* 2>/dev/null |wc -l )
12 if [ "$N" = "$EXPECTED_N" ]; then
13 msgpass
14 return 0
15 else
16 msgfail "Expected $EXPECTED_N canaries, got $N"
17 return 1
18 fi
19}
20
da3ebfe7
MV
21TESTDIR=$(readlink -f $(dirname $0))
22. $TESTDIR/framework
23
24setupenvironment
721b05b8 25configarchitecture 'native'
da3ebfe7 26
721b05b8 27insertpackage 'unstable' 'unrelated' 'all' '1.0' 'stable'
da3ebfe7
MV
28
29setupaptarchive
3ce22d4f 30changetowebserver --simulate-paywall
da3ebfe7
MV
31
32rm -rf rootdir/var/lib/apt/lists
721b05b8
DK
33msgtest 'excpected failure of' 'apt-get update'
34aptget update -qq 2>/dev/null && msgfail || msgpass
35
36ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ 'ni ni ni' 0
549b4939 37testequal 'partial' ls rootdir/var/lib/apt/lists/
da3ebfe7 38
549b4939 39# again, this time with pre-existing files valid data
721b05b8 40for f in Release Release.gpg main_binary-amd64_Packages stable_main_source_Sources; do
549b4939
MV
41 echo "canary" > rootdir/var/lib/apt/lists/localhost:8080_dists_stable_${f}
42done
da3ebfe7 43
721b05b8
DK
44# this will fail, the important part is that the canaries remain
45msgtest 'excpected failure of' 'apt-get update'
46aptget update -qq 2>/dev/null && msgfail || msgpass
47ensure_n_canary_strings_in_dir rootdir/var/lib/apt/lists/ 'canary' 4