Disable FTP support in QNAM by default

If necessary, the feature still can be enabled with -feature-ftp.

Task-number: QTBUG-80339
Change-Id: I7dafaad254d1396f24ac5c339d55c3bedfa97f1c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
This commit is contained in:
Karsten Heimrich 2020-02-11 12:28:35 +01:00
parent 94c04c3e54
commit 1b4dd753ed
7 changed files with 67 additions and 5 deletions

View File

@ -274,6 +274,7 @@ qt_feature("ftp" PUBLIC
SECTION "Networking"
LABEL "FTP"
PURPOSE "Provides support for the File Transfer Protocol in QNetworkAccessManager."
AUTODETECT OFF
CONDITION QT_FEATURE_textdate
)
qt_feature_definition("ftp" "QT_NO_FTP" NEGATE VALUE "1")

View File

@ -343,6 +343,7 @@
"label": "FTP",
"purpose": "Provides support for the File Transfer Protocol in QNetworkAccessManager.",
"section": "Networking",
"autoDetect": false,
"condition": "features.textdate",
"output": [ "publicFeature", "feature" ]
},
@ -480,6 +481,7 @@ For example:
"opensslv11",
"dtls",
"ocsp",
"ftp",
"sctp",
"system-proxies",
"gssapi"

View File

@ -13,8 +13,10 @@ add_subdirectory(qabstractnetworkcache)
if(QT_FEATURE_private_tests)
add_subdirectory(qhttpnetworkconnection)
add_subdirectory(qhttpnetworkreply)
add_subdirectory(qftp)
add_subdirectory(hpack)
add_subdirectory(http2)
add_subdirectory(hsts)
endif()
if(QT_FEATURE_ftp AND QT_FEATURE_private_tests)
add_subdirectory(qftp)
endif()

View File

@ -1,4 +1,6 @@
TEMPLATE=subdirs
QT_FOR_CONFIG += network
SUBDIRS=\
qnetworkdiskcache \
qnetworkcookiejar \
@ -8,7 +10,6 @@ SUBDIRS=\
qhttpnetworkconnection \
qnetworkreply \
qnetworkcachemetadata \
qftp \
qhttpnetworkreply \
qabstractnetworkcache \
hpack \
@ -18,7 +19,8 @@ SUBDIRS=\
!qtConfig(private_tests): SUBDIRS -= \
qhttpnetworkconnection \
qhttpnetworkreply \
qftp \
hpack \
http2 \
hsts
qtConfig(ftp): qtConfig(private_tests): SUBDIRS += qftp

View File

@ -1,5 +1,8 @@
# Generated from qftp.pro.
if(NOT QT_FEATURE_ftp)
return()
endif()
if(NOT QT_FEATURE_private_tests)
return()
endif()
@ -17,5 +20,6 @@ add_qt_test(tst_qftp
)
#### Keys ignored in scope 1:.:.:qftp.pro:<TRUE>:
# QT_FOR_CONFIG = "network"
# QT_TEST_SERVER_LIST = "vsftpd" "ftp-proxy" "squid" "danted"
# _REQUIREMENTS = "qtConfig(private_tests)"
# _REQUIREMENTS = "qtConfig(ftp)" "qtConfig(private_tests)"

View File

@ -1,7 +1,9 @@
CONFIG += testcase
TARGET = tst_qftp
SOURCES += tst_qftp.cpp
QT_FOR_CONFIG += network
requires(qtConfig(ftp))
requires(qtConfig(private_tests))
QT = core network network-private testlib

View File

@ -219,9 +219,11 @@ private Q_SLOTS:
void getFromFile();
void getFromFileSpecial_data();
void getFromFileSpecial();
#if QT_CONFIG(ftp)
void getFromFtp_data();
void getFromFtp();
void getFromFtpAfterError(); // QTBUG-40797
#endif
void getFromHttp_data();
void getFromHttp();
void getErrors_data();
@ -232,9 +234,11 @@ private Q_SLOTS:
#endif // !QT_NO_NETWORKPROXY
void putToFile_data();
void putToFile();
#if QT_CONFIG(ftp)
void putToFtp_data();
void putToFtp();
void putToFtpWithInvalidCredentials(); // QTBUG-40622
#endif
void putToHttp_data();
void putToHttp();
void putToHttpSynchronous_data();
@ -275,9 +279,11 @@ private Q_SLOTS:
void ioGetFromFileSpecial();
void ioGetFromFile_data();
void ioGetFromFile();
#if QT_CONFIG(ftp)
void ioGetFromFtp_data();
void ioGetFromFtp();
void ioGetFromFtpWithReuse();
#endif
void ioGetFromHttp();
void ioGetFromBuiltinHttp_data();
@ -319,8 +325,10 @@ private Q_SLOTS:
void ioPutToFileFromLocalSocket();
void ioPutToFileFromProcess_data();
void ioPutToFileFromProcess();
#if QT_CONFIG(ftp)
void ioPutToFtpFromFile_data();
void ioPutToFtpFromFile();
#endif
void ioPutToHttpFromFile_data();
void ioPutToHttpFromFile();
void ioPostToHttpFromFile_data();
@ -466,8 +474,10 @@ private Q_SLOTS:
void closeDuringDownload_data();
void closeDuringDownload();
#if QT_CONFIG(ftp)
void ftpAuthentication_data();
void ftpAuthentication();
#endif
void emitErrorForAllReplies(); // QTBUG-36890
@ -1852,6 +1862,7 @@ void tst_QNetworkReply::getFromFileSpecial()
QCOMPARE(reply->readAll(), resource.readAll());
}
#if QT_CONFIG(ftp)
void tst_QNetworkReply::getFromFtp_data()
{
QTest::addColumn<QString>("referenceName");
@ -1904,6 +1915,7 @@ void tst_QNetworkReply::getFromFtpAfterError()
QCOMPARE(validReply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), reference.size());
QCOMPARE(validReply->readAll(), reference.readAll());
}
#endif
void tst_QNetworkReply::getFromHttp_data()
{
@ -2073,6 +2085,7 @@ void tst_QNetworkReply::getErrors_data()
QTest::newRow("file-permissions") << "file:" + filePermissionFileName
<< int(QNetworkReply::ContentAccessDenied) << 0 << true;
#if QT_CONFIG(ftp)
// ftp: errors
QTest::newRow("ftp-host") << "ftp://invalid.test.qt-project.org/foo.txt"
<< int(QNetworkReply::HostNotFoundError) << 0 << true;
@ -2086,6 +2099,7 @@ void tst_QNetworkReply::getErrors_data()
<< int(QNetworkReply::ContentAccessDenied) << 0 << true;
QTest::newRow("ftp-exist") << "ftp://" + QtNetworkSettings::ftpServerName() + "/pub/this-file-doesnt-exist.txt"
<< int(QNetworkReply::ContentNotFoundError) << 0 << true;
#endif
// http: errors
QTest::newRow("http-host") << "http://invalid.test.qt-project.org/"
@ -2139,9 +2153,11 @@ void tst_QNetworkReply::getErrors()
QVERIFY2(waitResult != Timeout, msgGetErrors(waitResult, reply));
QFETCH(int, error);
#if QT_CONFIG(ftp)
QEXPECT_FAIL("ftp-is-dir", "QFtp cannot provide enough detail", Abort);
// the line below is not necessary
QEXPECT_FAIL("ftp-dir-not-readable", "QFtp cannot provide enough detail", Abort);
#endif
QCOMPARE(reply->networkError(), QNetworkReply::NetworkError(error));
QTEST(reply->readAll().isEmpty(), "dataIsEmpty");
@ -2211,6 +2227,7 @@ void tst_QNetworkReply::putToFile()
QCOMPARE(contents, data);
}
#if QT_CONFIG(ftp)
void tst_QNetworkReply::putToFtp_data()
{
putToFile_data();
@ -2283,6 +2300,7 @@ void tst_QNetworkReply::putToFtpWithInvalidCredentials()
r->close();
}
}
#endif
void tst_QNetworkReply::putToHttp_data()
{
@ -3283,6 +3301,7 @@ void tst_QNetworkReply::ioGetFromFile()
QCOMPARE(reader.data, data);
}
#if QT_CONFIG(ftp)
void tst_QNetworkReply::ioGetFromFtp_data()
{
QTest::addColumn<QString>("fileName");
@ -3349,6 +3368,7 @@ void tst_QNetworkReply::ioGetFromFtpWithReuse()
QCOMPARE(reader1.data, referenceData);
QCOMPARE(reader2.data, referenceData);
}
#endif
void tst_QNetworkReply::ioGetFromHttp()
{
@ -4205,6 +4225,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data()
<< "http://" + QtNetworkSettings::httpServerName() + "/qtest/rfc3252.txt"
<< QNetworkReply::NoError;
#if QT_CONFIG(ftp)
// FTP request with FTP caching proxy
proxyList.clear();
proxyList << QNetworkProxy(QNetworkProxy::FtpCachingProxy, QtNetworkSettings::ftpProxyServerName(), 2121);
@ -4223,6 +4244,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data()
<< proxyList << proxyList.at(0)
<< "ftp://" + QtNetworkSettings::ftpServerName() + "/qtest/rfc3252.txt"
<< QNetworkReply::NoError;
#endif
#ifndef QT_NO_SSL
// HTTPS with HTTP transparent proxy
@ -4252,6 +4274,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data()
<< "http://" + QtNetworkSettings::httpServerName() + "/qtest/rfc3252.txt"
<< QNetworkReply::ProxyNotFoundError;
#if QT_CONFIG(ftp)
// FTP request with HTTP caching proxy
proxyList.clear();
proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129);
@ -4268,6 +4291,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data()
<< proxyList << QNetworkProxy()
<< "ftp://" + QtNetworkSettings::ftpServerName() + "/qtest/rfc3252.txt"
<< QNetworkReply::ProxyNotFoundError;
#endif
#ifndef QT_NO_SSL
// HTTPS with HTTP caching proxy
@ -4335,6 +4359,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data()
<< "http://" + QtNetworkSettings::httpServerName() + "/qtest/rfc3252.txt"
<< QNetworkReply::NoError;
#if QT_CONFIG(ftp)
// FTP request with HTTP Caching + FTP
proxyList.clear();
proxyList << QNetworkProxy(QNetworkProxy::HttpCachingProxy, QtNetworkSettings::httpProxyServerName(), 3129)
@ -4343,6 +4368,7 @@ void tst_QNetworkReply::ioGetWithManyProxies_data()
<< proxyList << proxyList.at(1) // second proxy should be used
<< "ftp://" + QtNetworkSettings::ftpServerName() + "/qtest/rfc3252.txt"
<< QNetworkReply::NoError;
#endif
#ifndef QT_NO_SSL
// HTTPS request with HTTP Caching + HTTP transparent
@ -4403,7 +4429,9 @@ void tst_QNetworkReply::ioGetWithManyProxies()
#endif
QFETCH(QNetworkReply::NetworkError, expectedError);
#if QT_CONFIG(ftp)
QEXPECT_FAIL("ftp-on-socks", "QFtp is too limited and won't accept non-FTP proxies", Abort);
#endif
QCOMPARE(reply->networkError(), expectedError);
// Verify that the factory was called properly
@ -4419,8 +4447,10 @@ void tst_QNetworkReply::ioGetWithManyProxies()
if (proxyUsed.type() == QNetworkProxy::NoProxy) {
QCOMPARE(authspy.count(), 0);
} else {
#if QT_CONFIG(ftp)
if (QByteArray(QTest::currentDataTag()).startsWith("ftp-"))
return; // No authentication with current FTP or with FTP proxies
#endif
QCOMPARE(authspy.count(), 1);
QCOMPARE(qvariant_cast<QNetworkProxy>(authspy.at(0).at(0)), proxyUsed);
}
@ -4601,6 +4631,7 @@ void tst_QNetworkReply::ioPutToFileFromProcess()
#endif // QT_CONFIG(process)
}
#if QT_CONFIG(ftp)
void tst_QNetworkReply::ioPutToFtpFromFile_data()
{
ioPutToFileFromFile_data();
@ -4649,6 +4680,7 @@ void tst_QNetworkReply::ioPutToFtpFromFile()
QTestEventLoop::instance().enterLoop(10);
QObject::disconnect(r, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
}
#endif
void tst_QNetworkReply::ioPutToHttpFromFile_data()
{
@ -8016,7 +8048,9 @@ void tst_QNetworkReply::closeDuringDownload_data()
{
QTest::addColumn<QUrl>("url");
QTest::newRow("http") << QUrl("http://" + QtNetworkSettings::httpServerName() + "/bigfile");
#if QT_CONFIG(ftp)
QTest::newRow("ftp") << QUrl("ftp://" + QtNetworkSettings::ftpServerName() + "/qtest/bigfile");
#endif
}
void tst_QNetworkReply::closeDuringDownload()
@ -8034,6 +8068,7 @@ void tst_QNetworkReply::closeDuringDownload()
QVERIFY(destroySpy.wait());
}
#if QT_CONFIG(ftp)
void tst_QNetworkReply::ftpAuthentication_data()
{
QTest::addColumn<QString>("referenceName");
@ -8060,6 +8095,7 @@ void tst_QNetworkReply::ftpAuthentication()
QCOMPARE(reply->url(), request.url());
QCOMPARE(reply->networkError(), QNetworkReply::NetworkError(error));
}
#endif
void tst_QNetworkReply::emitErrorForAllReplies() // QTBUG-36890
{
@ -8103,7 +8139,9 @@ void tst_QNetworkReply::backgroundRequest_data()
QUrl httpurl("http://" + QtNetworkSettings::httpServerName());
QUrl httpsurl("https://" + QtNetworkSettings::httpServerName());
#if QT_CONFIG(ftp)
QUrl ftpurl("ftp://" + QtNetworkSettings::ftpServerName() + "/qtest/rfc3252.txt");
#endif
QTest::newRow("http, fg, normal") << httpurl << false << (int)QNetworkSession::NoPolicy << QNetworkReply::NoError;
QTest::newRow("http, bg, normal") << httpurl << true << (int)QNetworkSession::NoPolicy << QNetworkReply::NoError;
@ -8117,10 +8155,12 @@ void tst_QNetworkReply::backgroundRequest_data()
QTest::newRow("https, bg, nobg") << httpsurl << true << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::BackgroundRequestNotAllowedError;
#endif
#if QT_CONFIG(ftp)
QTest::newRow("ftp, fg, normal") << ftpurl << false << (int)QNetworkSession::NoPolicy << QNetworkReply::NoError;
QTest::newRow("ftp, bg, normal") << ftpurl << true << (int)QNetworkSession::NoPolicy << QNetworkReply::NoError;
QTest::newRow("ftp, fg, nobg") << ftpurl << false << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::NoError;
QTest::newRow("ftp, bg, nobg") << ftpurl << true << (int)QNetworkSession::NoBackgroundTrafficPolicy << QNetworkReply::BackgroundRequestNotAllowedError;
#endif
#endif // !QT_NO_BEARERMANAGEMENT
}
#endif
@ -8175,7 +8215,9 @@ void tst_QNetworkReply::backgroundRequestInterruption_data()
QUrl httpurl("http://" + QtNetworkSettings::httpServerName() + "/qtest/mediumfile");
QUrl httpsurl("https://" + QtNetworkSettings::httpServerName() + "/qtest/mediumfile");
#if QT_CONFIG(ftp)
QUrl ftpurl("ftp://" + QtNetworkSettings::ftpServerName() + "/qtest/bigfile");
#endif
QTest::newRow("http, fg, nobg") << httpurl << false << QNetworkReply::NoError;
QTest::newRow("http, bg, nobg") << httpurl << true << QNetworkReply::BackgroundRequestNotAllowedError;
@ -8185,9 +8227,10 @@ void tst_QNetworkReply::backgroundRequestInterruption_data()
QTest::newRow("https, bg, nobg") << httpsurl << true << QNetworkReply::BackgroundRequestNotAllowedError;
#endif
#if QT_CONFIG(ftp)
QTest::newRow("ftp, fg, nobg") << ftpurl << false << QNetworkReply::NoError;
QTest::newRow("ftp, bg, nobg") << ftpurl << true << QNetworkReply::BackgroundRequestNotAllowedError;
#endif
}
#endif
@ -8251,13 +8294,17 @@ void tst_QNetworkReply::backgroundRequestConnectInBackground_data()
QTest::addColumn<bool>("background");
QUrl httpurl("http://" + QtNetworkSettings::httpServerName());
#if QT_CONFIG(ftp)
QUrl ftpurl("ftp://" + QtNetworkSettings::ftpServerName() + "/qtest/rfc3252.txt");
#endif
QTest::newRow("http, fg") << httpurl << false;
QTest::newRow("http, bg") << httpurl << true;
#if QT_CONFIG(ftp)
QTest::newRow("ftp, fg") << ftpurl << false;
QTest::newRow("ftp, bg") << ftpurl << true;
#endif
}
#endif
@ -9183,7 +9230,9 @@ void tst_QNetworkReply::autoDeleteRepliesAttribute_data()
QTest::newRow("http") << QUrl("http://QInvalidDomain.qt/test");
QTest::newRow("https") << QUrl("https://QInvalidDomain.qt/test");
#if QT_CONFIG(ftp)
QTest::newRow("ftp") << QUrl("ftp://QInvalidDomain.qt/test");
#endif
QTest::newRow("file") << QUrl("file:///thisfolderdoesn'texist/probably.txt");
#ifdef Q_OS_WIN
// Only supported on windows.