aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/sasl.cpp23
-rw-r--r--tests/sasl.h1
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/sasl.cpp b/tests/sasl.cpp
index 8ea635b3..a5399294 100644
--- a/tests/sasl.cpp
+++ b/tests/sasl.cpp
@@ -231,3 +231,26 @@ void tst_QXmppSaslServer::testPlain()
delete server;
}
+
+void tst_QXmppSaslServer::testPlainChallenge()
+{
+ QXmppSaslServer *server = QXmppSaslServer::create("PLAIN");
+ QVERIFY(server != 0);
+ QCOMPARE(server->mechanism(), QLatin1String("PLAIN"));
+
+ // initial step returns challenge
+ QByteArray response;
+ QCOMPARE(server->respond(QByteArray(), response), QXmppSaslServer::Challenge);
+ QCOMPARE(response, QByteArray());
+
+ // initial step returns success
+ QCOMPARE(server->respond(QByteArray("\0foo\0bar", 8), response), QXmppSaslServer::InputNeeded);
+ QCOMPARE(response, QByteArray());
+ QCOMPARE(server->username(), QLatin1String("foo"));
+ QCOMPARE(server->password(), QLatin1String("bar"));
+
+ // any further step is an error
+ QCOMPARE(server->respond(QByteArray(), response), QXmppSaslServer::Failed);
+
+ delete server;
+}
diff --git a/tests/sasl.h b/tests/sasl.h
index 05c03ca5..0d2db34e 100644
--- a/tests/sasl.h
+++ b/tests/sasl.h
@@ -54,5 +54,6 @@ private slots:
void testAnonymous();
void testDigestMd5();
void testPlain();
+ void testPlainChallenge();
};