summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-05-13 16:09:12 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-05-13 16:09:12 +0200
commit8eafc759544298211cd0bfaa3919afc0fadd47d1 (patch)
treee1a6e74d6d1abdc177316b9422aae3723f727732 /test
parent495b7a615a2d8f485beadf88c6ed298f5bbe50c2 (diff)
detect Releasefile IMS hits even if the server doesn't
Not all servers we are talking to support If-Modified-Since and some are not even sending Last-Modified for us, so in an effort to detect such hits we run a hashsum check on the 'old' compared to the 'new' file, we got the hashes for the 'new' already for "free" from the methods anyway and hence just need to calculated the old ones. This allows us to detect hits even with unsupported servers, which in turn means we benefit from all the new hit behavior also here.
Diffstat (limited to 'test')
-rw-r--r--test/integration/framework9
-rwxr-xr-xtest/integration/test-apt-update-expected-size1
-rwxr-xr-xtest/integration/test-apt-update-not-modified58
-rwxr-xr-xtest/integration/test-apt-update-rollback1
-rwxr-xr-xtest/integration/test-apt-update-transactions2
5 files changed, 70 insertions, 1 deletions
diff --git a/test/integration/framework b/test/integration/framework
index 2a53e8365..8c8936ead 100644
--- a/test/integration/framework
+++ b/test/integration/framework
@@ -1005,6 +1005,15 @@ signreleasefiles() {
msgdone "info"
}
+redatereleasefiles() {
+ local DATE="$(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')"
+ for release in $(find aptarchive/ -name 'Release'); do
+ sed -i "s/^Date: .*$/Date: ${DATE}/" $release
+ touch -d "$DATE" $release
+ done
+ signreleasefiles "${2:-Joe Sixpack}"
+}
+
webserverconfig() {
local WEBSERVER="${3:-http://localhost:8080}"
local NOCHECK=false
diff --git a/test/integration/test-apt-update-expected-size b/test/integration/test-apt-update-expected-size
index 7efccaa57..55a5da848 100755
--- a/test/integration/test-apt-update-expected-size
+++ b/test/integration/test-apt-update-expected-size
@@ -26,6 +26,7 @@ test_inreleasetoobig() {
}
test_packagestoobig() {
+ redatereleasefiles '+1hour'
# append junk at the end of the Packages.gz/Packages
SIZE="$(stat --printf=%s aptarchive/dists/unstable/main/binary-i386/Packages)"
find aptarchive/dists -name 'Packages*' | while read pkg; do
diff --git a/test/integration/test-apt-update-not-modified b/test/integration/test-apt-update-not-modified
index 2dc56e76c..a67ecb760 100755
--- a/test/integration/test-apt-update-not-modified
+++ b/test/integration/test-apt-update-not-modified
@@ -12,7 +12,7 @@ insertpackage 'unstable' 'apt' 'all' '1.0'
setupaptarchive --no-update
methodtest() {
- msgmsg 'Test with' "$1"
+ msgmsg 'Test InRelease with' "$1"
rm -rf rootdir/var/lib/apt/lists
# get our cache populated
testsuccess aptget update
@@ -36,6 +36,62 @@ Reading package lists..." aptget update
Get:1 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
Reading package lists..." aptget update
testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
+
+ webserverconfig 'aptwebserver::support::modified-since' 'false'
+ webserverconfig 'aptwebserver::support::last-modified' 'false'
+ testsuccessequal "Get:1 $1 unstable InRelease [$(stat -c '%s' 'aptarchive/dists/unstable/InRelease') B]
+Reading package lists..." aptget update
+ webserverconfig 'aptwebserver::support::modified-since' 'true'
+ webserverconfig 'aptwebserver::support::last-modified' 'true'
+
+ msgmsg 'Test Release.gpg with' "$1"
+ rm -rf rootdir/var/lib/apt/lists
+ cp -a aptarchive/dists aptarchive/dists.good
+ find aptarchive/dists -name 'InRelease' -delete
+ # get our cache populated
+ testsuccess aptget update
+ listcurrentlistsdirectory > listsdir.lst
+
+ # hit again with a good cache
+ testsuccessequal "Ign $1 unstable InRelease
+ 404 Not Found
+Hit $1 unstable Release
+Hit $1 unstable Release.gpg
+Reading package lists..." aptget update
+ testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
+
+ # drop an architecture, which means the file should be gone now
+ configarchitecture 'i386'
+ sed '/_binary-amd64_Packages/ d' listsdir.lst > listsdir-without-amd64.lst
+ testsuccessequal "Ign $1 unstable InRelease
+ 404 Not Found
+Hit $1 unstable Release
+Hit $1 unstable Release.gpg
+Reading package lists..." aptget update
+ testfileequal 'listsdir-without-amd64.lst' "$(listcurrentlistsdirectory)"
+
+ # readd arch so its downloaded again
+ configarchitecture 'amd64' 'i386'
+ testsuccessequal "Ign $1 unstable InRelease
+ 404 Not Found
+Hit $1 unstable Release
+Hit $1 unstable Release.gpg
+Get:1 $1 unstable/main amd64 Packages [$(stat -c '%s' 'aptarchive/dists/unstable/main/binary-amd64/Packages.gz') B]
+Reading package lists..." aptget update
+ testfileequal 'listsdir.lst' "$(listcurrentlistsdirectory)"
+
+ webserverconfig 'aptwebserver::support::modified-since' 'false'
+ webserverconfig 'aptwebserver::support::last-modified' 'false'
+ testsuccessequal "Ign $1 unstable InRelease
+ 404 Not Found
+Get:1 $1 unstable Release [$(stat -c '%s' 'aptarchive/dists/unstable/Release') B]
+Get:2 $1 unstable Release.gpg [$(stat -c '%s' 'aptarchive/dists/unstable/Release.gpg') B]
+Reading package lists..." aptget update
+ webserverconfig 'aptwebserver::support::modified-since' 'true'
+ webserverconfig 'aptwebserver::support::last-modified' 'true'
+
+ rm -rf aptarchive/dists
+ cp -a aptarchive/dists.good aptarchive/dists
}
changetowebserver
diff --git a/test/integration/test-apt-update-rollback b/test/integration/test-apt-update-rollback
index f4500b69d..29fe1ab56 100755
--- a/test/integration/test-apt-update-rollback
+++ b/test/integration/test-apt-update-rollback
@@ -158,6 +158,7 @@ test_inrelease_to_broken_gzip() {
msgmsg "Test InRelease to broken gzip"
start_with_good_inrelease
+ redatereleasefiles '+2hours'
# append junk at the end of the compressed file
echo "lala" >> $APTARCHIVE/dists/unstable/main/source/Sources.gz
touch -d '+2min' $APTARCHIVE/dists/unstable/main/source/Sources.gz
diff --git a/test/integration/test-apt-update-transactions b/test/integration/test-apt-update-transactions
index 67dd633f9..63b318056 100755
--- a/test/integration/test-apt-update-transactions
+++ b/test/integration/test-apt-update-transactions
@@ -47,6 +47,7 @@ testrun() {
testsetup() {
msgmsg 'Test with no initial data over' "$1"
+ redatereleasefiles 'now'
rm -rf rootdir/var/lib/apt/lists
mkdir -p rootdir/var/lib/apt/lists/partial
listcurrentlistsdirectory > listsdir.lst
@@ -55,6 +56,7 @@ testsetup() {
msgmsg 'Test with initial data over' "$1"
testsuccess aptget update
listcurrentlistsdirectory > listsdir.lst
+ redatereleasefiles '+1hour'
testrun 'listsdir.lst'
}