KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64
User : www-data ( 33)
PHP Version : 8.2.12
Disable Function : NONE
Directory :  /lib/python3/dist-packages/certbot/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/certbot/tests/__pycache__/account_test.cpython-38.pyc
U

�]&7�@s�dZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mmZ
ddlmZddlmZddlmZddlmZej�e
�d��ZGd	d
�d
ej�ZGdd�de
j�ZGd
d�dej�ZGdd�de
j�Zedkr�e��dS)zTests for certbot.account.�N)�messages)�errors)�
filesystem)�misc)�oszrsa512_key.pemc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�AccountTestz"Tests for certbot.account.Account.cCs�ddlm}t��|_|jdtjddddddtjd	�d
�|_	||jt
|j	�|_tjdd�|j_t�
d
��@}d|j_t�
d��"}|j	j|jj_||jt
�|_W5QRXW5QRXdS)Nr��Accountztest.certbot.orgi�����
)Ztzinfo)Z
creation_host�creation_dtZi_am_a_regr)�return_valuezcertbot.account.socketzcertbot.account.datetime)�certbot.accountr	�mock�	MagicMock�regrZMeta�datetime�pytzZUTC�meta�KEY�acc�__repr__�patchZgetfqdnrrZnow�acc_no_meta)�selfr	Zmock_socketZmock_dt�r�</usr/lib/python3/dist-packages/certbot/tests/account_test.py�setUps*
��zAccountTest.setUpcCs8|�|j|jj�|�t|jj�|�|j|jj�dS�N)�assertEqualrrr�keyrr�rrrr�	test_init(szAccountTest.test_initcCs|�|jjd�dS)NZ 7adac10320f585ddf118429c0c4af2cd)r!r�idr#rrr�test_id-s�zAccountTest.test_idcCs|�|jjd�dS)Nz,test.certbot.org@2015-07-04T14:04:10Z (7ada))r!rZslugr#rrr�	test_slug1s�zAccountTest.test_slugcCs|�t|j��d��dS)Nz=<Account(i_am_a_regr, 7adac10320f585ddf118429c0c4af2cd, Meta()�
assertTrue�reprr�
startswithr#rrr�	test_repr5s�zAccountTest.test_reprN)	�__name__�
__module__�__qualname__�__doc__rr$r&r'r+rrrrrsrc@s<eZdZdZdd�Ze�d�dd��Ze�d�dd��Zd	S)
�ReportNewAccountTestz-Tests for certbot.account.report_new_account.cCsddlm}||j�dS)Nr)�report_new_account)rr1�config)rr1rrr�_call<szReportNewAccountTest._callz+certbot.account.zope.component.queryUtilitycCsd|_|��dSr )rr3)r�	mock_zoperrr�test_no_reporter@sz%ReportNewAccountTest.test_no_reportercCs4|��|�jj}|�|jj|dddk�dS)Nr)r3Zadd_messageZcall_args_listr(r2Z
config_dir)rr4Z	call_listrrr�test_itEs
zReportNewAccountTest.test_itN)	r,r-r.r/r3rrr5r6rrrrr09s
r0c@s eZdZdZdd�Zdd�ZdS)�AccountMemoryStorageTestz/Tests for certbot.account.AccountMemoryStorage.cCsddlm}|�|_dS)Nr)�AccountMemoryStorage)rr8�storage)rr8rrrrOszAccountMemoryStorageTest.setUpcCs�tjdd�}|�g|j���|�tj|jjd�|j�	|d�|�|g|j���|�||j�d��|j�	|d�|�|g|j���dS)N�x)r%)
rZMockr!r9�find_all�assertRaisesr�AccountNotFound�load�save)r�accountrrrr6Ssz AccountMemoryStorageTest.test_itN)r,r-r.r/rr6rrrrr7Lsr7cseZdZdZ�fdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Ze�d$�d%d&��Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Z d9d:�Z!d;d<�Z"d=d>�Z#d?d@�Z$�Z%S)A�AccountFileStorageTestz-Tests for certbot.account.AccountFileStorage.csltt|���ddlm}||j�|_ddlm}d}|tj	dt�
�|d�td�|_t
��|_||jj_dS)Nr��AccountFileStorager�hi)ZuriZbody�new_authzr_uri)rr")�superrArrrCr2r9r	rZRegistrationResourceZRegistrationrrrr�mock_clientZ	directoryZ	new_authz)rrCr	rE��	__class__rrrbs��
zAccountFileStorageTest.setUpcCs |�tj�t�|jj���dSr )r(r�path�isdirrZ.underscores_for_unsupported_characters_in_pathr2�accounts_dirr#rrr�test_init_creates_dirrs
�z,AccountFileStorageTest.test_init_creates_dirc	Cs�|j�|j|j�tj�|jj|jj	�}|�
tj�|��dD] }|�
tj�tj�||���q>|�
t�
tj�|d�d��|j�|jj	�}|�|j|�dS)N)�	regr.json�	meta.json�private_key.jsonrP�)r9r?rrGrrJ�joinr2rLr%r(�existsrZ
check_moder>r!)r�account_path�	file_nameZloadedrrr�test_save_and_restorevs
��z,AccountFileStorageTest.test_save_and_restorec	Cs\|j�|j|j�tj�|jj|jj	d�}t
|d��}t�|�}W5QRX|�
d|k�dS)z=Saved regr should include a new_authzr_uri for older CertbotsrN�rrEN)r9r?rrGrrJrRr2rLr%�open�jsonr>r()rrJ�frrrr�!test_save_and_restore_old_version�s
z8AccountFileStorageTest.test_save_and_restore_old_versionc	Cs�|j�|j|j�tj�|jj|jj	�}|�
tj�|��|�
tj�tj�|d���dD] }|�tj�tj�||���qZdS)NrN)rOrP)
r9Z	save_regrrrGrrJrRr2rLr%r(rS�assertFalse)rrTrUrrr�test_save_regr�s�
�z%AccountFileStorageTest.test_save_regrcCs,|j�|j|j�|�|jg|j���dSr )r9r?rrGr!r;r#rrr�
test_find_all�sz$AccountFileStorageTest.test_find_allcCs|�g|j���dSr )r!r9r;r#rrr�test_find_all_none_empty_list�sz4AccountFileStorageTest.test_find_all_none_empty_listcCs$t�|jj�|�g|j���dSr )r�rmdirr2rLr!r9r;r#rrr�!test_find_all_accounts_dir_absent�sz8AccountFileStorageTest.test_find_all_accounts_dir_absentc	CsTtjdtjdgd�|j_t�d��(}dddg|_|�ddg|j�	��W5QRXdS)Nr:�z��side_effectzcertbot.account.os.listdir�y)
rrr�AccountStorageErrorr9�_load_for_server_pathrrr!r;)rZmock_listdirrrr�test_find_all_load_skips�s
�
z/AccountFileStorageTest.test_find_all_load_skipscCs|�tj|jjd�dS)NZmissing)r<rr=r9r>r#rrr�#test_load_non_existent_raises_error�sz:AccountFileStorageTest.test_load_non_existent_raises_errorcCs$||j_ddlm}||j�|_dS)NrrB)r2�serverrrCr9)rrjrCrrr�_set_server�sz"AccountFileStorageTest._set_servercCsH|�d�|�g|j���|�g|j���|�tj�|jj	��dS�N�6https://acme-staging-v02.api.letsencrypt.org/directory)
rkr!r9r;r\rrJ�islinkr2rLr#rrr�test_find_all_neither_exists�s
z3AccountFileStorageTest.test_find_all_neither_existscCs�|�d�|�g|j���|j�|j|j�|�|jg|j���|�|jg|j���|�tj	�
|jj��d}|�tj	�
|j�|���dS�Nrm�2https://acme-staging.api.letsencrypt.org/directory)rkr!r9r;r?rrGr\rrJrnr2rLrK�accounts_dir_for_server_path�rZprev_server_pathrrr�test_find_all_find_before_save�s
z5AccountFileStorageTest.test_find_all_find_before_savecCs�|�d�|j�|j|j�|�|jg|j���|�|jg|j���|�tj	�
|jj��|�
tj	�|jj��d}|�tj	�|j�|���dSrp)rkr9r?rrGr!r;r\rrJrnr2rLr(rKrrrsrrr�test_find_all_save_before_find�s
z5AccountFileStorageTest.test_find_all_save_before_findcCsd|�d�|�g|j���|j�|j|j�|�|jg|j���|�d�|�g|j���dSrp)rkr!r9r;r?rrGr#rrr�test_find_all_server_downgrade�s

z5AccountFileStorageTest.test_find_all_server_downgradecCs@|�d�|j�|j|j�|�d�|�|jg|j���dS�Nrqrm�rkr9r?rrGr!r;r#rrr�test_upgrade_version_staging�s

z3AccountFileStorageTest.test_upgrade_version_stagingcCs@|�d�|j�|j|j�|�d�|�|jg|j���dS)Nz.https://acme-v01.api.letsencrypt.org/directoryz.https://acme-v02.api.letsencrypt.org/directoryrxr#rrr�test_upgrade_version_production�s

z6AccountFileStorageTest.test_upgrade_version_productionzcertbot.compat.os.rmdircCsT|�d�|j�|j|j�t|_tjt	j
d�|j_|�d�|�g|j�
��dS)Nrqrcrm)rkr9r?rrG�OSErrorrdrrrrfrgr!r;)rZ
mock_rmdirrrr�test_corrupted_account�s
�

z-AccountFileStorageTest.test_corrupted_accountcCsV|�d�|j�|j|j�|j�|jj�}|�d�|j�|jj�}|�||�dSrw)rkr9r?rrGr>r%r!�rZprev_accountr@rrr�test_upgrade_load�s

z(AccountFileStorageTest.test_upgrade_loadcCsV|�d�|j�|j|j�|j�|jj�}|�d�|j�|jj�}|�||�dSrw)	rkr9r?rrGr>r%�_set_server_and_stop_symlinkr!r}rrr� test_upgrade_load_single_account�s

z7AccountFileStorageTest.test_upgrade_load_single_accountc	CsT|j�|j|j�t��}t|_t�d|��|�	t
j|jj|jj
�W5QRXdS�Nzsix.moves.builtins.open)r9r?rrGr�	mock_open�IOErrorrdrr<rrfr>r%�rr�rrr�test_load_ioerror�s�z(AccountFileStorageTest.test_load_ioerrorc	CsDt��}t|_t�d|�� |�tj|jj	|j
|j�W5QRXdSr�)rr�r�rdrr<rrfr9r?rrGr�rrr�test_save_ioerrorss�z)AccountFileStorageTest.test_save_ioerrorscCs>|j�|j|j�|j�|jj�|�tj|jj	|jj�dSr )
r9r?rrG�deleter%r<rr=r>r#rrr�test_deletesz"AccountFileStorageTest.test_deletecCs|�tj|jj|jj�dSr )r<rr=r9r�rr%r#rrr�test_delete_no_accountsz-AccountFileStorageTest.test_delete_no_accountc	CsZ|�d�|j�|j|j�t�di��(|�d�|�tj	|jj
|jj�W5QRXdS)Nrqz"certbot.constants.LE_REUSE_SERVERSrm)rkr9r?rrGrrr<rr=r>r%r#rrr�!_assert_symlinked_account_removeds


z8AccountFileStorageTest._assert_symlinked_account_removedcCs�|�d�|j�|j|j�|�d�|j�|jj�|�|�|j�|jj�|�d�|�t	j
|jj|jj�|�d�|�t	j
|jj|jj�dSrw)rkr9r?rrGr>r%r�r<rr=)rZ
server_urlrrr�_test_delete_folderss




z+AccountFileStorageTest._test_delete_folderscCs|�d�|��dS)Nrq�r�r�r#rrr�test_delete_folders_up.s
z-AccountFileStorageTest.test_delete_folders_upcCs|�d�|��dSrlr�r#rrr�test_delete_folders_down2s
z/AccountFileStorageTest.test_delete_folders_downc	Cs<|�|�ttj�|jjd�d��}|�d�W5QRXdS)NZfoo�wZbar)rkrXrrJrRr2rL�write)rZserver_pathrZrrrr6s
z3AccountFileStorageTest._set_server_and_stop_symlinkcCs|�d�|�d�dSrp�rr�r#rrr�test_delete_shared_account_up;s
z4AccountFileStorageTest.test_delete_shared_account_upcCs|�d�|�d�dSrlr�r#rrr�test_delete_shared_account_down?s
z6AccountFileStorageTest.test_delete_shared_account_down)&r,r-r.r/rrMrVr[r]r^r_rarhrirkrortrurvryrzrrr|r~r�r�r�r�r�r�r�r�r�rr�r��
__classcell__rrrHrrA^sB

	

	rA�__main__) r/rrYZunittestZjosepyZjoserrZacmerZcertbot.tests.utilZtests�utilZ	test_utilZcertbotrZcertbot.compatrrrZJWKRSAr>Zload_vectorrZTestCaserZConfigTestCaser0r7rAr,�mainrrrr�<module>s($g

Anon7 - 2021