a ‚oeK ã@sÞdZddlmZddlmZddlmZddlmZddlZddlZ ddl m Z ddl m Z dd lmZdd lmZdd lmZdd lmZd Ze j e d¡¡ZGdd„deƒZGdd„dƒZeeefeddœdd„ZdS)z'Base test class for DNS authenticators.é)ÚAny)ÚMapping)ÚProtocol)ÚmockN)Ú challenges)Ú achallenges)Ú filesystem)ÚDNSAuthenticator)Ú acme_util)Úutilz example.comzrsa512_key.pemc@sJeZdZUdZeed<eddœdd„Zeddœdd„Zeddœd d „Z dS) Ú_AuthenticatorCallableTestCasezMProtocol describing a TestCase able to call a real DNSAuthenticator instance.ÚauthN)Ú unused_argsÚreturncGsdS)zj See https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertTrue N©©Úselfrrrú@C:\Program Files\Certbot\pkgs\certbot\plugins\dns_test_common.pyÚ assertTruesz)_AuthenticatorCallableTestCase.assertTruecGsdS)zk See https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertEqual NrrrrrÚ assertEqualsz*_AuthenticatorCallableTestCase.assertEqualcGsdS)zl See https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaises NrrrrrÚ assertRaises%sz+_AuthenticatorCallableTestCase.assertRaises) Ú__name__Ú __module__Ú __qualname__Ú__doc__r Ú__annotations__rrrrrrrrr s r c@sReZdZdZejejee d�Z e ddœdd„Z e ddœdd„Z e ddœd 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 )ZchallbÚdomainZ account_keyN)rrcCs| t|j ¡tƒ¡dS)N)rÚ isinstancer Z more_infoÚstr©rrrrÚtest_more_info8sz$BaseAuthenticatorTest.test_more_infocCs| |j d¡tjg¡dS)Nz example.org)rr Zget_chall_prefrÚDNS01r rrrÚtest_get_chall_pref;sz)BaseAuthenticatorTest.test_get_chall_prefcCs.t ¡}|j |¡|jdttjtjd�dS)Nzpropagation-seconds)ÚtypeÚdefaultÚhelp)rZ MagicMockr Zadd_parser_argumentsZassert_any_callÚintÚANY)rÚmrrrÚtest_parser_arguments>s z+BaseAuthenticatorTest.test_parser_arguments)rrrrrZ"KeyAuthorizationAnnotatedChallenger r"ÚDOMAINÚKEYZachallr r!r#r*rrrrr,sÿr)ÚvaluesÚpathrcCsdt ¡}|D]}||||<q t|dƒ�}|j|d�Wdƒn1sJ0Yt |d¡dS)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)ZoutfileNi€)Ú configobjZ ConfigObjÚopenÚwriterÚchmod)r-r.ZconfigÚkeyÚfrrrr2Es  *r2)rÚtypingrrrZunittestrr0ZjosepyZjoseZacmerZcertbotrZcertbot.compatrZcertbot.plugins.dns_commonr Z certbot.testsr r Z test_utilr+ZJWKRSAÚloadZ load_vectorr,r rrr2rrrrÚs"