aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-08-15 17:31:29 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-08-15 21:37:50 +0300
commitda62262d982eb2ea27c3d5b42171e073c2bc9a89 (patch)
tree575681a066481db0593bdad584cc6d6ebd819b6a /src/testcurl
parent8a210d2885a5cf8c072806cc64d9b46f1d9c8e05 (diff)
downloadlibmicrohttpd-da62262d982eb2ea27c3d5b42171e073c2bc9a89.tar.gz
libmicrohttpd-da62262d982eb2ea27c3d5b42171e073c2bc9a89.zip
test_digestauth2: added third request with new connection
Diffstat (limited to 'src/testcurl')
-rw-r--r--src/testcurl/test_digestauth2.c55
1 files changed, 47 insertions, 8 deletions
diff --git a/src/testcurl/test_digestauth2.c b/src/testcurl/test_digestauth2.c
index ade4d2a5..ff82eeb8 100644
--- a/src/testcurl/test_digestauth2.c
+++ b/src/testcurl/test_digestauth2.c
@@ -229,6 +229,14 @@ _checkCURLE_OK_func (CURLcode code, const char *curlFunc,
229 229
230#define MHD_URI_BASE_PATH "/bar%20foo?key=value" 230#define MHD_URI_BASE_PATH "/bar%20foo?key=value"
231#define MHD_URI_BASE_PATH2 "/another_path" 231#define MHD_URI_BASE_PATH2 "/another_path"
232/* Should not fit buffer in the stack */
233#define MHD_URI_BASE_PATH3 \
234 "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \
235 "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \
236 "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \
237 "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \
238 "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \
239 "/path?with%20some=parameters"
232 240
233#define REALM_VAL "TestRealm" 241#define REALM_VAL "TestRealm"
234#define USERNAME1 "test_user" 242#define USERNAME1 "test_user"
@@ -705,7 +713,7 @@ ahc_echo (void *cls,
705 713
706 if (test_rfc2069) 714 if (test_rfc2069)
707 { 715 {
708 if ((1 == tr_p->uri_num) && (1 == tr_p->req_num)) 716 if ((0 != tr_p->uri_num) && (1 == tr_p->req_num))
709 expect_res = MHD_DAUTH_NONCE_STALE; 717 expect_res = MHD_DAUTH_NONCE_STALE;
710 else 718 else
711 expect_res = MHD_DAUTH_OK; 719 expect_res = MHD_DAUTH_OK;
@@ -1060,19 +1068,26 @@ ahc_echo (void *cls,
1060 * 1068 *
1061 * @param c the CURL handle to use 1069 * @param c the CURL handle to use
1062 * @param port the port to set 1070 * @param port the port to set
1063 * @param uri_num the number of URI, 0 or 1 1071 * @param uri_num the number of URI, should be 0, 1 or 2
1064 */ 1072 */
1065static void 1073static void
1066setCURL_rq_path (CURL *c, unsigned int port, unsigned int uri_num) 1074setCURL_rq_path (CURL *c, unsigned int port, unsigned int uri_num)
1067{ 1075{
1076 const char *req_path;
1068 char uri[512]; 1077 char uri[512];
1069 int res; 1078 int res;
1079
1080 if (0 == uri_num)
1081 req_path = MHD_URI_BASE_PATH;
1082 else if (1 == uri_num)
1083 req_path = MHD_URI_BASE_PATH2;
1084 else
1085 req_path = MHD_URI_BASE_PATH3;
1070 /* A workaround for some old libcurl versions, which ignore the specified 1086 /* A workaround for some old libcurl versions, which ignore the specified
1071 * port by CURLOPT_PORT when authorisation is used. */ 1087 * port by CURLOPT_PORT when authorisation is used. */
1072 res = snprintf (uri, (sizeof(uri) / sizeof(uri[0])), 1088 res = snprintf (uri, (sizeof(uri) / sizeof(uri[0])),
1073 "http://127.0.0.1:%u%s", port, 1089 "http://127.0.0.1:%u%s", port,
1074 (0 == uri_num) ? 1090 req_path);
1075 MHD_URI_BASE_PATH : MHD_URI_BASE_PATH2);
1076 if ((0 >= res) || ((sizeof(uri) / sizeof(uri[0])) <= (size_t) res)) 1091 if ((0 >= res) || ((sizeof(uri) / sizeof(uri[0])) <= (size_t) res))
1077 externalErrorExitDesc ("Cannot form request URL"); 1092 externalErrorExitDesc ("Cannot form request URL");
1078 1093
@@ -1357,12 +1372,14 @@ testDigestAuth (void)
1357 /* First request */ 1372 /* First request */
1358 if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc)) 1373 if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc))
1359 { 1374 {
1375 fflush (stderr);
1360 if (verbose) 1376 if (verbose)
1361 printf ("Got expected response.\n"); 1377 printf ("Got first expected response.\n");
1378 fflush (stdout);
1362 } 1379 }
1363 else 1380 else
1364 { 1381 {
1365 fprintf (stderr, "Request FAILED.\n"); 1382 fprintf (stderr, "First request FAILED.\n");
1366 failed = 1; 1383 failed = 1;
1367 } 1384 }
1368 cbc.pos = 0; /* Reset buffer position */ 1385 cbc.pos = 0; /* Reset buffer position */
@@ -1371,14 +1388,36 @@ testDigestAuth (void)
1371 setCURL_rq_path (c, port, ++rq_tr.uri_num); 1388 setCURL_rq_path (c, port, ++rq_tr.uri_num);
1372 if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc)) 1389 if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc))
1373 { 1390 {
1391 fflush (stderr);
1374 if (verbose) 1392 if (verbose)
1375 printf ("Got expected response.\n"); 1393 printf ("Got second expected response.\n");
1394 fflush (stdout);
1376 } 1395 }
1377 else 1396 else
1378 { 1397 {
1379 fprintf (stderr, "Request FAILED.\n"); 1398 fprintf (stderr, "Second request FAILED.\n");
1380 failed = 1; 1399 failed = 1;
1381 } 1400 }
1401 cbc.pos = 0; /* Reset buffer position */
1402 rq_tr.req_num = 0;
1403 /* Third request */
1404 if (NULL != multi_reuse)
1405 curl_multi_cleanup (multi_reuse);
1406 multi_reuse = NULL; /* Force new connection */
1407 setCURL_rq_path (c, port, ++rq_tr.uri_num);
1408 if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc))
1409 {
1410 fflush (stderr);
1411 if (verbose)
1412 printf ("Got third expected response.\n");
1413 fflush (stdout);
1414 }
1415 else
1416 {
1417 fprintf (stderr, "Third request FAILED.\n");
1418 failed = 1;
1419 }
1420
1382 curl_easy_cleanup (c); 1421 curl_easy_cleanup (c);
1383 if (NULL != multi_reuse) 1422 if (NULL != multi_reuse)
1384 curl_multi_cleanup (multi_reuse); 1423 curl_multi_cleanup (multi_reuse);