Preventing caching of null authenticator
In some cases, e.g. when bad credentials are provided in an ftp URI, QNetworkAccessAuthenticationManager::cacheCredentials is called with a null authenticator. This authenticator should not be cached, because it is useless, and leads to inconsistencies in the use of the cache Task-number: QTBUG-40622 Change-Id: If2a0a422b915f268648f5eef1d68601446123371 Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
This commit is contained in:
parent
529a31c967
commit
3e80497668
@ -231,6 +231,8 @@ void QNetworkAccessAuthenticationManager::cacheCredentials(const QUrl &url,
|
||||
const QAuthenticator *authenticator)
|
||||
{
|
||||
Q_ASSERT(authenticator);
|
||||
if (authenticator->isNull())
|
||||
return;
|
||||
QString domain = QString::fromLatin1("/"); // FIXME: make QAuthenticator return the domain
|
||||
QString realm = authenticator->realm();
|
||||
|
||||
|
@ -219,6 +219,7 @@ private Q_SLOTS:
|
||||
void putToFile();
|
||||
void putToFtp_data();
|
||||
void putToFtp();
|
||||
void putToFtpWithInvalidCredentials(); // QTBUG-40622
|
||||
void putToHttp_data();
|
||||
void putToHttp();
|
||||
void putToHttpSynchronous_data();
|
||||
@ -2075,6 +2076,28 @@ void tst_QNetworkReply::putToFtp()
|
||||
QObject::disconnect(r, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
}
|
||||
|
||||
void tst_QNetworkReply::putToFtpWithInvalidCredentials()
|
||||
{
|
||||
QUrl url("ftp://" + QtNetworkSettings::serverName());
|
||||
url.setPath(QString("/qtest/upload/qnetworkaccess-putToFtp-%1-%2")
|
||||
.arg(QTest::currentDataTag())
|
||||
.arg(uniqueExtension));
|
||||
url.setUserName("invalidUser");
|
||||
url.setPassword("InvalidPassword");
|
||||
QNetworkRequest req(url);
|
||||
QNetworkReplyPtr r;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
runSimpleRequest(QNetworkAccessManager::PutOperation, req, r, QByteArray());
|
||||
|
||||
QVERIFY(r->isFinished());
|
||||
QCOMPARE(r->url(), url);
|
||||
QCOMPARE(r->error(), QNetworkReply::AuthenticationRequiredError);
|
||||
r->close();
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QNetworkReply::putToHttp_data()
|
||||
{
|
||||
putToFile_data();
|
||||
|
Loading…
Reference in New Issue
Block a user