QAuthenticator - test NTLM SSO and normal paths separately
Single signon code path gets the NTLM responses from the system, so we can't predict the contents. Task-number: QTBUG-25851 Change-Id: Ia8aa1741ae5af9e48643331bf9a3768550a30166 Reviewed-by: Martin Petersson <Martin.Petersson@nokia.com>
This commit is contained in:
parent
6a7dc02160
commit
f604fd8ff4
@ -111,17 +111,26 @@ void tst_QAuthenticator::ntlmAuth_data()
|
||||
{
|
||||
QTest::addColumn<QString>("data");
|
||||
QTest::addColumn<QString>("realm");
|
||||
QTest::addColumn<bool>("sso");
|
||||
|
||||
QTest::newRow("no-realm") << "TlRMTVNTUAACAAAAHAAcADAAAAAFAoEATFZ3OLRQADIAAAAAAAAAAJYAlgBMAAAAUQBUAC0AVABFAFMAVAAtAEQATwBNAEEASQBOAAIAHABRAFQALQBUAEUAUwBUAC0ARABPAE0AQQBJAE4AAQAcAFEAVAAtAFQARQBTAFQALQBTAEUAUgBWAEUAUgAEABYAcQB0AC0AdABlAHMAdAAtAG4AZQB0AAMANABxAHQALQB0AGUAcwB0AC0AcwBlAHIAdgBlAHIALgBxAHQALQB0AGUAcwB0AC0AbgBlAHQAAAAAAA==" << "";
|
||||
QTest::newRow("with-realm") << "TlRMTVNTUAACAAAADAAMADgAAAAFAoECWCZkccFFAzwAAAAAAAAAAL4AvgBEAAAABQLODgAAAA9NAEcARABOAE8ASwACAAwATQBHAEQATgBPAEsAAQAcAE4ATwBLAC0AQQBNAFMAUwBTAEYARQAtADAAMQAEACAAbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQADAD4AbgBvAGsALQBhAG0AcwBzAHMAZgBlAC0AMAAxAC4AbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQAFACAAbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQAAAAAA" << "NOE";
|
||||
QTest::newRow("no-realm") << "TlRMTVNTUAACAAAAHAAcADAAAAAFAoEATFZ3OLRQADIAAAAAAAAAAJYAlgBMAAAAUQBUAC0AVABFAFMAVAAtAEQATwBNAEEASQBOAAIAHABRAFQALQBUAEUAUwBUAC0ARABPAE0AQQBJAE4AAQAcAFEAVAAtAFQARQBTAFQALQBTAEUAUgBWAEUAUgAEABYAcQB0AC0AdABlAHMAdAAtAG4AZQB0AAMANABxAHQALQB0AGUAcwB0AC0AcwBlAHIAdgBlAHIALgBxAHQALQB0AGUAcwB0AC0AbgBlAHQAAAAAAA==" << "" << false;
|
||||
QTest::newRow("with-realm") << "TlRMTVNTUAACAAAADAAMADgAAAAFAoECWCZkccFFAzwAAAAAAAAAAL4AvgBEAAAABQLODgAAAA9NAEcARABOAE8ASwACAAwATQBHAEQATgBPAEsAAQAcAE4ATwBLAC0AQQBNAFMAUwBTAEYARQAtADAAMQAEACAAbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQADAD4AbgBvAGsALQBhAG0AcwBzAHMAZgBlAC0AMAAxAC4AbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQAFACAAbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQAAAAAA" << "NOE" << false;
|
||||
QTest::newRow("no-realm-sso") << "TlRMTVNTUAACAAAAHAAcADAAAAAFAoEATFZ3OLRQADIAAAAAAAAAAJYAlgBMAAAAUQBUAC0AVABFAFMAVAAtAEQATwBNAEEASQBOAAIAHABRAFQALQBUAEUAUwBUAC0ARABPAE0AQQBJAE4AAQAcAFEAVAAtAFQARQBTAFQALQBTAEUAUgBWAEUAUgAEABYAcQB0AC0AdABlAHMAdAAtAG4AZQB0AAMANABxAHQALQB0AGUAcwB0AC0AcwBlAHIAdgBlAHIALgBxAHQALQB0AGUAcwB0AC0AbgBlAHQAAAAAAA==" << "" << true;
|
||||
QTest::newRow("with-realm-sso") << "TlRMTVNTUAACAAAADAAMADgAAAAFAoECWCZkccFFAzwAAAAAAAAAAL4AvgBEAAAABQLODgAAAA9NAEcARABOAE8ASwACAAwATQBHAEQATgBPAEsAAQAcAE4ATwBLAC0AQQBNAFMAUwBTAEYARQAtADAAMQAEACAAbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQADAD4AbgBvAGsALQBhAG0AcwBzAHMAZgBlAC0AMAAxAC4AbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQAFACAAbQBnAGQAbgBvAGsALgBuAG8AawBpAGEALgBjAG8AbQAAAAAA" << "NOE" << true;
|
||||
}
|
||||
|
||||
void tst_QAuthenticator::ntlmAuth()
|
||||
{
|
||||
QFETCH(QString, data);
|
||||
QFETCH(QString, realm);
|
||||
QFETCH(bool, sso);
|
||||
|
||||
QAuthenticator auth;
|
||||
if (!sso) {
|
||||
auth.setUser("unimportant");
|
||||
auth.setPassword("unimportant");
|
||||
}
|
||||
|
||||
auth.detach();
|
||||
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(auth);
|
||||
QVERIFY(priv->phase == QAuthenticatorPrivate::Start);
|
||||
@ -134,7 +143,10 @@ void tst_QAuthenticator::ntlmAuth()
|
||||
// NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_REQUEST_TARGET
|
||||
headers << qMakePair<QByteArray, QByteArray>("WWW-Authenticate", "NTLM");
|
||||
priv->parseHttpResponse(headers, /*isProxy = */ false);
|
||||
QCOMPARE(priv->calculateResponse("GET", "/").constData(), "NTLM TlRMTVNTUAABAAAABQIAAAAAAAAAAAAAAAAAAAAAAAA=");
|
||||
if (sso)
|
||||
QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM "));
|
||||
else
|
||||
QCOMPARE(priv->calculateResponse("GET", "/").constData(), "NTLM TlRMTVNTUAABAAAABQIAAAAAAAAAAAAAAAAAAAAAAAA=");
|
||||
|
||||
// NTLM phase 2: challenge
|
||||
headers.clear();
|
||||
@ -142,12 +154,10 @@ void tst_QAuthenticator::ntlmAuth()
|
||||
priv->parseHttpResponse(headers, /*isProxy = */ false);
|
||||
|
||||
QEXPECT_FAIL("with-realm", "NTLM authentication code doesn't extract the realm", Continue);
|
||||
QEXPECT_FAIL("with-realm-sso", "NTLM authentication code doesn't extract the realm", Continue);
|
||||
QCOMPARE(auth.realm(), realm);
|
||||
|
||||
auth.setUser("unimportant");
|
||||
auth.setPassword("unimportant");
|
||||
|
||||
QVERIFY(!priv->calculateResponse("GET", "/").isEmpty());
|
||||
QVERIFY(priv->calculateResponse("GET", "/").startsWith("NTLM "));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAuthenticator);
|
||||
|
Loading…
Reference in New Issue
Block a user