HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/certbot/plugins/__pycache__/disco_test.cpython-38.pyc
U

�]\-�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZddlm
Z
ddlmZddlmZejdd	d
ejdd�d
�Zejddd
ejdd�d
�ZGdd�dej�ZGdd�dej�Zedkr�e��dS)z Tests for certbot.plugins.disco.�N)�List)�errors)�
interfaces)�
standalone)�webroot�sazcertbot.plugins.standalone)�
Authenticator�certbot��key)Zattrs�dist�wrzcertbot.plugins.webrootc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd S)!�PluginEntryPointTestz1Tests for certbot.plugins.disco.PluginEntryPoint.cCs�tjddtjdd�d�|_tjddtjdd�d�|_tjdd	tjdd�d�|_tjd
dtjdd�d�|_d
dlm	}|t
�|_dS)N�ep1zp1.ep1Zp1r
)rzp2.ep2Zp2�ep2z
p2.foo.ep2�ep3za.ep3Zp3r��PluginEntryPoint)�
pkg_resources�
EntryPoint�mock�	MagicMockr�ep1primrr�certbot.plugins.discor�EP_SA�	plugin_ep)�selfr�r�</usr/lib/python3/dist-packages/certbot/plugins/disco_test.py�setUps,
�
�
�
�zPluginEntryPointTest.setUpc
CsVddlm}|jd|jd|jd|jdtdi}t�|�D]\}}|�	||�
|��q6dS)Nrrzp1:ep1zp2:ep1zp2:ep2zp3:ep3r)rrrrrrr�sixZ	iteritems�assertEqualZentry_point_to_plugin_name)rr�names�entry_point�namerrr�test_entry_point_to_plugin_name.s"��z4PluginEntryPointTest.test_entry_point_to_plugin_namecCs|�d|jjk�dS)Nztemporary webserver)�
assertTruer�description�rrrr�test_description=sz%PluginEntryPointTest.test_descriptioncCs$tjdd�|j_|�d|jj�dS)NZDesc)r'z	Desc (sa))rrr�
plugin_clsr!Zdescription_with_namer(rrr�test_description_with_name@s
�z/PluginEntryPointTest.test_description_with_namecCs$tjdd�|j_|�d|jj�dS)Nz	Long desc)�long_description�rrrr*r!r,r(rrr�test_long_descriptionEs�
�z*PluginEntryPointTest.test_long_descriptioncCs(tjddgd�|j_|�d|jj�dS)NzLong desc not foundr')r'�specr-r(rrr�!test_long_description_nonexistentKs�
�z6PluginEntryPointTest.test_long_description_nonexistentcCsJ|�|j�tjf��|�|j�tjf��|�|j�tjtjf��dS�N)r&r�ifacesrZIAuthenticator�assertFalseZ
IInstallerr(rrr�test_ifacesQs
�z PluginEntryPointTest.test_ifacescCs�|�|jj�|�|jj�|�|jj�|�|jj�|�|jjdk�|�|jjt	k�|�
d|jj�|�|jjt
jk�dS)Nr)r3r�initialized�prepared�
misconfigured�	availabler&�problemr#rr!r$r*rrr(rrr�test__init__Wsz!PluginEntryPointTest.test__init__cCs�t��}|jj|d�}|�|jj�|�|j|k�|�|j��|k�|�|j|k�|�|j�d�|k�|�|j|k�|�|jj�|�|jj	�|�|jj
�dS)N��config�{)rrr�initr&r5r<r3r6r7r8)rr<�pluginrrr�	test_initbszPluginEntryPointTest.test_initc	s�tjdd��tjdd��tjdd��t��|j_�tjj}t�d��~�|�_�����fdd�}|�jj	_
|�|j��f��|�|j���f��|�|j��f��|�|j���f��W5QRXdS)N�iface1)�__name__�iface2�iface3z$certbot.plugins.disco.zope.interfacecsB|�kst�|�ks(|�ks(|�ks(t�|�kr>�j�dd��dSr1)�AssertionError�
exceptionsZBrokenImplementation)Ziface�obj�rArCrDZ	mock_zoper?rr�
verify_object~sz7PluginEntryPointTest.test_verify.<locals>.verify_object)
rrr�_initialized�zopeZ	interfacerF�patch�verifyZverifyObject�side_effectr&r3)rrFrIrrHr�test_verifyrs

z PluginEntryPointTest.test_verifycCsJt��}|jj|d�|j��|�|jj�|�|jj�t	|j�dS)Nr;)
rrrr>�preparer&r6r3r7�str)rr<rrr�test_prepare�s
z!PluginEntryPointTest.test_preparecCsvt��}tj|j_||j_|�t	|j��tj��|�|jj
�|�|jj�|�t	|jjtj��|�|jj
�dSr1)rrrZMisconfigurationErrorrPrNrrJr&�
isinstancer6r7r9r8�rr?rrr�test_prepare_misconfigured�s
��z/PluginEntryPointTest.test_prepare_misconfiguredcCs`t��}tj|j_||j_|�t	|j��tj��|�|jj
�|�|jj�|�|jj
�dSr1)rrrZNoInstallationErrorrPrNrrJr&rSr6r3r7r8rTrrr�test_prepare_no_installation�s
�z1PluginEntryPointTest.test_prepare_no_installationcCs`t��}tj|j_||j_|�t	|j��tj��|�|jj
�|�|jj�|�|jj
�dSr1)rrrZPluginErrorrPrNrrJr&rSr6r3r7r8rTrrr�!test_prepare_generic_plugin_error�s
z6PluginEntryPointTest.test_prepare_generic_plugin_errorcCs|�dt|j��dS)NzPluginEntryPoint#sa)r!�reprrr(rrr�	test_repr�szPluginEntryPointTest.test_reprN)rB�
__module__�__qualname__�__doc__rr%r)r+r.r0r4r:r@rOrRrUrVrWrYrrrrrs 


rc@s�eZdZdZedd��Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"S)#�PluginsRegistryTestz0Tests for certbot.plugins.disco.PluginsRegistry.cCsddlm}||�S)Nr��PluginsRegistry)rr_)�cls�pluginsr_rrr�_create_new_registry�sz(PluginsRegistryTest._create_new_registrycCs>t��|_d|j_t|jj_|jj|ji|_|�|j�|_	dS�Nr)
rrrr$�	TypeError�__hash__rNrarb�regr(rrrr�s


zPluginsRegistryTest.setUpc	Cs�ddlm}t�d��&}ttg�ttg�g|j_|�	�}W5QRX|�
|djtj
k�|�
|djtk�|�
|djtj
k�|�
|djtk�dS)Nrr^z#certbot.plugins.disco.pkg_resourcesrr
)rr_rrL�iterr�EP_WRZiter_entry_pointsrNZfind_allr&r*rrr#r)rr_Zmock_pkgrarrr�
test_find_all�s�z!PluginsRegistryTest.test_find_allcCs|�|j|jd�dSrc)r!rrfr(rrr�test_getitem�sz PluginsRegistryTest.test_getitemcCs|�dgt|j��dSrc)r!�listrfr(rrr�	test_iter�szPluginsRegistryTest.test_itercCs,|�dt|�i���|�dt|j��dS)Nr�)r!�lenrbrfr(rrr�test_len�szPluginsRegistryTest.test_lencCs2d|jj_|�dg|j�d��|jj�d�dS)N�bazZbar)rr>�return_valuer!rf�assert_called_once_withr(rrrr@�s
zPluginsRegistryTest.test_initcCs6|�|j|j�dd���|�i|j�dd���dS)NcSs|j�d�S)N�m�r$�
startswith�Zp_eprrr�<lambda>��z1PluginsRegistryTest.test_filter.<locals>.<lambda>cSs|j�d�S)N�brtrvrrrrw�rx)r!rarf�filterr(rrr�test_filter�s��zPluginsRegistryTest.test_filtercCsBd|jj_|�|j|j��j�d|jj_|�i|j��j�dS�NTF)rr2rqr!rarf�_pluginsr(rrrr4�s

zPluginsRegistryTest.test_ifacescCsNd|jj_|�|j|j�t���j�d|jj_|�i|j�t���j�dSr|)	rrMrqr!rarfrrr}r(rrrrO�s
�
zPluginsRegistryTest.test_verifycCs.d|jj_|�dg|j���|jj��dS)Nrp)rrPrqr!rfrrr(rrrrR�s
z PluginsRegistryTest.test_preparecsDg�t�fdd�tjD��}|�|�}|��|��ttj��dS)Nc3s(|] }|tjt��j|�d�fVqdS))rPN)rr�	functools�partial�append)�.0�c��orderrr�	<genexpr>�s�z9PluginsRegistryTest.test_prepare_order.<locals>.<genexpr>)�dict�stringZ
ascii_lettersrbrPr!�sorted�rrarfrr�r�test_prepare_order�s�
z&PluginsRegistryTest.test_prepare_ordercCs>d|j_|�|j|j��j�d|j_|�i|j��j�dSr|)rr8r!rarfr}r(rrr�test_availablesz"PluginsRegistryTest.test_availablecCsD|�|j�t���dk�d|j_|�|j�|j���|jk�dS)NT)r&rfZ	find_initr�Mockrr5r>r(rrr�test_find_inits
�z"PluginsRegistryTest.test_find_initcCs"dd�|j_|�dt|j��dS)NcSsdS)NzPluginEntryPoint#mockr��_rrrrwrxz/PluginsRegistryTest.test_repr.<locals>.<lambda>z&PluginsRegistry(PluginEntryPoint#mock))r�__repr__r!rXrfr(rrrrYs�zPluginsRegistryTest.test_reprcCsd|�dt|�i���dd�|j_|�dt|j��|jj|jddi}|�|�}|�dt|��dS)Nz
No pluginscSsdS)Nr�rr�rrrrwrxz.PluginsRegistryTest.test_str.<locals>.<lambda>r�ZfooZBarz	Bar

Mock)r!rQrbr�__str__rfr$r�rrr�test_strs
zPluginsRegistryTest.test_strN)rBrZr[r\�classmethodrbrrirjrlror@r{r4rOrRr�r�r�rYr�rrrrr]�s$
r]�__main__)r\r~r�Zunittestrrr Zzope.interfacerKZacme.magic_typingrr	rrZcertbot.pluginsrrrrrrhZTestCaserr]rB�mainrrrr�<module>s:
�
�j