From 674a0662cf937f2e3407e3d4237a41aa23ad5778 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 8 Mar 2023 14:31:33 +0100 Subject: [PATCH] test1903: test use of COOKIEFILE - reset - COOKIEFILE 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 | 2 +- tests/data/test1903 | 51 +++++++++++++++++++++++++++++++++++ tests/libtest/Makefile.inc | 5 +++- tests/libtest/lib1903.c | 55 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 tests/data/test1903 create mode 100644 tests/libtest/lib1903.c diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc index 4a1dc2c1d7..846087642b 100644 --- a/tests/data/Makefile.inc +++ b/tests/data/Makefile.inc @@ -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 index 0000000000..16704e893c --- /dev/null +++ b/tests/data/test1903 @@ -0,0 +1,51 @@ + + + +HTTP +cookies +CURLOPT_COOKIEFILE + + + +# Server-side + + +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; + + + + +# Client-side + + +http + + +CURLOPT_COOKIEFILE then reset then set again + + +lib%TESTNUMBER + + +http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER + + +# 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 + + + +# Verify data after the test has been "shot" + + + diff --git a/tests/libtest/Makefile.inc b/tests/libtest/Makefile.inc index a82df608ed..615e76e3d1 100644 --- a/tests/libtest/Makefile.inc +++ b/tests/libtest/Makefile.inc @@ -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 index 0000000000..701cd7f0d3 --- /dev/null +++ b/tests/libtest/lib1903.c @@ -0,0 +1,55 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) Daniel Stenberg, , 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; +} -- 2.47.3