aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/testcurl/test_digestauth.c22
-rw-r--r--src/testcurl/test_digestauth_sha256.c20
-rw-r--r--src/testcurl/test_digestauth_with_arguments.c28
3 files changed, 37 insertions, 33 deletions
diff --git a/src/testcurl/test_digestauth.c b/src/testcurl/test_digestauth.c
index 872eebc4..42ddd874 100644
--- a/src/testcurl/test_digestauth.c
+++ b/src/testcurl/test_digestauth.c
@@ -265,7 +265,7 @@ ahc_echo (void *cls,
265 const char *password = "testpass"; 265 const char *password = "testpass";
266 const char *realm = "test@example.com"; 266 const char *realm = "test@example.com";
267 enum MHD_Result ret; 267 enum MHD_Result ret;
268 enum MHD_DigestAuthResult ret_e; 268 int ret_i;
269 static int already_called_marker; 269 static int already_called_marker;
270 (void) cls; (void) url; /* Unused. Silent compiler warning. */ 270 (void) cls; (void) url; /* Unused. Silent compiler warning. */
271 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 271 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
@@ -297,14 +297,14 @@ ahc_echo (void *cls,
297 MHD_destroy_response (response); 297 MHD_destroy_response (response);
298 return ret; 298 return ret;
299 } 299 }
300 ret_e = MHD_digest_auth_check3 (connection, 300 ret_i = MHD_digest_auth_check2 (connection,
301 realm, 301 realm,
302 username, 302 username,
303 password, 303 password,
304 300, 304 300,
305 MHD_DIGEST_ALG_MD5); 305 MHD_DIGEST_ALG_MD5);
306 MHD_free (username); 306 MHD_free (username);
307 if (ret_e != MHD_DAUTH_OK) 307 if (ret_i != MHD_YES)
308 { 308 {
309 response = MHD_create_response_from_buffer_static (strlen (DENIED), 309 response = MHD_create_response_from_buffer_static (strlen (DENIED),
310 DENIED); 310 DENIED);
@@ -314,7 +314,7 @@ ahc_echo (void *cls,
314 realm, 314 realm,
315 MY_OPAQUE, 315 MY_OPAQUE,
316 response, 316 response,
317 (MHD_DAUTH_NONCE_STALE == ret_e) ? 317 (MHD_INVALID_NONCE == ret_i) ?
318 MHD_YES : MHD_NO, 318 MHD_YES : MHD_NO,
319 MHD_DIGEST_ALG_MD5); 319 MHD_DIGEST_ALG_MD5);
320 if (MHD_YES != ret) 320 if (MHD_YES != ret)
@@ -337,7 +337,7 @@ ahc_echo (void *cls,
337 337
338 338
339static CURL * 339static CURL *
340setupCURL (void *cbc, int port) 340setupCURL (void *cbc, uint16_t port)
341{ 341{
342 CURL *c; 342 CURL *c;
343 char url[512]; 343 char url[512];
@@ -348,7 +348,7 @@ setupCURL (void *cbc, int port)
348 /* A workaround for some old libcurl versions, which ignore the specified 348 /* A workaround for some old libcurl versions, which ignore the specified
349 * port by CURLOPT_PORT when digest authorisation is used. */ 349 * port by CURLOPT_PORT when digest authorisation is used. */
350 res = snprintf (url, (sizeof(url) / sizeof(url[0])), 350 res = snprintf (url, (sizeof(url) / sizeof(url[0])),
351 "http://127.0.0.1:%d%s", port, MHD_URI_BASE_PATH); 351 "http://127.0.0.1:%d%s", (int) port, MHD_URI_BASE_PATH);
352 if ((0 >= res) || ((sizeof(url) / sizeof(url[0])) <= (size_t) res)) 352 if ((0 >= res) || ((sizeof(url) / sizeof(url[0])) <= (size_t) res))
353 externalErrorExitDesc ("Cannot form request URL"); 353 externalErrorExitDesc ("Cannot form request URL");
354 } 354 }
@@ -387,15 +387,15 @@ setupCURL (void *cbc, int port)
387} 387}
388 388
389 389
390static int 390static unsigned int
391testDigestAuth () 391testDigestAuth (void)
392{ 392{
393 CURL *c; 393 CURL *c;
394 struct MHD_Daemon *d; 394 struct MHD_Daemon *d;
395 struct CBC cbc; 395 struct CBC cbc;
396 char buf[2048]; 396 char buf[2048];
397 char rnd[8]; 397 char rnd[8];
398 int port; 398 uint16_t port;
399#ifndef WINDOWS 399#ifndef WINDOWS
400 int fd; 400 int fd;
401 size_t len; 401 size_t len;
@@ -446,7 +446,7 @@ testDigestAuth ()
446#endif 446#endif
447 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 447 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
448 port, NULL, NULL, 448 port, NULL, NULL,
449 &ahc_echo, PAGE, 449 &ahc_echo, NULL,
450 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, 450 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd,
451 MHD_OPTION_NONCE_NC_SIZE, 300, 451 MHD_OPTION_NONCE_NC_SIZE, 300,
452 MHD_OPTION_END); 452 MHD_OPTION_END);
@@ -461,7 +461,7 @@ testDigestAuth ()
461 if ( (NULL == dinfo) || 461 if ( (NULL == dinfo) ||
462 (0 == dinfo->port) ) 462 (0 == dinfo->port) )
463 mhdErrorExitDesc ("MHD_get_daemon_info() failed"); 463 mhdErrorExitDesc ("MHD_get_daemon_info() failed");
464 port = (int) dinfo->port; 464 port = dinfo->port;
465 } 465 }
466 c = setupCURL (&cbc, port); 466 c = setupCURL (&cbc, port);
467 467
diff --git a/src/testcurl/test_digestauth_sha256.c b/src/testcurl/test_digestauth_sha256.c
index b34dff9f..dfaf1ec8 100644
--- a/src/testcurl/test_digestauth_sha256.c
+++ b/src/testcurl/test_digestauth_sha256.c
@@ -94,7 +94,7 @@ ahc_echo (void *cls,
94 const char *password = "testpass"; 94 const char *password = "testpass";
95 const char *realm = "test@example.com"; 95 const char *realm = "test@example.com";
96 enum MHD_Result ret; 96 enum MHD_Result ret;
97 enum MHD_DigestAuthResult ret_e; 97 int ret_i;
98 static int already_called_marker; 98 static int already_called_marker;
99 (void) cls; (void) url; /* Unused. Silent compiler warning. */ 99 (void) cls; (void) url; /* Unused. Silent compiler warning. */
100 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 100 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
@@ -122,14 +122,14 @@ ahc_echo (void *cls,
122 MHD_destroy_response (response); 122 MHD_destroy_response (response);
123 return ret; 123 return ret;
124 } 124 }
125 ret_e = MHD_digest_auth_check3 (connection, 125 ret_i = MHD_digest_auth_check2 (connection,
126 realm, 126 realm,
127 username, 127 username,
128 password, 128 password,
129 300, 129 300,
130 MHD_DIGEST_ALG_SHA256); 130 MHD_DIGEST_ALG_SHA256);
131 MHD_free (username); 131 MHD_free (username);
132 if (ret_e != MHD_DAUTH_OK) 132 if (ret_i != MHD_YES)
133 { 133 {
134 response = MHD_create_response_from_buffer_static (strlen (DENIED), 134 response = MHD_create_response_from_buffer_static (strlen (DENIED),
135 DENIED); 135 DENIED);
@@ -139,7 +139,7 @@ ahc_echo (void *cls,
139 realm, 139 realm,
140 MY_OPAQUE, 140 MY_OPAQUE,
141 response, 141 response,
142 (MHD_DAUTH_NONCE_STALE == ret_e) ? 142 (MHD_INVALID_NONCE == ret_i) ?
143 MHD_YES : MHD_NO, 143 MHD_YES : MHD_NO,
144 MHD_DIGEST_ALG_SHA256); 144 MHD_DIGEST_ALG_SHA256);
145 MHD_destroy_response (response); 145 MHD_destroy_response (response);
@@ -155,8 +155,8 @@ ahc_echo (void *cls,
155} 155}
156 156
157 157
158static int 158static unsigned int
159testDigestAuth () 159testDigestAuth (void)
160{ 160{
161 CURL *c; 161 CURL *c;
162 CURLcode errornum; 162 CURLcode errornum;
@@ -164,7 +164,7 @@ testDigestAuth ()
164 struct CBC cbc; 164 struct CBC cbc;
165 char buf[2048]; 165 char buf[2048];
166 char rnd[8]; 166 char rnd[8];
167 int port; 167 uint16_t port;
168 char url[128]; 168 char url[128];
169#ifndef WINDOWS 169#ifndef WINDOWS
170 int fd; 170 int fd;
@@ -239,7 +239,7 @@ testDigestAuth ()
239#endif 239#endif
240 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 240 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
241 port, NULL, NULL, 241 port, NULL, NULL,
242 &ahc_echo, PAGE, 242 &ahc_echo, NULL,
243 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, 243 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd,
244 MHD_OPTION_NONCE_NC_SIZE, 300, 244 MHD_OPTION_NONCE_NC_SIZE, 300,
245 MHD_OPTION_END); 245 MHD_OPTION_END);
@@ -257,12 +257,12 @@ testDigestAuth ()
257 MHD_stop_daemon (d); 257 MHD_stop_daemon (d);
258 return 32; 258 return 32;
259 } 259 }
260 port = (int) dinfo->port; 260 port = dinfo->port;
261 } 261 }
262 snprintf (url, 262 snprintf (url,
263 sizeof (url), 263 sizeof (url),
264 "http://127.0.0.1:%d/bar%%20foo?key=value", 264 "http://127.0.0.1:%d/bar%%20foo?key=value",
265 port); 265 (int) port);
266 c = curl_easy_init (); 266 c = curl_easy_init ();
267 curl_easy_setopt (c, CURLOPT_URL, url); 267 curl_easy_setopt (c, CURLOPT_URL, url);
268 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 268 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
diff --git a/src/testcurl/test_digestauth_with_arguments.c b/src/testcurl/test_digestauth_with_arguments.c
index 631169e8..a606f363 100644
--- a/src/testcurl/test_digestauth_with_arguments.c
+++ b/src/testcurl/test_digestauth_with_arguments.c
@@ -87,7 +87,7 @@ ahc_echo (void *cls,
87 const char *password = "testpass"; 87 const char *password = "testpass";
88 const char *realm = "test@example.com"; 88 const char *realm = "test@example.com";
89 enum MHD_Result ret; 89 enum MHD_Result ret;
90 enum MHD_DigestAuthResult ret_e; 90 int ret_i;
91 static int already_called_marker; 91 static int already_called_marker;
92 (void) cls; (void) url; /* Unused. Silent compiler warning. */ 92 (void) cls; (void) url; /* Unused. Silent compiler warning. */
93 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 93 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
@@ -114,24 +114,28 @@ ahc_echo (void *cls,
114 MHD_destroy_response (response); 114 MHD_destroy_response (response);
115 return ret; 115 return ret;
116 } 116 }
117 ret_e = MHD_digest_auth_check3 (connection, realm, 117 ret_i = MHD_digest_auth_check2 (connection,
118 realm,
118 username, 119 username,
119 password, 120 password,
120 300, 121 300,
121 MHD_DIGEST_ALG_MD5); 122 MHD_DIGEST_ALG_MD5);
122 MHD_free (username); 123 MHD_free (username);
123 if (ret_e != MHD_DAUTH_OK) 124 if (ret_i != MHD_YES)
124 { 125 {
125 response = MHD_create_response_from_buffer_static (strlen (DENIED), 126 response = MHD_create_response_from_buffer_static (strlen (DENIED),
126 DENIED); 127 DENIED);
127 if (NULL == response) 128 if (NULL == response)
128 return MHD_NO; 129 fprintf (stderr, "MHD_create_response_from_buffer() failed.\n");
129 ret = MHD_queue_auth_fail_response2 (connection, realm, 130 ret = MHD_queue_auth_fail_response2 (connection,
131 realm,
130 MY_OPAQUE, 132 MY_OPAQUE,
131 response, 133 response,
132 (ret_e == MHD_DAUTH_NONCE_STALE) ? 134 (MHD_INVALID_NONCE == ret_i) ?
133 MHD_YES : MHD_NO, 135 MHD_YES : MHD_NO,
134 MHD_DIGEST_ALG_MD5); 136 MHD_DIGEST_ALG_MD5);
137 if (MHD_YES != ret)
138 fprintf (stderr, "MHD_queue_auth_fail_response2() failed.\n");
135 MHD_destroy_response (response); 139 MHD_destroy_response (response);
136 return ret; 140 return ret;
137 } 141 }
@@ -143,8 +147,8 @@ ahc_echo (void *cls,
143} 147}
144 148
145 149
146static int 150static unsigned int
147testDigestAuth () 151testDigestAuth (void)
148{ 152{
149 CURL *c; 153 CURL *c;
150 CURLcode errornum; 154 CURLcode errornum;
@@ -152,7 +156,7 @@ testDigestAuth ()
152 struct CBC cbc; 156 struct CBC cbc;
153 char buf[2048]; 157 char buf[2048];
154 char rnd[8]; 158 char rnd[8];
155 int port; 159 uint16_t port;
156 char url[128]; 160 char url[128];
157#ifndef WINDOWS 161#ifndef WINDOWS
158 int fd; 162 int fd;
@@ -216,7 +220,7 @@ testDigestAuth ()
216 } 220 }
217#endif 221#endif
218 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 222 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
219 port, NULL, NULL, &ahc_echo, PAGE, 223 port, NULL, NULL, &ahc_echo, NULL,
220 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, 224 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd,
221 MHD_OPTION_NONCE_NC_SIZE, 300, 225 MHD_OPTION_NONCE_NC_SIZE, 300,
222 MHD_OPTION_END); 226 MHD_OPTION_END);
@@ -230,13 +234,13 @@ testDigestAuth ()
230 { 234 {
231 MHD_stop_daemon (d); return 32; 235 MHD_stop_daemon (d); return 32;
232 } 236 }
233 port = (int) dinfo->port; 237 port = dinfo->port;
234 } 238 }
235 snprintf (url, 239 snprintf (url,
236 sizeof (url), 240 sizeof (url),
237 "http://127.0.0.1:%d/bar%%20foo?" 241 "http://127.0.0.1:%d/bar%%20foo?"
238 "key=value&more=even%%20more&empty&=no_key&&same=one&&same=two", 242 "key=value&more=even%%20more&empty&=no_key&&same=one&&same=two",
239 port); 243 (int) port);
240 c = curl_easy_init (); 244 c = curl_easy_init ();
241 curl_easy_setopt (c, CURLOPT_URL, url); 245 curl_easy_setopt (c, CURLOPT_URL, url);
242 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 246 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);