a }|gd=@s*dZddlZddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z dd l m Z dd lmZddlZddlZdd lmZdd lmZddlmZddlmZddlmZddlmZe*ejde dddl!m"Z"Wdn1s0Yddl#m$Z$ddl%m&Z'dZ(ej)*e'+dZ,e-dZ.eZ/ededZ0ededZ1Gddde$e Z2Gdd d e Z3Gd!d"d"ej4Z5Gd#d$d$Z6Gd%d&d&e$e Z7Gd'd(d(ej4Z8ej9ee 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_errors   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_domains   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_records   z=BaseLexiconClientTest.test_add_txt_record_error_adding_recordcCs0|jt|j|j|jjjd|j|jddSrF)r!r@r7r$r%r" delete_recordrKrLrrrtest_del_txt_records  z)BaseLexiconClientTest.test_del_txt_recordcCs.|j|j|jg|jj_|jt|j|jdSrR) r&r"rOrPr!r@r7r$r%rLrrr'test_del_txt_record_fail_to_find_domains  z=BaseLexiconClientTest.test_del_txt_record_fail_to_find_domaincCs$|j|jj_|jt|j|jdSrR) r(r"rOrPr!r@r7r$r%rLrrr(test_del_txt_record_fail_to_authenticates z>BaseLexiconClientTest.test_del_txt_record_fail_to_authenticatecCs$|j|jj_|jt|j|jdSrR) r)r"rOrPr!r@r7r$r%rLrrr;test_del_txt_record_fail_to_authenticate_with_unknown_errors zQBaseLexiconClientTest.test_del_txt_record_fail_to_authenticate_with_unknown_errorcCs$|j|jj_|jt|j|jdSrR) r'r"rOrPr!r@r7r$r%rLrrr(test_del_txt_record_error_finding_domains z>BaseLexiconClientTest.test_del_txt_record_error_finding_domaincCs$|j|jj_|jt|j|jdSrR) r'r"rYrPr!r@r7r$r%rLrrr)test_del_txt_record_error_deleting_records 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@seZdZeZeZeZeZeddddZeddddZ eddddZ eddd d Z eddd d Z eddd dZ eddddZeddddZeddddZeddddZeddddZeddddZeddddZdS)BaseLexiconDNSAuthenticatorTestNr=c CstJt$\}}|j|jgWdn1s:0YWdn1sX0Y||jdd}|t | d|j j ddt t jddS)Nrlexicon:domainrGr2rH)rBrC_patch_lexicon_clientr3r4r assert_called call_argsr9r7resolverJrKr r8r,rmock_operationsZconfigrrrtest_perform_succeeds  Lz4BaseLexiconDNSAuthenticatorTest.test_perform_succeedc Csxt\t6\}}|j||g|jj_|j|j gWdn1sL0YWdn1sj0YdSrR) rBrCrcr& return_value __enter__rPr3r4r)r,rrhrrr7test_perform_with_one_domain_resolution_failure_succeeds   zWBaseLexiconDNSAuthenticatorTest.test_perform_with_one_domain_resolution_failure_succeedc Cszt^t8\}}|j|jj_|tj |j j |j gWdn1sN0YWdn1sl0YdSrR) rBrCrcr&rjrkrPr-rrSr3r4rr,r_rrr6test_perform_with_two_domain_resolution_failures_raises   zVBaseLexiconDNSAuthenticatorTest.test_perform_with_two_domain_resolution_failures_raisec Cszt^t8\}}|j|jj_|tj |j j |j gWdn1sN0YWdn1sl0YdSrR) rBrCrcr'rjrkrPr-rrSr3r4rrmrrr9test_perform_with_domain_resolution_general_failure_raises   zYBaseLexiconDNSAuthenticatorTest.test_perform_with_domain_resolution_general_failure_raisec CsvtZt4\}}|j|_|tj|jj |j gWdn1sJ0YWdn1sh0YdSrR) rBrCrcr(rPr-rrSr3r4rrmrrr$test_perform_with_auth_failure_raises  zDBaseLexiconDNSAuthenticatorTest.test_perform_with_auth_failure_raisec CsvtZt4\}}|j|_|tj|jj |j gWdn1sJ0YWdn1sh0YdSrR) rBrCrcr)rPr-rrSr3r4rrmrrr,test_perform_with_unknown_auth_failure_raises  zLBaseLexiconDNSAuthenticatorTest.test_perform_with_unknown_auth_failure_raisec Csxt\t6\}}|j|j_|tj|j j |j gWdn1sL0YWdn1sj0YdSrR) rBrCrcr'rJrPr-rrSr3r4rr,rnrhrrr-test_perform_with_create_record_failure_raise s   zMBaseLexiconDNSAuthenticatorTest.test_perform_with_create_record_failure_raisecCsd|j_t$\}}|j|jgWdn1s80Y||jdd}|t| d|j j ddtt j ddS)NTrrbrGr2rH)r3r>rcr?rrdrer9r7rfrYrKr r8rgrrrtest_cleanup_successs .z4BaseLexiconDNSAuthenticatorTest.test_cleanup_successcCsFt,\}}|j|_|j|jgWdn1s80YdSrRrcr(rPr3r?rrmrrr%test_cleanup_with_auth_failure_ignore!s zEBaseLexiconDNSAuthenticatorTest.test_cleanup_with_auth_failure_ignorecCsFt,\}}|j|_|j|jgWdn1s80YdSrRrvrmrrr-test_cleanup_with_unknown_auth_failure_ignore&s zMBaseLexiconDNSAuthenticatorTest.test_cleanup_with_unknown_auth_failure_ignorecCsJt0\}}|j|jj_|j|jgWdn1s<0YdSrR)rcr&rjrkrPr3r?rrmrrr2test_cleanup_with_domain_resolution_failure_ignore,s  zRBaseLexiconDNSAuthenticatorTest.test_cleanup_with_domain_resolution_failure_ignorecCsJt0\}}|j|jj_|j|jgWdn1s<0YdSrR)rcr'rjrkrPr3r?rrmrrr:test_cleanup_with_domain_resolution_general_failure_ignore2s  zZBaseLexiconDNSAuthenticatorTest.test_cleanup_with_domain_resolution_general_failure_ignorecCsHt.\}}|j|j_|j|jgWdn1s: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{rrrrras4           rar+ccsHtd*}t}||jj_||fVWdn1s:0YdS)Nz)certbot.plugins.dns_common_lexicon.Client)r Zpatchr rjrk)rrhrrrrc?s  rcc@sbeZdZdZedddZeedddZeedd d d Z eedd d Z e edddZ dS)_DeprecationModulez Internal class delegating to a module, and displaying warnings when attributes related to deprecated attributes in the current module. )modulecCs||jd<dSN_module)__dict__)r,r~rrr__init__Osz_DeprecationModule.__init__)attrr+cCs0|dvr$tj|dtdtddt|j|S)N)r0rDz attribute in z/ module is deprecated and will be removed soon.) stacklevel)warningswarnrDeprecationWarninggetattrrr,rrrr __getattr__Rs z_DeprecationModule.__getattr__N)rvaluer+cCst|j||dSrR)setattrr)r,rrrrr __setattr__Ysz_DeprecationModule.__setattr__cCst|j|dSrR)delattrrrrrr __delattr__\sz_DeprecationModule.__delattr__r|cCsdgt|jSr)dirrrLrrr__dir___sz_DeprecationModule.__dir__) rrrrrrr.rrrrrrrrrrr}Js r})>r contextlibsystypesrtypingrrrrrrZunittestr Z unittest.mockr rZjosepyZjoseZrequestsr Zrequests.exceptionsr r ZcertbotrZcertbot.achallengesrZcertbot.pluginsrcatch_warningsfilterwarningsrZ"certbot.plugins.dns_common_lexiconrZcertbot.plugins.dns_test_commonrZ certbot.testsrrBr7ZJWKRSAloadZ load_vectorZKEYr/r&r'r(r)rr ZBaseAuthenticatorTestr0rDr`racontextmanagerrcr}modulesrrrrrsP                ,   d t"