Your IP : 216.73.216.172


Current Path : /lib/python3/dist-packages/certbot_apache/tests/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/certbot_apache/tests/__pycache__/util.cpython-38.pyc

U

���]�)�@s�dZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZddlm
ZddlmZddlm
ZddlmZddlmZddlmZGd	d
�d
ej�ZGdd�de�Zddd�Zdd�ZdS)z$Common utilities for certbot_apache.�N)�os)�util)�common��configurator)�
entrypoint)�objcs&eZdZd�fdd�	Zdd�Z�ZS)	�
ApacheTest�!debian_apache_2_4/multiple_vhosts�)debian_apache_2_4/multiple_vhosts/apache2�9debian_apache_2_4/multiple_vhosts/apache2/sites-availablecs�tt|���tj|dd�\|_|_|_tj	�
|j|�|_tj	�
|j|�|_t
j�t�d��|_t|j||j|j�|_tj	�
|jd�}tj	�|�s�dSt�|�D]R}|dkr�q�tj	�
||�}tj	�|�s�t�|�tj	�
tj	jd|�}t�||�q�dS)Nzcertbot_apache.tests)�test_dir�pkgzrsa512_key.pemz
sites-enabled�non-symlink.confzsites-available)�superr	�setUprZ	dir_setup�temp_dir�
config_dir�work_dirr�path�join�config_path�
vhost_path�joseZJWKRSA�load�	test_utilZload_vectorZ	rsa512jwk�get_apache_configurator�config�exists�listdir�islink�remove�pardir�symlink)�selfr
�config_root�
vhost_rootZ
sites_enabledZvhost_basenameZvhost�target��	__class__��;/usr/lib/python3/dist-packages/certbot_apache/tests/util.pyrs:�
��
�zApacheTest.setUpcCs(t�|j�t�|j�t�|j�dS)N)�shutilZrmtreerrr)r$r*r*r+�tearDown;szApacheTest.tearDown)r
rr)�__name__�
__module__�__qualname__rr-�
__classcell__r*r*r(r+r	s
�$r	cseZdZd�fdd�	Z�ZS)�
ParserTestr
rrc	s�tt|��|||�tj�t�tj	d��ddl
m}tj
tj
jtj
jBd�|_t�d��||j|j|jd�|_W5QRXdS)NFr)�ApacheParser)�flags�;certbot_apache.parser.ApacheParser.update_runtime_variablesr)rr2r�zopeZ	componentZprovideUtility�display_utilZFileDisplay�sys�stdoutZcertbot_apache.parserr3�augeasZAugeasZNONEZNO_MODL_AUTOLOADZaug�mock�patchrrr�parser)r$r
r%r&r3r(r*r+rCs���zParserTest.setUp)r
rr)r.r/r0rr1r*r*r(r+r2As�r2�����genericcCs�tj�|d�}tj|dd|d||dtj�|d�tj�|d�|d�}t�d���t�d	���}	d
|	_t�d��lztj|}
Wnt	k
r�t
j}
YnX|
|d|d
�}|s�||
jd<n||j
_|
jd|j
_|��W5QRXW5QRXW5QRX|S)z�Create an Apache Configurator with the specified options.

    :param conf: Function that returns binary paths. self.conf in Configurator

    �backupsNz-le-ssl.conf�PZtemp_checkpointsZIN_PROGRESS)Zapache_server_root�apache_vhost_rootZapache_le_vhost_extZapache_challenge_locationZapache_enmodZ
backup_dirrZhttp01_portZtemp_checkpoint_dirZin_progress_dirrz+certbot_apache.configurator.util.run_scriptz+certbot_apache.configurator.util.exe_existsTr5Zapache)r�name�versionr&Zctl)rrrr;Z	MagicMockr<Zreturn_valuerZOVERRIDE_CLASSES�KeyErrorrZApacheConfiguratorZOS_DEFAULTSrrEZ
apache_ctlZprepare)rrrrrGZos_infoZconf_vhost_pathrCZmock_le_configZmock_exe_existsZconfig_classrr*r*r+rTs@
�

�&rcCs|dk�r�tj�||d�}d|}t�tj�|d�tj�|d�ttj�d�g�ddd	�t�tj�|d
�tj�|d�ttj�d�g�dd�t�tj�|d
�tj�|d�ttj�d�tj�d�g�ddd�tjtj�|d�tj�|d�ttj�d�g�ddddgd�tjtj�|d�tj�|d�ttj�d�g�dddd�t�tj�|d�tj�|d�ttj�d�g�dd�tjtj�|d�tj�|d�ttj�d�g�ddddgd�t�tj�|d�tj�|d�ttj�d �g�ddd!�t�tj�|d"�tj�|d#�ttj�d�g�ddd$�t�tj�|d�tj�|d%�ttj�d�g�ddd&�t�tj�||d'�dtj�||d(�ttj�d�g�ddd)�t�tj�|d*�tj�|d+�ttj�d,�g�ddd-�t�tj�|d.�tj�|d/�ttj�d �g�ddd-�g
}|S|d0k�rtj�||d1�}d|}t�tj�|d2�tj�|d3�ttj�d�g�ddd�t�tj�|d2�tj�|d4�ttj�d�g�ddd5�t�tj�|d6�tj�|d7�ttj�d�g�ddd8�t�tj�|d6�tj�|d9�ttj�d�g�ddd:�t�tj�|d6�tj�|d;�ttj�d�g�ddd<�g}|Sd=S)>z4Return the ground truth for the specified directory.r
zapache2/sites-enabledz/fileszencryption-example.confz#encryption-example.conf/Virtualhostz*:80FTzencryption-example.demozdefault-ssl.confz%default-ssl.conf/IfModule/VirtualHostz
_default_:443z000-default.confz000-default.conf/VirtualHostz[::]:80zip-172-30-0-17zcertbot.confzcertbot.conf/VirtualHostzcertbot.demozwww.certbot.demo)�aliaseszmod_macro-example.confz(mod_macro-example.conf/Macro/VirtualHost)Zmodmacrozdefault-ssl-port-only.confz/default-ssl-port-only.conf/IfModule/VirtualHostz
wildcard.confzwildcard.conf/VirtualHostz*.blue.purple.comz
ocsp-ssl.confz"ocsp-ssl.conf/IfModule/VirtualHostz10.2.3.4:443z
ocspvhost.comrznon-symlink.conf/VirtualHostznonsym.linkz&default-ssl-port-only.conf/VirtualHost�zapache2/apache2.confz apache2/apache2.conf/VirtualHostzvhost.in.rootconfzduplicatehttp.confzduplicatehttp.conf/VirtualHostz10.2.3.4:80zduplicate.example.comzduplicatehttps.confz(duplicatehttps.conf/IfModule/VirtualHostzdebian_apache_2_4/multi_vhostszapache2/sites-availablezdefault.confzdefault.conf/VirtualHost[1]zdefault.conf/VirtualHost[2]zbanana.vomit.comzmulti-vhost.confzmulti-vhost.conf/VirtualHost[1]z1.multi.vhost.tldz%multi-vhost.conf/IfModule/VirtualHostz2.multi.vhost.tldzmulti-vhost.conf/VirtualHost[2]z3.multi.vhost.tldN)rrrrZVirtualHost�setZAddrZ
fromstring)rZconfig_name�prefixZaug_preZvh_truthr*r*r+�get_vh_truth�s^
����
�����������
������F
�������rM)r>rBN)�__doc__r,r8Zunittestr:Zjosepyrr;Zzope.componentr6Zcertbot.compatrZcertbot.displayrr7Zcertbot.pluginsrZ
certbot.testsrZcertbot_apacherrrZTestCaser	r2rrMr*r*r*r+�<module>s*,�
.