aboutsummaryrefslogtreecommitdiff
path: root/tests/sasl.cpp
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2012-07-21 11:07:50 +0200
committerJeremy Lainé <jeremy.laine@m4x.org>2012-07-21 11:07:50 +0200
commit9a1b98eba567366519e58481368cd8b5a411d1a8 (patch)
treededb837c1a84d9f95a27a9f68392ae9513424d4f /tests/sasl.cpp
parent0ee6b11759f22cc81f06933982debf52035f9095 (diff)
downloadqxmpp-9a1b98eba567366519e58481368cd8b5a411d1a8.tar.gz
improve SASL stanza test coverage
Diffstat (limited to 'tests/sasl.cpp')
-rw-r--r--tests/sasl.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/sasl.cpp b/tests/sasl.cpp
index 46f5f22b..e874e120 100644
--- a/tests/sasl.cpp
+++ b/tests/sasl.cpp
@@ -74,6 +74,32 @@ void tst_QXmppSasl::testAuth()
serializePacket(auth, xml);
}
+void tst_QXmppSasl::testChallenge_data()
+{
+ QTest::addColumn<QByteArray>("xml");
+ QTest::addColumn<QByteArray>("value");
+
+ QTest::newRow("empty")
+ << QByteArray("<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"/>")
+ << QByteArray();
+
+ QTest::newRow("value")
+ << QByteArray("<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">AGZvbwBiYXI=</challenge>")
+ << QByteArray("\0foo\0bar", 8);
+}
+
+void tst_QXmppSasl::testChallenge()
+{
+ QFETCH(QByteArray, xml);
+ QFETCH(QByteArray, value);
+
+ // no condition
+ QXmppSaslChallenge challenge;
+ parsePacket(challenge, xml);
+ QCOMPARE(challenge.value(), value);
+ serializePacket(challenge, xml);
+}
+
void tst_QXmppSasl::testFailure()
{
// no condition
@@ -91,6 +117,32 @@ void tst_QXmppSasl::testFailure()
serializePacket(failure2, xml2);
}
+void tst_QXmppSasl::testResponse_data()
+{
+ QTest::addColumn<QByteArray>("xml");
+ QTest::addColumn<QByteArray>("value");
+
+ QTest::newRow("empty")
+ << QByteArray("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"/>")
+ << QByteArray();
+
+ QTest::newRow("value")
+ << QByteArray("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">AGZvbwBiYXI=</response>")
+ << QByteArray("\0foo\0bar", 8);
+}
+
+void tst_QXmppSasl::testResponse()
+{
+ QFETCH(QByteArray, xml);
+ QFETCH(QByteArray, value);
+
+ // no condition
+ QXmppSaslResponse response;
+ parsePacket(response, xml);
+ QCOMPARE(response.value(), value);
+ serializePacket(response, xml);
+}
+
void tst_QXmppSasl::testSuccess()
{
const QByteArray xml = "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"/>";