Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_http_cookies.cpython-39.pyc

a

��gP�@s~ddlZddlmZmZddlZddlmZddlZddlm	Z	Gdd�dej
�ZGdd�dej
�Zd	d
�Z
edkrze
�dS)�N)�run_unittest�run_doctest)�cookies)�supportc@s�eZdZdd�Zdd�Ze�d�dd��Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$S)%�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�assertEqualr	r
�sorted�items�value)�self�casesZcase�C�k�v�r!�2/usr/local/lib/python3.9/test/test_http_cookies.py�
test_basic
sB������(zCookieTests.test_basicc	Cshgd�}|D]V\}}|�|��4t��}|�|�|�|dj|�Wd�q1sX0YqdS)N))za="b=\""�b=")za="b=\\"�b=\)za="b=\="zb==)za="b=\n"zb=n)z
a="b=\042"r$)z
a="b=\134"r%)z
a="b=\377"ub=ÿ)z
a="b=\400"zb=400)z	a="b=\42"zb=42)za="b=\\042"zb=\042)za="b=\\134"zb=\134)z
a="b=\\\""�b=\")za="b=\\\042"r&)za="b=\134\""r&)za="b=\134\042"r&r)�subTestrrrrr)rr�encodedZdecodedrr!r!r"�test_unquote>s
zCookieTests.test_unquoteZcpuc	Cs�d}dD]�}|�|��xd||d}t��}|�|�|dj}|�|dd�d�|�|dd�d	�|�t|�|d�Wd�q1s�0YqdS)
Ni@B)z\\z\134za="b=z;"r�r%���z\;)r'rrrrr�len)r�nr(rrrr!r!r"�test_unquote_largeVs

zCookieTests.test_unquote_largecCs�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_loadcs
�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_encode|s
�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)Nr?Tr/�secure�httponlyz6Set-Cookie: Customer="WILE_E_COYOTE"; HttpOnly; Securer=r:r!r!r"�test_set_secure_httponly_attrs�s

�z*CookieTests.test_set_secure_httponly_attrsc	Cs�gd�}|D]�}|j|d��dt�d�}||dd<|�|��d|�t��}|�d|�|�|dd|�Wd�q1s�0YqdS)N)ZStrictZLax�strictZlax)r<r?r/Zsamesitez1Set-Cookie: Customer="WILE_E_COYOTE"; SameSite=%sz%Customer="WILL_E_COYOTE"; SameSite=%s)r'rrrr
r)rZsamesite_valuesr<rr!r!r"�test_samesite_attrs�s

�zCookieTests.test_samesite_attrscCs:t��}|�d�|�|dd�|�|dd�dS)Nzeggs=scrambled; Path=/bacon�eggsrGrF)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=/baconrKrGrF)rrrrCr: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=/baconrKrGrF�foo�bar)rrrrCrr: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/r0r1r2r3r4r5r6r7r8r: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]T}|j|d��4t�	tj
||d��}|�|��|�Wd�q<1s�0Yq<dS)Nz/Customer="WILE_E_COYOTE"; Path=/acme; Version=1zSet-Cookie: %s���proto)�protocol)rrrrr
�range�pickle�HIGHEST_PROTOCOLr'�loads�dumps)r�rawdataZexpected_outputrrYZC1r!r!r"�test_pickle�s
zCookieTests.test_picklecCsFd}t��}|�tj��|�|�Wd�n1s80YdS)Nz
a=b; c,d=e)rr�assertRaises�CookieErrorr)rr`rr!r!r"�test_illegal_chars�szCookieTests.test_illegal_charscCsHt��}d|d<|�t|d�d�d|dd<|�t|d�d�dS)N�©rOzSet-Cookie: foo="\251"u
comment ©�commentz.Set-Cookie: foo="\251"; Comment="comment \251")rrr�str)rrr!r!r"�test_comment_quotings
�z CookieTests.test_comment_quotingN)�__name__�
__module__�__qualname__r#r)rZrequires_resourcer.r;r>rErHrJrMrNrQrRrSrVrardrhr!r!r!r"rs$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|�qLdS�NrT)
r�MorselZassertIsNone�keyr�coded_valuer�keys�	_reservedr)r�morselror<r!r!r"�
test_defaultsszMorselTests.test_defaultscCszt��}|jD] }|�|�|��d|||<q|jD]}|�||d|�q6d��D]}|�tj|j	|d|�qXdS)N�%s_valuezthe holy hand grenade)
rrnrrrCZ
isReservedKeyr�splitrbrc�__setitem__)r�M�ir!r!r"�test_reserved_keyss

�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)
Nruz(thou cast _the- !holy! ^hand| +*grenade~z/foor3z%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)
rrnrrrbrc�setrvrrorrpr
r9)rrxryZexpected_js_outputr!r!r"�test_setter+s.
��
��zMorselTests.test_settercCs�t��}|�t��d|_Wd�n1s.0Y|�t��d|_Wd�n1s^0Y|�t��d|_Wd�n1s�0YdSrm)rrnrb�AttributeErrorrorrp�rrsr!r!r"�test_set_propertiesJs$$zMorselTests.test_set_propertiesc		Cs�d}ddddd�}t��}|�|�|j|�t��}|�|�|j|�|�||k�|�||k�d}|D]f}|�|��Ht��}|�|�|j|�|�||k�|�||k�Wd�qn1s�0Yqnt��}|�|�|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)ror�"value"�/rO�example.com�)r3rf�domainr1))ror�mismatch)ror�r�)r�rr�rPrfrWrT)
rrn�updater{rCrLr'�listrr)	rZ	base_case�attribs�morsel_a�morsel_brZcase_brrsr!r!r"�test_eqSsP�





.



zMorselTests.test_eqcCs�t��}|�ddd�|�ddd��|��}|�|tj�|�||�|�||�t�|�}|�|tj�|�||�|�||�dS)NrOrP�bazr��r1rf)rrnr{r��copy�assertIsInstanceZassertIsNotr)rr�r�r!r!r"�	test_copy�s�
zMorselTests.test_copycCs�t��}d|d<|�|dd�d|d<|�|dd�d|d<|�|dd�|�tj��d	|d
<Wd�n1sz0Y|�d
|�dS)Nrr@r��Versionr1r��DOMAINr�r�invalid)rrnrrbrc�assertNotInr~r!r!r"�test_setitem�s&zMorselTests.test_setitemcCs�t��}|�ddd��|�|�dd�d�|�|dd�|�|�dd�d�|�|d	d�|�|�d
d�d�|�|dd�|�tj��|�dd�Wd�n1s�0Y|�d|�dS)
Nr�r�)r�r1r@rrTr�rWr1r�r�r�)rrnr�r�
setdefaultrbrcr�r~r!r!r"�test_setdefault�s�*zMorselTests.test_setdefaultcCsRdddd�}t��}|�|�|�|dd�|�|dd�|�|dd�t��}|�t|����|�|dd�|�|dd�|�|dd�t��}|�dd	�|��D��|�|dd�|�|dd�|�|dd�|�tj��|�d
di�Wd�n1�s0Y|�d
|�|�t	|j�|�t	|jd�dS)
NrWr�r�)r@r�r�r@r1r�css|]\}}||fVqdS�Nr!)�.0rr r!r!r"�	<genexpr>��z*MorselTests.test_update.<locals>.<genexpr>r�rr)
rrnr�rr�rrbrcr��	TypeError)rr�rsr!r!r"�test_update�s*
.zMorselTests.test_updatec	Cs�t��}|�ddd�|�ddd��ttjd�D]p}|j|d��Pt�t�	||��}|�
|tj�|�||�|�t|�t|��Wd�q41s�0Yq4dS)NrOrPr�r�r�rWrX)
rrnr{r�r[r\r]r'r^r_r�rrg)rr�rYr�r!r!r"ra�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=Noneror<Z	coded_valz<Morsel: key=coded_val>zSet-Cookie: key=coded_valr�rOr�rrW)r3rfr�rBrFr1zV<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=1TrFrGzh<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=1r@zA<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+)rrnrr	rgr{r�ZassertRegexr~r!r!r"�	test_repr�sJ�
�
�
�
�
�
�zMorselTests.test_reprN)rirjrk�__doc__rtrzr|rr�r�r�r�r�rar�r!r!r!r"rls		4
rlcCsttt�tt�dSr�)rrrlrrr!r!r!r"�	test_mains
r��__main__)r�Ztest.supportrrZunittest�httprr\�testrZTestCaserrlr�rir!r!r!r"�<module>sy

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists