
    M/eK
                     2   d Z ddlmZ ddlmZ ddlmZ ddlm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dlmZ dZe	j.                  j1                   ej2                  d            Z G d de      Z G d d      Zdeeef   deddfdZy)z'Base test class for DNS authenticators.    )Any)Mapping)Protocol)mockN)
challenges)achallenges)
filesystem)DNSAuthenticator)	acme_util)utilzexample.comzrsa512_key.pemc                   L    e Zd ZU dZeed<   deddfdZdeddfdZdeddfdZ	y)	_AuthenticatorCallableTestCasezMProtocol describing a TestCase able to call a real DNSAuthenticator instance.authunused_argsreturnNc                      y)zj
        See
        https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertTrue
        N selfr   s     A/usr/lib/python3/dist-packages/certbot/plugins/dns_test_common.py
assertTruez)_AuthenticatorCallableTestCase.assertTrue           c                      y)zk
        See
        https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertEqual
        Nr   r   s     r   assertEqualz*_AuthenticatorCallableTestCase.assertEqual   r   r   c                      y)zl
        See
        https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaises
        Nr   r   s     r   assertRaisesz+_AuthenticatorCallableTestCase.assertRaises%   r   r   )
__name__
__module____qualname____doc__r
   __annotations__r   r   r   r   r   r   r   r   r      sD    W
s t     r   r   c                   ~    e Zd ZdZ ej
                  ej                  ee	      Z
deddfdZdeddfdZdeddfdZy)	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
    )challbdomainaccount_keyr   r   Nc                 r    | j                  t        | j                  j                         t                     y )N)r   
isinstancer   	more_infostrr   s    r   test_more_infoz$BaseAuthenticatorTest.test_more_info8   s"    
499#6#6#8#>?r   c                 x    | j                  | j                  j                  d      t        j                  g       y )Nzexample.org)r   r   get_chall_prefr   DNS01r,   s    r   test_get_chall_prefz)BaseAuthenticatorTest.test_get_chall_pref;   s*    11-@:CSCSBTUr   c                     t        j                         }| j                  j                  |       |j	                  dt
        t         j                  t         j                         y )Nzpropagation-seconds)typedefaulthelp)r   	MagicMockr   add_parser_argumentsassert_any_callintANY)r   ms     r   test_parser_argumentsz+BaseAuthenticatorTest.test_parser_arguments>   sC    NN		&&q)	/c488RVRZRZ[r   )r   r   r    r!   r   "KeyAuthorizationAnnotatedChallenger   r0   DOMAINKEYachallr   r-   r1   r<   r   r   r   r$   r$   ,   sl     <[;;v3@F@; @ @V"@ VT V\$B \t \r   r$   valuespathr   c                     t        j                         }| D ]
  }| |   ||<    t        |d      5 }|j                  |       ddd       t	        j
                  |d       y# 1 sw Y    xY w)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)outfileNi  )	configobj	ConfigObjopenwriter	   chmod)rA   rB   configkeyfs        r   rI   rI   E   sq       "F "Sks" 
dD	  QQ  T5!   s   A""A+)r!   typingr   r   r   unittestr   rF   josepyjoseacmer   certbotr   certbot.compatr	   certbot.plugins.dns_commonr
   certbot.testsr   r   	test_utilr>   JWKRSAloadload_vectorr?   r   r$   r+   rI   r   r   r   <module>r[      s    -         % 7 # +	
kk,y,,-=>?X .\ \2"'#s(# "3 "4 "r   