3 گac @sdZddlmZddlmZddlmZddlZddlZddlm Z ddl m Z ddl m Z dd lmZdd lmZdd lmZerdd lmZneZy ddlZWn ek rdd lmZYnXdZejjejdZGdddeZGdddZ ee!efe!ddddZ"dS)z'Base test class for DNS authenticators.)Any)Mapping) TYPE_CHECKINGN) challenges) achallenges) filesystem)DNSAuthenticator) acme_util)util)Protocol)mockz example.comzrsa512_key.pemc@s6eZdZUdZeeddddZeddddZdS)_AuthenticatorCallableTestCasezMProtocol describing a TestCase able to call a real DNSAuthenticator instance.N) unused_argsreturncGsdS)zj See https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertTrue N)selfrrr%/usr/lib/python3.6/dns_test_common.py assertTrue$sz)_AuthenticatorCallableTestCase.assertTruecGsdS)zk See https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertEqual Nr)rrrrr assertEqual+sz*_AuthenticatorCallableTestCase.assertEqual) __name__ __module__ __qualname____doc__rauthrrrrrrrr s r c@sReZdZdZejejee dZ e ddddZ e ddddZ e ddd d ZdS) 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 )ZchallbZdomainZ account_keyN)rrcCs|jt|jjtdS)N)r isinstancerZ more_infostr)rrrrtest_more_info?sz$BaseAuthenticatorTest.test_more_infocCs|j|jjdtjgdS)Nz example.org)rrZget_chall_prefrDNS01)rrrrtest_get_chall_prefBsz)BaseAuthenticatorTest.test_get_chall_prefcCs.tj}|jj||jdttjtjddS)Nzpropagation-seconds)typedefaulthelp)r Z MagicMockrZadd_parser_argumentsZassert_any_callintANY)rmrrrtest_parser_argumentsEs z+BaseAuthenticatorTest.test_parser_arguments)rrrrrZ"KeyAuthorizationAnnotatedChallenger rDOMAINKEYZachallr rrr&rrrrr3s r)valuespathrc CsTtj}x|D]}||||<qWt|d}|j|dWdQRXtj|ddS)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)ZoutfileNi) configobjZ ConfigObjopenwriterchmod)r)r*configkeyfrrrr.Ls   r.)#rZtypingrrrr,ZjosepyZjoseZacmerZcertbotrZcertbot.compatrZcertbot.plugins.dns_commonrZ certbot.testsr r Z test_utilZtyping_extensionsr objectr ImportErrorZunittestr'ZJWKRSAloadZ load_vectorr(r rrr.rrrrs.