U
    ÓZj•  ã                   @   s’   d Z ddlZddlZddlZddlZddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ dZej e d	¡¡ZG d
d„ deƒZdd„ ZdS )z'Base test class for DNS authenticators.é    N)Ú
challenges)Úachallenges)Ú
filesystem)Ú	acme_util)Úutilzexample.comzrsa512_key.pemc                   @   s:   e Zd ZdZejejee	d�Z
dd„ Zdd„ Zdd„ Zd	S )
ÚBaseAuthenticatorTestzÜ
    A base test class to reduce duplication between test code for DNS Authenticator Plugins.

    Assumes:
     * That subclasses also subclass unittest.TestCase
     * That the authenticator is stored as self.auth
    )ZchallbÚdomainZaccount_keyc                 C   s   |   t| j ¡ tjƒ¡ d S ©N)Z
assertTrueÚ
isinstanceÚauthZ	more_infoÚsixÚstring_types©Úself© r   úb/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/certbot/plugins/dns_test_common.pyÚtest_more_info   s    z$BaseAuthenticatorTest.test_more_infoc                 C   s   |   | j d ¡tjg¡ d S r	   )ZassertEqualr   Zget_chall_prefr   ÚDNS01r   r   r   r   Útest_get_chall_pref#   s    z)BaseAuthenticatorTest.test_get_chall_prefc                 C   s.   t  ¡ }| j |¡ |jdtt jt jd� d S )Nzpropagation-seconds)ÚtypeÚdefaultÚhelp)ÚmockZ	MagicMockr   Zadd_parser_argumentsZassert_any_callÚintÚANY)r   Úmr   r   r   Útest_parser_arguments'   s    z+BaseAuthenticatorTest.test_parser_argumentsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Z"KeyAuthorizationAnnotatedChallenger   r   ÚDOMAINÚKEYZachallr   r   r   r   r   r   r   r      s     ÿr   c              	   C   sP   t  ¡ }| D ]}| | ||< qt|dƒ�}|j|d� W 5 Q R X t |d¡ dS )z”Write the specified values to a config file.

    :param dict values: A map of values to write.
    :param str path: Where to write the values.
    Úwb)Úoutfilei€  N)Ú	configobjZ	ConfigObjÚopenÚwriter   Úchmod)ÚvaluesÚpathÚconfigÚkeyÚfr   r   r   r'   0   s    r'   )r    r%   ZjosepyZjoser   r   Zacmer   Zcertbotr   Zcertbot.compatr   Zcertbot.testsr   r   Z	test_utilr!   ZJWKRSAÚloadZload_vectorr"   Úobjectr   r'   r   r   r   r   Ú<module>   s   