diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2024-05-08 22:13:21 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2024-05-13 11:14:58 -0700 |
commit | c1d864fb523b108b56f0d1dbe9cced5fbdc0acb1 (patch) | |
tree | b851cb33dd36bf8d5bfdc20e97b3a2c962593e36 /tests | |
parent | 561df44cade81c05721d076ceff0b0813e883f4a (diff) |
QOAuthHttpServerReplyHandler: add a test for a non-HTTP command
EHLO is SMTP.
Pick-to: 6.7
Change-Id: Ie30a3caf09ef4176bb36fffd17cdba0ddd765c6a
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp b/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp index c3e5798..22e6a84 100644 --- a/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp +++ b/tests/auto/oauthhttpserverreplyhandler/tst_oauthhttpserverreplyhandler.cpp @@ -21,6 +21,7 @@ private Q_SLOTS: void callbackWithQuery(); void badCallbackUris_data(); void badCallbackUris(); + void badCallbackWrongMethod(); }; void tst_QOAuthHttpServerReplyHandler::callback_data() @@ -162,5 +163,32 @@ void tst_QOAuthHttpServerReplyHandler::badCallbackUris() QVERIFY(!QTestEventLoop::instance().timeout()); } +void tst_QOAuthHttpServerReplyHandler::badCallbackWrongMethod() +{ + int count = 0; + QOAuthHttpServerReplyHandler replyHandler; + QVERIFY(replyHandler.isListening()); + connect(&replyHandler, &QOAuthHttpServerReplyHandler::callbackReceived, this, [&]( + const QVariantMap &) { + ++count; + QTestEventLoop::instance().exitLoop(); + }); + QUrl callback(replyHandler.callback()); + QVERIFY(!callback.isEmpty()); + + QTcpSocket socket; + socket.connectToHost(QHostAddress::LocalHost, replyHandler.port()); + socket.write("EHLO localhost\r\n"); + connect(&socket, &QTcpSocket::disconnected, &QTestEventLoop::instance(), + &QTestEventLoop::exitLoop); + + QTest::ignoreMessage(QtWarningMsg, "Invalid operation EHLO"); + QTest::ignoreMessage(QtWarningMsg, "Invalid Method"); + + QTestEventLoop::instance().enterLoop(Timeout); + QCOMPARE(count, 0); + QVERIFY(!QTestEventLoop::instance().timeout()); +} + QTEST_MAIN(tst_QOAuthHttpServerReplyHandler) #include "tst_oauthhttpserverreplyhandler.moc" |