HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_http_cookies.cpython-312.opt-2.pyc
�

}h�e�J���ddlZddlZddlZddlmZddlZGd�dej�ZGd�dej�Zd�Z	e
dk(rej�yy)	�N)�cookiesc�f�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�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=hrr
)�seprr)
�joinr�SimpleCookie�load�assertEqualr
r�sorted�items�value)�self�cases�case�C�k�vs      �=/opt/alt/python312/lib64/python3.12/test/test_http_cookies.py�
test_basiczCookieTests.test_basics9��0�$�x�8�C�J�
L�
D��"A�B�Q�Q�
S�%��'�*�6�2�
4�,� �<�0�<�8�:�-� �c�s��<�A��)�)�%��	

�7&
��P�	0�D��$�$�&�A�
�F�F�4��<� ����T�!�W�d�6�l�3����Q�X�X�$�X�/��h��@��t�F�|�1�1�3�4�
0���1�� � ��1����Q�/�
0�	0�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_load=s���� � �"��	���@�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"�rrrrr6s  r'�test_extended_encodez CookieTests.test_extended_encodeVs9��
� � �"��%��%��������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�endswithrrr6s  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)Nr=Tr+�secure�httponlyz6Set-Cookie: Customer="WILE_E_COYOTE"; HttpOnly; Securer:r6s  r'�test_set_secure_httponly_attrsz*CookieTests.test_set_secure_httponly_attrsusI��� � �!;�<��"&��*�
�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)r9r=r+�samesitez1Set-Cookie: Customer="WILE_E_COYOTE"; SameSite=%sz%Customer="WILL_E_COYOTE"; SameSite=%s)�subTestrrrrr)r!�samesite_valuesr9r$s    r'�test_samesite_attrszCookieTests.test_samesite_attrs|s���<��"�		A�C����#��&�
A��(�(�)C�D��,/��*�
�j�)�� � �����G�#�M�O��(�(�*�����>��D�E�� � ��:��z�!:�C�@�
A�
A�		A�
A�
A�s�BB(�(B1	c��tj�}|jd�|j|dd�|j|dd�y)Nzeggs=scrambled; Path=/bacon�eggsrGrF)rrr�assertFalser6s  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=/baconrSrGrF)rrrrBr6s  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=/baconrSrGrF�foo�bar)rrrrBrr6s  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)rrrrrr6s  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/r0r1r2r3r4r6s  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�sX��� � �"��9�	-�A�
�F�F�1�I����T�!�W�b�)����Q�X�X�Z��,�
	-r)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_PROTOCOLrO�loads�dumps)r!�rawdata�expected_outputr$rg�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�>�
?�
?�	?�
?�
?�s
�>AC�C	c��d}tj�}|jtj�5|j	|�ddd�y#1swYyxYw)Nz
a=b; c,d=e)rr�assertRaises�CookieErrorr)r!rnr$s   r'�test_illegal_charszCookieTests.test_illegal_chars�sI����� � �"��
�
�
�w�2�2�
3�	�
�F�F�7�O�	�	�	�s�A�Ac��tj�}d|d<|jt|d�d�d|dd<|jt|d�d�y)N�©rYzSet-Cookie: foo="\251"u
comment ©�commentz.Set-Cookie: foo="\251"; Comment="comment \251")rrr�str)r!rs  r'�test_comment_quotingz CookieTests.test_comment_quoting�s\��� � �"��'��%������Q�u�X��(A�B�:��%���������%��M�>�	
r)N)�__name__�
__module__�__qualname__r(r7r;rDrHrQrUrWr[r]r_rcrqrurz�r)r'rr
sR��/0�b
�2:�M�.F�A�.�-�
5�S�
�2	-�?��
r)rc�P�eZdZ	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
y)
�MorselTestsc��tj�}|j|j�|j|j�|j|j
�|j
|j�tjjj��|j�D]\}}|j
|d|��y�Nra)
r�Morsel�assertIsNone�keyr �coded_valuer�keys�	_reservedr)r!�morselr�r9s    r'�
test_defaultszMorselTests.test_defaults�s������!�����&�*�*�%����&�,�,�'����&�,�,�-�����������(@�(@�(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�rB�
isReservedKeyr�splitrsrt�__setitem__)r!�M�is   r'�test_reserved_keyszMorselTests.test_reserved_keys�s����N�N������	"�A��O�O�A�O�O�A�.�/���>�A�a�D�	"����	3�A����Q�q�T�:��>�2�	3�)�.�.�0�	@�A����g�1�1��m�m�Q�
�Q��
@�	@r)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�rsrt�setr�rr�r r�rr5)r!r�r��expected_js_outputs    r'�test_setterzMorselTests.test_setterse���N�N������	H�A����g�1�1��e�e�Q�
�Q��
�Q��
H�	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�[�[�]�,>�?�%	@�&(�	H�A����g�1�1��e�e�Q�
�Q��
�Q��
H�	Hr)c�R�tj�}|jt�5d|_ddd�|jt�5d|_ddd�|jt�5d|_ddd�y#1swY�TxYw#1swY�;xYw#1swYyxYwr�)rr�rs�AttributeErrorr�r r��r!r�s  r'�test_set_propertieszMorselTests.test_set_properties$s������!��
�
�
�~�
.�	��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"�/rY�example.com�)r/rx�domainr-))r�r �mismatch)r�r�r�)r�r r�rZrxrera)
rr��updater�rBrTrO�listrr)	r!�	base_case�attribs�morsel_a�morsel_br"�case_brr�s	         r'�test_eqzMorselTests.test_eq-sp��/�	���#��	
���>�>�#������ �����i� ��>�>�#������ �����i� �����H�,�-�����X�-�.�
��
�	6�F����f�%�
6�"�>�>�+������(�����f�%�� � ��X�!5�6�����H� 4�5�
6�
6�	6��>�>�#������ �����i� �#��������X�-�.�����H�,�-�	
������)�Q�.�/�������(�A�-�.�������)�R�/�0�������(�B�.�/��W�^�^�%�+�+�-�.��������)�U�2�3�������(�E�1�2����!����
�
�I���
�
�g������$�v�,�.�/�����4��<�/�0�9
6�
6�s
�2AK8�8L	c���tj�}|jddd�|jddd��|j	�}|j|tj�|j
||�|j||�t	j|�}|j|tj�|j
||�|j||�y)NrYrZ�bazr��r-rx)rr�r�r��copy�assertIsInstance�assertIsNotr)r!r�r�s   r'�	test_copyzMorselTests.test_copyas����>�>�#�����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)Nrr>r��Versionr-r��DOMAINr�r �invalid)rr�rrsrt�assertNotInr�s  r'�test_setitemzMorselTests.test_setitemrs������!����y������	�*�A�.���y������	�*�A�.�(��x�������)�=�9�
�
�
�w�2�2�
3�	(� '�F�9��	(�����F�+�	(�	(�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-r>r rar�rer-r�r�r�)rr�r�r�
setdefaultrsrtr�r�s  r'�test_setdefaultzMorselTests.test_setdefaults�����!���
�
�#��
�	�
	
����*�*�9�g�>��C�����	�*�B�/�����*�*�9�a�8�!�<�����	�*�A�.�����*�*�8�W�=�}�M������)�=�9�
�
�
�w�2�2�
3�	2����i��1�	2�����F�+�	2�	2�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)Nrer�r�)r>r�r�r>r-r�c3�*K�|]\}}||f���
y�w�Nr~)�.0r%r&s   r'�	<genexpr>z*MorselTests.test_update.<locals>.<genexpr>�s����9���A�q�!�f�9�s�r�r r)
rr�r�rr�rrsrtr��	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�	0��M�M�9�g�.�/�	0�����F�+����)�V�]�]�3����)�V�]�]�A�6�		0�	0�s�>G.�.G7c��tj�}|jddd�|jddd��t	t
jdz�D]�}|j|��5tjtj||��}|j|tj�|j||�|jt|�t|��ddd���y#1swY��xYw)NrYrZr�r�r�rerf)
rr�r�r�rirjrkrOrlrmr�rry)r!r�rgr�s    r'rqzMorselTests.test_pickle�s����>�>�#�����U�E�5�)������
�	��6�2�2�Q�6�7�	?�E����E��*�
?�!�<�<����X�u�(E�F���%�%�h����?�� � ��8�4�� � ��X���H�
�>�	
?�
?�	?�
?�
?�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�r9�	coded_valz<Morsel: key=coded_val>zSet-Cookie: key=coded_valr�rYr�rre)r/rxr�rArFr-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=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+)rr�rr
ryr�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}r�r�r�r�r�r�r�r�r�rqr�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��httprrj�TestCaserr�r�r{�mainr~r)r'�<module>r�s_������
�]
�(�#�#�]
�@v=�(�#�#�v=�r�
�z���H�M�M�O�r)