From: Matt Caswell Date: Wed, 11 Jan 2023 16:04:25 +0000 (+0000) Subject: Add a qtest_check_server_transport_err helper function X-Git-Tag: openssl-3.2.0-alpha1~1248 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c88de5607829f8d98427ba3fa3d465c4e66e07fb;p=thirdparty%2Fopenssl.git Add a qtest_check_server_transport_err helper function Allows tests to check that a given transport error was received by the server. Reviewed-by: Hugo Landau Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/20030) --- diff --git a/test/helpers/quictestlib.c b/test/helpers/quictestlib.c index 423e50f29f1..ca3719c2675 100644 --- a/test/helpers/quictestlib.c +++ b/test/helpers/quictestlib.c @@ -203,24 +203,31 @@ int qtest_create_quic_connection(QUIC_TSERVER *qtserv, SSL *clientssl) return ret; } -int qtest_check_server_protocol_err(QUIC_TSERVER *qtserv) +int qtest_check_server_transport_err(QUIC_TSERVER *qtserv, uint64_t code) { QUIC_TERMINATE_CAUSE cause; ossl_quic_tserver_tick(qtserv); /* - * Check that the server has received the protocol violation error - * connection close from the client + * Check that the server has closed with the specified code from the client */ - if (!TEST_true(ossl_quic_tserver_is_term_any(qtserv, &cause)) - || !TEST_true(cause.remote) - || !TEST_uint64_t_eq(cause.error_code, QUIC_ERR_PROTOCOL_VIOLATION)) + if (!TEST_true(ossl_quic_tserver_is_term_any(qtserv))) + return 0; + + cause = ossl_quic_tserver_get_terminate_cause(qtserv); + if (!TEST_true(cause.remote) + || !TEST_uint64_t_eq(cause.error_code, code)) return 0; return 1; } +int qtest_check_server_protocol_err(QUIC_TSERVER *qtserv) +{ + return qtest_check_server_transport_err(qtserv, QUIC_ERR_PROTOCOL_VIOLATION); +} + void ossl_quic_fault_free(OSSL_QUIC_FAULT *fault) { if (fault == NULL) diff --git a/test/helpers/quictestlib.h b/test/helpers/quictestlib.h index 7cfbb6ce95f..2737e585727 100644 --- a/test/helpers/quictestlib.h +++ b/test/helpers/quictestlib.h @@ -45,7 +45,13 @@ void ossl_quic_fault_free(OSSL_QUIC_FAULT *fault); int qtest_create_quic_connection(QUIC_TSERVER *qtserv, SSL *clientssl); /* - * Confirm the server has received a protocol error + * Confirm that the server has received the given transport error code. + */ +int qtest_check_server_transport_err(QUIC_TSERVER *qtserv, uint64_t code); + +/* + * Confirm the server has received a protocol error. Equivalent to calling + * qtest_check_server_transport_err with a code of QUIC_ERR_PROTOCOL_VIOLATION */ int qtest_check_server_protocol_err(QUIC_TSERVER *qtserv);