]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
test1903: test use of COOKIEFILE - reset - COOKIEFILE
authorDaniel Stenberg <daniel@haxx.se>
Wed, 8 Mar 2023 13:31:33 +0000 (14:31 +0100)
committerJay Satiro <raysatiro@yahoo.com>
Fri, 10 Mar 2023 08:56:59 +0000 (03:56 -0500)
This also tests for the memory leak bug fixed by parent commit b559ef6f.

Ref: #10694

Closes https://github.com/curl/curl/pull/10712

tests/data/Makefile.inc
tests/data/test1903 [new file with mode: 0644]
tests/libtest/Makefile.inc
tests/libtest/lib1903.c [new file with mode: 0644]

index 4a1dc2c1d79ea580ffab040c7d8c7835c78f7fbb..846087642b9b2c8411f870ead832cb545e31dab8 100644 (file)
@@ -219,7 +219,7 @@ test1700 test1701 test1702 test1703 \
 \
 test1800 test1801 \
 \
-                                    test1904 test1905 test1906 test1907 \
+                           test1903 test1904 test1905 test1906 test1907 \
 test1908 test1909 test1910 test1911 test1912 test1913 test1914 test1915 \
 test1916 test1917 test1918 test1919 \
 \
diff --git a/tests/data/test1903 b/tests/data/test1903
new file mode 100644 (file)
index 0000000..16704e8
--- /dev/null
@@ -0,0 +1,51 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+cookies
+CURLOPT_COOKIEFILE
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data nocheck="yes" crlf="yes">
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Type: text/html
+Funny-head: yesyes swsclose
+Set-Cookie: foobar=name;
+Set-Cookie: secondcookie=present;
+
+</data>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+CURLOPT_COOKIEFILE then reset then set again
+ </name>
+<tool>
+lib%TESTNUMBER
+</tool>
+<command>
+http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER
+</command>
+<file name="log/cookies%TESTNUMBER" mode="text">
+# Netscape HTTP Cookie File
+# https://curl.se/docs/http-cookies.html
+# This file was generated by libcurl! Edit at your own risk.
+
+%HOSTIP        FALSE   /we/want/       FALSE   0       secondcookie    present
+%HOSTIP        FALSE   /we/want/       FALSE   0       foobar  name
+</file>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+</verify>
+</testcase>
index a82df608ed095752f25918dfdf4d5ee3b6c72ebc..615e76e3d1ea8283393c4fc99940006ddb4811d8 100644 (file)
@@ -65,7 +65,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect                \
  \
  lib1662 \
  \
        lib1905 lib1906 lib1907 lib1908 lib1910 lib1911 lib1912 lib1913 \
lib1903 lib1905 lib1906 lib1907 lib1908 lib1910 lib1911 lib1912 lib1913 \
          lib1915 lib1916 lib1917 lib1918 lib1919 \
  lib1933 lib1934 lib1935 lib1936 lib1937 lib1938 lib1939 lib1940 \
  lib1945 lib1946 lib1947 lib1948 lib1955 lib1956 lib1957 lib1958 lib1959 \
@@ -676,6 +676,9 @@ lib1597_LDADD = $(TESTUTIL_LIBS)
 lib1662_SOURCES = lib1662.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
 lib1662_LDADD = $(TESTUTIL_LIBS)
 
+lib1903_SOURCES = lib1903.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
+lib1903_LDADD = $(TESTUTIL_LIBS)
+
 lib1905_SOURCES = lib1905.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS)
 lib1905_LDADD = $(TESTUTIL_LIBS)
 lib1905_CPPFLAGS = $(AM_CPPFLAGS)
diff --git a/tests/libtest/lib1903.c b/tests/libtest/lib1903.c
new file mode 100644 (file)
index 0000000..701cd7f
--- /dev/null
@@ -0,0 +1,55 @@
+/***************************************************************************
+ *                                  _   _ ____  _
+ *  Project                     ___| | | |  _ \| |
+ *                             / __| | | | |_) | |
+ *                            | (__| |_| |  _ <| |___
+ *                             \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ * SPDX-License-Identifier: curl
+ *
+ ***************************************************************************/
+#include "test.h"
+
+#include "testutil.h"
+#include "timediff.h"
+#include "warnless.h"
+#include "memdebug.h"
+
+int test(char *URL)
+{
+  CURL *ch = NULL;
+  curl_global_init(CURL_GLOBAL_ALL);
+
+  ch = curl_easy_init();
+  if(!ch)
+    goto cleanup;
+
+  curl_easy_setopt(ch, CURLOPT_URL, URL);
+  curl_easy_setopt(ch, CURLOPT_COOKIEFILE, "log/cookies1903");
+  curl_easy_perform(ch);
+
+  curl_easy_reset(ch);
+
+  curl_easy_setopt(ch, CURLOPT_URL, URL);
+  curl_easy_setopt(ch, CURLOPT_COOKIEFILE, "log/cookies1903");
+  curl_easy_perform(ch);
+
+  cleanup:
+  curl_easy_cleanup(ch);
+  curl_global_cleanup();
+
+  return 0;
+}