aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/https/mhds_session_info_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/https/mhds_session_info_test.c')
-rw-r--r--src/testcurl/https/mhds_session_info_test.c38
1 files changed, 9 insertions, 29 deletions
diff --git a/src/testcurl/https/mhds_session_info_test.c b/src/testcurl/https/mhds_session_info_test.c
index 7bd797af..45675765 100644
--- a/src/testcurl/https/mhds_session_info_test.c
+++ b/src/testcurl/https/mhds_session_info_test.c
@@ -28,34 +28,14 @@
28#include "microhttpd.h" 28#include "microhttpd.h"
29#include <curl/curl.h> 29#include <curl/curl.h>
30 30
31#define DEBUG_CURL_VERBOSE 0 31#include "tls_test_common.h"
32#define EMPTY_PAGE "<html><head><title>Empty page</title></head><body>Empty page</body></html>"
33
34#include "tls_test_keys.h"
35 32
36extern int curl_check_version (const char *req_version, ...); 33extern int curl_check_version (const char *req_version, ...);
34extern const char srv_key_pem[];
35extern const char srv_self_signed_cert_pem[];
37 36
38struct MHD_Daemon *d; 37struct MHD_Daemon *d;
39 38
40struct CBC
41{
42 char *buf;
43 size_t pos;
44 size_t size;
45};
46
47static size_t
48copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
49{
50 struct CBC *cbc = ctx;
51
52 if (cbc->pos + size * nmemb > cbc->size)
53 return 0; /* overflow */
54 memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb);
55 cbc->pos += size * nmemb;
56 return size * nmemb;
57}
58
59/* 39/*
60 * HTTP access handler call back 40 * HTTP access handler call back
61 * used to query negotiated security parameters 41 * used to query negotiated security parameters
@@ -103,20 +83,21 @@ query_session_ahc (void *cls, struct MHD_Connection *connection,
103static int 83static int
104test_query_session () 84test_query_session ()
105{ 85{
106
107 CURL *c; 86 CURL *c;
108 struct CBC cbc; 87 struct CBC cbc;
109 CURLcode errornum; 88 CURLcode errornum;
110 char url[] = "https://localhost:42433/"; 89 char url[256];
111 90
112 if (NULL == (cbc.buf = malloc (sizeof (char) * 255))) 91 if (NULL == (cbc.buf = malloc (sizeof (char) * 255)))
113 return 16; 92 return 16;
114 cbc.size = 255; 93 cbc.size = 255;
115 cbc.pos = 0; 94 cbc.pos = 0;
116 95
96 gen_test_file_url (url, DEAMON_TEST_PORT);
97
117 /* setup test */ 98 /* setup test */
118 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL | 99 d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_SSL |
119 MHD_USE_DEBUG, 42433, 100 MHD_USE_DEBUG, DEAMON_TEST_PORT,
120 NULL, NULL, &query_session_ahc, NULL, 101 NULL, NULL, &query_session_ahc, NULL,
121 MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, 102 MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
122 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, 103 MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
@@ -126,7 +107,7 @@ test_query_session ()
126 return 2; 107 return 2;
127 108
128 c = curl_easy_init (); 109 c = curl_easy_init ();
129#if DEBUG_CURL_VERBOSE 110#if DEBUG_HTTPS_TEST
130 curl_easy_setopt (c, CURLOPT_VERBOSE, 1); 111 curl_easy_setopt (c, CURLOPT_VERBOSE, 1);
131#endif 112#endif
132 curl_easy_setopt (c, CURLOPT_URL, url); 113 curl_easy_setopt (c, CURLOPT_URL, url);
@@ -183,8 +164,7 @@ main (int argc, char *const *argv)
183 164
184 errorCount += test_query_session (); 165 errorCount += test_query_session ();
185 166
186 if (errorCount != 0) 167 print_test_result (errorCount, argv[0]);
187 fprintf (stderr, "Failed test: %s.\n", argv[0]);
188 168
189 curl_global_cleanup (); 169 curl_global_cleanup ();
190 170