HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_netrc.cpython-37.pyc
B

��g��@snddlZddlZddlZddlZddlZddlZddlmZddlmZGdd�dej	�Z
edkrje��dS)�N)�mock)�supportc@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)*�
NetrcTestCasec	Csht�|�}d}tjdkr |d7}t��\}}tj||d��}|�|�WdQRX|�	tj
|�t�|�S)N�w�cygwin�t)�mode)�textwrap�dedent�sys�platform�tempfileZmkstemp�os�fdopen�write�
addCleanup�unlink�netrc)�selfZ	test_datarZtemp_fdZ
temp_filename�fp�r�+/usr/local/lib/python3.7/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_macrosszNetrcTestCase.test_macroscCs&|�|�}|�|jddd|f�dS)Nzhost.domain.com�logZacct)rrr)rr�passwdrrr�_test_passwords,s
zNetrcTestCase._test_passwordscCs|�dd�dS)NzV            machine host.domain.com login log password #pass account acct
            z#pass)r")rrrr�test_password_with_leading_hash0sz-NetrcTestCase.test_password_with_leading_hashcCs|�dd�dS)NzV            machine host.domain.com login log password pass# account acct
            zpass#)r")rrrr� test_password_with_trailing_hash5sz.NetrcTestCase.test_password_with_trailing_hashcCs|�dd�dS)NzV            machine host.domain.com login log password pa#ss account acct
            zpa#ss)r")rrrr� test_password_with_internal_hash:sz.NetrcTestCase.test_password_with_internal_hash�passcCs8|�|�}|�|jddd|f�|�|jdd�dS)Nzfoo.domain.com�barzbar.domain.com)ZfooNr&)rrr)rrr!rrr�
_test_comment?s
zNetrcTestCase._test_commentcCs|�d�dS)Nz�            # comment
            machine foo.domain.com login bar password pass
            machine bar.domain.com login foo password pass
            )r()rrrr� test_comment_before_machine_lineDsz.NetrcTestCase.test_comment_before_machine_linecCs|�d�dS)Nz�            #comment
            machine foo.domain.com login bar password pass
            machine bar.domain.com login foo password pass
            )r()rrrr�)test_comment_before_machine_line_no_spaceKsz7NetrcTestCase.test_comment_before_machine_line_no_spacecCs|�d�dS)Nz�            #
            machine foo.domain.com login bar password pass
            machine bar.domain.com login foo password pass
            )r()rrrr�*test_comment_before_machine_line_hash_onlyRsz8NetrcTestCase.test_comment_before_machine_line_hash_onlycCs|�d�dS)Nz�            machine foo.domain.com login bar password pass # comment
            machine bar.domain.com login foo password pass
            )r()rrrr�#test_comment_at_end_of_machine_lineYsz1NetrcTestCase.test_comment_at_end_of_machine_linecCs|�d�dS)Nz�            machine foo.domain.com login bar password pass #comment
            machine bar.domain.com login foo password pass
            )r()rrrr�,test_comment_at_end_of_machine_line_no_space_sz:NetrcTestCase.test_comment_at_end_of_machine_line_no_spacecCs|�dd�dS)Nz�            machine foo.domain.com login bar password #pass #comment
            machine bar.domain.com login foo password pass
            z#pass)r()rrrr�1test_comment_at_end_of_machine_line_pass_has_hashesz?NetrcTestCase.test_comment_at_end_of_machine_line_pass_has_hash�posixzPOSIX only testc	Cs�tj}t�|�|�tj|�tj�|d�}t|d��}|�	d�WdQRXt�
��T}|�d|�t�|d�t
�
�}|�|jdd�t�|d�|�t
jt
j
�WdQRXdS)	Nz.netrcZwtz                machine foo.domain.com login bar password pass
                default login foo password pass
                �HOMEi�zfoo.domain.com)r'Nr&i�)r�TESTFNr�mkdirr�rmtree�path�join�openr�EnvironmentVarGuard�set�chmodrrr�assertRaisesZNetrcParseError)r�d�fn�f�environrrrr�
test_securityls

zNetrcTestCase.test_securityc	CsPtj}t�|�|�tj|�t��� }|�d|�|�t	t
j
�WdQRXdS)Nr0)rr1rr2rr3r7r8r:�FileNotFoundErrorr)rr;r>rrr�test_file_not_found_in_home�s

z)NetrcTestCase.test_file_not_found_in_homecCs|jttjdd�dS)NZunlikely_netrc)�file)r:r@r)rrrr�test_file_not_found_explicit�s
z*NetrcTestCase.test_file_not_found_explicitc	s�tj�t���|�tj��tj��d�}t|d��}|�	d�WdQRXt�
|d�tjj�g����fdd�}t�tjd|��*t
�
�}|�d�\}}}|�|d	�WdQRX|���dS)
Nz.netrcrz.machine foo.domain.com login bar password passi�c	s6��|�t���}|�d���|�}|SQRXdS)Nr0)�appendrr7r8)�sr>�result)�called�	fake_home�orig_expanduserrr�fake_expanduser�s


z8NetrcTestCase.test_home_not_set.<locals>.fake_expanduser�
expanduserzfoo.domain.comr')rr1rr2rr3r4r5r6rr9rKZ	swap_attrrZauthenticatorsrZ
assertTrue)rZfake_netrc_pathr=rJrZloginZaccountZpasswordr)rGrHrIr�test_home_not_set�s
zNetrcTestCase.test_home_not_setN)r&)�__name__�
__module__�__qualname__rrrr"r#r$r%r(r)r*r+r,r-r.�unittestZ
skipUnlessr�namer?rArCrLrrrrrs$

r�__main__)
rrrPrr
r	rZtestrZTestCaserrM�mainrrrr�<module>s0$