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
This commit is contained in:
Daniel Stenberg 2023-03-08 14:31:33 +01:00 committed by Jay Satiro
parent b559ef6f36
commit 674a0662cf
4 changed files with 111 additions and 2 deletions

View 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 \
\

51
tests/data/test1903 Normal file
View file

@ -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>

View 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)

55
tests/libtest/lib1903.c Normal file
View file

@ -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;
}