a ‚oed=ã@s*dZddlZddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd l m Z dd lmZddlZddlZdd lmZdd lmZddlmZddlmZddlmZddlmZe ¡�*ejde d�ddl!m"Z"Wdƒn1�s0Yddl#m$Z$ddl%m&Z'dZ(ej) *e' +d¡¡Z,e-dƒZ.eZ/edeƒd�Z0edeƒd�Z1Gdd„de$e ƒZ2Gdd „d e ƒZ3Gd!d"„d"ej4ƒZ5Gd#d$„d$ƒZ6Gd%d&„d&e$e ƒZ7Gd'd(„d(ej4ƒZ8ej9ee eefddfd)œd*d+„ƒZ:Gd,d-„d-ƒZ;eee;ejBaseLexiconClientTest.test_add_txt_record_fail_to_authenticatecCs,|j|jj_| tj|jjt |j |j ¡dSrR) r)r"rOrPr-rrSr!r6r7r$r%rLrrrÚ;test_add_txt_record_fail_to_authenticate_with_unknown_error‡s   þzQBaseLexiconClientTest.test_add_txt_record_fail_to_authenticate_with_unknown_errorcCs,|j|jj_| tj|jjt |j |j ¡dSrR) r'r"rOrPr-rrSr!r6r7r$r%rLrrrÚ(test_add_txt_record_error_finding_domain�s   þz>BaseLexiconClientTest.test_add_txt_record_error_finding_domaincCs,|j|jj_| tj|jjt |j |j ¡dSrR) r'r"rJrPr-rrSr!r6r7r$r%rLrrrÚ'test_add_txt_record_error_adding_record–s   þz=BaseLexiconClientTest.test_add_txt_record_error_adding_recordcCs0|j t|j|j¡|jjjd|j|jd�dSrF)r!r@r7r$r%r"Ú delete_recordrKrLrrrÚtest_del_txt_record�s  þz)BaseLexiconClientTest.test_del_txt_recordcCs.|j|j|jg|jj_|j t|j|j¡dSrR) r&r"rOrPr!r@r7r$r%rLrrrÚ'test_del_txt_record_fail_to_find_domain¤s þ z=BaseLexiconClientTest.test_del_txt_record_fail_to_find_domaincCs$|j|jj_|j t|j|j¡dSrR) r(r"rOrPr!r@r7r$r%rLrrrÚ(test_del_txt_record_fail_to_authenticate«s z>BaseLexiconClientTest.test_del_txt_record_fail_to_authenticatecCs$|j|jj_|j t|j|j¡dSrR) r)r"rOrPr!r@r7r$r%rLrrrÚ;test_del_txt_record_fail_to_authenticate_with_unknown_error°s zQBaseLexiconClientTest.test_del_txt_record_fail_to_authenticate_with_unknown_errorcCs$|j|jj_|j t|j|j¡dSrR) r'r"rOrPr!r@r7r$r%rLrrrÚ(test_del_txt_record_error_finding_domain¶s z>BaseLexiconClientTest.test_del_txt_record_error_finding_domaincCs$|j|jj_|j t|j|j¡dSrR) r'r"rYrPr!r@r7r$r%rLrrrÚ)test_del_txt_record_error_deleting_record»s z?BaseLexiconClientTest.test_del_txt_record_error_deleting_record)rrrr&r'r(r)r#r7r$r%r rMrQrTrUrVrWrXrZr[r\r]r^r_rrrrrD]s,   ÿ ÿ rDc@s:eZdZUdZeed<eed<eed<eed<eed<dS)Ú%_BaseLexiconDNSAuthenticatorTestProtoz6Protocol for BaseLexiconDNSAuthenticatorTest instancesr&r'r(r)rN)rrrrr/rrrrrrr`Ás r`c@sìeZdZeZeZeZeZeddœdd„Zeddœdd„Z eddœdd„Z eddœd d „Z eddœd d „Z eddœd d„Z eddœdd„Zeddœdd„Zeddœdd„Zeddœdd„Zeddœdd„Zeddœdd„Zeddœdd„ZdS)ÚBaseLexiconDNSAuthenticatorTestNr=c Cs¨t ¡�Jtƒ�$\}}|j |jg¡Wdƒn1s:0YWdƒn1sX0Y| ¡|jdd}| t |  d¡¡|j j ddt ›�t jd�dS)Nrúlexicon:domainrGr2rH)rBrCÚ_patch_lexicon_clientr3r4rÚ assert_calledÚ call_argsr9r7ÚresolverJrKr r8©r,rÚmock_operationsZconfigrrrÚtest_perform_succeedÒs  Lÿz4BaseLexiconDNSAuthenticatorTest.test_perform_succeedc Csxt ¡�\tƒ�6\}}|j||g|jj_|j |j g¡Wdƒn1sL0YWdƒn1sj0YdSrR) rBrCrcr&Ú return_valueÚ __enter__rPr3r4r)r,rrhrrrÚ7test_perform_with_one_domain_resolution_failure_succeedÞs  ý zWBaseLexiconDNSAuthenticatorTest.test_perform_with_one_domain_resolution_failure_succeedc Cszt ¡�^tƒ�8\}}|j|jj_| tj |j j |j g¡Wdƒn1sN0YWdƒn1sl0YdSrR) rBrCrcr&rjrkrPr-rrSr3r4r©r,rÚ_rrrÚ6test_perform_with_two_domain_resolution_failures_raiseés   þzVBaseLexiconDNSAuthenticatorTest.test_perform_with_two_domain_resolution_failures_raisec Cszt ¡�^tƒ�8\}}|j|jj_| tj |j j |j g¡Wdƒn1sN0YWdƒn1sl0YdSrR) rBrCrcr'rjrkrPr-rrSr3r4rrmrrrÚ9test_perform_with_domain_resolution_general_failure_raiseòs   þzYBaseLexiconDNSAuthenticatorTest.test_perform_with_domain_resolution_general_failure_raisec Csvt ¡�Ztƒ�4\}}|j|_| tj|jj |j g¡Wdƒn1sJ0YWdƒn1sh0YdSrR) rBrCrcr(rPr-rrSr3r4rrmrrrÚ$test_perform_with_auth_failure_raiseûs  þzDBaseLexiconDNSAuthenticatorTest.test_perform_with_auth_failure_raisec Csvt ¡�Ztƒ�4\}}|j|_| tj|jj |j g¡Wdƒn1sJ0YWdƒn1sh0YdSrR) rBrCrcr)rPr-rrSr3r4rrmrrrÚ,test_perform_with_unknown_auth_failure_raises  þzLBaseLexiconDNSAuthenticatorTest.test_perform_with_unknown_auth_failure_raisec Csxt ¡�\tƒ�6\}}|j|j_| tj|j j |j g¡Wdƒn1sL0YWdƒn1sj0YdSrR) rBrCrcr'rJrPr-rrSr3r4r©r,rnrhrrrÚ-test_perform_with_create_record_failure_raise s   þzMBaseLexiconDNSAuthenticatorTest.test_perform_with_create_record_failure_raisecCsˆd|j_tƒ�$\}}|j |jg¡Wdƒn1s80Y| ¡|jdd}| t|  d¡¡|j j ddt›�t j d�dS)NTrrbrGr2rH)r3r>rcr?rrdrer9r7rfrYrKr r8rgrrrÚtest_cleanup_successs .ÿz4BaseLexiconDNSAuthenticatorTest.test_cleanup_successcCsFtƒ�,\}}|j|_|j |jg¡Wdƒn1s80YdSrR©rcr(rPr3r?rrmrrrÚ%test_cleanup_with_auth_failure_ignore!s zEBaseLexiconDNSAuthenticatorTest.test_cleanup_with_auth_failure_ignorecCsFtƒ�,\}}|j|_|j |jg¡Wdƒn1s80YdSrRrvrmrrrÚ-test_cleanup_with_unknown_auth_failure_ignore&s zMBaseLexiconDNSAuthenticatorTest.test_cleanup_with_unknown_auth_failure_ignorecCsJtƒ�0\}}|j|jj_|j |jg¡Wdƒn1s<0YdSrR)rcr&rjrkrPr3r?rrmrrrÚ2test_cleanup_with_domain_resolution_failure_ignore,s  zRBaseLexiconDNSAuthenticatorTest.test_cleanup_with_domain_resolution_failure_ignorecCsJtƒ�0\}}|j|jj_|j |jg¡Wdƒn1s<0YdSrR)rcr'rjrkrPr3r?rrmrrrÚ:test_cleanup_with_domain_resolution_general_failure_ignore2s  zZBaseLexiconDNSAuthenticatorTest.test_cleanup_with_domain_resolution_general_failure_ignorecCsHtƒ�.\}}|j|j_|j |jg¡Wdƒn1s:0YdSrR)rcr'rJrPr3r?rrsrrrÚ.test_cleanup_with_delete_record_failure_ignore8s  zNBaseLexiconDNSAuthenticatorTest.test_cleanup_with_delete_record_failure_ignore)rrrr&r'r(r)r`rirlrorprqrrrtrurwrxryrzr{rrrrraËs4 ÿ ÿ ÿ  ÿ ÿ  ÿ ÿ ÿ ÿra©r+ccsHt d¡�*}tƒ}||jj_||fVWdƒn1s:0YdS)Nz)certbot.plugins.dns_common_lexicon.Client)r Zpatchr rjrk)rrhrrrrc?s  rcc@sbeZdZdZedœdd„Zeedœdd„Zeedd œd d „Z eedœd d „Z e edœdd„Z dS)Ú_DeprecationModulez” Internal class delegating to a module, and displaying warnings when attributes related to deprecated attributes in the current module. )ÚmodulecCs||jd<dS©NÚ_module)Ú__dict__)r,r~rrrÚ__init__Osz_DeprecationModule.__init__)Úattrr+cCs0|dvr$tj|›dt›d�tdd�t|j|ƒS)N)r0rDz attribute in z/ module is deprecated and will be removed soon.é)Ú stacklevel)ÚwarningsÚwarnrÚDeprecationWarningÚgetattrr€©r,rƒrrrÚ __getattr__Rs þz_DeprecationModule.__getattr__N)rƒÚvaluer+cCst|j||ƒdSrR)Úsetattrr€)r,rƒrŒrrrÚ __setattr__Ysz_DeprecationModule.__setattr__cCst|j|ƒdSrR)Údelattrr€rŠrrrÚ __delattr__\sz_DeprecationModule.__delattr__r|cCsdgt|jƒSr)Údirr€rLrrrÚ__dir___sz_DeprecationModule.__dir__) rrrrrr‚r.rr‹rŽr�rr’rrrrr}Js r})>rÚ contextlibÚsysÚtypesrÚtypingrrrrrrZunittestr Z unittest.mockr r†ZjosepyZjoseZrequestsr Zrequests.exceptionsr r ZcertbotrZcertbot.achallengesrZcertbot.pluginsrÚcatch_warningsÚfilterwarningsrˆZ"certbot.plugins.dns_common_lexiconrZcertbot.plugins.dns_test_commonrZ certbot.testsrrBr7ZJWKRSAÚloadZ load_vectorZKEYr/r&r'r(r)rr ZBaseAuthenticatorTestr0rDr`raÚcontextmanagerrcr}ÚmodulesrrrrrÚsP                ,   d t"