[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 07/10: testcurl/https: added test for MHD_OPTION_HTTPS_P
From: |
gnunet |
Subject: |
[libmicrohttpd] 07/10: testcurl/https: added test for MHD_OPTION_HTTPS_PRIORITIES_APPEND |
Date: |
Thu, 13 Oct 2022 08:40:47 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit f8502a2e07a5e3402431d6218252879c46621f46
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Wed Oct 12 18:16:44 2022 +0300
testcurl/https: added test for MHD_OPTION_HTTPS_PRIORITIES_APPEND
---
src/testcurl/https/Makefile.am | 3 ++
src/testcurl/https/test_https_session_info.c | 11 +++++-
src/testcurl/https/tls_test_common.c | 54 ++++++++++++++++++++++++++++
src/testcurl/https/tls_test_common.h | 21 +++++++++++
4 files changed, 88 insertions(+), 1 deletion(-)
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 = \
$(HTTPS_PARALLEL_TESTS) \
$(TEST_HTTPS_SNI) \
test_https_session_info \
+ test_https_session_info_append \
test_https_multi_daemon \
test_https_get \
test_empty_response \
@@ -119,6 +120,8 @@ test_https_session_info_SOURCES = \
tls_test_common.h \
tls_test_common.c
+test_https_session_info_append_SOURCES = $(test_https_session_info_SOURCES)
+
test_https_multi_daemon_SOURCES = \
test_https_multi_daemon.c \
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 @@
#include "tls_test_common.h"
#include "tls_test_keys.h"
+
+static int test_append_prio;
+
/*
* HTTP access handler call back
* used to query negotiated security parameters
@@ -113,7 +116,12 @@ test_query_session (enum know_gnutls_tls_id tls_ver,
uint16_t *pport)
| MHD_USE_ERROR_LOG, *pport,
NULL, NULL,
&query_info_ahc, &found_tls_ver,
- MHD_OPTION_HTTPS_PRIORITIES, priorities_map[tls_ver],
+ test_append_prio ?
+ MHD_OPTION_HTTPS_PRIORITIES_APPEND :
+ MHD_OPTION_HTTPS_PRIORITIES,
+ test_append_prio ?
+ priorities_append_map[tls_ver] :
+ priorities_map[tls_ver],
MHD_OPTION_HTTPS_MEM_KEY, srv_self_signed_key_pem,
MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
MHD_OPTION_END);
@@ -344,6 +352,7 @@ main (int argc, char *const *argv)
gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
#endif
#endif /* MHD_HTTPS_REQUIRE_GCRYPT */
+ test_append_prio = has_in_name (argv[0], "_append");
if (! testsuite_curl_global_init ())
return 99;
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 @@
* @file tls_test_common.c
* @brief Common tls test functions
* @author Sagie Amir
+ * @author Karlson2k (Evgeny Grin)
*/
+#include <string.h>
#include "tls_test_common.h"
#include "tls_test_keys.h"
@@ -51,6 +53,18 @@ const char *priorities_map[KNOW_TLS_IDS_COUNT] = {
"NORMAL:!VERS-ALL:+VERS-TLS1.3"
};
+/**
+ * Map @a know_gnutls_tls_ids values to GnuTLS priorities append strings.
+ */
+const char *priorities_append_map[KNOW_TLS_IDS_COUNT] = {
+ "NONE",
+ "!VERS-ALL:+VERS-SSL3.0",
+ "!VERS-ALL:+VERS-TLS1.0",
+ "!VERS-ALL:+VERS-TLS1.1",
+ "!VERS-ALL:+VERS-TLS1.2",
+ "!VERS-ALL:+VERS-TLS1.3"
+};
+
/**
* Map @a know_gnutls_tls_ids values to libcurl @a CURLOPT_SSLVERSION value.
@@ -726,3 +740,43 @@ testsuite_curl_global_init (void)
}
return 1;
}
+
+
+/**
+ * Check whether program name contains specific @a marker string.
+ * Only last component in pathname is checked for marker presence,
+ * all leading directories names (if any) are ignored. Directories
+ * separators are handled correctly on both non-W32 and W32
+ * platforms.
+ * @param prog_name program name, may include path
+ * @param marker marker to look for.
+ * @return zero if any parameter is NULL or empty string or
+ * @prog_name ends with slash or @marker is not found in
+ * program name, non-zero if @maker is found in program
+ * name.
+ */
+int
+has_in_name (const char *prog_name, const char *marker)
+{
+ size_t name_pos;
+ size_t pos;
+
+ if (! prog_name || ! marker || ! prog_name[0] || ! marker[0])
+ return 0;
+
+ pos = 0;
+ name_pos = 0;
+ while (prog_name[pos])
+ {
+ if ('/' == prog_name[pos])
+ name_pos = pos + 1;
+#if defined(_WIN32) || defined(__CYGWIN__)
+ else if ('\\' == prog_name[pos])
+ name_pos = pos + 1;
+#endif /* _WIN32 || __CYGWIN__ */
+ pos++;
+ }
+ if (name_pos == pos)
+ return 0;
+ return strstr (prog_name + name_pos, marker) != (char *) 0;
+}
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
@@ -90,6 +90,11 @@ extern const char *tls_names[KNOW_TLS_IDS_COUNT];
*/
extern const char *priorities_map[KNOW_TLS_IDS_COUNT];
+/**
+ * Map @a know_gnutls_tls_ids values to GnuTLS priorities append strings.
+ */
+extern const char *priorities_append_map[KNOW_TLS_IDS_COUNT];
+
/**
* Map @a know_gnutls_tls_ids values to libcurl @a CURLOPT_SSLVERSION value.
*/
@@ -218,4 +223,20 @@ test_wrap (const char *test_name, unsigned int
int testsuite_curl_global_init (void);
+/**
+ * Check whether program name contains specific @a marker string.
+ * Only last component in pathname is checked for marker presence,
+ * all leading directories names (if any) are ignored. Directories
+ * separators are handled correctly on both non-W32 and W32
+ * platforms.
+ * @param prog_name program name, may include path
+ * @param marker marker to look for.
+ * @return zero if any parameter is NULL or empty string or
+ * @prog_name ends with slash or @marker is not found in
+ * program name, non-zero if @maker is found in program
+ * name.
+ */
+int
+has_in_name (const char *prog_name, const char *marker);
+
#endif /* TLS_TEST_COMMON_H_ */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (c930fe1a -> 778e2a03), gnunet, 2022/10/13
- [libmicrohttpd] 01/10: testcurl/https: handle libcurl with missing custom CA support, gnunet, 2022/10/13
- [libmicrohttpd] 04/10: TLS: use application-specific system-wide configuration with fallbacks, gnunet, 2022/10/13
- [libmicrohttpd] 03/10: mhd_assert: use "DEBUG" macro defined by some toolchains, gnunet, 2022/10/13
- [libmicrohttpd] 05/10: testcurl/https/Makefile.am: removed bad whitespace, gnunet, 2022/10/13
- [libmicrohttpd] 09/10: daemon: added reporting of the position of problem in priorities string, gnunet, 2022/10/13
- [libmicrohttpd] 08/10: daemon: merged processing of two similar options, gnunet, 2022/10/13
- [libmicrohttpd] 02/10: testcurl/https: enabled parallel make, gnunet, 2022/10/13
- [libmicrohttpd] 06/10: Added new MHD option to append TLS priorities string, gnunet, 2022/10/13
- [libmicrohttpd] 07/10: testcurl/https: added test for MHD_OPTION_HTTPS_PRIORITIES_APPEND,
gnunet <=
- [libmicrohttpd] 10/10: testcurl/https: minor improvements, gnunet, 2022/10/13