summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2023-10-17 10:00:58 +0200
committerMatt Caswell <matt@openssl.org>2023-10-20 16:29:28 +0100
commit7757f5ef731ad4e8d6c0f59ef752e4f726ba4f90 (patch)
treebac56bfc65b11b4d72cff176130d95fa780fa2d8 /test
parent8e520d2714abf4c6254ceec24b57f238433541ee (diff)
QUIC: Add handling of SSL_get_shutdown()
Return SSL_SENT_SHUTDOWN and SSL_RECEIVED_SHUTDOWN with semantics similar to TLS connections. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22408)
Diffstat (limited to 'test')
-rw-r--r--test/quicapitest.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/quicapitest.c b/test/quicapitest.c
index 81c8c215bd..37d7803005 100644
--- a/test/quicapitest.c
+++ b/test/quicapitest.c
@@ -1335,6 +1335,52 @@ static int test_alpn(int idx)
return testresult;
}
+/*
+ * Test SSL_get_shutdown() behavior.
+ */
+static int test_get_shutdown(void)
+{
+ SSL_CTX *cctx = SSL_CTX_new_ex(libctx, NULL, OSSL_QUIC_client_method());
+ SSL *clientquic = NULL;
+ QUIC_TSERVER *qtserv = NULL;
+ int testresult = 0;
+
+ if (!TEST_ptr(cctx)
+ || !TEST_true(qtest_create_quic_objects(libctx, cctx, NULL, cert,
+ privkey,
+ QTEST_FLAG_FAKE_TIME,
+ &qtserv, &clientquic,
+ NULL, NULL))
+ || !TEST_true(qtest_create_quic_connection(qtserv, clientquic)))
+ goto err;
+
+ if (!TEST_int_eq(SSL_get_shutdown(clientquic), 0))
+ goto err;
+
+ if (!TEST_int_eq(SSL_shutdown(clientquic), 0))
+ goto err;
+
+ if (!TEST_int_eq(SSL_get_shutdown(clientquic), SSL_SENT_SHUTDOWN))
+ goto err;
+
+ do {
+ ossl_quic_tserver_tick(qtserv);
+ qtest_add_time(100);
+ } while (SSL_shutdown(clientquic) == 0);
+
+ if (!TEST_int_eq(SSL_get_shutdown(clientquic),
+ SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN))
+ goto err;
+
+ testresult = 1;
+ err:
+ ossl_quic_tserver_free(qtserv);
+ SSL_free(clientquic);
+ SSL_CTX_free(cctx);
+
+ return testresult;
+}
+
#define MAX_LOOPS 2000
/*
@@ -1586,6 +1632,7 @@ int setup_tests(void)
ADD_ALL_TESTS(test_client_auth, 2);
ADD_ALL_TESTS(test_alpn, 2);
ADD_ALL_TESTS(test_noisy_dgram, 2);
+ ADD_TEST(test_get_shutdown);
return 1;
err: