HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/lib64/python3.6/site-packages/gssapi/tests/__pycache__/test_high_level.cpython-36.pyc
3

�O[�y�@s"ddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddl
m
Zddl
mZddl
mZddl
mZddl
mZddljZddlZd	Zej�jd
�ZedeZ dej!_"Gd
d�dej#�Z$dd�Z%dd�Z&dd�Z'Gdd�de$�Z(Gdd�de$�Z)Gdd�de$�Z*dS)�N)�
parameterized)�creds)�names)�sec_contexts)�raw)�_utils)�
exceptionsshostzutf-8�/FcsHeZdZe�fdd��Zedd��Zedd��Ze�fdd��Z�ZS)	�_GSSAPIKerberosTestCasecsjtt|�j�tjd�}|jj|dgd�|j�|jjj	d�dj
d�|_|jjj	d�dj
d�|_
dS)NzUTF-8z-k)�flags�@r)�superr
�
setUpClass�SERVICE_PRINCIPAL�decode�realm�kinit�	_init_envZ
user_princ�split�encode�
USER_PRINCZadmin_princZADMIN_PRINC)�cls�	svc_princ)�	__class__��'/usr/lib64/python3.6/test_high_level.pyrs
z"_GSSAPIKerberosTestCase.setUpClasscCs6tjtj�|_x"|jjj�D]\}}|tj|<qWdS)N)�copy�deepcopy�os�environ�
_saved_envr�env�items)r�k�vrrrr*sz!_GSSAPIKerberosTestCase._init_envcCsDx8tjtj�D](}||jkr.|j|tj|<qtj|=qWd|_dS)N)rrrrr )rr#rrr�_restore_env0s

z$_GSSAPIKerberosTestCase._restore_envcstt|�j�|j�dS)N)r
r
�
tearDownClassr%)r)rrrr&:sz%_GSSAPIKerberosTestCase.tearDownClass)	�__name__�
__module__�__qualname__�classmethodrrr%r&�
__classcell__rr)rrr
s
r
c	Cs�|dkrDd}dd�|j�D�}|s,|d7}n|dj|�7}||fgSt|�dkrZ|j�}nd}g}x6d	D].}tj|�}|||<|jt|tj|�|��qhW|SdS)
NZwith_params_cSsg|]\}}|r|�qSrr)�.0r#r$rrr�
<listcomp>Csz _perms_cycle.<locals>.<listcomp>Znone�_rTF)TF)r"�join�len�poprr�extend�_perms_cycle)	�elem�restZold_d�name_strZ	true_keysZ	next_elem�resr$Znew_drrrr3@s 




r3csnt|j��}tj|�}t|j�|i�}g}x8|D]0\}�t�fdd�|j�D��}|j||f�q0Wt	j
|�S)Ncs g|]\}}�|r||f�qSrr)r,r#r$)�permrrr-`szexist_perms.<locals>.<listcomp>)�list�keysrrr3r1�dictr"�appendr�expand)�kwargs�	all_elems�
curr_elems�permsr7r6�argsr)r8r�exist_permsYs
rCcGs,t|�}tj|�}t|j�|i�}tj|�S)N)r9rrr3r1rr=)Zall_elems_tupler?r@rArrr�true_false_permsfs
rDcsDeZdZ�fdd�Zedejjgdd�dd��Zedejjgdd�dd	��Z	e
jd
d�dd
��Ze
jdd�dd��Z
dd�Zedddd�dd��Zedddd�dd��Zdd�Ze
jdd�d d!��Ze
jd"d#�d$d%��Ze
jd"d#�d&d'��Ze
jd"d#�d(d)��Zedejjgd*d�e
jd+d,�d-d.���Ze
jd+d,�d/d0��Z�ZS)1�
CredsTestCasecs@tt|�j�tjd�}|jj|dgd�tjtt	j
j�|_dS)NzUTF-8z-k)r)
r
rE�setUprrrr�gssnames�Name�gb�NameType�kerberos_principal�name)�selfr)rrrrFss

zCredsTestCase.setUp��both)�lifetime�mechs�usagecCs&tjfd|ji|��}|jj�~dS)NrL)�gsscreds�CredentialsrLrP�should_be_an_integer)rM�str_namer>rrrr�test_acquire_by_init|s
z"CredsTestCase.test_acquire_by_initcCsbtjjfd|ji|��}|j�|\}}}|j�|jtj�|j�|jtj	j
�|j�~dS)NrL)rSrT�acquirerL�shouldnt_be_none�should_be_a�shouldnt_be_empty�should_includerI�MechType�kerberosrU)rMrVr>Z	cred_resprZactual_mechsZttlrrr�test_acquire_by_method�s
z$CredsTestCase.test_acquire_by_methodZrfc5588zRFC 5588cCs�tjd�}|jj|ddgd�tjttjj	�}t
jdd�}tj
||tjjd�}|j�}t
jdd�}tj
|d	�}|j|�|j}|j�|jdd
d
d�}	|	jjd�|	jjtjj�t
j|jdd�}
|
j�dS)
NzUTF-8z-kz-f)r�initiate)rR)rLrr�accept)rT)rRZset_default�	overwrite)rLrR)rrrrrGrH�TARGET_SERVICE_NAMErIrJ�hostbased_servicerSrT�gssctx�SecurityContextZRequirementFlagZdelegate_to_peer�stepZdelegated_credsrY�storerR�	should_berQr\r]r^rL)rMr�target_name�client_creds�
client_ctx�client_token�server_creds�
server_ctxZdeleg_creds�	store_resZreacquired_credsrrr�test_store_acquire�s*


z CredsTestCase.test_store_acquireZ
cred_storezcredentials storec	Cs�dj|jjd�}dj|jjd�}||d�}d|jj}|jj|�|jj||�|jj|ddd|g�tjddd	�}|j|d
d�}|j	j
�|j	j�|jj
d�tj|�}tj||d�}|j
�dS)
NzFILE:{tmpdir}/other_ccache)�tmpdirz{tmpdir}/other_keytab)�ccache�keytabzservice/cs@z-kz-tr`)rLrRT)rb)rLrh)�formatrrr�addprinc�extract_keytabrrSrTrhrQrYr[rRrirGrH)	rM�CCACHE�KTrh�
princ_name�
initial_credsrprL�retrieved_credsrrr�test_store_into_acquire_from�s 



z*CredsTestCase.test_store_into_acquire_fromcCs*tjddd�j}tj|�}|jjd�dS)Nra)rR)rIZacquire_credrrSrTrRri)rMZ	raw_credsZhigh_level_credsrrr�test_create_from_other�s
z$CredsTestCase.test_create_from_otherrLrPrRrQcCs�tj|jd�}|jf|�}|dr2|jj|j�n
|jj�|drP|jj�n
|jj�|drp|jjd�n
|jj�|dr�|j	j
�|j	jtj
j�n
|j	j�dS)N)rLrLrPrRrOrQ)rSrTrLZinquireri�should_be_nonerPrUrRrQr[r\rIr]r^)rMrVr>r�resprrr�test_inquire�s



zCredsTestCase.test_inquire�
init_lifetime�accept_lifetimecCs�tj|jd�}|jfdtjji|��}|dr>|jj|j�n
|jj�|dr\|j	j
�n
|j	j�|drz|jj
�n
|jj�|dr�|jjd�n
|jj�dS)N)rL�mechrLr�r�rRrO)
rSrTrLZinquire_by_mechrIr]r^rirr�rUr�rR)rMrVr>rr�rrr�test_inquire_by_mech�s


z"CredsTestCase.test_inquire_by_mechcCsDtjtj��}tjt�}|j|tjj	dd�}|j
�|jtj�dS)Nr`)rR)rSrTrI�CredsrGrHr�addr]r^rYrZ)rM�input_credsrL�	new_credsrrr�test_adds
zCredsTestCase.test_addc
Cs�dj|jjd�}dj|jjd�}||d�}d|jj}|jj|�|jj||�|jj|ddd|g�tjddd	�}|j|d
d�}|j	j
�|j	j�|jj
d�tj|�}tjtj��}|j|tjj|d�}	|	j
�|	jtj�dS)
NzFILE:{tmpdir}/other_ccache)rrz{tmpdir}/other_keytab)rsrtzservice/cs@z-kz-tr`)rLrRT)rb)rh)rurrrrvrwrrSrTrhrQrYr[rRrirGrHrIr�r�r]r^rZ)
rMrxryrhrzr{rprLr�r|rrr�test_store_into_add_froms&



z&CredsTestCase.test_store_into_add_fromZcred_imp_expzcredentials import-exportcCs$tj|jd�}|j�}|jt�dS)N)rL)rSrTrL�exportrZ�bytes)rMr�tokenrrr�test_export0szCredsTestCase.test_exportcCsBtj|jd�}|j�}tj|d�}|jj|j�|jj|j�dS)N)rL)r�)rSrTrLr�rPri)rMrr�Zimported_credsrrr�test_import_by_init6s
z!CredsTestCase.test_import_by_initcCsBtj|jd�}tj|�}tj|�}|jj|j�|jj|j�dS)N)rL)rSrTrL�pickle�dumps�loadsrPri)rMrZ
pickled_credsZunpickled_credsrrr�test_pickle_unpickle?s


z"CredsTestCase.test_pickle_unpickler`Zs4uZS4Uc
Csptjttjj�}tj|�}|d}~|j}tj	|dd�}tj
||d�}|j|df|�}	|	j�|	j
tj	�dS)N�rO)rLrR)Zacceptor_creds�)rGrHrcrIrJrdZinit_sec_contextrLrSrTZaccept_sec_contextZimpersonaterYrZ)
rMrVr>rjZclient_ctx_resprm�server_namernZserver_ctx_respZ	imp_credsrrr�test_impersonateHs

zCredsTestCase.test_impersonatecCs�tjttjj�}tj|d�}|j�}t	j
dd�}tj|dd�}|j|�t	j
tj��}|j|j
tjj|dd�}|jd�|jt	j
�dS)N)rLrO)rRra)rrRr`)ZimpersonatorrR)rGrHrcrIrJrdrerfrgrSrTr�r��initiator_namer]r^�shouldnt_berZ)rMrjrlrmrnror�r�rrr�test_add_with_impersonate^s


z'CredsTestCase.test_add_with_impersonate)r'r(r)rFrCrIr]r^rWr_�ktu�gssapi_extension_testrqr}r~rDr�r�r�r�r�r�r�r�r�r+rr)rrrErs&	 			rEc@seZdZdd�Zdd�Zdd�Zdd�Zejd	d
�dd��Z	ejd	d
�d
d��Z
ejd	d
�ejdd�dd���Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zejd	d
�d!d"��Zejd	d
�d#d$��Zejd	d
�ejdd�d%d&���Zejd	d
�ejdd�d'd(���Zd)S)*�
NamesTestCasecCs&tjt�}tj|�}t|�jt�dS)N)rIZimport_namerrGrHr�ri)rMZraw_nameZhigh_level_namerrrr~us

z$NamesTestCase.test_create_from_othercCstjt�}|j�dS)N)rGrHrrY)rMrLrrr�test_create_from_name_no_type{s
z+NamesTestCase.test_create_from_name_no_typecCs,tjttjj�}|j�|jjtjj�dS)N)	rGrHrrIrJrKrY�	name_typeri)rMrLrrr�test_create_from_name_and_type�sz,NamesTestCase.test_create_from_name_and_typecCsJtjttjj�}|jtjj�j	�}tj|d�}|j
�|jjtjj
�dS)N)r�)rGrHrcrIrJrd�canonicalizer]r^r�rYr�rirK)rM�name1�
exported_name�name2rrr�test_create_from_token�s
z$NamesTestCase.test_create_from_tokenZrfc6680zRFC 6680cCsdtjttjj�}|jtjj�}|j	tjj�}t
jd�d}tj
|�j|�|jtj
�|j|�dS)Nzutf-8r)rGrHrcrIrJrdr�r]r^Z
display_asrr�six�	text_typerirZ)rMrL�canonical_nameZkrb_nameZ	princ_strrrr�test_display_as�s

zNamesTestCase.test_display_ascCs@tjttjj�}|jtjj�j	dd�}tj|dd�}|j
�dS)NT)�	composite)r�r�)rGrHrcrIrJrdr�r]r^r�rY)rMr�r�r�rrr�)test_create_from_composite_token_no_attrs�s
z7NamesTestCase.test_create_from_composite_token_no_attrsZauthdataZgreet_clientcCs�tjttjj�}|jtjj�}d|j	d<|j
dd�}tj|d�}|j�|j	djj
tdg��|j	djj�|j	djj�dS)Nssome valzurn:greet:greetingT)r�)r�)rGrHrcrIrJrdr�r]r^�
attributesr�rY�valuesri�set�complete�should_be_true�
authenticated�should_be_false)rMr��
canon_namer�r�rrr�+test_create_from_composite_token_with_attrs�s

z9NamesTestCase.test_create_from_composite_token_with_attrscCsRtjttjj�}t|�}|jt�tj	ddkr6t}ntj
tj��}|j
|�dS)Nr�)rGrHrrIrJrK�strrZ�sys�version_infor�gssutils�
_get_encodingri)rMrLr6Z
target_valrrr�test_to_str�s
zNamesTestCase.test_to_strcCs>tjttjj�}tj|�}|jtj�|j	tj
tj���dS)N)
rGrHrrIrJrKr�r�rZrirr�r�)rMrLr6rrr�test_to_unicode�s
zNamesTestCase.test_to_unicodecCs0tjttjj�}|j�}|jt�|j	t�dS)N)
rGrHrrIrJrK�	__bytes__rZr�ri)rMrLZ
name_bytesrrr�
test_to_bytes�s
zNamesTestCase.test_to_bytescCs<tjt�}tjt�}tjttjj�}|j|�|j|�dS)N)	rGrHrrcrIrJrdrir�)rMr�r�Zname3rrr�test_compare�s



zNamesTestCase.test_comparecCs4tjttjj�}|jtjj�}|j	�}|j
t�dS)N)rGrHrrIrJrKr�r]r^r�rZr�)rMrLr�r�rrr�test_canoncialize_and_export�sz*NamesTestCase.test_canoncialize_and_exportcCs@tjttjj�}|jtjj�}|j	tj�t
|�jtd�dS)N�@)
rGrHrcrIrJrdr�r]r^rZr�rir)rMrLZcanonicalized_namerrr�test_canonicalize�s

zNamesTestCase.test_canonicalizecCs"tjt�}tj|�}|j|�dS)N)rGrHrrri)rMr�r�rrr�	test_copy�s

zNamesTestCase.test_copycCsTtjttjj�}|jj�|jtj	j
�}|jj�|jj
tj�|jjtj	j
�dS)N)rGrHrcrIrJrdZis_mech_namer�r�r]r^r�r�rZ�OIDri)rMrLr�rrr�test_is_mech_names


zNamesTestCase.test_is_mech_namecCs8tjttjj�}|jtjj�}|j	dd�}|j
t�dS)NT)r�)rGrHrcrIrJrdr�r]r^r�rZr�)rMrLr�r�rrr�#test_export_name_composite_no_attrss

z1NamesTestCase.test_export_name_composite_no_attrscCsBtjttjj�}|jtjj�}d|j	d<|j
dd�}|jt�dS)Nssome valzurn:greet:greetingT)r�)
rGrHrcrIrJrdr�r]r^r�r�rZr�)rMrLr�r�rrr�%test_export_name_composite_with_attrss

z3NamesTestCase.test_export_name_composite_with_attrscCsvtjttjj�}|jtjj�}d|j	d<|j	dj
jtdg��|j	dj
j�|j	djj�|j	d=d|j	d<dS)N�some valTzurn:greet:greetingssome other val)r�T)rGrHrcrIrJrdr�r]r^r�r�rir�r�r�r�r�)rMrLr�rrr�-test_basic_get_set_del_name_attribute_no_auth&s

z;NamesTestCase.test_basic_get_set_del_name_attribute_no_authN)r'r(r)r~r�r�r�r�r�r�r�Zkrb_plugin_testr�r�r�r�r�r�r�r�r�r�r�r�rrrrr�ts*	


			
	


r�cs�eZdZ�fdd�Zdd�Zdd�Zedgejj	dd	�d
d��Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zejd*d+�d,d-��Zejd*d+�d.d/��Z�ZS)0�SecurityContextTestCasecshtt|�j�dtj_tj|j�|_	t
jddd�|_tjt
tjj�|_tjt�|_t
j|jdd�|_dS)NFr`)rLrRra)r
r�rFrerf�__DEFER_STEP_ERRORS__rGrHrZclient_namerSrTrkrcrIrJrdrjrr�rn)rM)rrrrF@s
zSecurityContextTestCase.setUpcKstjfd|ji|��S)NrL)rerfrj)rMr>rrr�_create_client_ctxNsz*SecurityContextTestCase._create_client_ctxcCs(|j�\}}tj|�}|jj|j�dS)N)�_create_completed_contextsrerfrjri)rMZraw_client_ctxZraw_server_ctxZhigh_level_ctxrrrr~Us
z.SecurityContextTestCase.test_create_from_otherrNN)rPrr��channel_bindingscCsBtjf|j|jd�|��}|jjd�|jf|�}|jjd�dS)N)rLrr`)rerfrjrkrRrir�)rMrVr>rlrrr�test_create_new_initZs
z,SecurityContextTestCase.test_create_new_initcCstj|jd�}|jjd�dS)N)rra)rerfrnrRri)rMrorrr�test_create_new_acceptfsz.SecurityContextTestCase.test_create_new_acceptcs�fdd�}|jt�dS)Ncstjd�jd�dS)Nra)rRrL)rerfrjr)rMrr�create_sec_contextkszZSecurityContextTestCase.test_init_throws_error_on_invalid_args.<locals>.create_sec_context)�should_raise�	TypeError)rMr�r)rMr�&test_init_throws_error_on_invalid_argsjsz>SecurityContextTestCase.test_init_throws_error_on_invalid_argscCsR|jdd�}|j�}|jt�tj|jd�}|j|�}|jt�|j|�||fS)Ni�)rP)r)r�rgrZr�rerfrn)rMrlrmro�server_tokenrrrr�ps



z2SecurityContextTestCase._create_completed_contextscCsT|j�}|j�}|jj�tj|jd�}|j|�}|j|�|jj�|jj�dS)N)r)r�rgr�r�rerfrnr�)rMrlZ
client_tokroZ
server_tokrrr�$test_complete_on_partially_completed~s



z<SecurityContextTestCase.test_complete_on_partially_completedcCs�|j�\}}|jjd�|jj|j�|jjtj�|j	jtj
�|jj�|j
j�|jjd�|jj|j�|jjtj�|j	jtj
�|jj�|j
j�dS)Ni�i,i�)r�rP�should_be_at_mostr�rir�rZrIr�Zactual_flagsZIntEnumFlagSetZlocally_initiatedr�r�r�rj)rMrlrorrr�test_initiate_accept_steps�s


z2SecurityContextTestCase.test_initiate_accept_stepscCsntjdtjjdtjjdd�}|jd|d�}|j�}|jt�tj	|j
|d�}|j|�}|jt�|j|�dS)Nsabcxyzs	127.0.0.1)�application_data�initiator_address_type�initiator_address�acceptor_address_type�acceptor_addressi�)rPr�)rr�)rI�ChannelBindings�AddressType�ipr�rgrZr�rerfrn)rM�bdgsrlrmror�rrr�test_channel_bindings�s


z-SecurityContextTestCase.test_channel_bindingscCsftjdtjjdtjjdd�}|jd|d�}|j�}|jt�d|_t	j
|j|d�}|jjtj
|�dS)Nsabcxyzs	127.0.0.1)r�r�r�r�r�i�)rPr�s	127.0.1.0)rr�)rIr�r�r�r�rgrZr�r�rerfrnr��BadChannelBindingsError)rMr�rlrmrorrr�&test_bad_channel_bindings_raises_error�s
z>SecurityContextTestCase.test_bad_channel_bindings_raises_errorcCsH|j�\}}|j�}|jt�tj|d�}|jjd�|jj|j�dS)N)r�r`)	r�r�rZr�rerfrRrirj)rMrlror�Zimported_ctxrrr�test_export_create_from_token�s
z5SecurityContextTestCase.test_export_create_from_tokencCsJ|j�\}}tj|�}tj|�}|jtj�|jjd�|j	j|j	�dS)Nr`)
r�r�r�r�rZrerfrRrirj)rMrlroZpickled_ctxZ
unpickled_ctxrrrr��s

z,SecurityContextTestCase.test_pickle_unpicklecCsB|j�\}}|jd�}|jt�|j|�}|jt�|jd�dS)Nstest message)r��encryptrZr��decryptri)rMrlroZ
encrypted_msgZ
decrypted_msgrrr�test_encrypt_decrypt�s



z,SecurityContextTestCase.test_encrypt_decryptcCsP|j�\}}|jdd�}|jtj�|jj�|jjt�|j	j
tj|j�dS)Nstest messageF)
r��wraprZrI�
WrapResult�	encryptedr��messager�r�r��excsZEncryptionNotUsed)rMrlro�wrap_resrrr�2test_encrypt_decrypt_throws_error_on_no_encryption�s

zJSecurityContextTestCase.test_encrypt_decrypt_throws_error_on_no_encryptioncCsx|j�\}}|jdd�}|jtj�|jj�|jjt�|j	|j�}|jtj
�|jjt�|jjd�|jj�dS)Nstest messageT)r�r�rZrIr�r�r�r�r�ZunwrapZUnwrapResultri)rMrlror�Z
unwrap_resrrr�test_wrap_unwrap�s
z(SecurityContextTestCase.test_wrap_unwrapcCsL|j�\}}|jd�}|jddd�}|j�|j�|jd�|jd�dS)N�dT)r�)r�Zget_wrap_size_limitrUr�)rMrlroZ	with_confZwithout_confrrr�test_get_wrap_size_limit�s

z0SecurityContextTestCase.test_get_wrap_size_limitcCs,|j�\}}|jd�}|jt�|j�dS)Nssome message)r��
get_signaturerZr�r[)rMrlro�	mic_tokenrrr�test_get_signatures

z*SecurityContextTestCase.test_get_signaturecCs8|j�\}}|jd�}|jd|�|jjtjd|�dS)Nssome messages
other message)r�r�Zverify_signaturer�rIZGSSError)rMrlror�rrr�test_verify_signature_raises


z3SecurityContextTestCase.test_verify_signature_raisez1.11zreturning tokenscCsndtj_tjdd�}|jd|d�}|j�}|jt�d|_	tj|j
|d�}|j|�jt�|jjtj
d�dS)	NTsabcxyz)r�i�)rPr�sdefuvw)rr�stest)rerfr�rIr�r�rgrZr�r�rnr�r�r�)rMr�rlrmrorrr�test_defer_step_error_on_methods
z7SecurityContextTestCase.test_defer_step_error_on_methodcsvdtj_tjdd�}|jd|d�}|j�}|jt�d|_	tj|j
|d���j|�jt��fdd	�}|jtj�dS)
NTsabcxyz)r�i�)rPr�sdefuvw)rr�cs�jS)N)r�r)rorr�check_complete4szaSecurityContextTestCase.test_defer_step_error_on_complete_property_access.<locals>.check_complete)
rerfr�rIr�r�rgrZr�r�rnr�r�)rMr�rlrmr�r)ror�1test_defer_step_error_on_complete_property_access%s
zISecurityContextTestCase.test_defer_step_error_on_complete_property_access)r'r(r)rFr�r~rCrIr]r^r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Zkrb_minversion_testr�r�r+rr)rrr�?s.



	r�)+rrZsocketr�r�Z
should_be.allrir�Znose_parameterizedrZgssapirrSrrGrrerrIrr�rr�Zk5test.unitZunitr�Zk5testZktrcZgetfqdnrZFQDNrrfr�ZKerberosTestCaser
r3rCrDrEr�r�rrrr�<module>s:
#
L