diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-09-16 09:40:22 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-09-16 09:40:22 +0200 |
commit | 75efcd89b40e5c9e54ccf1f9d5dce192a2a199d0 (patch) | |
tree | 65980fdfffa2dea205cef6cf6e57e60be3fd35e2 /test | |
parent | e9f9bf1601d3a4373c318fbb441ae92e99cd703d (diff) |
cherry pick r2162.1.7 and r2162.1.8 from the debian-sid branch
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/framework | 31 | ||||
-rwxr-xr-x | test/integration/test-releasefile-valid-until | 90 |
2 files changed, 108 insertions, 13 deletions
diff --git a/test/integration/framework b/test/integration/framework index ccab010e6..8937c0a91 100644 --- a/test/integration/framework +++ b/test/integration/framework @@ -508,8 +508,9 @@ getcodenamefromsuite() { echo -n "$1"; } getreleaseversionfromsuite() { true; } generatereleasefiles() { + # $1 is the Date header and $2 is the ValidUntil header to be set + # both should be given in notation date/touch can understand msgninfo "\tGenerate Release files… " - local DATE="${1:-now}" if [ -e aptarchive/dists ]; then for dir in $(find ./aptarchive/dists -mindepth 3 -maxdepth 3 -type d -name 'i18n'); do aptftparchive -qq release $dir -o APT::FTPArchive::Release::Patterns::='Translation-*' > $dir/Index @@ -518,27 +519,31 @@ generatereleasefiles() { local SUITE="$(echo "$dir" | cut -d'/' -f 4)" local CODENAME="$(getcodenamefromsuite $SUITE)" local VERSION="$(getreleaseversionfromsuite $SUITE)" - if [ -z "$VERSION" ]; then - aptftparchive -qq release $dir \ - -o APT::FTPArchive::Release::Suite="${SUITE}" \ - -o APT::FTPArchive::Release::Codename="${CODENAME}" \ - | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference - else - aptftparchive -qq release $dir \ - -o APT::FTPArchive::Release::Suite="${SUITE}" \ - -o APT::FTPArchive::Release::Codename="${CODENAME}" \ - -o APT::FTPArchive::Release::Version="${VERSION}" \ - | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference + if [ -n "$VERSION" ]; then + VERSION="-o APT::FTPArchive::Release::Version='${VERSION}'" fi + aptftparchive -qq release $dir \ + -o APT::FTPArchive::Release::Suite="${SUITE}" \ + -o APT::FTPArchive::Release::Codename="${CODENAME}" \ + -o APT::FTPArchive::Release::Label="Testcases" \ + ${VERSION} \ + | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then sed -i '/^Date: / a\ NotAutomatic: yes' $dir/Release fi + if [ -n "$1" -a "$1" != "now" ]; then + sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release + fi + if [ -n "$2" ]; then + sed -i "/^Date: / a\ +Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release + fi done else aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference fi - if [ "$DATE" != "now" ]; then + if [ -n "$1" -a "$1" != "now" ]; then for release in $(find ./aptarchive -name 'Release'); do touch -d "$1" $release done diff --git a/test/integration/test-releasefile-valid-until b/test/integration/test-releasefile-valid-until new file mode 100755 index 000000000..c35fe97ff --- /dev/null +++ b/test/integration/test-releasefile-valid-until @@ -0,0 +1,90 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' + +insertpackage 'wheezy' 'apt' 'all' '0.8.15' + +setupaptarchive + +setupreleasefile() { + rm -rf rootdir/var/lib/apt/lists + aptget clean + generatereleasefiles "$1" "$2" + signreleasefiles +} + +aptgetupdate() { + if aptget update $* 2>&1 | grep -q 'is expired'; then + return 1 + else + return 0 + fi +} + +setupreleasefile +msgtest 'Release file is accepted as it has' 'no Until' +aptgetupdate && msgpass || msgfail + +setupreleasefile +msgtest 'Release file is accepted as it has' 'no Until and good Max-Valid' +aptgetupdate -o Acquire::Max-ValidTime=3600 && msgpass || msgfail + +setupreleasefile 'now - 2 days' +msgtest 'Release file is rejected as it has' 'no Until, but bad Max-Valid' +aptgetupdate -o Acquire::Max-ValidTime=3600 && msgfail || msgpass + +setupreleasefile 'now - 3 days' 'now + 1 day' +msgtest 'Release file is accepted as it has' 'good Until' +aptgetupdate && msgpass || msgfail + +setupreleasefile 'now - 7 days' 'now - 4 days' +msgtest 'Release file is rejected as it has' 'bad Until' +aptgetupdate && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now - 4 days' +msgtest 'Release file is rejected as it has' 'bad Until (ignore good Max-Valid)' +aptgetupdate -o Acquire::Max-ValidTime=1209600 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now - 4 days' +msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until)' +aptgetupdate -o Acquire::Max-ValidTime=86400 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now + 4 days' +msgtest 'Release file is rejected as it has' 'bad Max-Valid (good Until)' +aptgetupdate -o Acquire::Max-ValidTime=86400 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now + 4 days' +msgtest 'Release file is accepted as it has' 'good labeled Max-Valid' +aptgetupdate -o Acquire::Max-ValidTime=86400 -o Acquire::Max-ValidTime::Testcases=1209600 && msgpass || msgfail + +setupreleasefile 'now - 7 days' 'now + 4 days' +msgtest 'Release file is rejected as it has' 'bad labeled Max-Valid' +aptgetupdate -o Acquire::Max-ValidTime=1209600 -o Acquire::Max-ValidTime::Testcases=86400 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now + 1 days' +msgtest 'Release file is accepted as it has' 'good Until (good Min-Valid, no Max-Valid)' +aptgetupdate -o Acquire::Min-ValidTime=1209600 && msgpass || msgfail + +setupreleasefile 'now - 7 days' 'now - 4 days' +msgtest 'Release file is accepted as it has' 'good Min-Valid (bad Until, no Max-Valid)' +aptgetupdate -o Acquire::Min-ValidTime=1209600 && msgpass || msgfail + +setupreleasefile 'now - 7 days' 'now - 2 days' +msgtest 'Release file is accepted as it has' 'good Min-Valid (bad Until, good Max-Valid) <' +aptgetupdate -o Acquire::Min-ValidTime=1209600 -o Acquire::Max-ValidTime=2419200 && msgpass || msgfail + +setupreleasefile 'now - 7 days' 'now - 2 days' +msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, good Min-Valid) >' +aptgetupdate -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=2419200 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now - 2 days' +msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, bad Min-Valid) <' +aptgetupdate -o Acquire::Min-ValidTime=12096 -o Acquire::Max-ValidTime=241920 && msgfail || msgpass + +setupreleasefile 'now - 7 days' 'now - 2 days' +msgtest 'Release file is rejected as it has' 'bad Max-Valid (bad Until, bad Min-Valid) >' +aptgetupdate -o Acquire::Max-ValidTime=12096 -o Acquire::Min-ValidTime=241920 && msgfail || msgpass |