Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_netrc.cpython-310.opt-1.pyc

o

0�i�@srddlZddlZddlZddlZddlZddlZddlmZddlm	Z	Gdd�dej
�Zedkr7e�
�dSdS)�N)�support)�	os_helperc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	d)dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Ze�ejdkd�d d!��Zd"d#�Zd$d%�Zd&d'�Zd(S)*�
NetrcTestCasecCs~t�|�}d}tjdkr|d7}t��\}}tj||dd��
}|�|�Wd�n1s.wY|�	tj
|�t�|�S)N�w�cygwin�tzutf-8)�mode�encoding)�textwrap�dedent�sys�platform�tempfileZmkstemp�os�fdopen�writeZ
addCleanup�unlink�netrc)�selfZ	test_datarZtemp_fdZ
temp_filename�fp�r�6/opt/alt/python310/lib64/python3.10/test/test_netrc.py�make_nrcs

�
zNetrcTestCase.make_nrccCsP|�d�}|�|jdd�|�|jdd�|�|���}|�|j|j�dS)Nz�            machine host1.domain.com login log1 password pass1 account acct1
            default login log2 password pass2
            zhost1.domain.com)Zlog1Zacct1Zpass1�default)Zlog2NZpass2)r�assertEqual�hosts�__repr__)r�nrcZnrc2rrr�test_defaults
�zNetrcTestCase.test_defaultcCs*|�d�}|�|jddgddgd��dS)Nz�            macdef macro1
            line1
            line2

            macdef macro2
            line3
            line4
            zline1
zline2
zline3
zline4
)Zmacro1Zmacro2)rrZmacros)rrrrr�test_macross
	�zNetrcTestCase.test_macroscCs&|�|�}|�|jddd|f�dS)Nzhost.domain.com�logZacct�rrr�rrZpasswdrrr�_test_passwords,s
zNetrcTestCase._test_passwordscC�|�dd�dS)NzV            machine host.domain.com login log password #pass account acct
            �#pass�r#�rrrr�test_password_with_leading_hash0��z-NetrcTestCase.test_password_with_leading_hashcCr$)NzV            machine host.domain.com login log password pass# account acct
            zpass#r&r'rrr� test_password_with_trailing_hash5r)z.NetrcTestCase.test_password_with_trailing_hashcCr$)NzV            machine host.domain.com login log password pa#ss account acct
            zpa#ssr&r'rrr� test_password_with_internal_hash:r)z.NetrcTestCase.test_password_with_internal_hash�passcCs8|�|�}|�|jddd|f�|�|jdd�dS)N�foo.domain.com�barzbar.domain.com)ZfooNr,r!r"rrr�
_test_comment?s
zNetrcTestCase._test_commentcC�|�d�dS)Nz�            # comment
            machine foo.domain.com login bar password pass
            machine bar.domain.com login foo password pass
            �r/r'rrr� test_comment_before_machine_lineD�z.NetrcTestCase.test_comment_before_machine_linecCr0)Nz�            #comment
            machine foo.domain.com login bar password pass
            machine bar.domain.com login foo password pass
            r1r'rrr�)test_comment_before_machine_line_no_spaceKr3z7NetrcTestCase.test_comment_before_machine_line_no_spacecCr0)Nz�            #
            machine foo.domain.com login bar password pass
            machine bar.domain.com login foo password pass
            r1r'rrr�*test_comment_before_machine_line_hash_onlyRr3z8NetrcTestCase.test_comment_before_machine_line_hash_onlycCr0)Nz�            machine foo.domain.com login bar password pass # comment
            machine bar.domain.com login foo password pass
            r1r'rrr�#test_comment_at_end_of_machine_lineYr3z1NetrcTestCase.test_comment_at_end_of_machine_linecCr0)Nz�            machine foo.domain.com login bar password pass #comment
            machine bar.domain.com login foo password pass
            r1r'rrr�,test_comment_at_end_of_machine_line_no_space_r3z:NetrcTestCase.test_comment_at_end_of_machine_line_no_spacecCr$)Nz�            machine foo.domain.com login bar password #pass #comment
            machine bar.domain.com login foo password pass
            r%r1r'rrr�1test_comment_at_end_of_machine_line_pass_has_hashes�z?NetrcTestCase.test_comment_at_end_of_machine_line_pass_has_hash�posixzPOSIX only testc	Cs�t�d��m}tj�|d�}t|d��
}|�d�Wd�n1s"wYt���/}|�d|�t�	|d�t
�
�}|�|jdd�t�	|d�|�
t
jt
j
�Wd�n1s]wYWd�dSWd�dS1suwYdS)	N�.netrcZwtz�                    machine foo.domain.com login bar password pass
                    default login foo password pass
                    �HOME�r-)r.Nr,i�)r�temp_cwdr�path�join�openr�EnvironmentVarGuard�set�chmodrrr�assertRaisesZNetrcParseError)r�d�fn�f�environrrrr�
test_securityls$�
���"�zNetrcTestCase.test_securityc	Cs�t�d��2}t���}|�d|�|�ttj�Wd�n1s"wYWd�dSWd�dS1s:wYdS)Nr;)rr=rArBrD�FileNotFoundErrorr)rrErHrrr�test_file_not_found_in_home�s
��"�z)NetrcTestCase.test_file_not_found_in_homecCs|jttjdd�dS)NZunlikely_netrc)�file)rDrJrr'rrr�test_file_not_found_explicit�s

�z*NetrcTestCase.test_file_not_found_explicitc	s�t�d��m�tj��d�}t|d��
}|�d�Wd�n1s"wYt�|d�tjj�g����fdd�}t	�
tjd|��t��}|�d�\}}}|�
|d	�Wd�n1s`wY|���Wd�dS1suwYdS)
Nr:rz.machine foo.domain.com login bar password passr<csZ��|�t���}|�d��|�d���|�}|Wd�S1s&wYdS)Nr;ZUSERPROFILE)�appendrrArB)�srH�result�ZcalledZ	fake_homeZorig_expanduserrr�fake_expanduser�s

$�z8NetrcTestCase.test_home_not_set.<locals>.fake_expanduser�
expanduserr-r.)rr=rr>r?r@rrCrSrZ	swap_attrrZauthenticatorsrZ
assertTrue)rZfake_netrc_pathrGrRrZloginZaccountZpasswordrrQr�test_home_not_set�s ��"�zNetrcTestCase.test_home_not_setN)r,)�__name__�
__module__�__qualname__rrrr#r(r*r+r/r2r4r5r6r7r8�unittestZ
skipUnlessr�namerIrKrMrTrrrrrs(


r�__main__)rrrXrrr
�testrZtest.supportrZTestCaserrU�mainrrrr�<module>s0�