Rework QNetworkReply tests to use docker-based test servers

This change frees the tests of their dependence on the Qt internal test
server (qt-test-server.qt-test-net). It makes the developers run the
tests out of Qt testing infrastructure.

If the user has installed Docker engine on their host, the test servers
will be built up inside separate Docker containers, and then, the test
case goes with the Docker-based test servers. Otherwise, the test case
will keep using the Qt internal test server.

Task-number: QTQAINFRA-1686
Change-Id: I518bc3675bfd658938509744b0e7e0610bc8bf66
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
This commit is contained in:
Ryan Chu 2018-05-03 15:01:57 +02:00
parent 0bb760260e
commit 3f80783b11
12 changed files with 513 additions and 210 deletions

View File

@ -173,4 +173,45 @@ public:
return result.toLocal8Bit();
}
#endif // QT_NETWORK_LIB
static QString ftpServerName()
{
#ifdef QT_TEST_SERVER
return QString("vsftpd.") % serverDomainName();
#else
return serverName();
#endif
}
static QString ftpProxyServerName()
{
#ifdef QT_TEST_SERVER
return QString("ftp-proxy.") % serverDomainName();
#else
return serverName();
#endif
}
static QString httpServerName()
{
#ifdef QT_TEST_SERVER
return QString("apache2.") % serverDomainName();
#else
return serverName();
#endif
}
static QString httpProxyServerName()
{
#ifdef QT_TEST_SERVER
return QString("squid.") % serverDomainName();
#else
return serverName();
#endif
}
static QString socksProxyServerName()
{
#ifdef QT_TEST_SERVER
return QString("danted.") % serverDomainName();
#else
return serverName();
#endif
}
};

View File

@ -0,0 +1,16 @@
-----BEGIN CERTIFICATE-----
MIIClTCCAf4CCQC2xMhNhwvATDANBgkqhkiG9w0BAQQFADCBjjELMAkGA1UEChMC
UXQxGTAXBgNVBAsTEENvcmUgQW5kIE5ldHdvcmsxGzAZBgkqhkiG9w0BCQEWDG5v
Ym9keS5xdC5pbzENMAsGA1UEBxMET3NsbzENMAsGA1UECBMET3NsbzELMAkGA1UE
BhMCTk8xHDAaBgNVBAMUEyoudGVzdC1uZXQucXQubG9jYWwwHhcNMTgwNzAxMTgz
NjI3WhcNNDgwNjIzMTgzNjI3WjCBjjELMAkGA1UEChMCUXQxGTAXBgNVBAsTEENv
cmUgQW5kIE5ldHdvcmsxGzAZBgkqhkiG9w0BCQEWDG5vYm9keS5xdC5pbzENMAsG
A1UEBxMET3NsbzENMAsGA1UECBMET3NsbzELMAkGA1UEBhMCTk8xHDAaBgNVBAMU
EyoudGVzdC1uZXQucXQubG9jYWwwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
AM2q22/WNMmn8cC+5EEYGeICySLmp9W6Ay6eKHr0Xxp3X3epETuPfvAuxp7rOtkS
18EMUegkUj8jw0IMEcbyHKFC/rTCaYOt93CxGBXMIChiMPAsFeYzGa/D6xzAkfcR
aJRQ+Ek3CDLXPnXfo7xpABXezYcPXAJrgsgBfWrwHdxzAgMBAAEwDQYJKoZIhvcN
AQEEBQADgYEAZu/lQPy8PXeyyYGamOVms/FZKJ48BH1y8KC3BeBU5FYnhvgG7pz8
Wz9JKvt2t/r45wQeAkNL6HnGUBhPJsHMjPHl5KktqN+db3D+FQygBeS2V1+zmC0X
UZNRE4aWiHvt1Lq+pTx89SOMOpfqWfh4qTQKiE5jC2V4DeCNQ3u7uI8=
-----END CERTIFICATE-----

View File

@ -14,3 +14,6 @@ TESTDATA += ../empty ../rfc3252.txt ../resource ../bigfile ../*.jpg ../certs \
../index.html ../smb-file.txt
!android:!winrt: TEST_HELPER_INSTALLS = ../echo/echo
QT_TEST_SERVER_LIST = vsftpd apache2 ftp-proxy danted squid
include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri)

View File

@ -0,0 +1,3 @@
<h1>Welcome to qt-test-server</h1>
<img src="fluke.gif" alt="fluke">
<p>This is a network test server. It serves as a caching ftp and http proxy, transparent http/socks5 proxy, imap, ftp and http server, and more.</p>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
#!/bin/sh
echo "Content-Type: text/plain"
echo
echo "$HTTP_COOKIE"

View File

@ -0,0 +1,22 @@
#!/usr/bin/perl
use CGI;
if ($ENV{'REQUEST_METHOD'} eq "DELETE") {
$queryString = $ENV{'QUERY_STRING'};
if ($queryString eq "200-ok") {
$returnCode = 200;
} elsif ($queryString eq "202-accepted") {
$returnCode = 202;
} elsif ($queryString eq "204-no-content") {
$returnCode = 204;
} else {
$returnCode = 404;
}
} else {
# 405 = Method Not Allowed
$returnCode = 405;
}
$q = new CGI;
print $q->header(-status=>$returnCode);

View File

@ -0,0 +1,17 @@
#!/usr/bin/perl
use CGI;
$queryString = $ENV{'QUERY_STRING'};
my $message;
if ($queryString eq "407-proxy-authorization-required") {
$status = 407;
} else {
$status = 401;
}
$q = new CGI;
print $q->header(-status=>$status,
-type=>"text/plain",
-WWW_Authenticate=>'WSSE realm="Test", profile="TestProfile"'),
"authorization required";

View File

@ -0,0 +1,12 @@
#!/bin/bash
if [ "${HTTP_IF_MODIFIED_SINCE}" ]
then
echo "Status: 500"
echo ""
exit;
fi
echo "Expires: Mon, 30 Oct 2028 14:19:41 GMT"
echo "Content-type: text/html";
echo ""
echo "Hello World!"

View File

@ -0,0 +1,42 @@
#!/usr/bin/perl
use CGI;
use Digest::MD5 qw(md5_hex);
$q = new CGI;
print $q->header();
$contentType = $ENV{"CONTENT_TYPE"};
print "content type: $contentType\n";
if ($contentType =~ /^multipart\/form-data/) {
foreach my $key ($q->param) {
foreach my $value ($q->param($key)) {
if ($key =~ /text/) {
$retValue = $value;
} else {
$retValue = md5_hex($value);
}
print "key: $key, value: $retValue\n";
}
}
} else {
#$contentLength = $ENV{"CONTENT_LENGTH"};
#print "content length: $contentLength\r\n";
$data = $q->param('POSTDATA');
$data =~ s/--\S*--$//; # remove ending boundary
@parts = split(/--\S*\r\n/, $data);
shift(@parts);
foreach (@parts) {
#print "raw: $_";
($header, $content) = split("\r\n\r\n");
@headerFields = split("\r\n", $header);
foreach (@headerFields) {
($fieldName, $value) = split(": ");
print "header: $fieldName, value: '$value'\n";
}
$content =~ s/\r\n//;
print "content: $content\n\n";
}
}

View File

@ -0,0 +1,9 @@
#!/bin/sh
echo "Content-type: text/plain"
while read line; do
echo "Set-Cookie: $line"
done
echo
echo "Success"

View File

@ -0,0 +1,5 @@
Require valid-user
AuthUserFile /home/qt-test-server/passwords
AuthType basic
AuthName "password-protected area"
Options Indexes