Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_http_cookies.cpython-312.pyc

�

'ΜgP����ddlZddlZddlZddlmZddlZddlmZGd�dej�Z	Gd�dej�Z
d�Zed	k(rej�yy)
�N)�cookies)�supportc��eZdZd�Zd�Zejd�d��Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zy)�CookieTestsc
���dddd�ddd�dd	d
iddd�d
d	diddd�dddiddd�dddddd�ddjd�d�g}|D]�}tj�}|j|d�|j	t|�|d �|j	|j
d�!�|d"�t|d#j��D]$\}}|j	||j|��&��y)$Nzchips=ahoy; vienna=finger�ahoy�finger)�chips�viennaz,<SimpleCookie: chips='ahoy' vienna='finger'>z0Set-Cookie: chips=ahoy
Set-Cookie: vienna=finger)�data�dict�repr�outputz)keebler="E=mc2; L=\"Loves\"; fudge=\012;"�keeblerzE=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=hrr)�seprr
)
�joinr�SimpleCookie�load�assertEqualrr�sorted�items�value)�self�cases�case�C�k�vs      �3/usr/local/lib/python3.12/test/test_http_cookies.py�
test_basiczCookieTests.test_basic
s/��0�$�x�8�C�J�
L�
D��"A�B�Q�Q�
S�%��'�*�6�2�
4�,� �<�0�<�8�:�-� �c�s��<�A��)�)�%��	

�7&
��P�D��$�$�&�A�
�F�F�4��<� ����T�!�W�d�6�l�3����Q�X�X�$�X�/��h��@��t�F�|�1�1�3�4���1�� � ��1����Q�/�5��c���gd�}|D]c\}}|j|�5tj�}|j|�|j	|dj
|�ddd��ey#1swY�pxYw)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!)r"r#�encoded�decodedr%s     r(�test_unquotezCookieTests.test_unquote>sf��
��"!&��G�W����g�&��(�(�*�����w��� � ��3����w�7�'�&�!&�&�&�s�AA.�.A7	�cpuc�p�d}dD]�}|j|�5d||zzdz}tj�}|j|�|dj}|j|ddd�|j|ddd	�|jt
|�|dz�ddd���y#1swY��xYw)
Ni@B)z\\z\134za="b=z;"r�r-���z\;)r/rrrr!r�len)r"�nr0rr%r!s      r(�test_unquote_largezCookieTests.test_unquote_largeVs�����%�G����g�&�����*�T�1���(�(�*�����t���#������ � ��r���F�3�� � ��r�s��U�3�� � ��U��Q��U�3�'�&�&�&�&�s�BB,�,B5	c��tj�}|jd�|j|djd�|j|ddd�|j|ddd�|j|jdg�d�|j|j
�d	�|j|j
dg�d
�y)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>
        �rrrrr!r�	js_output�r"r%s  r(�	test_loadzCookieTests.test_loadcs���� � �"��	���@�A�����:��,�,�o�>�����:��y�1�3�7�����:��v�.��8�������6�(�+�>�	@��������)�	
�	
������f�X�.�1�	
r*c�z�tj�}d|d<|j|jdg�d�y)Nzsome,funky;stuff�valz(Set-Cookie: val="some\054funky\073stuff"�rrrrrFs  r(�test_extended_encodez CookieTests.test_extended_encode|s9��
� � �"��%��%��������5�'�*�8�	:r*c��tjd�}d|dd<|j|j�j	d��tj�}|jd�|j
|ddd�tj�}|jd�|j
|ddd	�tjd�}d
|dd<|j
|j�d�y)
N�Customer="WILE_E_COYOTE"rr;�expires�GMTz3Customer="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�endswithrrrFs  r(�test_special_attrszCookieTests.test_special_attrs�s���� � �!;�<��#$��*�
�i� �������
�+�+�E�2�3�
� � �"��	���D�E�����:��y�1�8�	:�� � �"��	���B�C�����:��y�1�6�	8�
� � �!;�<��#%��*�
�i� ��������K�	Mr*c��tjd�}d|dd<d|dd<|j|j�d�y)NrMTr;�secure�httponlyz6Set-Cookie: Customer="WILE_E_COYOTE"; HttpOnly; SecurerJrFs  r(�test_set_secure_httponly_attrsz*CookieTests.test_set_secure_httponly_attrs�sI��� � �!;�<��"&��*�
�h��$(��*�
�j�!��������D�	Fr*c�h�gd�}|D]�}|j|��5tjd�}||dd<|j|j	�d|z�tj�}|jd|z�|j|dd|�ddd���y#1swY��xYw)N)�Strict�Lax�strict�lax)rIrMr;�samesitez1Set-Cookie: Customer="WILE_E_COYOTE"; SameSite=%sz%Customer="WILL_E_COYOTE"; SameSite=%s)r/rrrrr)r"�samesite_valuesrIr%s    r(�test_samesite_attrszCookieTests.test_samesite_attrs�s���<��"�C����#��&��(�(�)C�D��,/��*�
�j�)�� � �����G�#�M�O��(�(�*�����>��D�E�� � ��:��z�!:�C�@�'�&�#�&�&�s�BB(�(B1	c��tj�}|jd�|j|dd�|j|dd�y)Nzeggs=scrambled; Path=/bacon�eggsrWrV)rrr�assertFalserFs  r(�)test_secure_httponly_false_if_not_presentz5CookieTests.test_secure_httponly_false_if_not_present�sK��� � �"��	���,�-�����6��:�.�/�����6��8�,�-r*c��tj�}|jd�|j|dd�|j|dd�y)Nz-eggs=scrambled; httponly; secure; Path=/baconrbrWrV)rrrrRrFs  r(�$test_secure_httponly_true_if_presentz0CookieTests.test_secure_httponly_true_if_present�sG��� � �"��	���>�?�����&�	�*�-�.�����&�	�(�+�,r*c�
�tj�}|jd�|j|dd�|j|dd�|j	|ddd�|j	|ddd�y)Nz5eggs=scrambled; httponly=foo; secure=bar; Path=/baconrbrWrV�foo�bar)rrrrRrrFs  r(�'test_secure_httponly_true_if_have_valuez3CookieTests.test_secure_httponly_true_if_have_value�s}��
� � �"��	���F�G�����&�	�*�-�.�����&�	�(�+�,�	
����6��:�.��6�����6��8�,�e�4r*c��tj�}|jd�|j|j	�d�y)Nz=eggs  =  scrambled  ;  secure  ;  path  =  bar   ; foo=foo   zASet-Cookie: eggs=scrambled; Path=bar; Secure
Set-Cookie: foo=foo)rrrrrrFs  r(�test_extra_spaceszCookieTests.test_extra_spaces�s7��� � �"��	���N�O��������Q�	Sr*c��tj�}|jd�|j|djd�|j|ddd�|j|ddd�|j|jdg�d�|j|j
�d	�|j|j
dg�d
�y)Nz3Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"r;r<r=r>r?r@rArBrCrDrFs  r(�test_quoted_metazCookieTests.test_quoted_meta�s���� � �"��	���D�E�����:��,�,�o�>�����:��y�1�3�7�����:��v�.��8�������6�(�+�K�	M��������)�	
�	
������f�X�.�1�	
r*c���tj�}dD]N}|j|�|jt	|�i�|j|j�d��Py)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�)rrrrr
r)r"r%�ss   r(�test_invalid_cookiesz CookieTests.test_invalid_cookies�sS��� � �"��9�A�
�F�F�1�I����T�!�W�b�)����Q�X�X�Z��,�
9r*c��d}d|z}tj�}|j|�|j|j	�|�ttjdz�D]g}|j|��5t
jt
j||���}|j|j	�|�ddd��iy#1swY�txYw)Nz/Customer="WILE_E_COYOTE"; Path=/acme; Version=1zSet-Cookie: %s���proto)�protocol)rrrrr�range�pickle�HIGHEST_PROTOCOLr/�loads�dumps)r"�rawdata�expected_outputr%rv�C1s      r(�test_picklezCookieTests.test_pickle�s���C��*�W�4��� � �"��	���w���������_�5��6�2�2�Q�6�7�E����E��*��\�\�&�,�,�q�5�"A�B��� � �����o�>�+�*�8�*�*�s
�>AC�C	c��d}tj�}|jtj�5|j	|�ddd�y#1swYyxYw)Nz
a=b; c,d=e)rr�assertRaises�CookieErrorr)r"r}r%s   r(�test_illegal_charszCookieTests.test_illegal_chars�s@����� � �"��
�
�
�w�2�2�
3�
�F�F�7�O�4�
3�
3�s�A�Ac��tj�}d|d<|jt|d�d�d|dd<|jt|d�d�y)N�©rhzSet-Cookie: foo="\251"u
comment ©�commentz.Set-Cookie: foo="\251"; Comment="comment \251")rrr�str)r"rs  r(�test_comment_quotingz CookieTests.test_comment_quotings\��� � �"��'��%������Q�u�X��(A�B�:��%���������%��M�>�	
r*N)�__name__�
__module__�__qualname__r)r2r�requires_resourcer9rGrKrTrXr`rdrfrjrlrnrrr�r�r��r*r(rrsx��/0�b8�0�W���u�%�
4�&�
4�
�2:�M�.F�A�.�-�
5�S�
�2	-�?��
r*rc�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�MorselTestszTests for the Morsel object.c��tj�}|j|j�|j|j�|j|j
�|j
|j�tjjj��|j�D]\}}|j
|d|��y�Nrp)
r�Morsel�assertIsNone�keyr!�coded_valuer�keys�	_reservedr )r"�morselr�rIs    r(�
test_defaultszMorselTests.test_defaultss������!�����&�*�*�%����&�,�,�'����&�,�,�-�����������(@�(@�(E�(E�(G�H�����H�C�����S�"�c�*�'r*c�x�tj�}|jD]*}|j|j	|��d|z||<�,|jD]}|j||d|z��dj
�D]1}|jtj|j|d|z��3y)N�%s_valuezthe holy hand grenade)
rr�r�rR�
isReservedKeyr�splitr�r��__setitem__)r"�M�is   r(�test_reserved_keyszMorselTests.test_reserved_keyss����N�N������A��O�O�A�O�O�A�.�/���>�A�a�D�����A����Q�q�T�:��>�2��)�.�.�0�A����g�1�1��m�m�Q�
�Q��
@�1r*c	���tj�}|jD]5}|jtj|j
|d|zd|z��7dj
�D]�}d|d<|j|d|zd|z�|j|j|�|j|jd|z�|j|jd|z�|j|j�d|�dd|z�d	��d
|�dd|z�d�}|j|j�|���dD]5}|jtj|j
|d|zd|z��7y)
Nr�z(thou cast _the- !holy! ^hand| +*grenade~z/foor?z%s_valz%s_coded_valzSet-Cookie: �=z; Path=/fooz^
        <script type="text/javascript">
        <!-- begin hiding
        document.cookie = "zB; Path=/foo";
        // end hiding -->
        </script>
        )zfoo barzfoo@bar)
rr�r�r�r��setr�rr�r!r�rrE)r"r�r��expected_js_outputs    r(�test_setterzMorselTests.test_setter+sQ���N�N������A����g�1�1��e�e�Q�
�Q��
�Q��
H��<�A�A�C�A��A�f�I�
�E�E�!�X��\�>�A�#5�6����Q�U�U�A�&����Q�W�W�h��l�3����Q�]�]�N�Q�,>�?�������
�23�^�a�5G�H�
J��.�1�$�
"&��
���Q�[�[�]�,>�?�%D�&(�A����g�1�1��e�e�Q�
�Q��
�Q��
H�(r*c�R�tj�}|jt�5d|_ddd�|jt�5d|_ddd�|jt�5d|_ddd�y#1swY�TxYw#1swY�;xYw#1swYyxYwr�)rr�r��AttributeErrorr�r!r��r"r�s  r(�test_set_propertieszMorselTests.test_set_propertiesJsw�����!��
�
�
�~�
.��F�J�/�
�
�
�~�
.��F�L�/�
�
�
�~�
.�!#�F��/�
.�	/�
.��
.�
.��
.�
.�s#�B�B�4B�B�B�B&c�
�d}ddddd�}tj�}|j|�|j|�tj�}|j|�|j|�|j	||k(�|j||k7�d}|D]x}|j
|�5tj�}|j|�|j|�|j||k(�|j	||k7�ddd��ztj�}|j|�|j|�d|d	<|j||k(�|j	||k7�|jtj�d
k(�|j	tj�d
k7�|jtj�dk(�|j	tj�dk7�ttj�j��}|jtj�|k(�|j	tj�|k7�tj�}|j|�|j|�|j	|t|�k(�|j|t|�k7�y#1swY��dxYw)N)r�r!�"value"�/rh�example.com�)r?r��domainr=))r�r!�mismatch)r�r�r�)r�r!r�rir�rtrp)
rr��updater�rRrcr/�listr r
)	r"�	base_case�attribs�morsel_a�morsel_br#�case_br r�s	         r(�test_eqzMorselTests.test_eqSsb��/�	���#��	
���>�>�#������ �����i� ��>�>�#������ �����i� �����H�,�-�����X�-�.�
��
�F����f�%�"�>�>�+������(�����f�%�� � ��X�!5�6�����H� 4�5�&�%���>�>�#������ �����i� �#��������X�-�.�����H�,�-�	
������)�Q�.�/�������(�A�-�.�������)�R�/�0�������(�B�.�/��W�^�^�%�+�+�-�.��������)�U�2�3�������(�E�1�2����!����
�
�I���
�
�g������$�v�,�.�/�����4��<�/�0�9&�%�s
�2AK8�8L	c���tj�}|jddd�|jddd��|j	�}|j|tj�|j
||�|j||�t	j|�}|j|tj�|j
||�|j||�y)Nrhri�bazr��r=r�)rr�r�r��copy�assertIsInstance�assertIsNotr)r"r�r�s   r(�	test_copyzMorselTests.test_copy�s����>�>�#�����U�E�5�)������
�	��=�=�?�����h����7�����8�,�����8�,��9�9�X�&�����h����7�����8�,�����8�,r*c�^�tj�}d|d<|j|dd�d|d<|j|dd�d|d<|j|dd�|jtj�5d	|d
<ddd�|jd
|�y#1swY�xYw)NrrNr��Versionr=r��DOMAINr�r!�invalid)rr�rr�r��assertNotInr�s  r(�test_setitemzMorselTests.test_setitem�s������!����y������	�*�A�.���y������	�*�A�.�(��x�������)�=�9�
�
�
�w�2�2�
3� '�F�9��4�����F�+�4�
3�s�B#�#B,c�N�tj�}|jddd��|j|j	dd�d�|j|dd�|j|j	dd�d�|j|d	d�|j|j	d
d�d�|j|dd�|jtj�5|j	dd�ddd�|jd|�y#1swY�xYw)
Nr�r�)r�r=rNr!rpr�rtr=r�r�r�)rr�r�r�
setdefaultr�r�r�r�s  r(�test_setdefaultzMorselTests.test_setdefault�s������!���
�
�#��
�	�
	
����*�*�9�g�>��C�����	�*�B�/�����*�*�9�a�8�!�<�����	�*�A�.�����*�*�8�W�=�}�M������)�=�9�
�
�
�w�2�2�
3����i��1�4�����F�+�4�
3�s�-D�D$c���dddd�}tj�}|j|�|j|dd�|j|dd�|j|dd�tj�}|jt	|j���|j|dd�|j|dd�|j|dd�tj�}|jd�|j�D��|j|dd�|j|dd�|j|dd�|j
tj�5|jd	d
i�ddd�|jd	|�|j
t|j�|j
t|jd�y#1swY�]xYw)Nrtr�r�)rNr�r�rNr=r�c3�*K�|]\}}||f���
y�w�Nr�)�.0r&r's   r(�	<genexpr>z*MorselTests.test_update.<locals>.<genexpr>�s����9����A�q�!�f��s�r�r!r)
rr�r�rr�r r�r�r��	TypeError)r"r�r�s   r(�test_updatezMorselTests.test_update�s����A��G�����!���
�
�g������	�*�A�.�����	�*�A�.������)�=�9����!���
�
�d�7�=�=�?�+�,�����	�*�A�.�����	�*�A�.������)�=�9����!���
�
�9�����9�9�����	�*�A�.�����	�*�A�.������)�=�9�
�
�
�w�2�2�
3��M�M�9�g�.�/�4�����F�+����)�V�]�]�3����)�V�]�]�A�6�	4�
3�s�>G.�.G7c��tj�}|jddd�|jddd��t	t
jdz�D]�}|j|��5tjtj||��}|j|tj�|j||�|jt|�t|��ddd���y#1swY��xYw)Nrhrir�r�r�rtru)
rr�r�r�rxryrzr/r{r|r�rr�)r"r�rvr�s    r(r�zMorselTests.test_pickle�s����>�>�#�����U�E�5�)������
�	��6�2�2�Q�6�7�E����E��*�!�<�<����X�u�(E�F���%�%�h����?�� � ��8�4�� � ��X���H�
�>�	+�*�8�*�*�s
�-BC8�8D	c	�
�tj�}|jt|�d�|jt	|�d�|jddd�|jt|�d�|jt	|�d�|j
dd	d
dddd
��|jt|�d�|jt	|�d�d|d<d|d<|jt|�d�|jt	|�d�tj�}|jddd�d|d<|jt|�d�|jt	|�d�y)Nz<Morsel: None=None>zSet-Cookie: None=Noner�rI�	coded_valz<Morsel: key=coded_val>zSet-Cookie: key=coded_valr�rhr�rrt)r?r�r�rQrVr=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=1TrVrWzh<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=1rNzA<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+)rr�rrr�r�r��assertRegexr�s  r(�	test_reprzMorselTests.test_repr�su�����!������f��'<�=�����V��&=�>��
�
�5�%��-�����f��'@�A�����V��&A�B��
�
���#����

�	�	
����f��0�	1�	
����V��/�	0� ��x����z������f��B�	C�	
����V��A�	B����!���
�
�5�%��-���y������f��=�	>�	
����V��<�	=r*N)r�r�r��__doc__r�r�r�r�r�r�r�r�r�r�r�r�r*r(r�r�s?��&�+�
@�H�>$�21�h-�",�,�$7�6?�&=r*r�c�V�|jtjt��|Sr�)�addTest�doctest�DocTestSuiter)�loader�tests�patterns   r(�
load_testsr�	s��	�M�M�'�&�&�w�/�0��Lr*�__main__)r��unittestr��httprry�testr�TestCaserr�r�r��mainr�r*r(�<module>r�sb������
��B
�(�#�#�B
�Jv=�(�#�#�v=�r�
�z���H�M�M�O�r*

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