]> git.ipfire.org Git - thirdparty/openssl.git/blob - test/quicapitest.c
QUIC: Temporarily disable front-end API tests
[thirdparty/openssl.git] / test / quicapitest.c
1 /*
2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10 #include <stdio.h>
11 #include <string.h>
12
13 #include <openssl/opensslconf.h>
14 #include <openssl/quic.h>
15
16 #include "helpers/ssltestlib.h"
17 #include "testutil.h"
18 #include "testutil/output.h"
19
20 static OSSL_LIB_CTX *libctx = NULL;
21 static OSSL_PROVIDER *defctxnull = NULL;
22
23 static int is_fips = 0;
24
25 #if 0
26 /* TODO(QUIC): Temporarily disabled during front-end I/O API finalization. */
27
28 /*
29 * Test that we read what we've written.
30 */
31 static int test_quic_write_read(void)
32 {
33 SSL_CTX *cctx = NULL, *sctx = NULL;
34 SSL *clientquic = NULL, *serverquic = NULL;
35 int j, ret = 0;
36 char buf[20];
37 static char *msg = "A test message";
38 size_t msglen = strlen(msg);
39 size_t numbytes = 0;
40
41 if (!TEST_true(create_ssl_ctx_pair(libctx, OSSL_QUIC_server_method(),
42 OSSL_QUIC_client_method(),
43 0,
44 0,
45 &sctx, &cctx, NULL, NULL))
46 || !TEST_true(create_ssl_objects(sctx, cctx, &serverquic, &clientquic,
47 NULL, NULL))
48 || !TEST_true(create_bare_ssl_connection(serverquic, clientquic,
49 SSL_ERROR_NONE, 0, 0)))
50 goto end;
51
52 for (j = 0; j < 2; j++) {
53 /* Check that sending and receiving app data is ok */
54 if (!TEST_true(SSL_write_ex(clientquic, msg, msglen, &numbytes))
55 || !TEST_true(SSL_read_ex(serverquic, buf, sizeof(buf),
56 &numbytes))
57 || !TEST_mem_eq(buf, numbytes, msg, msglen))
58 goto end;
59
60 if (!TEST_true(SSL_write_ex(serverquic, msg, msglen, &numbytes))
61 || !TEST_true(SSL_read_ex(clientquic, buf, sizeof(buf),
62 &numbytes))
63 || !TEST_mem_eq(buf, numbytes, msg, msglen))
64 goto end;
65 }
66
67 ret = 1;
68
69 end:
70 SSL_free(serverquic);
71 SSL_free(clientquic);
72 SSL_CTX_free(sctx);
73 SSL_CTX_free(cctx);
74
75 return ret;
76 }
77 #endif
78
79 OPT_TEST_DECLARE_USAGE("provider config\n")
80
81 int setup_tests(void)
82 {
83 char *modulename;
84 char *configfile;
85
86 libctx = OSSL_LIB_CTX_new();
87 if (!TEST_ptr(libctx))
88 return 0;
89
90 defctxnull = OSSL_PROVIDER_load(NULL, "null");
91
92 /*
93 * Verify that the default and fips providers in the default libctx are not
94 * available
95 */
96 if (!TEST_false(OSSL_PROVIDER_available(NULL, "default"))
97 || !TEST_false(OSSL_PROVIDER_available(NULL, "fips")))
98 return 0;
99
100 if (!test_skip_common_options()) {
101 TEST_error("Error parsing test options\n");
102 return 0;
103 }
104
105 if (!TEST_ptr(modulename = test_get_argument(0))
106 || !TEST_ptr(configfile = test_get_argument(1)))
107 return 0;
108
109 if (!TEST_true(OSSL_LIB_CTX_load_config(libctx, configfile)))
110 return 0;
111
112 /* Check we have the expected provider available */
113 if (!TEST_true(OSSL_PROVIDER_available(libctx, modulename)))
114 return 0;
115
116 /* Check the default provider is not available */
117 if (strcmp(modulename, "default") != 0
118 && !TEST_false(OSSL_PROVIDER_available(libctx, "default")))
119 return 0;
120
121 if (strcmp(modulename, "fips") == 0)
122 is_fips = 1;
123
124 /* TODO(QUIC): Temporarily disabled during front-end I/O API finalization. */
125 #if 0
126 ADD_TEST(test_quic_write_read);
127 #endif
128 return 1;
129 }
130
131 void cleanup_tests(void)
132 {
133 OSSL_PROVIDER_unload(defctxnull);
134 OSSL_LIB_CTX_free(libctx);
135 }