diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-12 08:34:51 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-12 08:34:51 +0000 |
| commit | 37224e2eb0ba965ea6a3ffbf834209d7b9016a44 (patch) | |
| tree | 49726c90a92e8a39abfe6c30ea4872b117266cf0 | |
| parent | f312239c8cae0a2aa58edcdc0589479229c98b55 (diff) | |
| download | qxmpp-37224e2eb0ba965ea6a3ffbf834209d7b9016a44.tar.gz | |
fix and test plaintext Non-SASL Auth Iq
| -rw-r--r-- | src/QXmppNonSASLAuth.cpp | 2 | ||||
| -rw-r--r-- | tests/tests.cpp | 43 |
2 files changed, 41 insertions, 4 deletions
diff --git a/src/QXmppNonSASLAuth.cpp b/src/QXmppNonSASLAuth.cpp index 7fa1e9e8..dde91363 100644 --- a/src/QXmppNonSASLAuth.cpp +++ b/src/QXmppNonSASLAuth.cpp @@ -57,6 +57,8 @@ void QXmppNonSASLAuthIq::toXmlElementFromChild(QXmlStreamWriter *writer) const writer->writeTextElement("username", m_username); if (!m_digest.isEmpty()) writer->writeTextElement("digest", m_digest.toHex()); + if (!m_password.isEmpty()) + writer->writeTextElement("password", m_password); if (!m_resource.isEmpty()) writer->writeTextElement("resource", m_resource); writer->writeEndElement(); diff --git a/tests/tests.cpp b/tests/tests.cpp index 14c05890..cc46f2c1 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -186,14 +186,49 @@ void TestPackets::testMessageLegacyDelay() void TestPackets::testNonSaslAuth() { - const QByteArray xml( + // Client Requests Authentication Fields from Server + const QByteArray xml1( "<iq id=\"auth1\" to=\"shakespeare.lit\" type=\"get\">" "<query xmlns=\"jabber:iq:auth\"/>" "</iq>"); - QXmppNonSASLAuthIq iq; - parsePacket(iq, xml); - serializePacket(iq, xml); + QXmppNonSASLAuthIq iq1; + parsePacket(iq1, xml1); + serializePacket(iq1, xml1); + + // Client Provides Required Information (Plaintext) + const QByteArray xml3( + "<iq id=\"auth2\" type=\"set\">" + "<query xmlns=\"jabber:iq:auth\">" + "<username>bill</username>" + "<password>Calli0pe</password>" + "<resource>globe</resource>" + "</query>" + "</iq>"); + QXmppNonSASLAuthIq iq3; + parsePacket(iq3, xml3); + QCOMPARE(iq3.username(), QLatin1String("bill")); + QCOMPARE(iq3.digest(), QByteArray()); + QCOMPARE(iq3.password(), QLatin1String("Calli0pe")); + QCOMPARE(iq3.resource(), QLatin1String("globe")); + serializePacket(iq3, xml3); + + // Client Provides Required Information (Plaintext) + const QByteArray xml4( + "<iq id=\"auth2\" type=\"set\">" + "<query xmlns=\"jabber:iq:auth\">" + "<username>bill</username>" + "<digest>48fc78be9ec8f86d8ce1c39c320c97c21d62334d</digest>" + "<resource>globe</resource>" + "</query>" + "</iq>"); + QXmppNonSASLAuthIq iq4; + parsePacket(iq4, xml4); + QCOMPARE(iq4.username(), QLatin1String("bill")); + QCOMPARE(iq4.digest(), QByteArray("\x48\xfc\x78\xbe\x9e\xc8\xf8\x6d\x8c\xe1\xc3\x9c\x32\x0c\x97\xc2\x1d\x62\x33\x4d")); + QCOMPARE(iq4.password(), QString()); + QCOMPARE(iq4.resource(), QLatin1String("globe")); + serializePacket(iq4, xml4); } void TestPackets::testPresence() |
