curl/tests/data/test31
Daniel Stenberg 386f570df6
cookie: cap expire times to 400 days
The pending cookie RFC update (currently known as 6265bis draft-19) says

  Let cookie-age-limit be the maximum age of the cookie (which name of
  Max-Age and an attribute-value of expiry-time. SHOULD be 400 days or
  less.

This change makes received cookies over the wire get capped to 400 days.

It does not cap the expiry date of cookies loaded from file.

It does this by rounding the expire time to a even minute. This, to
allow the test suite to do the same and have a chance to get the same
number for stable testing without requiring a debug build.

The test script generates TWO numbers in the output file for each
%days[] used in the input test file, and the function that subsequently
compares and verifies output is fine with *either* of the two numbers.

This is done so that if the test case is generated the second
immediately before curl runs, that updated expiry number is also deemed
okay. It still checks for an exact match of either number.

Closes #15937
2025-01-10 08:20:03 +01:00

132 lines
5.2 KiB
Plaintext

<testcase>
<info>
<keywords>
HTTP
HTTP GET
cookies
cookiejar
</keywords>
</info>
# Server-side
#
<reply>
<data>
HTTP/1.1 200 OK
Date: Tue, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake
Content-Length: 4
Content-Type: text/html
Funny-head: yesyes
Set-Cookie: blankdomain=sure; domain=; path=/
Set-Cookie: foobar=name; domain=anything.com; path=/ ; secure
Set-Cookie:ismatch=this ; domain=test31.curl; path=/silly/
Set-Cookie:ISMATCH=this ; domain=test31.curl; path=/silly/
Set-Cookie: overwrite=this ; domain=test31.curl; path=/overwrite/
Set-Cookie: overwrite=this2 ; domain=test31.curl; path=/overwrite
Set-Cookie: sec1value=secure1 ; domain=test31.curl; path=/secure1/ ; secure
Set-Cookie: sec2value=secure2 ; domain=test31.curl; path=/secure2/ ; secure=
Set-Cookie: sec3value=secure3 ; domain=test31.curl; path=/secure3/ ; secure=
Set-Cookie: sec4value=secure4 ; secure=; domain=test31.curl; path=/secure4/ ;
Set-Cookie: sec5value=secure5 ; secure; domain=test31.curl; path=/secure5/ ;
Set-Cookie: sec6value=secure6 ; secure ; domain=test31.curl; path=/secure6/ ;
Set-Cookie: sec7value=secure7 ; secure ; domain=test31.curl; path=/secure7/ ;
Set-Cookie: sec8value=secure8 ; secure= ; domain=test31.curl; path=/secure8/ ;
Set-Cookie: secure=very1 ; secure=; domain=test31.curl; path=/secure9/;
Set-Cookie: httpo1=value1 ; domain=test31.curl; path=/p1/; httponly
Set-Cookie: httpo2=value2 ; domain=test31.curl; path=/p2/; httponly=
Set-Cookie: httpo3=value3 ; httponly; domain=test31.curl; path=/p3/;
Set-Cookie: httpo4=value4 ; httponly=; domain=test31.curl; path=/p4/;
Set-Cookie: httponly=myvalue1 ; domain=test31.curl; path=/p4/; httponly
Set-Cookie: httpandsec=myvalue2 ; domain=test31.curl; path=/p4/; httponly; secure
Set-Cookie: httpandsec2=myvalue3; domain=test31.curl; path=/p4/; httponly=; secure
Set-Cookie: httpandsec3=myvalue4 ; domain=test31.curl; path=/p4/; httponly; secure=
Set-Cookie: httpandsec4=myvalue5 ; domain=test31.curl; path=/p4/; httponly=; secure=
Set-Cookie: httpandsec5=myvalue6 ; domain=test31.curl; path=/p4/; secure; httponly=
Set-Cookie: httpandsec6=myvalue7 ; domain=test31.curl; path=/p4/; secure=; httponly=
Set-Cookie: httpandsec7=myvalue8 ; domain=test31.curl; path=/p4/; secure; httponly
Set-Cookie: httpandsec8=myvalue9; domain=test31.curl; path=/p4/; secure=; httponly
Set-Cookie: partmatch=present; domain=test31.curl ; path=/;
Set-Cookie:eat=this; domain=moo.foo.moo;
Set-Cookie: eat=this-too; domain=.foo.moo;
Set-Cookie: nodomainnovalue
%if large-time
Set-Cookie: nodomain=value; expires=Fri Feb 13 11:56:27 GMT 2525
Set-Cookie: novalue; domain=reallysilly
Set-Cookie: test=yes; domain=foo.com; expires=Sat Feb 2 11:56:27 GMT 2525
Set-Cookie: test2=yes; domain=se; expires=Sat Feb 2 11:56:27 GMT 2525
%else
Set-Cookie: nodomain=value; expires=Fri Feb 13 11:56:27 GMT 2037
Set-Cookie: novalue; domain=reallysilly
Set-Cookie: test=yes; domain=foo.com; expires=Sat Feb 2 11:56:27 GMT 2030
Set-Cookie: test2=yes; domain=se; expires=Sat Feb 2 11:56:27 GMT 2030
%endif
Set-Cookie: magic=yessir; path=/silly/; HttpOnly
Set-Cookie: blexp=yesyes; domain=test31.curl; domain=test31.curl; expiry=totally bad;
Set-Cookie: partialip=nono; domain=.0.0.1;
Set-Cookie: withspaces= yes within and around ;
Set-Cookie: withspaces2 =before equals;
Set-Cookie: prespace= yes before;
Set-Cookie: securewithspace=after ; secure =
boo
</data>
</reply>
# Client-side
<client>
<server>
http
</server>
<name>
HTTP with weirdly formatted cookies and cookiejar storage
</name>
# Explicitly set the time zone to a known good one, in case the user is
# using one of the 'right' zones that take into account leap seconds
# which causes the cookie expiry times to be different.
<setenv>
TZ=GMT
</setenv>
<command>
http://test31.curl:%HTTPPORT/we/want/%TESTNUMBER -b none -c %LOGDIR/jar%TESTNUMBER.txt --resolve test31.curl:%HTTPPORT:127.0.0.1
</command>
<features>
cookies
local-http
</features>
</client>
# Verify data after the test has been "shot"
<verify>
<protocol>
GET /we/want/%TESTNUMBER HTTP/1.1
Host: test31.curl:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
</protocol>
<file name="%LOGDIR/jar%TESTNUMBER.txt" mode="text">
# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
test31.curl FALSE /we/want/ FALSE 0 prespace yes before
test31.curl FALSE /we/want/ FALSE 0 withspaces2 before equals
test31.curl FALSE /we/want/ FALSE 0 withspaces yes within and around
.test31.curl TRUE /we/want/ FALSE 0 blexp yesyes
#HttpOnly_test31.curl FALSE /silly/ FALSE 0 magic yessir
test31.curl FALSE /we/want/ FALSE %days[400] nodomain value
.test31.curl TRUE / FALSE 0 partmatch present
#HttpOnly_.test31.curl TRUE /p4/ FALSE 0 httponly myvalue1
#HttpOnly_.test31.curl TRUE /p4/ FALSE 0 httpo4 value4
#HttpOnly_.test31.curl TRUE /p3/ FALSE 0 httpo3 value3
#HttpOnly_.test31.curl TRUE /p2/ FALSE 0 httpo2 value2
#HttpOnly_.test31.curl TRUE /p1/ FALSE 0 httpo1 value1
.test31.curl TRUE /overwrite FALSE 0 overwrite this2
.test31.curl TRUE /silly/ FALSE 0 ISMATCH this
.test31.curl TRUE /silly/ FALSE 0 ismatch this
test31.curl FALSE / FALSE 0 blankdomain sure
</file>
</verify>
</testcase>