Просмотр исходного кода

tests: add a webserverconfig method to abstract config

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
David Kalnischkies лет назад: 12
Родитель
Сommit
f2c0ec8bdb

+ 16 - 0
test/integration/framework

@@ -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

+ 2 - 4
test/integration/test-partial-file-support

@@ -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' '='

+ 1 - 1
test/integration/test-releasefile-verification

@@ -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}"

+ 1 - 1
test/interactive-helper/aptwebserver.cc

@@ -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 &&