a }|gK @sdZddlmZddlmZddlmZddlmZddlZddlZ ddl m Z ddl m Z dd lmZdd lmZdd lmZdd lmZd Ze jedZGdddeZGdddZeeefeddddZdS)z'Base test class for DNS authenticators.)Any)Mapping)Protocol)mockN) challenges) achallenges) filesystem)DNSAuthenticator) acme_util)utilz example.comzrsa512_key.pemc@sJeZdZUdZeed<eddddZeddddZeddd d Z dS) _AuthenticatorCallableTestCasezMProtocol describing a TestCase able to call a real DNSAuthenticator instance.authN) unused_argsreturncGsdS)zj See https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertTrue NselfrrrC/usr/lib/python3.9/site-packages/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 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 )ZchallbdomainZ account_keyN)rrcCs|t|jtdS)N)r isinstancer Z more_infostrrrrrtest_more_info8sz$BaseAuthenticatorTest.test_more_infocCs||jdtjgdS)Nz example.org)rr Zget_chall_prefrDNS01r rrrtest_get_chall_pref;sz)BaseAuthenticatorTest.test_get_chall_prefcCs.t}|j||jdttjtjddS)Nzpropagation-seconds)typedefaulthelp)rZ MagicMockr Zadd_parser_argumentsZassert_any_callintANY)rmrrrtest_parser_arguments>s z+BaseAuthenticatorTest.test_parser_arguments)rrrrrZ"KeyAuthorizationAnnotatedChallenger r"DOMAINKEYZachallr r!r#r*rrrrr,sr)valuespathrcCsdt}|D]}||||<q t|d}|j|dWdn1sJ0Yt|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.Zconfigkeyfrrrr2Es  *r2)rtypingrrrZunittestrr0ZjosepyZjoseZacmerZcertbotrZcertbot.compatrZcertbot.plugins.dns_commonr Z certbot.testsr r Z test_utilr+ZJWKRSAloadZ load_vectorr,r rrr2rrrrs"