HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/samba/tests/__pycache__/gensec.cpython-310.pyc
o

�/a�#�@s@dZddlmZddlmZmZddlZGdd�dejj�Z	dS)z�Tests for GENSEC.

Note that this just tests the bindings work. It does not intend to test
the functionality, that's already done in other tests.
�)�Credentials)�gensec�authNcs�eZdZ�fdd�Zdd�Zdd�Zdd�Zd d
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Z�ZS)!�GensecTestscs`tt|���i|_tj��|jd<|_|j�d�|jd<|j�	dd�	t
j�|j�|_
dS)N�lp_ctxznetbios name�target_hostname�spnego:simulate_w2k�no)
�superr�setUp�settings�samba�tests�env_loadparmr�get�setr�Security�start_client��self��	__class__��4/usr/lib/python3/dist-packages/samba/tests/gensec.pyrszGensecTests.setUpcCs|�t|jjd�dS)N�foo)�assertRaises�RuntimeErrorr�start_mech_by_namerrrr�test_start_mech_by_unknown_name)sz+GensecTests.test_start_mech_by_unknown_namecCs|j�d�dS)N�spnego)rrrrrr�test_start_mech_by_name,�z#GensecTests.test_start_mech_by_namecCs|�t|jj�dS)N)rrr�session_inforrrr�test_info_uninitialized/sz#GensecTests.test_info_uninitializedNc
Cs�	|r|j�|�}|s
d}|j�|d�tj�|j�|_|j�|�	��|j�
tj�|dur6|j�|�n|j�
|�|rE|j�|d�tjj|jtj|jd�d�|_t�}|�|j�|�|j�|j�|�|j�
tj�|j�
|�d}d}d}d}			|s�|r�|j�|d�td
�z
|j�|�\}}	Wntjy�}
zt|
��d}
~
ww|r�|j�|d�|s�td�z
|j�|	�\}}Wntjy�}
zt|
��d}
~
ww|r�|r�nq�|r�|j�||�|�|�|�|�|j��}d}z|j�|�}
|j�|
�}Wntj�y}z
|�t|��WYd}~nd}~ww|� ||�d
}|j�|�}
|j�|
�}|� ||�|j�!�}|j�!�}|� ||�dS)�JTest GENSEC by doing an exchange with ourselves using GSSAPI against a KDC��yesNr	�r�r�auth_contextF�Tzrunning client gensec_updatezrunning server gensec_update�Hello Server�Hello Client)"rrrrrrr�
gensec_client�set_credentials�get_credentials�want_feature�FEATURE_SEALr�start_mech_by_sasl_name�start_serverr�AuthContext�
gensec_serverr�guess�set_machine_account�print�updater
�
NTSTATUSError�AssertionError�
assertTruer"�wrap�unwrap�fail�str�assertEqual�session_key)r�mech�client_mech�client_only_opt�orig_client_opt�creds�client_finished�server_finished�server_to_client�client_to_server�ntr"�
test_bytes�test_wrapped�test_unwrapped�e�client_session_key�server_session_keyrrr�_test_update2s�
������


��

zGensecTests._test_updatecC�|�d�dS)N�GSSAPI�rSrrrr�test_update��zGensecTests.test_updatecCrT)N�
GSS-SPNEGOrVrrrr�test_update_spnego�rXzGensecTests.test_update_spnegocC�|�ddd�dS)NrYrzgensec:gssapi_krb5rVrrrr�test_update_spnego_downgrade��z(GensecTests.test_update_spnego_downgradecCr[)NrYrzspnego:client_no_optimisticrVrrrr� test_update_no_optimistic_spnego�r]z,GensecTests.test_update_no_optimistic_spnegocCs:|j�dd�tj�|j�|_|j�dd�|�d�dS)Nrr&r	rY�rrrrrrrSrrrr�test_update_w2k_spnego_client�sz)GensecTests.test_update_w2k_spnego_clientcCs,tj�|j�|_|j�dd�|�d�dS)Nrr&rY)rrrrrrrSrrrr�test_update_w2k_spnego_server�sz)GensecTests.test_update_w2k_spnego_servercCs,|j�dd�tj�|j�|_|�d�dS)Nrr	rYr_rrrr�test_update_w2k_spnego�sz"GensecTests.test_update_w2k_spnegocC�|�dd�dS)NrY�gssapi_krb5rVrrrr�test_update_gss_krb5_to_spnego�r!z*GensecTests.test_update_gss_krb5_to_spnegocCrc)NrY�ntlmssprVrrrr�test_update_ntlmssp_to_spnego�r!z)GensecTests.test_update_ntlmssp_to_spnegoc
Cs�	tj�|j�|_|j�|���|j�tj�|j�	d�|j�
d�tjj|jtj
|jd�d�|_t�}|�|j�|�|j�|j�|�|j�tj�|j�	d�|j�
d�d}d}d}	d}|rh|s�|d7}|s�td	t|�|f�|j�|�\}}|s�td
t|�|f�|j�|�\}}|rh|rh	|�|dk�|j��}d}|j�|�}	|j�|	�}
|�||
�d
}|j�|�}	|j�|	�}
|�||
�|j��}|j��}|�||�dS)r$�rr'r(Fr*r�z$running client gensec_update: %d: %rz$running server gensec_update: %d: %r�
r+r,N)rrrrr-r.r/r0�FEATURE_SIGN�set_max_update_sizerr3rr4rr5rr6r7r8�lenr9r<r"r=r>rArB)
rrGrHrIrJ�irKr"rMrNrOrQrRrrr�test_max_update_size�sX
��	


z GensecTests.test_max_update_size)NN)�__name__�
__module__�__qualname__rrr r#rSrWrZr\r^r`rarbrergro�
__classcell__rrrrrs 

T	r)
�__doc__�samba.credentialsrr
rr�samba.testsr�TestCaserrrrr�<module>s