Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_http_cookies.cpython-38.pyc
U

>��g�J�@srddlZddlmZmZddlZddlmZddlZGdd�dej�Z	Gdd�dej�Z
dd	�Zed
krne�dS)�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]r}t��}|�|d�|�t|�|d �|�|jdd!�|d"�t|d#���D]\}}|�||j	|�q�qfdS)$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�casesZcase�C�k�v�r �5/opt/cppython/lib/python3.8/test/test_http_cookies.py�
test_basicsB������(zCookieTests.test_basiccCs�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	r.r 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	�endswithrrr.r r r!�test_special_attrs^s$

�
�

�zCookieTests.test_special_attrscCs6t�d�}d|dd<d|dd<|�|��d�dS)Nr3Tr#�secure�httponlyz6Set-Cookie: Customer="WILE_E_COYOTE"; HttpOnly; Securer1r.r r r!�test_set_secure_httponly_attrsus

�z*CookieTests.test_set_secure_httponly_attrsc
Cs�ddddg}|D]p}|j|d��Zt�d�}||dd<|�|��d	|�t��}|�d
|�|�|dd|�W5QRXqdS)NZStrictZLax�strictZlax)r0r3r#Zsamesitez1Set-Cookie: Customer="WILE_E_COYOTE"; SameSite=%sz%Customer="WILL_E_COYOTE"; SameSite=%s)�subTestrrrr	r)rZsamesite_valuesr0rr r r!�test_samesite_attrs|s

�zCookieTests.test_samesite_attrscCs:t��}|�d�|�|dd�|�|dd�dS)Nzeggs=scrambled; Path=/bacon�eggsr;r:)rrr�assertFalser.r r r!�)test_secure_httponly_false_if_not_present�s
z5CookieTests.test_secure_httponly_false_if_not_presentcCs:t��}|�d�|�|dd�|�|dd�dS)Nz-eggs=scrambled; httponly; secure; Path=/baconr@r;r:)rrrr7r.r 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=/baconr@r;r:�foo�bar)rrrr7rr.r 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	r.r r r!�test_extra_spaces�s


�zCookieTests.test_extra_spacescCs�t��}|�d�|�|djd�|�|ddd�|�|ddd�|�|�dg�d�|�|��d	�|�|�dg�d
�dS)Nz3Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"r#r$r%r&r'r(r)r*r+r,r.r r r!�test_quoted_meta�s
�zCookieTests.test_quoted_metacCs@t��}dD].}|�|�|�t|�i�|�|��d�qdS)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��}|�|��|�W5QRXq<dS)Nz/Customer="WILE_E_COYOTE"; Path=/acme; Version=1zSet-Cookie: %s���proto)�protocol)rrrrr	�range�pickle�HIGHEST_PROTOCOLr>�loads�dumps)r�rawdataZexpected_outputrrNZC1r r r!�test_pickle�s
zCookieTests.test_picklec	Cs2d}t��}|�tj��|�|�W5QRXdS)Nz
a=b; c,d=e)rr�assertRaises�CookieErrorr)rrUrr r r!�test_illegal_chars�szCookieTests.test_illegal_charscCsHt��}d|d<|�t|d�d�d|dd<|�t|d�d�dS)N�©rDzSet-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"r/r2r9r<r?rBrCrFrGrHrKrVrYr]r r r r!r
s1

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|�qLdS�NrI)
r�MorselZassertIsNone�keyr�coded_valuer�keys�	_reservedr)r�morselrdr0r r r!�
test_defaults�szMorselTests.test_defaultscCszt��}|jD] }|�|�|��d|||<q|jD]}|�||d|�q6d��D]}|�tj|j	|d|�qXdS)N�%s_valuezthe holy hand grenade)
rrcrgr7Z
isReservedKeyr�splitrWrX�__setitem__)r�M�ir r r!�test_reserved_keys�s

�zMorselTests.test_reserved_keysc	Cs�t��}|jD]"}|�tj|j|d|d|�qd��D]�}d|d<|�|d|d|�|�|j|�|�|j	d|�|�|j
d|�|�|��d|d|f�d|d|f}|�|��|�q:d	D]"}|�tj|j|d|d|�q�dS)
Nrjz(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)
rrcrgrWrX�setrkrrdrrer	r-)rrmrnZexpected_js_outputr r r!�test_setters:
��
��zMorselTests.test_setterc	Cs`t��}|�t��d|_W5QRX|�t��d|_W5QRX|�t��d|_W5QRXdSrb)rrcrW�AttributeErrorrdrre�rrhr r r!�test_set_properties$szMorselTests.test_set_propertiesc	
Cs�d}ddddd�}t��}|�|�|j|�t��}|�|�|j|�|�||k�|�||k�d}|D]R}|�|��>t��}|�|�|j|�|�||k�|�||k�W5QRXqnt��}|�|�|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)rdr�"value"�/rD�example.com�)r'r[�domainr%))rdr�mismatch)rdrzru)rzrrurEr[rLrI)
rrc�updaterpr7rAr>�listrr)	rZ	base_case�attribs�morsel_a�morsel_brZcase_brrhr r r!�test_eq-sP�









zMorselTests.test_eqcCs�t��}|�ddd�|�ddd��|��}|�|tj�|�||�|�||�t�|�}|�|tj�|�||�|�||�dS)NrDrE�bazrx�r%r[)rrcrpr{�copy�assertIsInstanceZassertIsNotr)rr~rr r r!�	test_copyas�
zMorselTests.test_copyc	Cs�t��}d|d<|�|dd�d|d<|�|dd�d|d<|�|dd�|�tj��d	|d
<W5QRX|�d
|�dS)Nrr4rx�Versionr%rw�DOMAINryr�invalid)rrcrrWrX�assertNotInrsr r r!�test_setitemrszMorselTests.test_setitemc	Cs�t��}|�ddd��|�|�dd�d�|�|dd�|�|�dd�d�|�|d	d�|�|�d
d�d�|�|dd�|�tj��|�dd�W5QRX|�d|�dS)
Nrwrx)ryr%r4rrIr�rLr%r�ryr�)rrcr{r�
setdefaultrWrXr�rsr r r!�test_setdefaults�zMorselTests.test_setdefaultc	Cs<dddd�}t��}|�|�|�|dd�|�|dd�|�|dd�t��}|�t|����|�|dd�|�|dd�|�|dd�t��}|�dd	�|��D��|�|dd�|�|dd�|�|dd�|�tj��|�d
di�W5QRX|�d
|�|�t	|j�|�t	|jd�dS)
NrLrxrw)r4r�r�r4r%rycss|]\}}||fVqdS�Nr )�.0rrr r r!�	<genexpr>�sz*MorselTests.test_update.<locals>.<genexpr>r�rr)
rrcr{rr|rrWrXr��	TypeError)rr}rhr r r!�test_update�s*
zMorselTests.test_updatec
Cs�t��}|�ddd�|�ddd��ttjd�D]\}|j|d��Ft�t�	||��}|�
|tj�|�||�|�t|�t|��W5QRXq4dS)NrDrEr�rxr�rLrM)
rrcrpr{rPrQrRr>rSrTr�rr\)rr~rNrr r r!rV�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=Nonerdr0Z	coded_valz<Morsel: key=coded_val>zSet-Cookie: key=coded_valrvrDrwrrL)r'r[ryr6r: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=1r4zA<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+)rrcrrr\rpr{ZassertRegexrsr r r!�	test_repr�sJ�
�
�
�
�
�
�zMorselTests.test_reprN)r^r_r`�__doc__rirorqrtr�r�r�r�r�rVr�r r r r!ra�s		4
racCsttt�tt�dSr�)rrrarrr r r r!�	test_main�s
r��__main__)
r�Ztest.supportrrZunittestZhttprrQZTestCaserrar�r^r r r r!�<module>say

F1le Man4ger