summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2023-01-11 16:04:25 +0000
committerHugo Landau <hlandau@openssl.org>2023-02-22 05:34:05 +0000
commitc88de5607829f8d98427ba3fa3d465c4e66e07fb (patch)
tree959b1ab349761a6e767424e5c06e16b752124cea
parent6a9ab9bc6879b11110183704ca6364bafe794764 (diff)
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 <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20030)
-rw-r--r--test/helpers/quictestlib.c19
-rw-r--r--test/helpers/quictestlib.h8
2 files changed, 20 insertions, 7 deletions
diff --git a/test/helpers/quictestlib.c b/test/helpers/quictestlib.c
index 423e50f29f..ca3719c267 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 7cfbb6ce95..2737e58572 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);