diff options
Diffstat (limited to 'tests/auto/other/networkselftest/tst_networkselftest.cpp')
-rw-r--r-- | tests/auto/other/networkselftest/tst_networkselftest.cpp | 272 |
1 files changed, 160 insertions, 112 deletions
diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp index ebdad53e31..81d3b60248 100644 --- a/tests/auto/other/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/other/networkselftest/tst_networkselftest.cpp @@ -1,32 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2016 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-EXCEPT$ -** 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 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** 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$ -** -****************************************************************************/ - -#include <QtTest/QtTest> +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QTest> #include <QtNetwork/QtNetwork> #include <QtCore/QDateTime> #include <QtCore/QElapsedTimer> @@ -37,10 +12,20 @@ #include "../../network-settings.h" +#ifndef QT_NO_OPENSSL +QT_BEGIN_NAMESPACE +void qt_ForceTlsSecurityLevel(); +QT_END_NAMESPACE +#endif + class tst_NetworkSelfTest: public QObject { Q_OBJECT + // This is either old server's address, or the new http + // server's address (different from ftp, for example): QHostAddress cachedIpAddress; + // This is only for the new docker test server: + QHostAddress ftpServerIpAddress; public: tst_NetworkSelfTest(); virtual ~tst_NetworkSelfTest(); @@ -120,8 +105,8 @@ static QString prettyByteArray(const QByteArray &array) { // any control chars? QString result; - result.reserve(array.length() + array.length() / 3); - for (int i = 0; i < array.length(); ++i) { + result.reserve(array.size() + array.size() / 3); + for (int i = 0; i < array.size(); ++i) { char c = array.at(i); switch (c) { case '\n': @@ -211,8 +196,8 @@ static void netChat(int port, const QList<Chat> &chat) #else QTcpSocket socket; #endif - - socket.connectToHost(QtNetworkSettings::serverName(), port); + const auto serverName = QtNetworkSettings::hostWithServiceOnPort(port); + socket.connectToHost(serverName, port); qDebug() << 0 << "Connecting to server on port" << port; QVERIFY2(socket.waitForConnected(10000), QString("Failed to connect to server in step 0: %1").arg(socket.errorString()).toLocal8Bit()); @@ -223,11 +208,11 @@ static void netChat(int port, const QList<Chat> &chat) switch (it->type) { case Chat::Expect: { qDebug() << i << "Expecting" << prettyByteArray(it->data); - if (!doSocketRead(&socket, it->data.length(), 3 * defaultReadTimeoutMS)) - QFAIL(msgDoSocketReadFailed(QtNetworkSettings::serverName(), port, i, it->data.length())); + if (!doSocketRead(&socket, it->data.size(), 3 * defaultReadTimeoutMS)) + QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.size())); // pop that many bytes off the socket - QByteArray received = socket.read(it->data.length()); + QByteArray received = socket.read(it->data.size()); // is it what we expected? QVERIFY2(received == it->data, @@ -241,8 +226,8 @@ static void netChat(int port, const QList<Chat> &chat) qDebug() << i << "Discarding until" << prettyByteArray(it->data); while (true) { // scan the buffer until we have our string - if (!doSocketRead(&socket, it->data.length())) - QFAIL(msgDoSocketReadFailed(QtNetworkSettings::serverName(), port, i, it->data.length())); + if (!doSocketRead(&socket, it->data.size())) + QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.size())); QByteArray buffer; buffer.resize(socket.bytesAvailable()); @@ -254,7 +239,7 @@ static void netChat(int port, const QList<Chat> &chat) continue; } - buffer = socket.read(pos + it->data.length()); + buffer = socket.read(pos + it->data.size()); qDebug() << i << "Discarded" << prettyByteArray(buffer); break; } @@ -263,7 +248,7 @@ static void netChat(int port, const QList<Chat> &chat) case Chat::SkipBytes: { qDebug() << i << "Skipping" << it->value << "bytes"; if (!doSocketRead(&socket, it->value)) - QFAIL(msgDoSocketReadFailed(QtNetworkSettings::serverName(), port, i, it->value)); + QFAIL(msgDoSocketReadFailed(serverName, port, i, it->value)); // now discard the bytes QByteArray buffer = socket.read(it->value); @@ -312,7 +297,7 @@ static void netChat(int port, const QList<Chat> &chat) case Chat::Reconnect: qDebug() << i << "Reconnecting to server on port" << port; - socket.connectToHost(QtNetworkSettings::serverName(), port); + socket.connectToHost(serverName, port); QVERIFY2(socket.waitForConnected(10000), QString("Failed to reconnect to server in step %1: %2").arg(i).arg(socket.errorString()).toLocal8Bit()); break; @@ -335,6 +320,9 @@ static void netChat(int port, const QList<Chat> &chat) tst_NetworkSelfTest::tst_NetworkSelfTest() { +#ifndef QT_NO_OPENSSL + qt_ForceTlsSecurityLevel(); +#endif } tst_NetworkSelfTest::~tst_NetworkSelfTest() @@ -345,7 +333,7 @@ QHostAddress tst_NetworkSelfTest::serverIpAddress() { if (cachedIpAddress.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol) { // need resolving - QHostInfo resolved = QHostInfo::fromName(QtNetworkSettings::serverName()); + QHostInfo resolved = QHostInfo::fromName(QtNetworkSettings::httpServerName()); if(resolved.error() != QHostInfo::NoError || resolved.addresses().isEmpty()) { qWarning("QHostInfo::fromName failed (%d).", resolved.error()); @@ -358,8 +346,28 @@ QHostAddress tst_NetworkSelfTest::serverIpAddress() void tst_NetworkSelfTest::initTestCase() { +#if defined(QT_TEST_SERVER) + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::echoServerName(), 7)); + // TODO: 'daytime' , port 13. + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpServerName(), 21)); + const QHostInfo resolved = QHostInfo::fromName(QtNetworkSettings::ftpServerName()); + if (resolved.error() == QHostInfo::NoError && !resolved.addresses().isEmpty()) + ftpServerIpAddress = resolved.addresses().first(); + // TODO: 'ssh', port 22. + // QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpProxyServerName(), 2121)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80)); + // TODO: 'smb', port 139. + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 443)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3128)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3129)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpProxyServerName(), 3130)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1080)); + QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::socksProxyServerName(), 1081)); +#else if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); +#endif } void tst_NetworkSelfTest::hostTest() @@ -381,7 +389,7 @@ void tst_NetworkSelfTest::dnsResolution_data() { QTest::addColumn<QString>("hostName"); QTest::newRow("local-name") << QtNetworkSettings::serverLocalName(); - QTest::newRow("fqdn") << QtNetworkSettings::serverName(); + QTest::newRow("fqdn") << QtNetworkSettings::httpServerName(); } void tst_NetworkSelfTest::dnsResolution() @@ -399,7 +407,7 @@ void tst_NetworkSelfTest::serverReachability() { // check that we get a proper error connecting to port 12346 QTcpSocket socket; - socket.connectToHost(QtNetworkSettings::serverName(), 12346); + socket.connectToHost(QtNetworkSettings::httpServerName(), 12346); QElapsedTimer timer; timer.start(); @@ -413,7 +421,11 @@ void tst_NetworkSelfTest::serverReachability() void tst_NetworkSelfTest::remotePortsOpen_data() { +#if defined(QT_TEST_SERVER) + QSKIP("Skipping, for the docker test server already tested by initTestCase()"); +#endif QTest::addColumn<int>("portNumber"); + QTest::newRow("echo") << 7; QTest::newRow("daytime") << 13; QTest::newRow("ftp") << 21; @@ -432,9 +444,10 @@ void tst_NetworkSelfTest::remotePortsOpen_data() void tst_NetworkSelfTest::remotePortsOpen() { - QFETCH(int, portNumber); + QFETCH(const int, portNumber); + QTcpSocket socket; - socket.connectToHost(QtNetworkSettings::serverName(), portNumber); + socket.connectToHost(QtNetworkSettings::hostWithServiceOnPort(portNumber), quint16(portNumber)); if (!socket.waitForConnected(10000)) { if (socket.error() == QAbstractSocket::SocketTimeoutError) @@ -449,43 +462,43 @@ static QList<Chat> ftpChat(const QByteArray &userSuffix = QByteArray()) { QList<Chat> rv; rv << Chat::expect("220") - << Chat::discardUntil("\r\n") - << Chat::send("USER anonymous" + userSuffix + "\r\n") - << Chat::expect("331") - << Chat::discardUntil("\r\n") - << Chat::send("PASS user@hostname\r\n") - << Chat::expect("230") - << Chat::discardUntil("\r\n") - - << Chat::send("CWD pub\r\n") - << Chat::expect("250") - << Chat::discardUntil("\r\n") - << Chat::send("CWD dir-not-readable\r\n") - << Chat::expect("550") - << Chat::discardUntil("\r\n") - << Chat::send("PWD\r\n") - << Chat::expect("257 \"/pub\"\r\n") - << Chat::send("SIZE file-not-readable.txt\r\n") - << Chat::expect("213 41\r\n") - << Chat::send("CWD qxmlquery\r\n") - << Chat::expect("250") - << Chat::discardUntil("\r\n") - - << Chat::send("CWD /qtest\r\n") - << Chat::expect("250") - << Chat::discardUntil("\r\n") - << Chat::send("SIZE bigfile\r\n") - << Chat::expect("213 519240\r\n") - << Chat::send("SIZE rfc3252\r\n") - << Chat::expect("213 25962\r\n") - << Chat::send("SIZE rfc3252.txt\r\n") - << Chat::expect("213 25962\r\n") -// << Chat::send("SIZE nonASCII/german_\344\366\374\304\326\334\337\r\n") -// << Chat::expect("213 40\r\n") - - << Chat::send("QUIT\r\n"); - rv << Chat::expect("221") - << Chat::discardUntil("\r\n"); + << Chat::discardUntil("\r\n") + << Chat::send("USER anonymous" + userSuffix + "\r\n") + << Chat::expect("331") + << Chat::discardUntil("\r\n") + << Chat::send("PASS user@hostname\r\n") + << Chat::expect("230") + << Chat::discardUntil("\r\n") + << Chat::send("CWD pub\r\n") + << Chat::expect("250") + << Chat::discardUntil("\r\n") + << Chat::send("CWD dir-not-readable\r\n") + << Chat::expect("550") + << Chat::discardUntil("\r\n") + << Chat::send("PWD\r\n") +#if defined(QT_TEST_SERVER) + << Chat::expect("257 \"/pub\" is the current directory\r\n") +#else + << Chat::expect("257 \"/pub\"\r\n") +#endif + << Chat::send("SIZE file-not-readable.txt\r\n") + << Chat::expect("213 41\r\n") + << Chat::send("CWD qxmlquery\r\n") + << Chat::expect("250") + << Chat::discardUntil("\r\n") + << Chat::send("CWD /qtest\r\n") + << Chat::expect("250") + << Chat::discardUntil("\r\n") + << Chat::send("SIZE bigfile\r\n") + << Chat::expect("213 519240\r\n") + << Chat::send("SIZE rfc3252\r\n") + << Chat::expect("213 25962\r\n") + << Chat::send("SIZE rfc3252.txt\r\n") + << Chat::expect("213 25962\r\n") + << Chat::send("QUIT\r\n"); + + rv << Chat::expect("221") + << Chat::discardUntil("\r\n"); rv << Chat::RemoteDisconnect; return rv; @@ -498,7 +511,8 @@ void tst_NetworkSelfTest::ftpServer() void tst_NetworkSelfTest::ftpProxyServer() { - netChat(2121, ftpChat("@" + QtNetworkSettings::serverName().toLatin1())); + QSKIP("FTP not currently supported."); + netChat(2121, ftpChat("@" + QtNetworkSettings::ftpServerName().toLatin1())); } void tst_NetworkSelfTest::imapServer() @@ -530,7 +544,7 @@ void tst_NetworkSelfTest::httpServer() // HTTP/1.0 chat: << Chat::Reconnect << Chat::send("GET / HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Connection: close\r\n" "\r\n") << Chat::expect("HTTP/1.") @@ -542,7 +556,7 @@ void tst_NetworkSelfTest::httpServer() << Chat::Reconnect << Chat::send("POST / HTTP/1.0\r\n" "Content-Length: 5\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Connection: close\r\n" "\r\n" "Hello") @@ -554,7 +568,7 @@ void tst_NetworkSelfTest::httpServer() // HTTP protected area << Chat::Reconnect << Chat::send("GET /qtest/protected/rfc3252.txt HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Connection: close\r\n" "\r\n") << Chat::expect("HTTP/1.") @@ -564,7 +578,7 @@ void tst_NetworkSelfTest::httpServer() << Chat::Reconnect << Chat::send("HEAD /qtest/protected/rfc3252.txt HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Connection: close\r\n" "Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n" "\r\n") @@ -576,7 +590,7 @@ void tst_NetworkSelfTest::httpServer() // DAV area << Chat::Reconnect << Chat::send("HEAD /dav/ HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Connection: close\r\n" "\r\n") << Chat::expect("HTTP/1.") @@ -588,7 +602,7 @@ void tst_NetworkSelfTest::httpServer() << Chat::Reconnect << Chat::send("PUT /dav/networkselftest-" + uniqueExtension + ".txt HTTP/1.0\r\n" "Content-Length: 5\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Connection: close\r\n" "\r\n" "Hello") @@ -600,7 +614,7 @@ void tst_NetworkSelfTest::httpServer() // check that the file did get uploaded << Chat::Reconnect << Chat::send("HEAD /dav/networkselftest-" + uniqueExtension + ".txt HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Connection: close\r\n" "\r\n") << Chat::expect("HTTP/1.") @@ -612,7 +626,7 @@ void tst_NetworkSelfTest::httpServer() // HTTP/1.0 DELETE << Chat::Reconnect << Chat::send("DELETE /dav/networkselftest-" + uniqueExtension + ".txt HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Connection: close\r\n" "\r\n") << Chat::expect("HTTP/1.") @@ -647,7 +661,7 @@ void tst_NetworkSelfTest::httpServerFiles() QList<Chat> chat; chat << Chat::send("HEAD " + url.toEncoded() + " HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Connection: close\r\n" "Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n" "\r\n") @@ -736,7 +750,7 @@ void tst_NetworkSelfTest::httpsServer() netChat(443, QList<Chat>() << Chat::StartEncryption << Chat::send("GET / HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Connection: close\r\n" "\r\n") << Chat::expect("HTTP/1.") @@ -751,7 +765,7 @@ void tst_NetworkSelfTest::httpProxy() netChat(3128, QList<Chat>() // proxy GET by IP << Chat::send("GET http://" + serverIpAddress().toString().toLatin1() + "/ HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Proxy-connection: close\r\n" "\r\n") << Chat::expect("HTTP/1.") @@ -761,8 +775,8 @@ void tst_NetworkSelfTest::httpProxy() // proxy GET by hostname << Chat::Reconnect - << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + << Chat::send("GET http://" + QtNetworkSettings::httpServerName().toLatin1() + "/ HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Proxy-connection: close\r\n" "\r\n") << Chat::expect("HTTP/1.") @@ -772,8 +786,13 @@ void tst_NetworkSelfTest::httpProxy() // proxy CONNECT by IP << Chat::Reconnect +#if !defined(QT_TEST_SERVER) << Chat::send("CONNECT " + serverIpAddress().toString().toLatin1() + ":21 HTTP/1.0\r\n" "\r\n") +#else + << Chat::send("CONNECT " + ftpServerIpAddress.toString().toLatin1() + ":21 HTTP/1.0\r\n" + "\r\n") +#endif << Chat::expect("HTTP/1.") << Chat::discardUntil(" ") << Chat::expect("200 ") @@ -782,7 +801,7 @@ void tst_NetworkSelfTest::httpProxy() // proxy CONNECT by hostname << Chat::Reconnect - << Chat::send("CONNECT " + QtNetworkSettings::serverName().toLatin1() + ":21 HTTP/1.0\r\n" + << Chat::send("CONNECT " + QtNetworkSettings::ftpServerName().toLatin1() + ":21 HTTP/1.0\r\n" "\r\n") << Chat::expect("HTTP/1.") << Chat::discardUntil(" ") @@ -796,8 +815,8 @@ void tst_NetworkSelfTest::httpProxyBasicAuth() { netChat(3129, QList<Chat>() // test auth required response - << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + << Chat::send("GET http://" + QtNetworkSettings::httpServerName().toLatin1() + "/ HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Proxy-connection: close\r\n" "\r\n") << Chat::expect("HTTP/1.") @@ -808,8 +827,8 @@ void tst_NetworkSelfTest::httpProxyBasicAuth() // now try sending our credentials << Chat::Reconnect - << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + << Chat::send("GET http://" + QtNetworkSettings::httpServerName().toLatin1() + "/ HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" "Proxy-connection: close\r\n" "Proxy-Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n" "\r\n") @@ -823,9 +842,13 @@ void tst_NetworkSelfTest::httpProxyNtlmAuth() { netChat(3130, QList<Chat>() // test auth required response - << Chat::send("GET http://" + QtNetworkSettings::serverName().toLatin1() + "/ HTTP/1.0\r\n" - "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + << Chat::send("GET http://" + QtNetworkSettings::httpServerName().toLatin1() + "/ HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::httpServerName().toLatin1() + "\r\n" +#if !defined(QT_TEST_SERVER) "Proxy-connection: keep-alive\r\n" // NTLM auth will disconnect +#else + "Proxy-connection: close\r\n" // Well, what do you know? It keeps it alive! +#endif "\r\n") << Chat::expect("HTTP/1.") << Chat::discardUntil(" ") @@ -856,8 +879,12 @@ void tst_NetworkSelfTest::socks5Proxy() char buf[4]; quint32 data; } ip4Address; - ip4Address.data = qToBigEndian(serverIpAddress().toIPv4Address()); - + ip4Address.data = +#if !defined(QT_TEST_SERVER) + qToBigEndian(serverIpAddress().toIPv4Address()); +#else + qToBigEndian(ftpServerIpAddress.toIPv4Address()); +#endif const QByteArray handshakeNoAuthData = QByteArray(handshakeNoAuth, int(sizeof handshakeNoAuth) - 1); const QByteArray handshakeOkNoAuthData = QByteArray(handshakeOkNoAuth, int(sizeof handshakeOkNoAuth) - 1); const QByteArray connect1Data = QByteArray(connect1, int(sizeof connect1) - 1); @@ -866,6 +893,10 @@ void tst_NetworkSelfTest::socks5Proxy() netChat(1080, QList<Chat>() // IP address connection +#if !defined(QT_TEST_SERVER) + // This test relies on the proxy and ftp servers + // running on the same machine, which is not the + // case for the docker test server. << Chat::send(handshakeNoAuthData) << Chat::expect(handshakeOkNoAuthData) << Chat::send(connect1Data) @@ -876,6 +907,7 @@ void tst_NetworkSelfTest::socks5Proxy() // connect by IP << Chat::Reconnect +#endif << Chat::send(handshakeNoAuthData) << Chat::expect(handshakeOkNoAuthData) << Chat::send(QBA(connect1a) + QByteArray::fromRawData(ip4Address.buf, 4) + QBA(connect1b)) @@ -883,8 +915,9 @@ void tst_NetworkSelfTest::socks5Proxy() << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() - - // connect to "localhost" by hostname +#if !defined(QT_TEST_SERVER) + // connect to "localhost" by hostname, the same as above: + // makes no sense with the docker test server. << Chat::Reconnect << Chat::send(handshakeNoAuthData) << Chat::expect(handshakeOkNoAuthData) @@ -893,12 +926,12 @@ void tst_NetworkSelfTest::socks5Proxy() << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() - +#endif // connect to server by its official name << Chat::Reconnect << Chat::send(handshakeNoAuthData) << Chat::expect(handshakeOkNoAuthData) - << Chat::send(QBA(connect2a) + char(QtNetworkSettings::serverName().size()) + QtNetworkSettings::serverName().toLatin1() + QBA(connect1b)) + << Chat::send(QBA(connect2a) + char(QtNetworkSettings::ftpServerName().size()) + QtNetworkSettings::ftpServerName().toLatin1() + QBA(connect1b)) << Chat::expect(connectedData) << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port @@ -920,8 +953,10 @@ void tst_NetworkSelfTest::socks5ProxyAuth() << Chat::send(handshakeNoAuthData) << Chat::expect(handshakeAuthNotOkData) << Chat::RemoteDisconnect - - // now try to connect with authentication +#if !defined(QT_TEST_SERVER) + // now try to connect with authentication, + // danted is just that, socks 5 proxy and + // does not have ftp running, skip! << Chat::Reconnect << Chat::send(handshakeAuthPasswordData) << Chat::expect(handshakeOkPasswdAuthData) @@ -930,6 +965,16 @@ void tst_NetworkSelfTest::socks5ProxyAuth() << Chat::expect("\1") // IPv4 address following << Chat::skipBytes(6) // the server's local address and port << ftpChat() +#else + << Chat::Reconnect + << Chat::send(handshakeAuthPasswordData) + << Chat::expect(handshakeOkPasswdAuthData) + << Chat::send(QBA(connect2a) + char(QtNetworkSettings::ftpServerName().size()) + QtNetworkSettings::ftpServerName().toLatin1() + QBA(connect1b)) + << Chat::expect(connectedData) + << Chat::expect("\1") // IPv4 address following + << Chat::skipBytes(6) // the server's local address and port + << ftpChat() +#endif ); } @@ -963,6 +1008,9 @@ static void ensureTermination(QProcess &process) void tst_NetworkSelfTest::smbServer() { +#if defined(QT_TEST_SERVER) + QSKIP("Not supported by the docker test server"); +#endif // QT_TEST_SERVER static const char contents[] = "This is 34 bytes. Do not change..."; #ifdef Q_OS_WIN // use Windows's native UNC support to try and open a file on the server |