tst_qdtls: add 'invalidConfiguration' test

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 <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Timur Pocheptsov 2018-08-10 10:43:00 +02:00
parent 468c3717eb
commit 8f58e1319c

View File

@ -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();