HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_http_cookies.cpython-310.pyc
o

�i�J�@svddlZddlmZmZddlZddlmZddlZGdd�dej�Z	Gdd�dej�Z
dd	�Zed
kr9e�dSdS)�N)�run_unittest�run_doctest)�cookiesc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS) �CookieTestsc
Cs�dddd�ddd�dd	d
iddd�d
d	diddd�dddiddd�dddddd�dd�d�d�g}|D]9}t��}|�|d�|�t|�|d �|�|jdd!�|d"�t|d#���D]
\}}|�||j	|�q^q3dS)$Nzchips=ahoy; vienna=fingerZahoyZfinger)ZchipsZviennaz,<SimpleCookie: chips='ahoy' vienna='finger'>z0Set-Cookie: chips=ahoy
Set-Cookie: vienna=finger)�data�dict�repr�outputz)keebler="E=mc2; L=\"Loves\"; fudge=\012;"ZkeeblerzE=mc2; L="Loves"; fudge=
;z5<SimpleCookie: keebler='E=mc2; L="Loves"; fudge=\n;'>z5Set-Cookie: keebler="E=mc2; L=\"Loves\"; fudge=\012;"z
keebler=E=mc2zE=mc2z<SimpleCookie: keebler='E=mc2'>zSet-Cookie: keebler=E=mc2zkey:term=value:termzkey:termz
value:termz%<SimpleCookie: key:term='value:term'>zSet-Cookie: key:term=value:termza=b; c=[; d=r; f=h�b�[�r�h)�a�c�d�fz'<SimpleCookie: a='b' c='[' d='r' f='h'>�
)zSet-Cookie: a=bzSet-Cookie: c=[zSet-Cookie: d=rzSet-Cookie: f=hrr)�sepr	r)
�joinr�SimpleCookie�load�assertEqualrr	�sorted�items�value)�self�cases�case�C�k�v�r!�3/usr/local/lib/python3.10/test/test_http_cookies.py�
test_basicsF������(��zCookieTests.test_basiccC�t��}|�d�|�|djd�|�|ddd�|�|ddd�|�|�dg�d�|�|��d	�|�|�dg�d
�dS)Nz/Customer="WILE_E_COYOTE"; Version=1; Path=/acme�Customer�
WILE_E_COYOTE�version�1�path�/acme�0Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme��
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1";
        // end hiding -->
        </script>
        ��
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme";
        // end hiding -->
        </script>
        �rrrrrr	�	js_output�rrr!r!r"�	test_load=s
�zCookieTests.test_loadcCs(t��}d|d<|�|�dg�d�dS)Nzsome,funky;stuff�valz(Set-Cookie: val="some\054funky\073stuff"�rrrr	r0r!r!r"�test_extended_encodeVs
�z CookieTests.test_extended_encodecCs�t�d�}d|dd<|�|���d��t��}|�d�|�|ddd�t��}|�d�|�|ddd	�t�d�}d
|dd<|�|��d�dS)
N�Customer="WILE_E_COYOTE"rr%�expiresZGMTz3Customer="W"; expires=Wed, 01 Jan 2010 00:00:00 GMTzWed, 01 Jan 2010 00:00:00 GMTz1Customer="W"; expires=Wed, 01 Jan 98 00:00:00 GMTzWed, 01 Jan 98 00:00:00 GMT�
�max-agez0Set-Cookie: Customer="WILE_E_COYOTE"; Max-Age=10)rr�
assertTruer	�endswithrrr0r!r!r"�test_special_attrs^s$

�
�

�zCookieTests.test_special_attrscCs6t�d�}d|dd<d|dd<|�|��d�dS)Nr5Tr%�secure�httponlyz6Set-Cookie: Customer="WILE_E_COYOTE"; HttpOnly; Securer3r0r!r!r"�test_set_secure_httponly_attrsus

�z*CookieTests.test_set_secure_httponly_attrsc	Cs�gd�}|D]B}|j|d��2t�d�}||dd<|�|��d|�t��}|�d|�|�|dd|�Wd�n1sCwYqdS)N)ZStrictZLax�strictZlax)r2r5r%Zsamesitez1Set-Cookie: Customer="WILE_E_COYOTE"; SameSite=%sz%Customer="WILL_E_COYOTE"; SameSite=%s)�subTestrrrr	r)rZsamesite_valuesr2rr!r!r"�test_samesite_attrs|s

����zCookieTests.test_samesite_attrscC�:t��}|�d�|�|dd�|�|dd�dS)Nzeggs=scrambled; Path=/bacon�eggsr=r<)rrr�assertFalser0r!r!r"�)test_secure_httponly_false_if_not_present�s
z5CookieTests.test_secure_httponly_false_if_not_presentcCrB)Nz-eggs=scrambled; httponly; secure; Path=/baconrCr=r<)rrrr9r0r!r!r"�$test_secure_httponly_true_if_present�s
z0CookieTests.test_secure_httponly_true_if_presentcCsbt��}|�d�|�|dd�|�|dd�|�|ddd�|�|ddd�dS)Nz5eggs=scrambled; httponly=foo; secure=bar; Path=/baconrCr=r<�foo�bar)rrrr9rr0r!r!r"�'test_secure_httponly_true_if_have_value�s
z3CookieTests.test_secure_httponly_true_if_have_valuecCs&t��}|�d�|�|��d�dS)Nz=eggs  =  scrambled  ;  secure  ;  path  =  bar   ; foo=foo   zASet-Cookie: eggs=scrambled; Path=bar; Secure
Set-Cookie: foo=foo)rrrrr	r0r!r!r"�test_extra_spaces�s


�zCookieTests.test_extra_spacescCr$)Nz3Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"r%r&r'r(r)r*r+r,r-r.r0r!r!r"�test_quoted_meta�s
�zCookieTests.test_quoted_metacCs@t��}dD]}|�|�|�t|�i�|�|��d�qdS)N)
z]foo=xz[foo=xz
blah]foo=xz
blah[foo=xzSet-Cookie: foo=barzSet-Cookie: foozfoo=bar; bazzbaz; foo=barzsecure;foo=barzVersion=1;foo=bar�)rrrrrr	)rr�sr!r!r"�test_invalid_cookies�s
�z CookieTests.test_invalid_cookiesc	Cs�d}d|}t��}|�|�|�|��|�ttjd�D]*}|j|d��t�	tj
||d��}|�|��|�Wd�n1sCwYqdS)Nz/Customer="WILE_E_COYOTE"; Path=/acme; Version=1zSet-Cookie: %s���proto)�protocol)rrrrr	�range�pickle�HIGHEST_PROTOCOLr@�loads�dumps)r�rawdataZexpected_outputrrQZC1r!r!r"�test_pickle�s
���zCookieTests.test_picklecCsHd}t��}|�tj��|�|�Wd�dS1swYdS)Nz
a=b; c,d=e)rr�assertRaises�CookieErrorr)rrXrr!r!r"�test_illegal_chars�s
"�zCookieTests.test_illegal_charscCsHt��}d|d<|�t|d�d�d|dd<|�t|d�d�dS)N�©rGzSet-Cookie: foo="\251"u
comment ©�commentz.Set-Cookie: foo="\251"; Comment="comment \251")rrr�str)rrr!r!r"�test_comment_quoting�s
�z CookieTests.test_comment_quotingN)�__name__�
__module__�__qualname__r#r1r4r;r>rArErFrIrJrKrNrYr\r`r!r!r!r"r
s 1

rc@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�MorselTestszTests for the Morsel object.cCsht��}|�|j�|�|j�|�|j�|�|��tjj���|�	�D]\}}|�|d|�q&dS�NrL)
r�MorselZassertIsNone�keyr�coded_valuer�keys�	_reservedr)r�morselrgr2r!r!r"�
test_defaults�s�zMorselTests.test_defaultscCszt��}|jD]}|�|�|��d|||<q|jD]}|�||d|�qd��D]}|�tj|j	|d|�q,dS)N�%s_valuezthe holy hand grenade)
rrfrjr9Z
isReservedKeyr�splitrZr[�__setitem__)r�M�ir!r!r"�test_reserved_keys�s

��zMorselTests.test_reserved_keysc	Cs�t��}|jD]}|�tj|j|d|d|�qd��D]H}d|d<|�|d|d|�|�|j|�|�|j	d|�|�|j
d|�|�|��d|d|f�d|d|f}|�|��|�qd	D]}|�tj|j|d|d|�qhdS)
Nrmz(thou cast _the- !holy! ^hand| +*grenade~z/foor)z%s_valz%s_coded_valzSet-Cookie: %s=%s; Path=/fooz�
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "%s=%s; Path=/foo";
        // end hiding -->
        </script>
        )zfoo barzfoo@bar)
rrfrjrZr[�setrnrrgrrhr	r/)rrprqZexpected_js_outputr!r!r"�test_setters0
��
���zMorselTests.test_settercCs�t��}|�t��d|_Wd�n1swY|�t��d|_Wd�n1s/wY|�t��d|_Wd�dS1sHwYdSre)rrfrZ�AttributeErrorrgrrh�rrkr!r!r"�test_set_properties$s��"�zMorselTests.test_set_propertiesc		Cs�d}ddddd�}t��}|�|�|j|�t��}|�|�|j|�|�||k�|�||k�d}|D]3}|�|��$t��}|�|�|j|�|�||k�|�||k�Wd�n1sewYq7t��}|�|�|j|�d|d	<|�||k�|�||k�|�t��d
k�|�t��d
k�|�t��dk�|�t��dk�tt�����}|�t��|k�|�t��|k�t��}|j|�|�|�|�|t	|�k�|�|t	|�k�dS)N)rgr�"value"�/rG�example.com�)r)r^�domainr'))rgr�mismatch)rgr}rx)r}rrxrHr^rOrL)
rrf�updatersr9rDr@�listrr)	rZ	base_case�attribs�morsel_a�morsel_brZcase_brrkr!r!r"�test_eq-sT�





��



zMorselTests.test_eqcCs�t��}|�ddd�|�ddd��|��}|�|tj�|�||�|�||�t�|�}|�|tj�|�||�|�||�dS)NrGrH�bazr{�r'r^)rrfrsr~�copy�assertIsInstanceZassertIsNotr)rr�r�r!r!r"�	test_copyas�
zMorselTests.test_copycCs�t��}d|d<|�|dd�d|d<|�|dd�d|d<|�|dd�|�tj��d	|d
<Wd�n1s=wY|�d
|�dS)Nrr6r{�Versionr'rz�DOMAINr|r�invalid)rrfrrZr[�assertNotInrvr!r!r"�test_setitemrs
�zMorselTests.test_setitemcCs�t��}|�ddd��|�|�dd�d�|�|dd�|�|�dd�d�|�|d	d�|�|�d
d�d�|�|dd�|�tj��|�dd�Wd�n1sYwY|�d|�dS)
Nrzr{)r|r'r6rrLr�rOr'r�r|r�)rrfr~r�
setdefaultrZr[r�rvr!r!r"�test_setdefaults��zMorselTests.test_setdefaultcCsPdddd�}t��}|�|�|�|dd�|�|dd�|�|dd�t��}|�t|����|�|dd�|�|dd�|�|dd�t��}|�dd	�|��D��|�|dd�|�|dd�|�|dd�|�tj��|�d
di�Wd�n1s�wY|�d
|�|�t	|j�|�t	|jd�dS)
NrOr{rz)r6r�r�r6r'r|css�|]	\}}||fVqdS�Nr!)�.0rr r!r!r"�	<genexpr>�s�z*MorselTests.test_update.<locals>.<genexpr>r�rr)
rrfr~rrrrZr[r��	TypeError)rr�rkr!r!r"�test_update�s,
�zMorselTests.test_updatec	Cs�t��}|�ddd�|�ddd��ttjd�D]8}|j|d��(t�t�	||��}|�
|tj�|�||�|�t|�t|��Wd�n1sMwYqdS)NrGrHr�r{r�rOrP)
rrfrsr~rSrTrUr@rVrWr�rr_)rr�rQr�r!r!r"rY�s����zMorselTests.test_picklec	Cst��}|�t|�d�|�t|�d�|�ddd�|�t|�d�|�t|�d�|�dd	d
dddd
��|�t|�d�|�t|�d�d|d<d|d<|�t|�d�|�t|�d�t��}|�ddd�d|d<|�t|�d�|�t|�d�dS)Nz<Morsel: None=None>zSet-Cookie: None=Nonergr2Z	coded_valz<Morsel: key=coded_val>zSet-Cookie: key=coded_valryrGrzrrO)r)r^r|r8r<r'zV<Morsel: key=coded_val; Comment=foo; Domain=example.com; Max-Age=0; Path=/; Version=1>zXSet-Cookie: key=coded_val; Comment=foo; Domain=example.com; Max-Age=0; Path=/; Version=1Tr<r=zh<Morsel: key=coded_val; Comment=foo; Domain=example.com; HttpOnly; Max-Age=0; Path=/; Secure; Version=1>zjSet-Cookie: key=coded_val; Comment=foo; Domain=example.com; HttpOnly; Max-Age=0; Path=/; Secure; Version=1r6zA<Morsel: key=coded_val; expires=\w+, \d+ \w+ \d+ \d+:\d+:\d+ \w+>zCSet-Cookie: key=coded_val; expires=\w+, \d+ \w+ \d+ \d+:\d+:\d+ \w+)rrfrrr_rsr~ZassertRegexrvr!r!r"�	test_repr�sJ�
�
�
�
�
�
�zMorselTests.test_reprN)rarbrc�__doc__rlrrrtrwr�r�r�r�r�rYr�r!r!r!r"rd�s		4
rdcCsttt�tt�dSr�)rrrdrrr!r!r!r"�	test_main�s
r��__main__)
r�Ztest.supportrrZunittest�httprrTZTestCaserrdr�rar!r!r!r"�<module>say
�