msgtest 'Test for successful execution of' "$*"
fi
local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
+ if "$@" >${OUTPUT} 2>&1; then
+ if expr match "$1" '^apt.*' >/dev/null; then
+ if grep -q -E '^[WE]: ' "$OUTPUT"; then
+ echo >&2
+ cat >&2 $OUTPUT
+ msgfail 'successful run, but output contains warnings/errors'
+ else
+ msgpass
+ fi
+ else
+ msgpass
+ fi
+ else
+ local EXITCODE=$?
+ echo >&2
+ cat >&2 $OUTPUT
+ msgfail "exitcode $EXITCODE"
+ fi
+ aptautotest 'testsuccess' "$@"
+}
+testwarning() {
+ if [ "$1" = '--nomsg' ]; then
+ shift
+ else
+ msgtest 'Test for successful execution with warnings of' "$*"
+ fi
+ local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
if "$@" >${OUTPUT} 2>&1; then
if expr match "$1" '^apt.*' >/dev/null; then
if grep -q -E '^E: ' "$OUTPUT"; then
echo >&2
cat >&2 $OUTPUT
msgfail 'successful run, but output contains errors'
+ elif ! grep -q -E '^W: ' "$OUTPUT"; then
+ echo >&2
+ cat >&2 $OUTPUT
+ msgfail 'successful run, but output contains no warnings'
else
msgpass
fi
cat >&2 $OUTPUT
msgfail "exitcode $EXITCODE"
fi
- aptautotest 'testsuccess' "$@"
+ aptautotest 'testwarning' "$@"
}
-
testfailure() {
if [ "$1" = '--nomsg' ]; then
shift
E: Unable to locate package foo" aptget install -q -s foo
# ensure we can apt-get update by hash
-testsuccess aptget update -o APT::Acquire::By-Hash=1
+testsuccess aptget update -o APT::Acquire::By-Hash=1 -o Acquire::Languages=none
# ensure it works
testequal "Inst foo (1.0 unstable [all])
sed -i "s#Suite: unstable#Suite: unstable\n$MAGIC#" aptarchive/dists/unstable/Release
signreleasefiles
# ... and verify that it fetches by hash now
-testsuccess aptget update
+testsuccess aptget update -o Acquire::Languages=none
rm -f $APTARCHIVE/dists/unstable/*Release*
# update without authenticated InRelease file
-testsuccess aptget update --allow-insecure-repositories
+testwarning aptget update --allow-insecure-repositories
# this all should fail
testfailure aptget install -y foo
testequal "W: Failed to fetch http://localhost:8080/dists/unstable/main/binary-i386/Packages Writing more data than expected ($NEW_SIZE > $SIZE)
E: Some index files failed to download. They have been ignored, or old ones used instead." aptget update -qq
-
changetowebserver
runtest() {
+ configallowinsecurerepositories "${1:-false}"
+
rm -f rootdir/var/lib/apt/lists/localhost*
- testsuccess aptget update
+ if [ "$1" = 'true' ]; then
+ testwarning aptget update
+ else
+ testsuccess aptget update
+ fi
# ensure no leftovers in partial
testfailure ls "rootdir/var/lib/apt/lists/partial/*"
echo "Acquire::GzipIndexes "1";" > rootdir/etc/apt/apt.conf.d/02compressindex
runtest
-
# no Release.gpg or InRelease
-configallowinsecurerepositories "true"
-
msgmsg "Release only"
EXPECT="Ign http://localhost:8080 unstable InRelease
404 Not Found
find aptarchive -name 'Release.gpg' -delete
echo "Acquire::GzipIndexes "0";" > rootdir/etc/apt/apt.conf.d/02compressindex
-runtest
+runtest "true"
echo "Acquire::GzipIndexes "1";" > rootdir/etc/apt/apt.conf.d/02compressindex
-runtest
+runtest "true"
setupaptarchive_with_lists_clean()
{
setupaptarchive --no-update
- rm -f rootdir/var/lib/apt/lists/_*
- #rm -rf rootdir/var/lib/apt/lists
+ rm -rf rootdir/var/lib/apt/lists
}
test_from_inrelease_to_unsigned()
{
# setup archive with InRelease file
setupaptarchive_with_lists_clean
- testsuccess aptget update
+ # FIXME: is not what the server reported 4104 4106
+ testsuccess aptget update #-o Debug::pkgAcquire::Worker=1
# simulate moving to a unsigned but otherwise valid repo
simulate_mitm_and_inject_evil_package
generatereleasefiles
# and ensure we can update to it (with enough force)
- testsuccess aptget update --allow-insecure-repositories \
+ testwarning aptget update --allow-insecure-repositories \
-o Acquire::AllowDowngradeToInsecureRepositories=1
# but that the individual packages are still considered untrusted
testequal "WARNING: The following packages cannot be authenticated!
rm $APTARCHIVE/dists/unstable/InRelease
rm $APTARCHIVE/dists/unstable/Release.gpg
- testsuccess aptget update --allow-insecure-repositories
+ testwarning aptget update --allow-insecure-repositories
listcurrentlistsdirectory > lists.before
testequal "WARNING: The following packages cannot be authenticated!
old
rm -rf rootdir/var/lib/apt/lists/
find aptarchive/ -name '*Release*' -delete
- testsuccess aptget update --allow-insecure-repositories
+ testwarning aptget update --allow-insecure-repositories
# become authenticated
generatereleasefiles
aptgetupdate() {
rm -rf rootdir/var/lib/apt/ rootdir/var/cache/apt/*.bin
- testsuccess aptget update --allow-insecure-repositories
+ ${1:-testwarning} aptget update --allow-insecure-repositories
}
PKGTEXT="$(aptget install cool --assume-no -d | head -n 7)"
Download complete and in download only mode" aptget install cool --assume-no -d --allow-unauthenticated
sed -i -e 's#deb#deb [trusted=no]#' $DEBFILE
-aptgetupdate
+aptgetupdate 'testsuccess'
testequal "$PKGTEXT
WARNING: The following packages cannot be authenticated!
testsuccess aptget download cool --allow-unauthenticated
testfileexists 'cool_1.0_i386.deb'
else
- testsuccess aptget update --allow-insecure-repositories
+ testwarning aptget update --allow-insecure-repositories
testfailure aptget download cool
testfilemissing 'cool_1.0_i386.deb'
echo 'Acquire::http::Pipeline-Depth 10;' > rootdir/etc/apt/apt.conf.d/99enable-pipeline
# the output is a bit strange: it looks like it has downloaded pkga 4 times
-testsuccess aptget download pkga pkgb pkgc pkgd
+testwarning aptget download pkga pkgb pkgc pkgd
for pkg in 'pkga' 'pkgb' 'pkgc' 'pkgd'; do
testsuccess test -f ${pkg}_1.0_all.deb
testsuccess cmp incoming/${pkg}_1.0_all.deb ${pkg}_1.0_all.deb
# note that insecure with trusted=yes are allowed
# as the trusted=yes indicates that security is provided by
# something above the understanding of apt
- testsuccess aptget update --no-allow-insecure-repositories
+ ${1:-testsuccess} aptget update --no-allow-insecure-repositories
}
insecureaptgetupdate() {
rm -rf rootdir/var/lib/apt/lists
testfailure aptget update --no-allow-insecure-repositories
rm -rf rootdir/var/lib/apt/lists
- testsuccess aptget update --allow-insecure-repositories
+ testwarning aptget update --allow-insecure-repositories
}
msgmsg 'Test without trusted option and good sources'
msgmsg 'Test with trusted=yes option and good and unsigned sources'
cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
-aptgetupdate
+aptgetupdate 'testwarning'
everythingsucceeds
everythingsucceeds -t stable
everythingsucceeds -t testing
msgmsg 'Test with trusted=yes option and good and unknown sources'
cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
-aptgetupdate
+aptgetupdate 'testwarning'
everythingsucceeds
everythingsucceeds -t stable
everythingsucceeds -t testing
msgmsg 'Test with trusted=yes option and good and expired sources'
cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
-aptgetupdate
+aptgetupdate 'testwarning'
everythingsucceeds
everythingsucceeds -t stable
everythingsucceeds -t testing
msgmsg 'Test with trusted=yes option and unsigned and good sources'
cp -a rootdir/etc/apt/sources.list.d.bak/* rootdir/etc/apt/sources.list.d/
sed -i 's#^deb\(-src\)\? #deb\1 [trusted=yes] #' rootdir/etc/apt/sources.list.d/*
-aptgetupdate
+aptgetupdate 'testwarning'
everythingsucceeds
everythingsucceeds -t stable
everythingsucceeds -t testing