U
    ]                     @   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challbZdomainZaccount_keyc                 C   s   |  t| j tj d S N)Z
assertTrue
isinstanceauthZ	more_infosixZstring_typesself r   A/usr/lib/python3/dist-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 )zWrite 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)Zoutfilei  N)	configobjZ	ConfigObjopenwriter   chmod)valuespathZ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   