summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2023-09-08 17:36:38 +0100
committerMatt Caswell <matt@openssl.org>2023-09-13 09:41:05 +0100
commitd012319145b1c95ecb9ada29f4f03a3b30cf0f41 (patch)
tree8f7186c700456a958bf3de245cab60e0ba285da3 /test
parent23def9d37156cc3b2c00fb45ec3b8e271a5d4563 (diff)
Test we correctly handle missing ALPN from the server
ALPN is a requirement for QUIC so it is an error if the server does not send it. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22066)
Diffstat (limited to 'test')
-rw-r--r--test/quicfaultstest.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/test/quicfaultstest.c b/test/quicfaultstest.c
index 3b80385584..a6ba0dc053 100644
--- a/test/quicfaultstest.c
+++ b/test/quicfaultstest.c
@@ -161,25 +161,27 @@ static int test_unknown_frame(void)
* Test that a server that fails to provide transport params cannot be
* connected to.
*/
-static int drop_transport_params_cb(QTEST_FAULT *fault,
+static int drop_extensions_cb(QTEST_FAULT *fault,
QTEST_ENCRYPTED_EXTENSIONS *ee,
size_t eelen, void *encextcbarg)
{
- if (!qtest_fault_delete_extension(fault,
- TLSEXT_TYPE_quic_transport_parameters,
- ee->extensions, &ee->extensionslen))
+ int *ext = (int *)encextcbarg;
+
+ if (!qtest_fault_delete_extension(fault, *ext, ee->extensions,
+ &ee->extensionslen))
return 0;
return 1;
}
-static int test_no_transport_params(void)
+static int test_drop_extensions(int idx)
{
int testresult = 0;
SSL_CTX *cctx = SSL_CTX_new(OSSL_QUIC_client_method());
QUIC_TSERVER *qtserv = NULL;
SSL *cssl = NULL;
QTEST_FAULT *fault = NULL;
+ int ext, err;
if (!TEST_ptr(cctx))
goto err;
@@ -188,9 +190,17 @@ static int test_no_transport_params(void)
&qtserv, &cssl, &fault)))
goto err;
+ if (idx == 0) {
+ ext = TLSEXT_TYPE_quic_transport_parameters;
+ err = QUIC_ERR_CRYPTO_MISSING_EXT;
+ } else {
+ ext = TLSEXT_TYPE_application_layer_protocol_negotiation;
+ err = QUIC_ERR_CRYPTO_NO_APP_PROTO;
+ }
+
if (!TEST_true(qtest_fault_set_hand_enc_ext_listener(fault,
- drop_transport_params_cb,
- NULL)))
+ drop_extensions_cb,
+ &ext)))
goto err;
/*
@@ -200,8 +210,7 @@ static int test_no_transport_params(void)
if (!TEST_false(qtest_create_quic_connection(qtserv, cssl)))
goto err;
- if (!TEST_true(qtest_check_server_transport_err(qtserv,
- QUIC_ERR_CRYPTO_MISSING_EXT)))
+ if (!TEST_true(qtest_check_server_transport_err(qtserv, err)))
goto err;
testresult = 1;
@@ -384,7 +393,7 @@ int setup_tests(void)
ADD_TEST(test_basic);
ADD_TEST(test_unknown_frame);
- ADD_TEST(test_no_transport_params);
+ ADD_ALL_TESTS(test_drop_extensions, 2);
ADD_ALL_TESTS(test_corrupted_data, 2);
return 1;