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:
parent
0bb760260e
commit
3f80783b11
@ -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
|
||||
}
|
||||
};
|
||||
|
@ -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-----
|
@ -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)
|
||||
|
@ -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
5
tests/testserver/apache2/testdata/www/cgi-bin/get-cookie.cgi
vendored
Executable file
5
tests/testserver/apache2/testdata/www/cgi-bin/get-cookie.cgi
vendored
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Content-Type: text/plain"
|
||||
echo
|
||||
echo "$HTTP_COOKIE"
|
22
tests/testserver/apache2/testdata/www/cgi-bin/http-delete.cgi
vendored
Executable file
22
tests/testserver/apache2/testdata/www/cgi-bin/http-delete.cgi
vendored
Executable 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);
|
17
tests/testserver/apache2/testdata/www/cgi-bin/http-unknown-authentication-method.cgi
vendored
Executable file
17
tests/testserver/apache2/testdata/www/cgi-bin/http-unknown-authentication-method.cgi
vendored
Executable 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";
|
12
tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_expires500.cgi
vendored
Executable file
12
tests/testserver/apache2/testdata/www/cgi-bin/httpcachetest_expires500.cgi
vendored
Executable 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!"
|
42
tests/testserver/apache2/testdata/www/cgi-bin/multipart.cgi
vendored
Executable file
42
tests/testserver/apache2/testdata/www/cgi-bin/multipart.cgi
vendored
Executable 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";
|
||||
}
|
||||
}
|
9
tests/testserver/apache2/testdata/www/cgi-bin/set-cookie.cgi
vendored
Executable file
9
tests/testserver/apache2/testdata/www/cgi-bin/set-cookie.cgi
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Content-type: text/plain"
|
||||
while read line; do
|
||||
echo "Set-Cookie: $line"
|
||||
done
|
||||
|
||||
echo
|
||||
echo "Success"
|
5
tests/testserver/apache2/testdata/www/htdocs/protected/.htaccess
vendored
Normal file
5
tests/testserver/apache2/testdata/www/htdocs/protected/.htaccess
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
Require valid-user
|
||||
AuthUserFile /home/qt-test-server/passwords
|
||||
AuthType basic
|
||||
AuthName "password-protected area"
|
||||
Options Indexes
|
Loading…
x
Reference in New Issue
Block a user