diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2015-07-27 12:18:16 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2015-07-27 12:18:16 +0200 |
| commit | 418a89298beff8e434e7c07d89b0edf53e085e59 (patch) | |
| tree | 0033995a4c8515208687f01ce507d63255bca2e7 /tests | |
| parent | d948bf99f250559ff67acdb1a6d635fa721a4e7a (diff) | |
| download | qxmpp-418a89298beff8e434e7c07d89b0edf53e085e59.tar.gz | |
socks5: improve test coverage of failed CONNECT
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/qxmppsocks/tst_qxmppsocks.cpp | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/tests/qxmppsocks/tst_qxmppsocks.cpp b/tests/qxmppsocks/tst_qxmppsocks.cpp index 24af982e..a8cfe56c 100644 --- a/tests/qxmppsocks/tst_qxmppsocks.cpp +++ b/tests/qxmppsocks/tst_qxmppsocks.cpp @@ -171,19 +171,36 @@ void tst_QXmppSocks::testServer_data() { QTest::addColumn<QByteArray>("clientHandshake"); QTest::addColumn<bool>("clientHandshakeWorks"); + QTest::addColumn<QByteArray>("clientConnect"); + QTest::addColumn<bool>("clientConnectWorks"); - QTest::newRow("no authentication") << QByteArray::fromHex("050100") << true; - QTest::newRow("no authentication or GSSAPI") << QByteArray::fromHex("05020001") << true; + QTest::newRow("no authentication - connect to www.google.com:80") + << QByteArray::fromHex("050100") << true + << QByteArray::fromHex("050100030e7777772e676f6f676c652e636f6d0050") << true; + QTest::newRow("no authentication - bad connect") + << QByteArray::fromHex("050100") << true + << QByteArray::fromHex("0500") << false; + QTest::newRow("no authentication or GSSAPI - connect to www.google.com:80") + << QByteArray::fromHex("05020001") << true + << QByteArray::fromHex("050100030e7777772e676f6f676c652e636f6d0050") << true; - QTest::newRow("bad SOCKS version") << QByteArray::fromHex("060100") << false; - QTest::newRow("no methods") << QByteArray::fromHex("0500") << false; - QTest::newRow("GSSAPI only") << QByteArray::fromHex("050101") << false; + QTest::newRow("bad SOCKS version") + << QByteArray::fromHex("060100") << false + << QByteArray() << false; + QTest::newRow("no methods") + << QByteArray::fromHex("0500") << false + << QByteArray() << false; + QTest::newRow("GSSAPI only") + << QByteArray::fromHex("050101") << false + << QByteArray() << false; } void tst_QXmppSocks::testServer() { QFETCH(QByteArray, clientHandshake); QFETCH(bool, clientHandshakeWorks); + QFETCH(QByteArray, clientConnect); + QFETCH(bool, clientConnectWorks); QXmppSocksServer server; QVERIFY(server.listen()); @@ -215,8 +232,18 @@ void tst_QXmppSocks::testServer() QCOMPARE(client.readAll(), QByteArray::fromHex("0500")); // request connect to www.google.com port 80 - client.write(QByteArray::fromHex("050100030e7777772e676f6f676c652e636f6d0050")); + client.write(clientConnect); loop.exec(); + if (!clientConnectWorks) { + QCOMPARE(client.state(), QAbstractSocket::UnconnectedState); + + QVERIFY(!m_connectionSocket); + QVERIFY(m_connectionHostName.isNull()); + QCOMPARE(m_connectionPort, quint16(0)); + return; + } + + QCOMPARE(client.state(), QAbstractSocket::ConnectedState); QCOMPARE(client.readAll(), QByteArray::fromHex("050000030e7777772e676f6f676c652e636f6d0050")); QCOMPARE(client.state(), QAbstractSocket::ConnectedState); |
