Port tst_qtcpsocket to the docker server

The iptables container launches with extra capabilities to actually be
able to make changes to the tables.

Change-Id: I892fd18853ce882709e21791e6c88217e5029d53
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Mårten Nordheim 2019-02-12 17:05:51 +01:00
parent 1844f011f6
commit a247d08fae
5 changed files with 206 additions and 73 deletions

View File

@ -228,10 +228,58 @@ public:
#endif #endif
} }
static QString echoServerName()
{
#ifdef QT_TEST_SERVER_NAME
return QString("echo.") % serverDomainName();
#else
return serverName();
#endif
}
static QString firewallServerName()
{
#ifdef QT_TEST_SERVER_NAME
return QString("iptables.") % serverDomainName();
#else
return serverName();
#endif
}
#ifdef QT_NETWORK_LIB #ifdef QT_NETWORK_LIB
static QHostAddress imapServerIp() static QHostAddress imapServerIp()
{ {
return getServerIpImpl(imapServerName()); return getServerIpImpl(imapServerName());
} }
static QHostAddress httpServerIp()
{
return getServerIpImpl(httpServerName());
}
static QHostAddress httpProxyServerIp()
{
return getServerIpImpl(httpProxyServerName());
}
static QHostAddress socksProxyServerIp()
{
return getServerIpImpl(socksProxyServerName());
}
static QHostAddress ftpProxyServerIp()
{
return getServerIpImpl(ftpProxyServerName());
}
static QHostAddress ftpServerIp()
{
return getServerIpImpl(ftpServerName());
}
static QHostAddress firewallServerIp()
{
return getServerIpImpl(firewallServerName());
}
#endif #endif
}; };

View File

@ -15,3 +15,9 @@ win32 {
} else { } else {
DESTDIR = ../ DESTDIR = ../
} }
# Only on Linux until cyrus has been added to docker-compose-for-{windows,macOS}.yml and tested
linux {
QT_TEST_SERVER_LIST = danted squid apache2 ftp-proxy vsftpd iptables cyrus
include($$dirname(_QMAKE_CONF_)/tests/auto/testserver.pri)
}

View File

@ -317,7 +317,7 @@ tst_QTcpSocket::tst_QTcpSocket()
connect(earlyConstructedSockets->endPoints[1], SIGNAL(bytesWritten(qint64)), this, SLOT(earlySocketBytesSent(qint64))); connect(earlyConstructedSockets->endPoints[1], SIGNAL(bytesWritten(qint64)), this, SLOT(earlySocketBytesSent(qint64)));
earlyConstructedSockets->endPoints[1]->write("hello work"); earlyConstructedSockets->endPoints[1]->write("hello work");
firstFailInfo.setAddresses(QList<QHostAddress>() << QHostAddress("224.0.0.0") << QtNetworkSettings::serverIP()); firstFailInfo.setAddresses(QList<QHostAddress>() << QHostAddress("224.0.0.0") << QtNetworkSettings::httpServerIp());
} }
void tst_QTcpSocket::initTestCase_data() void tst_QTcpSocket::initTestCase_data()
@ -326,7 +326,6 @@ void tst_QTcpSocket::initTestCase_data()
QTest::addColumn<int>("proxyType"); QTest::addColumn<int>("proxyType");
QTest::addColumn<bool>("ssl"); QTest::addColumn<bool>("ssl");
qDebug() << QtNetworkSettings::serverName();
QTest::newRow("WithoutProxy") << false << 0 << false; QTest::newRow("WithoutProxy") << false << 0 << false;
//QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; ### temporarily disabled, QTBUG-38385 //QTest::newRow("WithSocks5Proxy") << true << int(Socks5Proxy) << false; ### temporarily disabled, QTBUG-38385
//QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; ### temporarily disabled, QTBUG-38385 //QTest::newRow("WithSocks5ProxyAuth") << true << int(Socks5Proxy | AuthBasic) << false; ### temporarily disabled, QTBUG-38385
@ -352,7 +351,17 @@ void tst_QTcpSocket::initTestCase_data()
void tst_QTcpSocket::initTestCase() void tst_QTcpSocket::initTestCase()
{ {
#ifdef QT_TEST_SERVER
QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80));
QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128));
QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143));
//QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::firewallServerName(), 1357));
QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080));
QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpServerName(), 21));
QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpProxyServerName(), 2121));
#else
QVERIFY(QtNetworkSettings::verifyTestNetworkSettings()); QVERIFY(QtNetworkSettings::verifyTestNetworkSettings());
#endif
} }
void tst_QTcpSocket::init() void tst_QTcpSocket::init()
@ -361,30 +370,33 @@ void tst_QTcpSocket::init()
if (setProxy) { if (setProxy) {
#ifndef QT_NO_NETWORKPROXY #ifndef QT_NO_NETWORKPROXY
QFETCH_GLOBAL(int, proxyType); QFETCH_GLOBAL(int, proxyType);
QList<QHostAddress> addresses = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses(); QList<QHostAddress> socks5Addresses = QHostInfo::fromName(QtNetworkSettings::socksProxyServerName()).addresses();
QVERIFY2(addresses.count() > 0, "failed to get ip address for test server"); QList<QHostAddress> httpProxyAddresses = QHostInfo::fromName(QtNetworkSettings::httpProxyServerName()).addresses();
QString fluke = addresses.first().toString(); QVERIFY2(socks5Addresses.count() > 0, "failed to get ip address for SOCKS5 proxy server");
QVERIFY2(httpProxyAddresses.count() > 0, "failed to get ip address for HTTP proxy server");
QString socks5Address = socks5Addresses.first().toString();
QString httpProxyAddress = httpProxyAddresses.first().toString();
QNetworkProxy proxy; QNetworkProxy proxy;
switch (proxyType) { switch (proxyType) {
case Socks5Proxy: case Socks5Proxy:
proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, fluke, 1080); proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socks5Address, 1080);
break; break;
case Socks5Proxy | AuthBasic: case Socks5Proxy | AuthBasic:
proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, fluke, 1081); proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, socks5Address, 1081);
break; break;
case HttpProxy | NoAuth: case HttpProxy | NoAuth:
proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3128); proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddress, 3128);
break; break;
case HttpProxy | AuthBasic: case HttpProxy | AuthBasic:
proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3129); proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddress, 3129);
break; break;
case HttpProxy | AuthNtlm: case HttpProxy | AuthNtlm:
proxy = QNetworkProxy(QNetworkProxy::HttpProxy, fluke, 3130); proxy = QNetworkProxy(QNetworkProxy::HttpProxy, httpProxyAddress, 3130);
break; break;
} }
QNetworkProxy::setApplicationProxy(proxy); QNetworkProxy::setApplicationProxy(proxy);
@ -644,8 +656,8 @@ void tst_QTcpSocket::bind()
void tst_QTcpSocket::bindThenResolveHost_data() void tst_QTcpSocket::bindThenResolveHost_data()
{ {
QTest::addColumn<QString>("hostName"); QTest::addColumn<QString>("hostName");
QTest::newRow("ip-literal") << QtNetworkSettings::serverIP().toString(); QTest::newRow("ip-literal") << QtNetworkSettings::httpServerIp().toString();
QTest::newRow("name") << QtNetworkSettings::serverName(); QTest::newRow("name") << QtNetworkSettings::httpServerName();
QTest::newRow("first-fail") << firstFailName; QTest::newRow("first-fail") << firstFailName;
} }
@ -715,7 +727,7 @@ void tst_QTcpSocket::setSocketDescriptor()
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// need the dummy to ensure winsock is started // need the dummy to ensure winsock is started
QTcpSocket *dummy = newSocket(); QTcpSocket *dummy = newSocket();
dummy->connectToHost(QtNetworkSettings::serverName(), 143); dummy->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(dummy->waitForConnected()); QVERIFY(dummy->waitForConnected());
SOCKET sock = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); SOCKET sock = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
@ -737,7 +749,7 @@ void tst_QTcpSocket::setSocketDescriptor()
QCOMPARE(socket->socketDescriptor(), (qintptr)sock); QCOMPARE(socket->socketDescriptor(), (qintptr)sock);
qt_qhostinfo_clear_cache(); //avoid the HostLookupState being skipped due to address being in cache from previous test. qt_qhostinfo_clear_cache(); //avoid the HostLookupState being skipped due to address being in cache from previous test.
socket->connectToHost(QtNetworkSettings::serverName(), 80); socket->connectToHost(QtNetworkSettings::httpServerName(), 80);
QCOMPARE(socket->state(), QTcpSocket::HostLookupState); QCOMPARE(socket->state(), QTcpSocket::HostLookupState);
QCOMPARE(socket->socketDescriptor(), (qintptr)sock); QCOMPARE(socket->socketDescriptor(), (qintptr)sock);
QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForConnected(10000));
@ -758,7 +770,7 @@ void tst_QTcpSocket::socketDescriptor()
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
QCOMPARE(socket->socketDescriptor(), (qintptr)-1); QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->state() == QAbstractSocket::HostLookupState || QVERIFY(socket->state() == QAbstractSocket::HostLookupState ||
socket->state() == QAbstractSocket::ConnectingState); socket->state() == QAbstractSocket::ConnectingState);
QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForConnected(10000));
@ -775,7 +787,7 @@ void tst_QTcpSocket::blockingIMAP()
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
// Connect // Connect
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForConnected(10000));
QCOMPARE(socket->state(), QTcpSocket::ConnectedState); QCOMPARE(socket->state(), QTcpSocket::ConnectedState);
QVERIFY(socket->isValid()); QVERIFY(socket->isValid());
@ -852,6 +864,14 @@ void tst_QTcpSocket::hostNotFound()
socket->connectToHost("nosuchserver.qt-project.org", 80); socket->connectToHost("nosuchserver.qt-project.org", 80);
QVERIFY(!socket->waitForConnected()); QVERIFY(!socket->waitForConnected());
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
#ifdef QT_TEST_SERVER
QFETCH_GLOBAL(bool, setProxy);
if (setProxy) {
QEXPECT_FAIL("", "QTBUG-73953: The version of Squid in the docker container behaves "
"differently to the one in the network testing server, returning 503 "
"when we expect 404", Continue);
}
#endif
QCOMPARE(int(socket->error()), int(QTcpSocket::HostNotFoundError)); QCOMPARE(int(socket->error()), int(QTcpSocket::HostNotFoundError));
delete socket; delete socket;
@ -861,8 +881,8 @@ void tst_QTcpSocket::hostNotFound()
void tst_QTcpSocket::timeoutConnect_data() void tst_QTcpSocket::timeoutConnect_data()
{ {
QTest::addColumn<QString>("address"); QTest::addColumn<QString>("address");
QTest::newRow("host") << QtNetworkSettings::serverName(); QTest::newRow("host") << QtNetworkSettings::firewallServerName();
QTest::newRow("ip") << QtNetworkSettings::serverIP().toString(); QTest::newRow("ip") << QtNetworkSettings::firewallServerIp().toString();
} }
void tst_QTcpSocket::timeoutConnect() void tst_QTcpSocket::timeoutConnect()
@ -910,7 +930,7 @@ void tst_QTcpSocket::nonBlockingIMAP()
nonBlockingIMAP_socket = socket; nonBlockingIMAP_socket = socket;
// Connect // Connect
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->state() == QTcpSocket::HostLookupState || QVERIFY(socket->state() == QTcpSocket::HostLookupState ||
socket->state() == QTcpSocket::ConnectingState); socket->state() == QTcpSocket::ConnectingState);
@ -1036,7 +1056,7 @@ void tst_QTcpSocket::delayedClose()
connect(socket, SIGNAL(connected()), SLOT(nonBlockingIMAP_connected())); connect(socket, SIGNAL(connected()), SLOT(nonBlockingIMAP_connected()));
connect(socket, SIGNAL(disconnected()), SLOT(exitLoopSlot())); connect(socket, SIGNAL(disconnected()), SLOT(exitLoopSlot()));
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
enterLoop(30); enterLoop(30);
if (timeout()) if (timeout())
@ -1082,7 +1102,7 @@ QByteArray tst_QTcpSocket::expectedReplyIMAP()
void tst_QTcpSocket::fetchExpectedReplyIMAP() void tst_QTcpSocket::fetchExpectedReplyIMAP()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString())); QVERIFY2(socket->waitForConnected(10000), qPrintable(socket->errorString()));
QVERIFY2(socket->state() == QTcpSocket::ConnectedState, qPrintable(socket->errorString())); QVERIFY2(socket->state() == QTcpSocket::ConnectedState, qPrintable(socket->errorString()));
@ -1101,7 +1121,7 @@ void tst_QTcpSocket::fetchExpectedReplyIMAP()
void tst_QTcpSocket::partialRead() void tst_QTcpSocket::partialRead()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForConnected(10000));
QCOMPARE(socket->state(), QTcpSocket::ConnectedState); QCOMPARE(socket->state(), QTcpSocket::ConnectedState);
char buf[512]; char buf[512];
@ -1125,7 +1145,7 @@ void tst_QTcpSocket::partialRead()
void tst_QTcpSocket::unget() void tst_QTcpSocket::unget()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForConnected(10000));
QCOMPARE(socket->state(), QTcpSocket::ConnectedState); QCOMPARE(socket->state(), QTcpSocket::ConnectedState);
char buf[512]; char buf[512];
@ -1162,7 +1182,7 @@ void tst_QTcpSocket::readRegularFile_readyRead()
void tst_QTcpSocket::readAllAfterClose() void tst_QTcpSocket::readAllAfterClose()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
connect(socket, SIGNAL(readyRead()), SLOT(readRegularFile_readyRead())); connect(socket, SIGNAL(readyRead()), SLOT(readRegularFile_readyRead()));
enterLoop(10); enterLoop(10);
if (timeout()) if (timeout())
@ -1202,7 +1222,7 @@ void tst_QTcpSocket::openCloseOpenClose()
QCOMPARE(socket->state(), QTcpSocket::UnconnectedState); QCOMPARE(socket->state(), QTcpSocket::UnconnectedState);
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForConnected(10000));
socket->close(); socket->close();
} }
@ -1225,7 +1245,7 @@ void tst_QTcpSocket::connectDisconnectConnectDisconnect()
QCOMPARE(int(socket->peerPort()), 0); QCOMPARE(int(socket->peerPort()), 0);
QCOMPARE(socket->peerAddress(), QHostAddress()); QCOMPARE(socket->peerAddress(), QHostAddress());
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForReadyRead(10000)); QVERIFY(socket->waitForReadyRead(10000));
QCOMPARE(QString::fromLatin1(socket->read(4)), QString("* OK")); QCOMPARE(QString::fromLatin1(socket->read(4)), QString("* OK"));
@ -1429,7 +1449,7 @@ void tst_QTcpSocket::disconnectWhileLookingUp()
// just connect and disconnect, then make sure nothing weird happened // just connect and disconnect, then make sure nothing weird happened
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 21); socket->connectToHost(QtNetworkSettings::ftpServerName(), 21);
// check that connect is in progress // check that connect is in progress
QVERIFY(socket->state() != QAbstractSocket::UnconnectedState); QVERIFY(socket->state() != QAbstractSocket::UnconnectedState);
@ -1477,7 +1497,7 @@ void tst_QTcpSocket::downloadBigFile()
connect(tmpSocket, SIGNAL(readyRead()), SLOT(downloadBigFileSlot())); connect(tmpSocket, SIGNAL(readyRead()), SLOT(downloadBigFileSlot()));
connect(tmpSocket, SIGNAL(disconnected()), SLOT(exitLoopSlot())); connect(tmpSocket, SIGNAL(disconnected()), SLOT(exitLoopSlot()));
tmpSocket->connectToHost(QtNetworkSettings::serverName(), 80); tmpSocket->connectToHost(QtNetworkSettings::httpServerName(), 80);
enterLoop(30); enterLoop(30);
if (timeout()) { if (timeout()) {
@ -1486,7 +1506,7 @@ void tst_QTcpSocket::downloadBigFile()
QFAIL("Network operation timed out"); QFAIL("Network operation timed out");
} }
QByteArray hostName = QtNetworkSettings::serverName().toLatin1(); QByteArray hostName = QtNetworkSettings::httpServerName().toLatin1();
QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState); QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0); QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
QVERIFY(tmpSocket->write("HOST: ") > 0); QVERIFY(tmpSocket->write("HOST: ") > 0);
@ -1552,7 +1572,7 @@ void tst_QTcpSocket::downloadBigFileSlot()
void tst_QTcpSocket::readLine() void tst_QTcpSocket::readLine()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForConnected(5000)); QVERIFY(socket->waitForConnected(5000));
while (!socket->canReadLine()) while (!socket->canReadLine())
@ -1601,7 +1621,7 @@ void tst_QTcpSocket::readLine()
void tst_QTcpSocket::readLineString() void tst_QTcpSocket::readLineString()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForReadyRead(10000)); QVERIFY(socket->waitForReadyRead(10000));
QByteArray arr = socket->readLine(); QByteArray arr = socket->readLine();
@ -1614,7 +1634,7 @@ void tst_QTcpSocket::readLineString()
void tst_QTcpSocket::readChunks() void tst_QTcpSocket::readChunks()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForConnected(10000));
QVERIFY(socket->waitForReadyRead(5000)); QVERIFY(socket->waitForReadyRead(5000));
@ -1634,7 +1654,7 @@ void tst_QTcpSocket::readChunks()
void tst_QTcpSocket::waitForBytesWritten() void tst_QTcpSocket::waitForBytesWritten()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 80); socket->connectToHost(QtNetworkSettings::httpServerName(), 80);
QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForConnected(10000));
socket->write("GET / HTTP/1.0\r\n\r\n"); socket->write("GET / HTTP/1.0\r\n\r\n");
@ -1652,7 +1672,7 @@ void tst_QTcpSocket::waitForBytesWrittenMinusOne()
QSKIP("QTBUG-24451 - indefinite wait may hang"); QSKIP("QTBUG-24451 - indefinite wait may hang");
#endif #endif
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 80); socket->connectToHost(QtNetworkSettings::httpServerName(), 80);
QVERIFY(socket->waitForConnected(10000)); QVERIFY(socket->waitForConnected(10000));
socket->write("GET / HTTP/1.0\r\n\r\n"); socket->write("GET / HTTP/1.0\r\n\r\n");
@ -1667,7 +1687,7 @@ void tst_QTcpSocket::waitForBytesWrittenMinusOne()
void tst_QTcpSocket::waitForReadyRead() void tst_QTcpSocket::waitForReadyRead()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 80); socket->connectToHost(QtNetworkSettings::httpServerName(), 80);
socket->write("GET / HTTP/1.0\r\n\r\n"); socket->write("GET / HTTP/1.0\r\n\r\n");
QVERIFY(socket->waitForReadyRead(5000)); QVERIFY(socket->waitForReadyRead(5000));
delete socket; delete socket;
@ -1680,7 +1700,7 @@ void tst_QTcpSocket::waitForReadyReadMinusOne()
QSKIP("QTBUG-24451 - indefinite wait may hang"); QSKIP("QTBUG-24451 - indefinite wait may hang");
#endif #endif
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 80); socket->connectToHost(QtNetworkSettings::httpServerName(), 80);
socket->write("GET / HTTP/1.0\r\n\r\n"); socket->write("GET / HTTP/1.0\r\n\r\n");
QVERIFY(socket->waitForReadyRead(-1)); QVERIFY(socket->waitForReadyRead(-1));
delete socket; delete socket;
@ -1693,7 +1713,7 @@ void tst_QTcpSocket::flush()
socket->flush(); socket->flush();
connect(socket, SIGNAL(connected()), SLOT(exitLoopSlot())); connect(socket, SIGNAL(connected()), SLOT(exitLoopSlot()));
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
enterLoop(60); enterLoop(60);
QVERIFY(socket->isOpen()); QVERIFY(socket->isOpen());
@ -1710,7 +1730,7 @@ void tst_QTcpSocket::flush()
void tst_QTcpSocket::synchronousApi() void tst_QTcpSocket::synchronousApi()
{ {
QTcpSocket *ftpSocket = newSocket(); QTcpSocket *ftpSocket = newSocket();
ftpSocket->connectToHost(QtNetworkSettings::serverName(), 21); ftpSocket->connectToHost(QtNetworkSettings::ftpServerName(), 21);
ftpSocket->write("QUIT\r\n"); ftpSocket->write("QUIT\r\n");
QVERIFY(ftpSocket->waitForDisconnected(10000)); QVERIFY(ftpSocket->waitForDisconnected(10000));
QVERIFY(ftpSocket->bytesAvailable() > 0); QVERIFY(ftpSocket->bytesAvailable() > 0);
@ -1757,10 +1777,10 @@ void tst_QTcpSocket::recursiveReadyRead()
QSignalSpy spy(testSocket, SIGNAL(readyRead())); QSignalSpy spy(testSocket, SIGNAL(readyRead()));
testSocket->connectToHost(QtNetworkSettings::serverName(), 143); testSocket->connectToHost(QtNetworkSettings::imapServerName(), 143);
enterLoop(30); enterLoop(30);
QVERIFY2(!timeout(), QVERIFY2(!timeout(),
"Timed out when connecting to QtNetworkSettings::serverName()."); "Timed out when connecting to QtNetworkSettings::imapServerName().");
enterLoop(30); enterLoop(30);
QVERIFY2(!timeout(), QVERIFY2(!timeout(),
@ -1794,7 +1814,7 @@ void tst_QTcpSocket::recursiveReadyReadSlot()
void tst_QTcpSocket::atEnd() void tst_QTcpSocket::atEnd()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 21); socket->connectToHost(QtNetworkSettings::ftpServerName(), 21);
QVERIFY(socket->waitForReadyRead(15000)); QVERIFY(socket->waitForReadyRead(15000));
QTextStream stream(socket); QTextStream stream(socket);
@ -1802,9 +1822,15 @@ void tst_QTcpSocket::atEnd()
QString greeting = stream.readLine(); QString greeting = stream.readLine();
QVERIFY(stream.atEnd()); QVERIFY(stream.atEnd());
#ifdef QT_TEST_SERVER
// Test server must use some vsFTPd 3.x.x version
QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 3.x.x)")-1, qPrintable(greeting));
QVERIFY2(greeting.startsWith("220 (vsFTPd 3."), qPrintable(greeting));
#else
// Test server must use some vsFTPd 2.x.x version // Test server must use some vsFTPd 2.x.x version
QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting)); QVERIFY2(greeting.length() == sizeof("220 (vsFTPd 2.x.x)")-1, qPrintable(greeting));
QVERIFY2(greeting.startsWith("220 (vsFTPd 2."), qPrintable(greeting)); QVERIFY2(greeting.startsWith("220 (vsFTPd 2."), qPrintable(greeting));
#endif
QVERIFY2(greeting.endsWith(QLatin1Char(')')), qPrintable(greeting)); QVERIFY2(greeting.endsWith(QLatin1Char(')')), qPrintable(greeting));
delete socket; delete socket;
@ -1835,7 +1861,7 @@ protected:
connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), connect(socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), Qt::DirectConnection); SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), Qt::DirectConnection);
socket->connectToHost(QtNetworkSettings::serverName(), 21); socket->connectToHost(QtNetworkSettings::ftpServerName(), 21);
socket->write("QUIT\r\n"); socket->write("QUIT\r\n");
exec(); exec();
@ -1909,7 +1935,7 @@ void tst_QTcpSocket::waitForReadyReadInASlot()
tmpSocket = socket; tmpSocket = socket;
connect(socket, SIGNAL(connected()), this, SLOT(waitForReadyReadInASlotSlot())); connect(socket, SIGNAL(connected()), this, SLOT(waitForReadyReadInASlotSlot()));
socket->connectToHost(QtNetworkSettings::serverName(), 80); socket->connectToHost(QtNetworkSettings::httpServerName(), 80);
socket->write("GET / HTTP/1.0\r\n\r\n"); socket->write("GET / HTTP/1.0\r\n\r\n");
enterLoop(30); enterLoop(30);
@ -2073,7 +2099,7 @@ void tst_QTcpSocket::waitForConnectedInHostLookupSlot()
timer.start(15000); timer.start(15000);
connect(tmpSocket, SIGNAL(hostFound()), this, SLOT(hostLookupSlot())); connect(tmpSocket, SIGNAL(hostFound()), this, SLOT(hostLookupSlot()));
tmpSocket->connectToHost(QtNetworkSettings::serverName(), 143); tmpSocket->connectToHost(QtNetworkSettings::imapServerName(), 143);
// only execute the loop if not already connected // only execute the loop if not already connected
if (tmpSocket->state() != QAbstractSocket::ConnectedState) if (tmpSocket->state() != QAbstractSocket::ConnectedState)
@ -2128,7 +2154,7 @@ public slots:
inline void doIt() inline void doIt()
{ {
attemptedToConnect = true; attemptedToConnect = true;
sock->connectToHost(QtNetworkSettings::serverName(), 80); sock->connectToHost(QtNetworkSettings::httpServerName(), 80);
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
pthread_yield_np(); pthread_yield_np();
@ -2179,7 +2205,7 @@ void tst_QTcpSocket::readyReadSignalsAfterWaitForReadyRead()
QSignalSpy readyReadSpy(socket, SIGNAL(readyRead())); QSignalSpy readyReadSpy(socket, SIGNAL(readyRead()));
// Connect // Connect
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
// Wait for the read // Wait for the read
QVERIFY(socket->waitForReadyRead(10000)); QVERIFY(socket->waitForReadyRead(10000));
@ -2315,7 +2341,7 @@ void tst_QTcpSocket::localAddressEmptyOnBSD()
void tst_QTcpSocket::zeroAndMinusOneReturns() void tst_QTcpSocket::zeroAndMinusOneReturns()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 80); socket->connectToHost(QtNetworkSettings::httpServerName(), 80);
socket->write("GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n"); socket->write("GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n");
QVERIFY(socket->waitForReadyRead(15000)); QVERIFY(socket->waitForReadyRead(15000));
@ -2376,7 +2402,7 @@ void tst_QTcpSocket::connectionRefused()
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
&QTestEventLoop::instance(), SLOT(exitLoop())); &QTestEventLoop::instance(), SLOT(exitLoop()));
socket->connectToHost(QtNetworkSettings::serverName(), 144); socket->connectToHost(QtNetworkSettings::httpServerName(), 144);
enterLoop(10); enterLoop(10);
disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)), disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
@ -2523,7 +2549,7 @@ void tst_QTcpSocket::moveToThread0()
{ {
// Case 1: Moved after connecting, before waiting for connection. // Case 1: Moved after connecting, before waiting for connection.
QTcpSocket *socket = newSocket();; QTcpSocket *socket = newSocket();;
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
socket->moveToThread(0); socket->moveToThread(0);
QVERIFY(socket->waitForConnected(5000)); QVERIFY(socket->waitForConnected(5000));
socket->write("XXX LOGOUT\r\n"); socket->write("XXX LOGOUT\r\n");
@ -2535,7 +2561,7 @@ void tst_QTcpSocket::moveToThread0()
// Case 2: Moved before connecting // Case 2: Moved before connecting
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->moveToThread(0); socket->moveToThread(0);
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForConnected(5000)); QVERIFY(socket->waitForConnected(5000));
socket->write("XXX LOGOUT\r\n"); socket->write("XXX LOGOUT\r\n");
QVERIFY(socket->waitForBytesWritten(5000)); QVERIFY(socket->waitForBytesWritten(5000));
@ -2545,7 +2571,7 @@ void tst_QTcpSocket::moveToThread0()
{ {
// Case 3: Moved after writing, while waiting for bytes to be written. // Case 3: Moved after writing, while waiting for bytes to be written.
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForConnected(5000)); QVERIFY(socket->waitForConnected(5000));
socket->write("XXX LOGOUT\r\n"); socket->write("XXX LOGOUT\r\n");
socket->moveToThread(0); socket->moveToThread(0);
@ -2556,7 +2582,7 @@ void tst_QTcpSocket::moveToThread0()
{ {
// Case 4: Moved after writing, while waiting for response. // Case 4: Moved after writing, while waiting for response.
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 143); socket->connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket->waitForConnected(5000)); QVERIFY(socket->waitForConnected(5000));
socket->write("XXX LOGOUT\r\n"); socket->write("XXX LOGOUT\r\n");
QVERIFY(socket->waitForBytesWritten(5000)); QVERIFY(socket->waitForBytesWritten(5000));
@ -2687,7 +2713,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorWaitForConnected()
// use waitForConnected, e.g. this should use a synchronous select() on the OS level // use waitForConnected, e.g. this should use a synchronous select() on the OS level
QTcpSocket socket; QTcpSocket socket;
socket.connectToHost(QtNetworkSettings::serverName(), 12346); socket.connectToHost(QtNetworkSettings::httpServerName(), 12346);
QTime timer; QTime timer;
timer.start(); timer.start();
socket.waitForConnected(10000); socket.waitForConnected(10000);
@ -2707,7 +2733,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop()
// This testcase uses an event loop // This testcase uses an event loop
QTcpSocket socket; QTcpSocket socket;
connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop())); connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
socket.connectToHost(QtNetworkSettings::serverName(), 12346); socket.connectToHost(QtNetworkSettings::httpServerName(), 12346);
QTestEventLoop::instance().enterLoop(10); QTestEventLoop::instance().enterLoop(10);
QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong"); QVERIFY2(!QTestEventLoop::instance().timeout(), "Connection to closed port timed out instead of refusing, something is wrong");
@ -2720,7 +2746,7 @@ void tst_QTcpSocket::taskQtBug7054TimeoutErrorResetting()
{ {
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->connectToHost(QtNetworkSettings::serverName(), 443); socket->connectToHost(QtNetworkSettings::httpServerName(), 443);
QVERIFY(socket->waitForConnected(5*1000)); QVERIFY(socket->waitForConnected(5*1000));
QCOMPARE(socket->error(), QAbstractSocket::UnknownSocketError); QCOMPARE(socket->error(), QAbstractSocket::UnknownSocketError);
@ -2749,10 +2775,12 @@ void tst_QTcpSocket::invalidProxy_data()
QTest::addColumn<bool>("failsAtConnect"); QTest::addColumn<bool>("failsAtConnect");
QTest::addColumn<int>("expectedError"); QTest::addColumn<int>("expectedError");
QString fluke = QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(); const QString ftpAddress = QtNetworkSettings::ftpServerIp().toString();
QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << fluke << 21 << true const QString httpProxyAddress = QtNetworkSettings::httpProxyServerIp().toString();
const QString socksProxyAddress = QtNetworkSettings::socksProxyServerIp().toString();
QTest::newRow("ftp-proxy") << int(QNetworkProxy::FtpCachingProxy) << ftpAddress << 21 << true
<< int(QAbstractSocket::UnsupportedSocketOperationError); << int(QAbstractSocket::UnsupportedSocketOperationError);
QTest::newRow("http-caching-proxy") << int(QNetworkProxy::HttpCachingProxy) << fluke << 3128 << true QTest::newRow("http-caching-proxy") << int(QNetworkProxy::HttpCachingProxy) << httpProxyAddress << 3128 << true
<< int(QAbstractSocket::UnsupportedSocketOperationError); << int(QAbstractSocket::UnsupportedSocketOperationError);
QTest::newRow("no-such-host-socks5") << int(QNetworkProxy::Socks5Proxy) QTest::newRow("no-such-host-socks5") << int(QNetworkProxy::Socks5Proxy)
<< "this-host-will-never-exist.qt-project.org" << 1080 << false << "this-host-will-never-exist.qt-project.org" << 1080 << false
@ -2760,9 +2788,9 @@ void tst_QTcpSocket::invalidProxy_data()
QTest::newRow("no-such-host-http") << int(QNetworkProxy::HttpProxy) QTest::newRow("no-such-host-http") << int(QNetworkProxy::HttpProxy)
<< "this-host-will-never-exist.qt-project.org" << 3128 << false << "this-host-will-never-exist.qt-project.org" << 3128 << false
<< int(QAbstractSocket::ProxyNotFoundError); << int(QAbstractSocket::ProxyNotFoundError);
QTest::newRow("http-on-socks5") << int(QNetworkProxy::HttpProxy) << fluke << 1080 << false QTest::newRow("http-on-socks5") << int(QNetworkProxy::HttpProxy) << socksProxyAddress << 1080 << false
<< int(QAbstractSocket::ProxyConnectionClosedError); << int(QAbstractSocket::ProxyConnectionClosedError);
QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << fluke << 3128 << false QTest::newRow("socks5-on-http") << int(QNetworkProxy::Socks5Proxy) << httpProxyAddress << 3128 << false
<< int(QAbstractSocket::SocketTimeoutError); << int(QAbstractSocket::SocketTimeoutError);
} }
@ -2781,7 +2809,7 @@ void tst_QTcpSocket::invalidProxy()
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
socket->setProxy(proxy); socket->setProxy(proxy);
socket->connectToHost(QHostInfo::fromName(QtNetworkSettings::serverName()).addresses().first().toString(), 80); socket->connectToHost(QtNetworkSettings::httpServerIp().toString(), 80);
if (failsAtConnect) { if (failsAtConnect) {
QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState); QCOMPARE(socket->state(), QAbstractSocket::UnconnectedState);
@ -2833,48 +2861,48 @@ void tst_QTcpSocket::proxyFactory_data()
// tests that do connect // tests that do connect
proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::serverName(), 3129); proxyList << QNetworkProxy(QNetworkProxy::HttpProxy, QtNetworkSettings::httpProxyServerName(), 3129);
QTest::newRow("http") QTest::newRow("http")
<< proxyList << proxyList.at(0) << proxyList << proxyList.at(0)
<< false << int(QAbstractSocket::UnknownSocketError); << false << int(QAbstractSocket::UnknownSocketError);
proxyList.clear(); proxyList.clear();
proxyList << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081); proxyList << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081);
QTest::newRow("socks5") QTest::newRow("socks5")
<< proxyList << proxyList.at(0) << proxyList << proxyList.at(0)
<< false << int(QAbstractSocket::UnknownSocketError); << false << int(QAbstractSocket::UnknownSocketError);
proxyList.clear(); proxyList.clear();
proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129) proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129)
<< QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081); << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081);
QTest::newRow("cachinghttp+socks5") QTest::newRow("cachinghttp+socks5")
<< proxyList << proxyList.at(1) << proxyList << proxyList.at(1)
<< false << int(QAbstractSocket::UnknownSocketError); << false << int(QAbstractSocket::UnknownSocketError);
proxyList.clear(); proxyList.clear();
proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121) proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121)
<< QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129) << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129)
<< QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::serverName(), 1081); << QNetworkProxy(QNetworkProxy::Socks5Proxy, QtNetworkSettings::socksProxyServerName(), 1081);
QTest::newRow("ftp+cachinghttp+socks5") QTest::newRow("ftp+cachinghttp+socks5")
<< proxyList << proxyList.at(2) << proxyList << proxyList.at(2)
<< false << int(QAbstractSocket::UnknownSocketError); << false << int(QAbstractSocket::UnknownSocketError);
// tests that fail to connect // tests that fail to connect
proxyList.clear(); proxyList.clear();
proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129); proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129);
QTest::newRow("cachinghttp") QTest::newRow("cachinghttp")
<< proxyList << QNetworkProxy() << proxyList << QNetworkProxy()
<< true << int(QAbstractSocket::UnsupportedSocketOperationError); << true << int(QAbstractSocket::UnsupportedSocketOperationError);
proxyList.clear(); proxyList.clear();
proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121); proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121);
QTest::newRow("ftp") QTest::newRow("ftp")
<< proxyList << QNetworkProxy() << proxyList << QNetworkProxy()
<< true << int(QAbstractSocket::UnsupportedSocketOperationError); << true << int(QAbstractSocket::UnsupportedSocketOperationError);
proxyList.clear(); proxyList.clear();
proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::serverName(), 2121) proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121)
<< QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::serverName(), 3129); << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129);
QTest::newRow("ftp+cachinghttp") QTest::newRow("ftp+cachinghttp")
<< proxyList << QNetworkProxy() << proxyList << QNetworkProxy()
<< true << int(QAbstractSocket::UnsupportedSocketOperationError); << true << int(QAbstractSocket::UnsupportedSocketOperationError);
@ -2895,7 +2923,7 @@ void tst_QTcpSocket::proxyFactory()
QNetworkProxyFactory::setApplicationProxyFactory(factory); QNetworkProxyFactory::setApplicationProxyFactory(factory);
QTcpSocket *socket = newSocket(); QTcpSocket *socket = newSocket();
QString host = QtNetworkSettings::serverName(); QString host = QtNetworkSettings::httpServerName();
socket->connectToHost(host, 80); socket->connectToHost(host, 80);
// Verify that the factory was called properly // Verify that the factory was called properly

View File

@ -31,6 +31,9 @@ services:
- apache2 - apache2
external_links: external_links:
- apache2:apache2.${TEST_DOMAIN} - apache2:apache2.${TEST_DOMAIN}
- cyrus:cyrus.${TEST_DOMAIN}
- iptables:iptables.${TEST_DOMAIN}
- vsftpd:vsftpd.${TEST_DOMAIN}
volumes: volumes:
- ./common:/common:ro - ./common:/common:ro
- ./squid:/service:ro - ./squid:/service:ro
@ -93,3 +96,17 @@ services:
- ./cyrus:/service:ro - ./cyrus:/service:ro
entrypoint: common/startup.sh entrypoint: common/startup.sh
command: service/cyrus.sh command: service/cyrus.sh
iptables:
image: qt-test-server-iptables:cb7a8bd6d28602085a88c8ced7d67e28e75781e2
container_name: qt-test-server-iptables
domainname: ${TEST_DOMAIN}
hostname: iptables
volumes:
- ./common:/common:ro
- ./iptables:/service:ro
entrypoint: common/startup.sh
command: service/iptables.sh
cap_add:
- NET_ADMIN
- NET_RAW

View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
#############################################################################
##
## Copyright (C) 2019 The Qt Company Ltd.
## Contact: https://www.qt.io/licensing/
##
## This file is part of the test suite of the Qt Toolkit.
##
## $QT_BEGIN_LICENSE:GPL$
## Commercial License Usage
## Licensees holding valid commercial Qt licenses may use this file in
## accordance with the commercial license agreement provided with the
## Software or, alternatively, in accordance with the terms contained in
## a written agreement between you and The Qt Company. For licensing terms
## and conditions see https://www.qt.io/terms-conditions. For further
## information use the contact form at https://www.qt.io/contact-us.
##
## GNU General Public License Usage
## Alternatively, this file may be used under the terms of the GNU
## General Public License version 3 or (at your option) any later version
## approved by the KDE Free Qt Foundation. The licenses are as published by
## the Free Software Foundation and appearing in the file LICENSE.GPL3
## included in the packaging of this file. Please review the following
## information to ensure the GNU General Public License requirements will
## be met: https://www.gnu.org/licenses/gpl-3.0.html.
##
## $QT_END_LICENSE$
##
#############################################################################
set -ex
iptables -A INPUT -p tcp --destination-port 1357 -j DROP