aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-10-12 18:16:44 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-10-13 09:07:03 +0300
commitf8502a2e07a5e3402431d6218252879c46621f46 (patch)
tree93507381d8c2d7f9f88ad6182f58a3de0ef3a00d
parent0b9776811f2d8bd1041b759bd84733754bba7b3e (diff)
downloadlibmicrohttpd-f8502a2e07a5e3402431d6218252879c46621f46.tar.gz
libmicrohttpd-f8502a2e07a5e3402431d6218252879c46621f46.zip
testcurl/https: added test for MHD_OPTION_HTTPS_PRIORITIES_APPEND
-rw-r--r--src/testcurl/https/Makefile.am3
-rw-r--r--src/testcurl/https/test_https_session_info.c11
-rw-r--r--src/testcurl/https/tls_test_common.c54
-rw-r--r--src/testcurl/https/tls_test_common.h21
4 files changed, 88 insertions, 1 deletions
diff --git a/src/testcurl/https/Makefile.am b/src/testcurl/https/Makefile.am
index c3db4dba..324076ef 100644
--- a/src/testcurl/https/Makefile.am
+++ b/src/testcurl/https/Makefile.am
@@ -40,6 +40,7 @@ THREAD_ONLY_TESTS = \
40 $(HTTPS_PARALLEL_TESTS) \ 40 $(HTTPS_PARALLEL_TESTS) \
41 $(TEST_HTTPS_SNI) \ 41 $(TEST_HTTPS_SNI) \
42 test_https_session_info \ 42 test_https_session_info \
43 test_https_session_info_append \
43 test_https_multi_daemon \ 44 test_https_multi_daemon \
44 test_https_get \ 45 test_https_get \
45 test_empty_response \ 46 test_empty_response \
@@ -119,6 +120,8 @@ test_https_session_info_SOURCES = \
119 tls_test_common.h \ 120 tls_test_common.h \
120 tls_test_common.c 121 tls_test_common.c
121 122
123test_https_session_info_append_SOURCES = $(test_https_session_info_SOURCES)
124
122test_https_multi_daemon_SOURCES = \ 125test_https_multi_daemon_SOURCES = \
123 test_https_multi_daemon.c \ 126 test_https_multi_daemon.c \
124 tls_test_keys.h \ 127 tls_test_keys.h \
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c
index bad47b1c..084ffe67 100644
--- a/src/testcurl/https/test_https_session_info.c
+++ b/src/testcurl/https/test_https_session_info.c
@@ -35,6 +35,9 @@
35#include "tls_test_common.h" 35#include "tls_test_common.h"
36#include "tls_test_keys.h" 36#include "tls_test_keys.h"
37 37
38
39static int test_append_prio;
40
38/* 41/*
39 * HTTP access handler call back 42 * HTTP access handler call back
40 * used to query negotiated security parameters 43 * used to query negotiated security parameters
@@ -113,7 +116,12 @@ test_query_session (enum know_gnutls_tls_id tls_ver, uint16_t *pport)
113 | MHD_USE_ERROR_LOG, *pport, 116 | MHD_USE_ERROR_LOG, *pport,
114 NULL, NULL, 117 NULL, NULL,
115 &query_info_ahc, &found_tls_ver, 118 &query_info_ahc, &found_tls_ver,
116 MHD_OPTION_HTTPS_PRIORITIES, priorities_map[tls_ver], 119 test_append_prio ?
120 MHD_OPTION_HTTPS_PRIORITIES_APPEND :
121 MHD_OPTION_HTTPS_PRIORITIES,
122 test_append_prio ?
123 priorities_append_map[tls_ver] :
124 priorities_map[tls_ver],
117 MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem, 125 MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem,
118 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 126 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
119 MHD_OPTION_END); 127 MHD_OPTION_END);
@@ -344,6 +352,7 @@ main (int argc, char *const *argv)
344 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); 352 gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
345#endif 353#endif
346#endif /* MHD_HTTPS_REQUIRE_GCRYPT */ 354#endif /* MHD_HTTPS_REQUIRE_GCRYPT */
355 test_append_prio = has_in_name (argv[0], "_append");
347 if (! testsuite_curl_global_init ()) 356 if (! testsuite_curl_global_init ())
348 return 99; 357 return 99;
349 358
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c
index 044394b9..f28f2fb2 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -23,7 +23,9 @@
23 * @file tls_test_common.c 23 * @file tls_test_common.c
24 * @brief Common tls test functions 24 * @brief Common tls test functions
25 * @author Sagie Amir 25 * @author Sagie Amir
26 * @author Karlson2k (Evgeny Grin)
26 */ 27 */
28#include <string.h>
27#include "tls_test_common.h" 29#include "tls_test_common.h"
28#include "tls_test_keys.h" 30#include "tls_test_keys.h"
29 31
@@ -51,6 +53,18 @@ const char *priorities_map[KNOW_TLS_IDS_COUNT] = {
51 "NORMAL:!VERS-ALL:+VERS-TLS1.3" 53 "NORMAL:!VERS-ALL:+VERS-TLS1.3"
52}; 54};
53 55
56/**
57 * Map @a know_gnutls_tls_ids values to GnuTLS priorities append strings.
58 */
59const char *priorities_append_map[KNOW_TLS_IDS_COUNT] = {
60 "NONE",
61 "!VERS-ALL:+VERS-SSL3.0",
62 "!VERS-ALL:+VERS-TLS1.0",
63 "!VERS-ALL:+VERS-TLS1.1",
64 "!VERS-ALL:+VERS-TLS1.2",
65 "!VERS-ALL:+VERS-TLS1.3"
66};
67
54 68
55/** 69/**
56 * Map @a know_gnutls_tls_ids values to libcurl @a CURLOPT_SSLVERSION value. 70 * Map @a know_gnutls_tls_ids values to libcurl @a CURLOPT_SSLVERSION value.
@@ -726,3 +740,43 @@ testsuite_curl_global_init (void)
726 } 740 }
727 return 1; 741 return 1;
728} 742}
743
744
745/**
746 * Check whether program name contains specific @a marker string.
747 * Only last component in pathname is checked for marker presence,
748 * all leading directories names (if any) are ignored. Directories
749 * separators are handled correctly on both non-W32 and W32
750 * platforms.
751 * @param prog_name program name, may include path
752 * @param marker marker to look for.
753 * @return zero if any parameter is NULL or empty string or
754 * @prog_name ends with slash or @marker is not found in
755 * program name, non-zero if @maker is found in program
756 * name.
757 */
758int
759has_in_name (const char *prog_name, const char *marker)
760{
761 size_t name_pos;
762 size_t pos;
763
764 if (! prog_name || ! marker || ! prog_name[0] || ! marker[0])
765 return 0;
766
767 pos = 0;
768 name_pos = 0;
769 while (prog_name[pos])
770 {
771 if ('/' == prog_name[pos])
772 name_pos = pos + 1;
773#if defined(_WIN32) || defined(__CYGWIN__)
774 else if ('\\' == prog_name[pos])
775 name_pos = pos + 1;
776#endif /* _WIN32 || __CYGWIN__ */
777 pos++;
778 }
779 if (name_pos == pos)
780 return 0;
781 return strstr (prog_name + name_pos, marker) != (char *) 0;
782}
diff --git a/src/testcurl/https/tls_test_common.h b/src/testcurl/https/tls_test_common.h
index 863bab66..998467f4 100644
--- a/src/testcurl/https/tls_test_common.h
+++ b/src/testcurl/https/tls_test_common.h
@@ -91,6 +91,11 @@ extern const char *tls_names[KNOW_TLS_IDS_COUNT];
91extern const char *priorities_map[KNOW_TLS_IDS_COUNT]; 91extern const char *priorities_map[KNOW_TLS_IDS_COUNT];
92 92
93/** 93/**
94 * Map @a know_gnutls_tls_ids values to GnuTLS priorities append strings.
95 */
96extern const char *priorities_append_map[KNOW_TLS_IDS_COUNT];
97
98/**
94 * Map @a know_gnutls_tls_ids values to libcurl @a CURLOPT_SSLVERSION value. 99 * Map @a know_gnutls_tls_ids values to libcurl @a CURLOPT_SSLVERSION value.
95 */ 100 */
96extern const long libcurl_tls_vers_map[KNOW_TLS_IDS_COUNT]; 101extern const long libcurl_tls_vers_map[KNOW_TLS_IDS_COUNT];
@@ -218,4 +223,20 @@ test_wrap (const char *test_name, unsigned int
218 223
219int testsuite_curl_global_init (void); 224int testsuite_curl_global_init (void);
220 225
226/**
227 * Check whether program name contains specific @a marker string.
228 * Only last component in pathname is checked for marker presence,
229 * all leading directories names (if any) are ignored. Directories
230 * separators are handled correctly on both non-W32 and W32
231 * platforms.
232 * @param prog_name program name, may include path
233 * @param marker marker to look for.
234 * @return zero if any parameter is NULL or empty string or
235 * @prog_name ends with slash or @marker is not found in
236 * program name, non-zero if @maker is found in program
237 * name.
238 */
239int
240has_in_name (const char *prog_name, const char *marker);
241
221#endif /* TLS_TEST_COMMON_H_ */ 242#endif /* TLS_TEST_COMMON_H_ */