gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 15/20: test_digestauth2: added third request with new co


From: gnunet
Subject: [libmicrohttpd] 15/20: test_digestauth2: added third request with new connection
Date: Mon, 15 Aug 2022 20:38:41 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit da62262d982eb2ea27c3d5b42171e073c2bc9a89
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Mon Aug 15 17:31:29 2022 +0300

    test_digestauth2: added third request with new connection
---
 src/testcurl/test_digestauth2.c | 55 +++++++++++++++++++++++++++++++++++------
 1 file 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,
 
 #define MHD_URI_BASE_PATH "/bar%20foo?key=value"
 #define MHD_URI_BASE_PATH2 "/another_path"
+/* Should not fit buffer in the stack */
+#define MHD_URI_BASE_PATH3 \
+  "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \
+  "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \
+  "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \
+  "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \
+  "/long/long/long/long/long/long/long/long/long/long/long/long/long/long" \
+  "/path?with%20some=parameters"
 
 #define REALM_VAL "TestRealm"
 #define USERNAME1 "test_user"
@@ -705,7 +713,7 @@ ahc_echo (void *cls,
 
       if (test_rfc2069)
       {
-        if ((1 == tr_p->uri_num) && (1 == tr_p->req_num))
+        if ((0 != tr_p->uri_num) && (1 == tr_p->req_num))
           expect_res = MHD_DAUTH_NONCE_STALE;
         else
           expect_res = MHD_DAUTH_OK;
@@ -1060,19 +1068,26 @@ ahc_echo (void *cls,
  *
  * @param c the CURL handle to use
  * @param port the port to set
- * @param uri_num the number of URI, 0 or 1
+ * @param uri_num the number of URI, should be 0, 1 or 2
  */
 static void
 setCURL_rq_path (CURL *c, unsigned int port, unsigned int uri_num)
 {
+  const char *req_path;
   char uri[512];
   int res;
+
+  if (0 == uri_num)
+    req_path = MHD_URI_BASE_PATH;
+  else if (1 == uri_num)
+    req_path = MHD_URI_BASE_PATH2;
+  else
+    req_path = MHD_URI_BASE_PATH3;
   /* A workaround for some old libcurl versions, which ignore the specified
    * port by CURLOPT_PORT when authorisation is used. */
   res = snprintf (uri, (sizeof(uri) / sizeof(uri[0])),
                   "http://127.0.0.1:%u%s";, port,
-                  (0 == uri_num) ?
-                  MHD_URI_BASE_PATH : MHD_URI_BASE_PATH2);
+                  req_path);
   if ((0 >= res) || ((sizeof(uri) / sizeof(uri[0])) <= (size_t) res))
     externalErrorExitDesc ("Cannot form request URL");
 
@@ -1357,12 +1372,14 @@ testDigestAuth (void)
   /* First request */
   if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc))
   {
+    fflush (stderr);
     if (verbose)
-      printf ("Got expected response.\n");
+      printf ("Got first expected response.\n");
+    fflush (stdout);
   }
   else
   {
-    fprintf (stderr, "Request FAILED.\n");
+    fprintf (stderr, "First request FAILED.\n");
     failed = 1;
   }
   cbc.pos = 0; /* Reset buffer position */
@@ -1371,14 +1388,36 @@ testDigestAuth (void)
   setCURL_rq_path (c, port, ++rq_tr.uri_num);
   if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc))
   {
+    fflush (stderr);
     if (verbose)
-      printf ("Got expected response.\n");
+      printf ("Got second expected response.\n");
+    fflush (stdout);
   }
   else
   {
-    fprintf (stderr, "Request FAILED.\n");
+    fprintf (stderr, "Second request FAILED.\n");
     failed = 1;
   }
+  cbc.pos = 0; /* Reset buffer position */
+  rq_tr.req_num = 0;
+  /* Third request */
+  if (NULL != multi_reuse)
+    curl_multi_cleanup (multi_reuse);
+  multi_reuse = NULL; /* Force new connection */
+  setCURL_rq_path (c, port, ++rq_tr.uri_num);
+  if (check_result (performQueryExternal (d, c, &multi_reuse), c, &cbc))
+  {
+    fflush (stderr);
+    if (verbose)
+      printf ("Got third expected response.\n");
+    fflush (stdout);
+  }
+  else
+  {
+    fprintf (stderr, "Third request FAILED.\n");
+    failed = 1;
+  }
+
   curl_easy_cleanup (c);
   if (NULL != multi_reuse)
     curl_multi_cleanup (multi_reuse);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]