]> git.saurik.com Git - apt.git/commitdiff
tests: add a webserverconfig method to abstract config
authorDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 23 Oct 2013 14:32:48 +0000 (16:32 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 30 Nov 2013 11:38:26 +0000 (12:38 +0100)
The URI to use to set a config option is a bit arcane to write/remember
and checking if the setting was successful doubly so.

Git-Dch: Ignore

test/integration/framework
test/integration/test-partial-file-support
test/integration/test-releasefile-verification
test/interactive-helper/aptwebserver.cc

index 6a2a78c83174a6f850ad6a94da4c774c8fe2d732..89b5bb0e4231ec99040ed9cddc2a77983d85174a 100644 (file)
@@ -792,6 +792,22 @@ signreleasefiles() {
        msgdone "info"
 }
 
+webserverconfig() {
+       msgtest "Set webserver config option '${1}' to" "$2"
+       downloadfile "http://localhost:8080/_config/set/${1}/${2}" '/dev/null' >/dev/null
+       local DOWNLOG='download-testfile.log'
+       rm -f "$DOWNLOG"
+       local STATUS="$(mktemp)"
+       addtrap "rm $STATUS;"
+       downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG"
+       if [ "$(cat "$STATUS")" = '200' ]; then
+               msgpass
+       else
+               cat >&2 "$DOWNLOG"
+               msgfail "Statuscode was $(cat "$STATUS")"
+       fi
+}
+
 rewritesourceslist() {
        local APTARCHIVE="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
        for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
index b176cc15e566ca793084f8ec9501a2bbbbcd3b12..382789e68515efed21d0b9e98b6d73ce7fb22586 100755 (executable)
@@ -66,8 +66,7 @@ TESTFILE='aptarchive/testfile'
 cp -a ${TESTDIR}/framework $TESTFILE
 
 testrun() {
-       downloadfile "$1/_config/set/aptwebserver::support::range/true" '/dev/null' >/dev/null
-       testwebserverlaststatuscode '200'
+       webserverconfig 'aptwebserver::support::range' 'true'
 
        copysource $TESTFILE 0 ./testfile
        testdownloadfile 'no data' "${1}/testfile" './testfile' '='
@@ -94,8 +93,7 @@ testrun() {
        testdownloadfile 'old data' "${1}/testfile" './testfile' '='
        testwebserverlaststatuscode '200'
 
-       downloadfile "$1/_config/set/aptwebserver::support::range/false" '/dev/null' >/dev/null
-       testwebserverlaststatuscode '200'
+       webserverconfig 'aptwebserver::support::range' 'false'
 
        copysource $TESTFILE 20 ./testfile
        testdownloadfile 'no server support' "${1}/testfile" './testfile' '='
index 9d34a521a45fe972e1e415147988c08e2e80102f..e558b83e8384fa639a3fd9666b7c6fc197aa8368 100755 (executable)
@@ -11,7 +11,7 @@ buildaptarchive
 setupflataptarchive
 changetowebserver
 
-downloadfile "http://localhost:8080/_config/set/aptwebserver::support::range/false" '/dev/null' >/dev/null
+webserverconfig 'aptwebserver::support::range' 'false'
 
 prepare() {
        local DATE="${2:-now}"
index 7d3589c9dbe154bc4cc40f8e96b81a854e1cc971..b7663a76aa421b34c48f2745890548b79c7dce4e 100644 (file)
@@ -546,7 +546,7 @@ void * handleClient(void * voidclient)                                      /*{{{*/
         {
            FileFd data(filename, FileFd::ReadOnly);
            std::string condition = LookupTag(*m, "If-Modified-Since", "");
-           if (condition.empty() == false)
+           if (_config->FindB("aptwebserver::support::modified-since", true) == true && condition.empty() == false)
            {
               time_t cache;
               if (RFC1123StrToTime(condition.c_str(), cache) == true &&