diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-06 20:10:42 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-10-10 11:54:32 +0300 |
commit | 3330f10e6242d4ef542a67e0d5af31a0251127ab (patch) | |
tree | dfaca08e5b100edfb24e7f592c15c618eea40262 | |
parent | 6e78e8022576955e89ff3626d9019320bd5d2228 (diff) | |
download | libmicrohttpd-3330f10e6242d4ef542a67e0d5af31a0251127ab.tar.gz libmicrohttpd-3330f10e6242d4ef542a67e0d5af31a0251127ab.zip |
testcurl/https: some simplifications and clean-ups
-rw-r--r-- | src/testcurl/https/test_https_get.c | 9 | ||||
-rw-r--r-- | src/testcurl/https/test_https_get_iovec.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/test_https_session_info.c | 6 | ||||
-rw-r--r-- | src/testcurl/https/test_tls_options.c | 7 | ||||
-rw-r--r-- | src/testcurl/https/tls_test_common.c | 34 | ||||
-rw-r--r-- | src/testcurl/https/tls_test_common.h | 31 |
6 files changed, 35 insertions, 59 deletions
diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c index a0cdb82f..13865502 100644 --- a/src/testcurl/https/test_https_get.c +++ b/src/testcurl/https/test_https_get.c | |||
@@ -26,8 +26,6 @@ | |||
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
28 | #include "microhttpd.h" | 28 | #include "microhttpd.h" |
29 | #include <limits.h> | ||
30 | #include <sys/stat.h> | ||
31 | #include <curl/curl.h> | 29 | #include <curl/curl.h> |
32 | #ifdef MHD_HTTPS_REQUIRE_GCRYPT | 30 | #ifdef MHD_HTTPS_REQUIRE_GCRYPT |
33 | #include <gcrypt.h> | 31 | #include <gcrypt.h> |
@@ -41,8 +39,7 @@ static uint16_t global_port; | |||
41 | 39 | ||
42 | /* perform a HTTP GET request via SSL/TLS */ | 40 | /* perform a HTTP GET request via SSL/TLS */ |
43 | static unsigned int | 41 | static unsigned int |
44 | test_secure_get (FILE *test_fd, | 42 | test_secure_get (const char *cipher_suite, |
45 | const char *cipher_suite, | ||
46 | int proto_version) | 43 | int proto_version) |
47 | { | 44 | { |
48 | unsigned int ret; | 45 | unsigned int ret; |
@@ -80,7 +77,7 @@ test_secure_get (FILE *test_fd, | |||
80 | port = dinfo->port; | 77 | port = dinfo->port; |
81 | } | 78 | } |
82 | 79 | ||
83 | ret = test_https_transfer (test_fd, | 80 | ret = test_https_transfer (NULL, |
84 | port, | 81 | port, |
85 | cipher_suite, | 82 | cipher_suite, |
86 | proto_version); | 83 | proto_version); |
@@ -252,7 +249,7 @@ main (int argc, char *const *argv) | |||
252 | return 77; | 249 | return 77; |
253 | } | 250 | } |
254 | errorCount += | 251 | errorCount += |
255 | test_secure_get (NULL, NULL, CURL_SSLVERSION_DEFAULT); | 252 | test_secure_get (NULL, CURL_SSLVERSION_DEFAULT); |
256 | errorCount += testEmptyGet (0); | 253 | errorCount += testEmptyGet (0); |
257 | curl_global_cleanup (); | 254 | curl_global_cleanup (); |
258 | 255 | ||
diff --git a/src/testcurl/https/test_https_get_iovec.c b/src/testcurl/https/test_https_get_iovec.c index 90ed5a07..d4e5821e 100644 --- a/src/testcurl/https/test_https_get_iovec.c +++ b/src/testcurl/https/test_https_get_iovec.c | |||
@@ -161,9 +161,9 @@ test_iovec_transfer (void *cls, | |||
161 | cbc.size = len; | 161 | cbc.size = len; |
162 | cbc.pos = 0; | 162 | cbc.pos = 0; |
163 | 163 | ||
164 | if (gen_test_file_url (url, | 164 | if (gen_test_uri (url, |
165 | sizeof (url), | 165 | sizeof (url), |
166 | port)) | 166 | port)) |
167 | { | 167 | { |
168 | ret = 1; | 168 | ret = 1; |
169 | goto cleanup; | 169 | goto cleanup; |
@@ -176,7 +176,6 @@ test_iovec_transfer (void *cls, | |||
176 | goto cleanup; | 176 | goto cleanup; |
177 | } | 177 | } |
178 | 178 | ||
179 | /* compare test file & daemon response */ | ||
180 | if ((cbc.pos != TESTSTR_SIZE) || | 179 | if ((cbc.pos != TESTSTR_SIZE) || |
181 | (0 != check_read_data (cbc.buf, cbc.pos))) | 180 | (0 != check_read_data (cbc.buf, cbc.pos))) |
182 | { | 181 | { |
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c index c1bb31ef..c3ddae4f 100644 --- a/src/testcurl/https/test_https_session_info.c +++ b/src/testcurl/https/test_https_session_info.c | |||
@@ -141,9 +141,9 @@ test_query_session (void) | |||
141 | port = dinfo->port; | 141 | port = dinfo->port; |
142 | } | 142 | } |
143 | 143 | ||
144 | gen_test_file_url (url, | 144 | gen_test_uri (url, |
145 | sizeof (url), | 145 | sizeof (url), |
146 | port); | 146 | port); |
147 | c = curl_easy_init (); | 147 | c = curl_easy_init (); |
148 | #ifdef _DEBUG | 148 | #ifdef _DEBUG |
149 | curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); | 149 | curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); |
diff --git a/src/testcurl/https/test_tls_options.c b/src/testcurl/https/test_tls_options.c index 7390b89a..f6fa477a 100644 --- a/src/testcurl/https/test_tls_options.c +++ b/src/testcurl/https/test_tls_options.c | |||
@@ -54,9 +54,9 @@ test_unmatching_ssl_version (void *cls, uint16_t port, const char *cipher_suite, | |||
54 | cbc.size = 256; | 54 | cbc.size = 256; |
55 | cbc.pos = 0; | 55 | cbc.pos = 0; |
56 | 56 | ||
57 | if (gen_test_file_url (url, | 57 | if (gen_test_uri (url, |
58 | sizeof (url), | 58 | sizeof (url), |
59 | port)) | 59 | port)) |
60 | { | 60 | { |
61 | free (cbc.buf); | 61 | free (cbc.buf); |
62 | fprintf (stderr, | 62 | fprintf (stderr, |
@@ -79,7 +79,6 @@ test_unmatching_ssl_version (void *cls, uint16_t port, const char *cipher_suite, | |||
79 | } | 79 | } |
80 | 80 | ||
81 | 81 | ||
82 | /* setup a temporary transfer test file */ | ||
83 | int | 82 | int |
84 | main (int argc, char *const *argv) | 83 | main (int argc, char *const *argv) |
85 | { | 84 | { |
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c index f27813a2..da62b267 100644 --- a/src/testcurl/https/tls_test_common.c +++ b/src/testcurl/https/tls_test_common.c | |||
@@ -55,9 +55,9 @@ test_daemon_get (void *cls, | |||
55 | cbc.pos = 0; | 55 | cbc.pos = 0; |
56 | 56 | ||
57 | /* construct url - this might use doc_path */ | 57 | /* construct url - this might use doc_path */ |
58 | gen_test_file_url (url, | 58 | gen_test_uri (url, |
59 | sizeof (url), | 59 | sizeof (url), |
60 | port); | 60 | port); |
61 | 61 | ||
62 | c = curl_easy_init (); | 62 | c = curl_easy_init (); |
63 | #ifdef _DEBUG | 63 | #ifdef _DEBUG |
@@ -308,27 +308,27 @@ send_curl_req (char *url, | |||
308 | 308 | ||
309 | 309 | ||
310 | /** | 310 | /** |
311 | * compile test file url pointing to the current running directory path | 311 | * compile test URI |
312 | * | 312 | * |
313 | * @param[out] url - char buffer into which the url is compiled | 313 | * @param[out] uri - char buffer into which the url is compiled |
314 | * @param url_len number of bytes available in url | 314 | * @param uri_len number of bytes available in @a url |
315 | * @param port port to use for the test | 315 | * @param port port to use for the test |
316 | * @return 1 on error | 316 | * @return 1 on error |
317 | */ | 317 | */ |
318 | unsigned int | 318 | unsigned int |
319 | gen_test_file_url (char *url, | 319 | gen_test_uri (char *uri, |
320 | size_t url_len, | 320 | size_t uri_len, |
321 | uint16_t port) | 321 | uint16_t port) |
322 | { | 322 | { |
323 | int res; | 323 | int res; |
324 | 324 | ||
325 | res = snprintf (url, | 325 | res = snprintf (uri, |
326 | url_len, | 326 | uri_len, |
327 | "https://127.0.0.1:%u/urlpath", | 327 | "https://127.0.0.1:%u/urlpath", |
328 | (unsigned int) port); | 328 | (unsigned int) port); |
329 | if (res <= 0) | 329 | if (res <= 0) |
330 | return 1; | 330 | return 1; |
331 | if ((size_t) res >= url_len) | 331 | if ((size_t) res >= uri_len) |
332 | return 1; | 332 | return 1; |
333 | 333 | ||
334 | return 0; | 334 | return 0; |
@@ -359,9 +359,9 @@ test_https_transfer (void *cls, | |||
359 | cbc.size = len; | 359 | cbc.size = len; |
360 | cbc.pos = 0; | 360 | cbc.pos = 0; |
361 | 361 | ||
362 | if (gen_test_file_url (url, | 362 | if (gen_test_uri (url, |
363 | sizeof (url), | 363 | sizeof (url), |
364 | port)) | 364 | port)) |
365 | { | 365 | { |
366 | ret = 1; | 366 | ret = 1; |
367 | goto cleanup; | 367 | goto cleanup; |
@@ -397,7 +397,7 @@ cleanup: | |||
397 | * @param arg_list | 397 | * @param arg_list |
398 | * @return port number on success or zero on failure | 398 | * @return port number on success or zero on failure |
399 | */ | 399 | */ |
400 | uint16_t | 400 | static uint16_t |
401 | setup_testcase (struct MHD_Daemon **d, uint16_t port, unsigned int daemon_flags, | 401 | setup_testcase (struct MHD_Daemon **d, uint16_t port, unsigned int daemon_flags, |
402 | va_list arg_list) | 402 | va_list arg_list) |
403 | { | 403 | { |
@@ -426,7 +426,7 @@ setup_testcase (struct MHD_Daemon **d, uint16_t port, unsigned int daemon_flags, | |||
426 | } | 426 | } |
427 | 427 | ||
428 | 428 | ||
429 | void | 429 | static void |
430 | teardown_testcase (struct MHD_Daemon *d) | 430 | teardown_testcase (struct MHD_Daemon *d) |
431 | { | 431 | { |
432 | MHD_stop_daemon (d); | 432 | MHD_stop_daemon (d); |
diff --git a/src/testcurl/https/tls_test_common.h b/src/testcurl/https/tls_test_common.h index 5192b774..a3fcc5dc 100644 --- a/src/testcurl/https/tls_test_common.h +++ b/src/testcurl/https/tls_test_common.h | |||
@@ -44,7 +44,6 @@ | |||
44 | #define MHD_E_FAILED_TO_CONNECT \ | 44 | #define MHD_E_FAILED_TO_CONNECT \ |
45 | "Error: server connection could not be established\n" | 45 | "Error: server connection could not be established\n" |
46 | 46 | ||
47 | /* TODO rm if unused */ | ||
48 | struct https_test_data | 47 | struct https_test_data |
49 | { | 48 | { |
50 | void *cls; | 49 | void *cls; |
@@ -60,16 +59,6 @@ struct CBC | |||
60 | size_t size; | 59 | size_t size; |
61 | }; | 60 | }; |
62 | 61 | ||
63 | struct CipherDef | ||
64 | { | ||
65 | int options[2]; | ||
66 | char *curlname; | ||
67 | }; | ||
68 | |||
69 | |||
70 | int | ||
71 | curl_check_version (const char *req_version, ...); | ||
72 | |||
73 | int | 62 | int |
74 | curl_tls_is_gnutls (void); | 63 | curl_tls_is_gnutls (void); |
75 | 64 | ||
@@ -113,17 +102,17 @@ http_dummy_ahc (void *cls, struct MHD_Connection *connection, | |||
113 | 102 | ||
114 | 103 | ||
115 | /** | 104 | /** |
116 | * compile test file url pointing to the current running directory path | 105 | * compile test URI |
117 | * | 106 | * |
118 | * @param[out] url - char buffer into which the url is compiled | 107 | * @param[out] uri - char buffer into which the url is compiled |
119 | * @param url_len number of bytes available in @a url | 108 | * @param uri_len number of bytes available in @a url |
120 | * @param port port to use for the test | 109 | * @param port port to use for the test |
121 | * @return 1 on error | 110 | * @return 1 on error |
122 | */ | 111 | */ |
123 | unsigned int | 112 | unsigned int |
124 | gen_test_file_url (char *url, | 113 | gen_test_uri (char *uri, |
125 | size_t url_len, | 114 | size_t uri_len, |
126 | uint16_t port); | 115 | uint16_t port); |
127 | 116 | ||
128 | CURLcode | 117 | CURLcode |
129 | send_curl_req (char *url, | 118 | send_curl_req (char *url, |
@@ -137,14 +126,6 @@ test_https_transfer (void *cls, | |||
137 | const char *cipher_suite, | 126 | const char *cipher_suite, |
138 | int proto_version); | 127 | int proto_version); |
139 | 128 | ||
140 | uint16_t | ||
141 | setup_testcase (struct MHD_Daemon **d, uint16_t port, unsigned int daemon_flags, | ||
142 | va_list arg_list); | ||
143 | |||
144 | void | ||
145 | teardown_testcase (struct MHD_Daemon *d); | ||
146 | |||
147 | |||
148 | unsigned int | 129 | unsigned int |
149 | setup_session (gnutls_session_t *session, | 130 | setup_session (gnutls_session_t *session, |
150 | gnutls_certificate_credentials_t *xcred); | 131 | gnutls_certificate_credentials_t *xcred); |