403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/zmq/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/zmq/tests/__pycache__/test_auth.cpython-311.pyc
�

mc�cS����ddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
Gd�de��ZGd�de��Zdd	�Zd
�Zd�ZGd�d
e��ZdS)�N)�ThreadAuthenticator)�BaseZMQTestCase�SkipTest�	skip_pypyc�L��eZdZ�fd�Zd�Zd�Zd�Z�fd�Zd�Zd�Z	d�Z
�xZS)	�BaseAuthTestCasec���tj��dkrtd���	tj��n"#tj$rtd���wxYwt�����tjd���	tj
��|���|_|�
��\|_|_|_|���dS)N)�rzsecurity is new in libzmq 4.0z.security requires libzmq to have curve supportzzmq.auth)�zmq�zmq_version_infor�
curve_keypair�ZMQError�super�setUp�logging�	getLogger�setLevel�DEBUG�	make_auth�auth�create_certs�base_dir�public_keys_dir�secret_keys_dir�
start_auth��self�	__class__s ��5/usr/lib/python3/dist-packages/zmq/tests/test_auth.pyrzBaseAuthTestCase.setUps������!�!�F�*�*��:�;�;�;�	M���������|�	M�	M�	M��K�L�L�L�	M����
���
�
������*�%�%�.�.�w�}�=�=�=��N�N�$�$��	�DH�DU�DU�DW�DW�A��
�t�+�T�-A��������s	�=�Ac��t����N)�NotImplementedError�rs rrzBaseAuthTestCase.make_auth s��!�#�#�#�c��|j|i|��Sr!)�send)r�socket�args�kwargss    rr&zBaseAuthTestCase.send#s���v�{�D�+�F�+�+�+r$c�8�|j���dSr!)r�startr#s rrzBaseAuthTestCase.start_auth's���	�������r$c����|jr |j���d|_|�|j��t	�����dSr!)r�stop�remove_certsrr�tearDownrs �rr/zBaseAuthTestCase.tearDown*sX����9�	��I�N�N�����D�I����$�-�(�(�(�
���������r$c���tj��}tj�|d��}tj�|d��}tj�|d��}tj|��tj|��tj|��tj�|d��\}}tj�|d��\}}tj	|��D]h}	|	�
d��rQtjtj�||	��tj�|d�����itj	|��D]h}	|	�
d��rQtjtj�||	��tj�|d�����i|||fS)	z$Create CURVE certificates for a test�certificates�public_keys�private_keys�server�clientz.key�.z.key_secret)
�tempfile�mkdtemp�os�path�join�mkdirrr�create_certificates�listdir�endswith�shutil�move)
rr�keys_dirrr�server_public_file�server_secret_file�client_public_file�client_secret_file�key_files
          rrzBaseAuthTestCase.create_certs1s����#�%�%���7�<�<��.�9�9���'�,�,�x��?�?���'�,�,�x��@�@��
������
���!�!�!�
���!�!�!�14��1M�1M��h�2
�2
�.��.�25��1M�1M��h�2
�2
�.��.��
�8�,�,�	�	�H�� � ��(�(�
����G�L�L��8�4�4�b�g�l�l�?�TW�6X�6X������
�8�,�,�	�	�H�� � ��/�/�
����G�L�L��8�4�4�b�g�l�l�?�TW�6X�6X������/�?�;�;r$c�.�tj|��dS)zRemove certificates for a testN)r@�rmtree)rrs  rr.zBaseAuthTestCase.remove_certsVs���
�h�����r$c��tj�|d��}tj�|d��}tj�|��\}}tj�|��\}}||||fS)z)Return server and client certificate keyszserver.key_secretzclient.key_secret)r9r:r;rr�load_certificate)rrrDrF�
server_public�
server_secret�
client_public�
client_secrets        r�
load_certszBaseAuthTestCase.load_certsZsu���W�\�\�/�;N�O�O���W�\�\�/�;N�O�O��'*�x�'@�'@�AS�'T�'T�$�
�}�'*�x�'@�'@�AS�'T�'T�$�
�}��m�]�M�I�Ir$)�__name__�
__module__�__qualname__rrr&rr/rr.rP�
__classcell__�rs@rrrs�������������$�$�$�,�,�,���������#<�#<�#<�J � � �J�J�J�J�J�J�Jr$rc�X�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zed
���Z
dS)�TestThreadAuthenticationz'Test authentication running in a threadc�*�t|j��Sr!)r�contextr#s rrz"TestThreadAuthentication.make_authhs��"�4�<�0�0�0r$c�x�d}d}|�|��}|�d||fz��dg}|�dtj��|�dtj��rR	|�|tj��n2#tj$rtj	dt��YdSwxYwdS|�d��rZ	|�tj��}||ksJ�d}n/#tj$rtj	d	t��YnwxYw|S)
�9Check if client can connect to server using tcp transportF�tcp://127.0.0.1�%s:%i�Hello World�di�z#server set POLLOUT, but cannot sendTz"client set POLLIN, but cannot recv)�bind_to_random_port�connect�pollr�POLLOUT�send_multipart�NOBLOCK�Again�warnings�warn�RuntimeWarning�recv_multipart)rr4r5�result�iface�port�msg�rcvd_msgs        r�can_connectz$TestThreadAuthentication.can_connectksW����!���)�)�%�0�0�����w�%���.�/�/�/����	���C���%�%�%��;�;�t�S�[�)�)�	�
��%�%�c�3�;�7�7�7�7���9�
�
�
��
�C�^�T�T�T��u�u�
�����5��;�;�t���	�
�!�0�0���=�=�� �3���������	�9�
T�
T�
T��
�B�N�S�S�S�S�S�
T����
�
s$�8 B�)C�C�!D�)D7�6D7c���|j���d|_|���|_|�t
j��}|�t
j��}|�||��sJ�|�t
j��}d|_	|�t
j��}|�||��sJ�dS)zthreaded auth - NULLN�global)
rr-�ContextrYr'r�PUSH�PULLrp�
zap_domain�rr4r5s   r�	test_nullz"TestThreadAuthentication.test_null�s���	
�	��������	��|�|�~�~������S�X�&�&�����S�X�&�&�������/�/�/�/�/�
���S�X�&�&��%������S�X�&�&�������/�/�/�/�/�/�/r$c���|j�d��|�tj��}d|_|�tj��}|�||��rJ�dS)zthreaded auth - Blacklist�	127.0.0.1rrN)r�denyr'rrtrvrurprws   r�test_blacklistz'TestThreadAuthentication.test_blacklist�sj��	
�	���{�#�#�#����S�X�&�&��&������S�X�&�&���#�#�F�F�3�3�3�3�3�3�3r$c���|j�d��|�tj��}d|_|�tj��}|�||��sJ�dS)zthreaded auth - WhitelistrzrrN)r�allowr'rrtrvrurprws   r�test_whitelistz'TestThreadAuthentication.test_whitelist�sj��	
�	����$�$�$����S�X�&�&��&������S�X�&�&�������/�/�/�/�/�/�/r$c��|�tj��}d|_|�tj��}d|_d|_|�||��rJ�|�tj��}d|_|�tj��}d|_d|_|j�	dddi���|�||��sJ�|�tj��}d|_|�tj��}d|_d|_|�||��rJ�|j�
��d	|_|�tj��}|�tj��}|�||��sJ�|���|���d	S)
zthreaded auth - PLAINT�admin�Password�*�admin�Password��domain�	passwords�BogusN)r'rrt�plain_serverru�plain_username�plain_passwordrpr�configure_plainr-�closerws   r�
test_plainz#TestThreadAuthentication.test_plain�s������S�X�&�&��"������S�X�&�&�� (��� +����#�#�F�F�3�3�3�3�3����S�X�&�&��"������S�X�&�&�� (��� +����	�!�!���*�8M�!�N�N�N������/�/�/�/�/����S�X�&�&��"������S�X�&�&�� (��� (����#�#�F�F�3�3�3�3�3�	
�	��������	����S�X�&�&�����S�X�&�&�������/�/�/�/�/��������������r$c��|j�d��|�|j��}|\}}}}|�t
j��}||_||_d|_	|�t
j
��}||_||_||_|�||��rJ�|j�
dt
jj���|�t
j��}||_||_d|_	|�t
j
��}||_||_||_|�||��sJ�|j�
d|j���|�t
j
��}||_||_d|_	|�t
j��}||_||_||_|�||��sJ�|j���d|_|�t
j��}|�t
j
��}|�||��sJ�dS)�threaded auth - CURVErzTr��r��locationN)rr~rPrr'rrt�curve_publickey�curve_secretkey�curve_serverru�curve_serverkeyrp�configure_curve�CURVE_ALLOW_ANYrr-)r�certsrLrMrNrOr4r5s        r�
test_curvez#TestThreadAuthentication.test_curve�s7���	����$�$�$����� 4�5�5��EJ�B�
�}�m�]����S�X�&�&��!.���!.���"������S�X�&�&��!.���!.���!.����#�#�F�F�3�3�3�3�3�	
�	�!�!��s�x�7O�!�P�P�P����S�X�&�&��!.���!.���"������S�X�&�&��!.���!.���!.��������/�/�/�/�/�	
�	�!�!��t�7K�!�L�L�L����S�X�&�&��!.���!.���"������S�X�&�&��!.���!.���!.��������/�/�/�/�/�	
�	��������	����S�X�&�&�����S�X�&�&�������/�/�/�/�/�/�/r$c�J�
�|j�d��|�|j��}|\}}�
}|�t
j��}||_||_d|_	|�t
j
��}�
|_||_||_|�||��rJ�G�
fd�d��}|��}|j�
|���|�t
j��}||_||_d|_	|�t
j
��}�
|_||_||_|�||��sJ�Gd�d��}	|	��}|j�
|���|�t
j��}||_||_d|_	|�t
j
��}�
|_||_||_|�||��rJ�dS)	z2threaded auth - CURVE with callback authenticationrzTc� ��eZdZ�fd�Zd�ZdS)�ITestThreadAuthentication.test_curve_callback.<locals>.CredentialsProviderc����|_dSr!�r5)rrNs �r�__init__zRTestThreadAuthentication.test_curve_callback.<locals>.CredentialsProvider.__init__ s���+����r$c� �||jkrdSdS�NTFr��rr��keys   r�callbackzRTestThreadAuthentication.test_curve_callback.<locals>.CredentialsProvider.callback#����$�+�%�%��4� �5r$N�rQrRrSr�r�)rNs�r�CredentialsProviderr�s=�������
,�
,�
,�
,�
,�
!�
!�
!�
!�
!r$r�)�credentials_providerc��eZdZd�Zd�ZdS)�NTestThreadAuthentication.test_curve_callback.<locals>.WrongCredentialsProviderc��d|_dS)N�WrongCredentialsr�r#s rr�zWTestThreadAuthentication.test_curve_callback.<locals>.WrongCredentialsProvider.__init__8s
��0����r$c� �||jkrdSdSr�r�r�s   rr�zWTestThreadAuthentication.test_curve_callback.<locals>.WrongCredentialsProvider.callback;r�r$Nr��r$r�WrongCredentialsProviderr�7s2������
1�
1�
1�
!�
!�
!�
!�
!r$r�N)rr~rPrr'rrtr�r�r�rur�rp�configure_curve_callback)rr�rLrMrOr4r5r��providerr�rNs          @r�test_curve_callbackz,TestThreadAuthentication.test_curve_callbacksC����	����$�$�$����� 4�5�5��EJ�B�
�}�m�]����S�X�&�&��!.���!.���"������S�X�&�&��!.���!.���!.����#�#�F�F�3�3�3�3�3�	!�	!�	!�	!�	!�	!�	!�	!�	!�	!�'�&�(�(���	�*�*��*�I�I�I����S�X�&�&��!.���!.���"������S�X�&�&��!.���!.���!.��������/�/�/�/�/�	!�	!�	!�	!�	!�	!�	!�	!�,�+�-�-���	�*�*��*�I�I�I����S�X�&�&��!.���!.���"������S�X�&�&��!.���!.���!.����#�#�F�F�3�3�3�3�3�3�3r$c�N�|j�d��|�|j��}|\}}}}|j�d|j���|�tj��}||_	||_
d|_|�tj��}||_	||_
||_
|�||��sJ�|�|d��|�|d���}|jdksJ�	|�d��}	|	|�d	��ksJ�n#tj$rYnwxYwd
�|j_|�tj��}
||
_	||
_
||
_
|�|
|��sJ�|�|
d��|�|d���}|jdksJ�	|�d��}	|	dksJ�d
S#tj$rYd
SwxYw)r�rzr�r�TstestF)�copyzUser-Id�utf8c��dS)N�customr�)�
client_keys r�<lambda>z=TestThreadAuthentication.test_curve_user_id.<locals>.<lambda>ks��X�r$stest2r�N)rr~rPrr�rr'rrur�r�r�rtr�rpr&�recv�bytes�get�decode�ZMQVersionError�
curve_user_id)rr�rLrMrNrOr4r5rn�user_id�client2s           r�test_curve_user_idz+TestThreadAuthentication.test_curve_user_idMsO��	
�	����$�$�$����� 4�5�5��EJ�B�
�}�m�]��	�!�!��t�7K�!�L�L�L����S�X�&�&��!.���!.���"������S�X�&�&��!.���!.���!.��������/�/�/�/�/�	
�	�	�&�'�"�"�"��i�i��U�i�+�+���y�G�#�#�#�#�	;��g�g�i�(�(�G��m�2�2�6�:�:�:�:�:�:�:���"�	�	�	��D�	����#>�"=��	���+�+�c�h�'�'��"/���"/���"/��������0�0�0�0�0��	�	�'�8�$�$�$��i�i��U�i�+�+���y�H�$�$�$�$�	'��g�g�i�(�(�G��h�&�&�&�&�&�&���"�	�	�	��D�D�	���s$�E	�	E�E�2H�H$�#H$N)rQrRrS�__doc__rrprxr|rr�r�r�rr�r�r$rrWrWes�������1�1�1�1�1����<0�0�0�*	4�	4�	4�	0�	0�	0�$�$�$�L00�00�00�d?4�?4�?4�B�-'�-'��Y�-'�-'�-'r$rWTc������fd�}|S)z*decorator for running tests with an IOLoopc����|��}|j}�r |j�|j��n|j�|j��|�d|j��|�d|j���r|�d|j��n|�d|j	��|�
��|jr|�|j��|S)N�g333333�?�)
�io_loop�
pullstream�on_recv�on_message_succeed�on_message_fail�
call_later�attempt_connection�send_msg�on_test_timeout_fail�on_test_timeout_succeedr+�fail_msg�fail)r�r�loop�expect_success�methods   ��r�test_methodz with_ioloop.<locals>.test_method�s�����F�4�L�L���|���	:��O�#�#�D�$;�<�<�<�<��O�#�#�D�$8�9�9�9�����4�2�3�3�3�����T�]�+�+�+��	=��O�O�A�t�8�9�9�9�9��O�O�A�t�;�<�<�<��
�
�����=�	%��I�I�d�m�$�$�$��r$r�)r�r�r�s`` r�with_ioloopr�~s*����������.�r$c�"�t|d��S)NT�r��r�s r�should_authr��s���v�t�$�$�$r$c�"�t|d��S)NFr�r�s r�should_not_authr��s���v�u�%�%�%r$c�2��eZdZdZ�fd�Zd�Z�fd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Ze
d���Ze
d���Zed
���Ze
d���Zed���Ze
d���Zed���Zed���Ze
d���Ze
d���Z�xZS)�TestIOLoopAuthenticationz%Test authentication running in ioloopc������	ddlm}n$#t$rtjd��YnwxYwddlm�d�_|�d����_	t�������tj���_��tj���_��fd�}�j	�|��dS)Nr)�ioloopzRequires tornado)�	zmqstreamF)�make_currentc���K����j���_���j���_dSr!)�	ZMQStreamr4�
pushstreamr5r�)rr�s��r�make_streamsz4TestIOLoopAuthentication.setUp.<locals>.make_streams�s9�����'�1�1�$�+�>�>�D�O�'�1�1�$�+�>�>�D�O�O�Or$)�tornador��ImportError�pytest�skip�
zmq.eventloopr�r��IOLoopr�rrr'rrtr4rur5�run_sync)rr�r�r�rs`  @�rrzTestIOLoopAuthentication.setUp�s������	,�&�&�&�&�&�&�&���	,�	,�	,��K�*�+�+�+�+�+�	,����+�+�+�+�+�+���
��}�}�%�}�8�8���
���
�
�����k�k�#�(�+�+����k�k�#�(�+�+���	?�	?�	?�	?�	?�	?�	
����l�+�+�+�+�+s��-�-c�R���ddlm���fd�}�j�|��S)Nr)�IOLoopAuthenticatorc��(�K���j��Sr!)rY)r�rs��rrz5TestIOLoopAuthentication.make_auth.<locals>.make_auth�s�����&�&�t�|�4�4�4r$)�zmq.auth.ioloopr�r�r�)rrr�s` @rrz"TestIOLoopAuthentication.make_auth�sL����7�7�7�7�7�7�	5�	5�	5�	5�	5�	5��|�$�$�Y�/�/�/r$c����|jr |j���d|_|j�d���t	�����dS)NT)�all_fds)rr-r�r�rr/rs �rr/z!TestIOLoopAuthentication.tearDown�s[����9�	��I�N�N�����D�I�����4��(�(�(�
���������r$c�|�d}|j�|��}|j�d||fz��dS)r[r\r]N)r4r`r5ra)rrlrms   rr�z+TestIOLoopAuthentication.attempt_connection�sA��!���{�.�.�u�5�5������G�u�d�m�3�4�4�4�4�4r$c�@�dg}|j�|��dS)z&Send a message from server to a clientr^N)r�rd)rrns  rr�z!TestIOLoopAuthentication.send_msg�s&�������&�&�s�+�+�+�+�+r$c�T�|dgkrd|_|j���dS)z$A message was received, as expected.r^zUnexpected message receivedN�r�r�r-�r�framess  rr�z+TestIOLoopAuthentication.on_message_succeed�s1���n�%�%�%�9�D�M���������r$c�F�d|_|j���dS)z%A message was received, unexpectedly.z/Received messaged unexpectedly, security failedNr�r�s  rr�z(TestIOLoopAuthentication.on_message_fail�s#��I��
���������r$c�8�|j���dS)z*Test timer expired, indicates test successN)r�r-r#s rr�z0TestIOLoopAuthentication.on_test_timeout_succeed�s����������r$c�F�d|_|j���dS)z*Test timer expired, indicates test failurezTest timed outNr�r#s rr�z-TestIOLoopAuthentication.on_test_timeout_fail�s#��(��
���������r$c�F�|j���d|_dS)zioloop auth - NONEN)rr-r#s r�	test_nonez"TestIOLoopAuthentication.test_none�s!��	
�	��������	�	�	r$c��d|j_dS)zioloop auth - NULLrrN)r4rvr#s rrxz"TestIOLoopAuthentication.test_null�s��"+�����r$c�R�|j�d��d|j_dS)zioloop auth - BlacklistrzrrN)rr{r4rvr#s rr|z'TestIOLoopAuthentication.test_blacklist�s(��	
�	���{�#�#�#�!*�����r$c��|j�d��|j�tjd��dS)zioloop auth - WhitelistrzrrN)rr~r4�
setsockoptr�
ZAP_DOMAINr#s rrz'TestIOLoopAuthentication.test_whitelist�s8��	
�	����$�$�$�����s�~�y�9�9�9�9�9r$c�N�d|j_d|j_d|j_dS)z(ioloop auth - PLAIN, unconfigured serverr�r�TN)r5r�r�r4r�r#s r�test_plain_unconfigured_serverz7TestIOLoopAuthentication.test_plain_unconfigured_servers(��&.���"�%0���"�#'��� � � r$c��d|j_d|j_d|j_|j�dddi���dS)	z&ioloop auth - PLAIN, configured serverr�r�Tr�r�r�r�N�r5r�r�r4r�rr�r#s r�test_plain_configured_serverz5TestIOLoopAuthentication.test_plain_configured_serversH��&.���"�%0���"�#'��� ��	�!�!���*�8M�!�N�N�N�N�Nr$c��d|j_d|j_d|j_|j�dddi���dS)	z&ioloop auth - PLAIN, bogus credentialsr�r�Tr�r�r�r�Nrr#s r�test_plain_bogus_credentialsz5TestIOLoopAuthentication.test_plain_bogus_credentialssH��&.���"�%-���"�#'��� ��	�!�!���*�8M�!�N�N�N�N�Nr$c��|�|j��}|\}}}}|j�d��||j_||j_d|j_||j_||j_||j_	dS)z(ioloop auth - CURVE, unconfigured serverrzTN)
rPrrr~r4r�r�r�r5r��rr�rLrMrNrOs      r�test_curve_unconfigured_serverz7TestIOLoopAuthentication.test_curve_unconfigured_server!s|������ 4�5�5��EJ�B�
�}�m�]��	����$�$�$�&3���#�&3���#�#'��� �&3���#�&3���#�&3���#�#�#r$c�b�|�|j��}|\}}}}|j�d��|j�dt
jj���||j_||j_	d|j_
||j_||j_	||j_dS)z$ioloop auth - CURVE, CURVE_ALLOW_ANYrzr�r�TN)
rPrrr~r�rr�r4r�r�r�r5r�rs      r�test_curve_allow_anyz-TestIOLoopAuthentication.test_curve_allow_any1s������� 4�5�5��EJ�B�
�}�m�]��	����$�$�$��	�!�!��s�x�7O�!�P�P�P�&3���#�&3���#�#'��� �&3���#�&3���#�&3���#�#�#r$c�N�|j�d��|�|j��}|\}}}}|j�d|j���||j_||j_d|j_	||j
_||j
_||j
_dS)z&ioloop auth - CURVE, configured serverrzr�r�TN)rr~rPrr�rr4r�r�r�r5r�rs      r�test_curve_configured_serverz5TestIOLoopAuthentication.test_curve_configured_serverBs���	
�	����$�$�$����� 4�5�5��EJ�B�
�}�m�]��	�!�!��t�7K�!�L�L�L�&3���#�&3���#�#'��� �&3���#�&3���#�&3���#�#�#r$)rQrRrSr�rrr/r�r�r�r�r�r�r�rrxr�r|rr
r
rrrrrTrUs@rr�r��s��������/�/�,�,�,�,�,�&0�0�0������5�5�5�,�,�,�
������
������
����[���+�+��[�+��+�+��_�+��:�:��[�:��(�(��_�(��O�O��[�O��O�O��_�O��
4�
4��_�
4��4�4��[�4� �4�4��[�4�4�4�4�4r$r�)T)rr9r@r7rgr��zmq.authr�zmq.auth.threadr�	zmq.testsrrrrrWr�r�r�r�r�r$r�<module>rsV������	�	�	�	�
�
�
�
���������
�
�
�
�����/�/�/�/�/�/�:�:�:�:�:�:�:�:�:�:�QJ�QJ�QJ�QJ�QJ��QJ�QJ�QJ�hV'�V'�V'�V'�V'�/�V'�V'�V'�r����:%�%�%�&�&�&�n4�n4�n4�n4�n4�/�n4�n4�n4�n4�n4r$

Youez - 2016 - github.com/yon3zu
LinuXploit