summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/kernel/qauthenticator
diff options
context:
space:
mode:
authorLena Biliaieva <lena.biliaieva@qt.io>2024-01-04 16:48:13 +0100
committerLena Biliaieva <lena.biliaieva@qt.io>2024-01-25 00:48:10 +0000
commit15b0bd69ff2a3ac967ddb98b5fc3c3ce8c3d5b4b (patch)
tree935f59cf41c0b2e122f44447e9ba7d14fdbd6030 /tests/auto/network/kernel/qauthenticator
parentc29a235833410fde4cb4d502f89129bccd7403f0 (diff)
Network: Use QHttpHeaders in QHttpHeaderParser
QHttpHeaderParser::headers() method is changed to return QHttpHeaders. QAuthenticatorPrivate::parseHttpResponse() method is changed to work with QHttpHeaders. QHttpNetworkHeader::header() method is updated to return QHttpHeaders. Tests are updated. Task-number: QTBUG-120133 Change-Id: I20a18b509acd7a8b8d93884cff8349519d64293e Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Diffstat (limited to 'tests/auto/network/kernel/qauthenticator')
-rw-r--r--tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
index 744dabd3da..5dfd652322 100644
--- a/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
+++ b/tests/auto/network/kernel/qauthenticator/tst_qauthenticator.cpp
@@ -6,6 +6,7 @@
#include <QTest>
#include <QtCore/QCoreApplication>
#include <QtNetwork/QAuthenticator>
+#include <QtNetwork/QHttpHeaders>
#include <private/qauthenticator_p.h>
@@ -60,8 +61,8 @@ void tst_QAuthenticator::basicAuth()
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth);
QCOMPARE(priv->phase, QAuthenticatorPrivate::Start);
- QList<QPair<QByteArray, QByteArray> > headers;
- headers << qMakePair(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8());
+ QHttpHeaders headers;
+ headers.append(QByteArray("WWW-Authenticate"), "Basic " + data.toUtf8());
priv->parseHttpResponse(headers, /*isProxy = */ false, {});
QCOMPARE(auth.realm(), realm);
@@ -103,13 +104,13 @@ void tst_QAuthenticator::ntlmAuth()
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth);
QCOMPARE(priv->phase, QAuthenticatorPrivate::Start);
- QList<QPair<QByteArray, QByteArray> > headers;
+ QHttpHeaders headers;
// NTLM phase 1: negotiate
// This phase of NTLM contains no information, other than what we're willing to negotiate
// Current implementation uses flags:
// NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_REQUEST_TARGET
- headers << qMakePair(QByteArrayLiteral("WWW-Authenticate"), QByteArrayLiteral("NTLM"));
+ headers.append(QByteArrayLiteral("WWW-Authenticate"), QByteArrayLiteral("NTLM"));
priv->parseHttpResponse(headers, /*isProxy = */ false, {});
if (sso)
QVERIFY(priv->calculateResponse("GET", "/", u"").startsWith("NTLM "));
@@ -118,7 +119,7 @@ void tst_QAuthenticator::ntlmAuth()
// NTLM phase 2: challenge
headers.clear();
- headers << qMakePair(QByteArray("WWW-Authenticate"), "NTLM " + data.toUtf8());
+ headers.append(QByteArray("WWW-Authenticate"), "NTLM " + data.toUtf8());
priv->parseHttpResponse(headers, /*isProxy = */ false, {});
QEXPECT_FAIL("with-realm", "NTLM authentication code doesn't extract the realm", Continue);
@@ -143,10 +144,10 @@ void tst_QAuthenticator::sha256AndMd5Digest()
QVERIFY(priv->isMethodSupported("digest")); // sanity check
QCOMPARE(priv->phase, QAuthenticatorPrivate::Start);
- QList<QPair<QByteArray, QByteArray>> headers;
+ QHttpHeaders headers;
// Put sha256 first, so that its parsed first...
- headers.emplace_back("WWW-Authenticate", sha256);
- headers.emplace_back("WWW-Authenticate", md5);
+ headers.append("WWW-Authenticate", sha256);
+ headers.append("WWW-Authenticate", md5);
priv->parseHttpResponse(headers, false, QString());
QByteArray response = priv->calculateResponse("GET", "/index", {});