From 8f58e1319c064fbdf5ec00a2b261c9d8069c6cfb Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 10 Aug 2018 10:43:00 +0200 Subject: tst_qdtls: add 'invalidConfiguration' test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test that we don't silently replace an invalid TLS configuration with the default one (for now, the only thing that is considered to be non-valid - is having non-DTLS protocol set). Change-Id: I6f714b009cf1345a085a3f26d638fc31330f1a94 Reviewed-by: Edward Welbourne Reviewed-by: MÃ¥rten Nordheim --- tests/auto/network/ssl/qdtls/tst_qdtls.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/auto/network/ssl') diff --git a/tests/auto/network/ssl/qdtls/tst_qdtls.cpp b/tests/auto/network/ssl/qdtls/tst_qdtls.cpp index 6ca4ca9b92..6a94eee389 100644 --- a/tests/auto/network/ssl/qdtls/tst_qdtls.cpp +++ b/tests/auto/network/ssl/qdtls/tst_qdtls.cpp @@ -88,6 +88,7 @@ private slots: void construction(); void configuration_data(); void configuration(); + void invalidConfiguration(); void setPeer_data(); void setPeer(); void handshake_data(); @@ -310,6 +311,20 @@ void tst_QDtls::configuration() } } +void tst_QDtls::invalidConfiguration() +{ + QUdpSocket socket; + QDtls crypto(QSslSocket::SslClientMode); + QVERIFY(crypto.setPeer(serverAddress, serverPort)); + // Note: not defaultDtlsConfiguration(), so the protocol is TLS (without D): + QVERIFY(crypto.setDtlsConfiguration(QSslConfiguration::defaultConfiguration())); + QDTLS_VERIFY_NO_ERROR(crypto); + QCOMPARE(crypto.dtlsConfiguration(), QSslConfiguration::defaultConfiguration()); + // Try to start the handshake: + QCOMPARE(crypto.doHandshake(&socket), false); + QCOMPARE(crypto.dtlsError(), QDtlsError::TlsInitializationError); +} + void tst_QDtls::setPeer_data() { clientServerData(); -- cgit v1.2.3