a }|ägäâã@s2dZddlZddlZddlmZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddlZddlmZddlZddlZddlZddlZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lm Z dd lm!Z!ddlm"Z"ddlm#Z#ddl$m%Z%ddl$m&Z&ddl$m'Z'ddl$m(Z(ddl)m*Z*ddl)m+Z+ddl,m-Z-ddl.m/mZ0e0 1d¡Z2e0 1d¡Z3e0 1d¡Z4e0 1d¡Z5ej6 7e0 8d¡¡Z9e0 1d¡Z:e0 1d¡Z;Gdd„dej<ƒZ=Gdd „d e0j>ƒZ?Gd!d"„d"ej<ƒZ@Gd#d$„d$ej<ƒZAGd%d&„d&e0jBƒZCGd'd(„d(e0jBƒZDGd)d*„d*e0j>ƒZEGd+d,„d,e0j>ƒZFGd-d.„d.e0j>ƒZGGd/d0„d0ej<ƒZHGd1d2„d2e0j>ƒZIGd3d4„d4e0j>ƒZJGd5d6„d6e0j>ƒZKGd7d8„d8ej<ƒZLGd9d:„d:ej<ƒZMGd;d<„dƒZNGd=d>„d>e0j>ƒZOGd?d@„d@ƒZPeQdAkr.e  Re "e jSdBd…eTg¡¡dS)Cz!Tests for certbot._internal.main.éN)Úreload)ÚList)Úmock)ÚError)Ú crypto_util©Úerrors)Ú interfaces)Úutil)Úaccount)Úcli)Ú constants)Úmain)Úupdater)Údisco)Úmanual)Únull)Ú standalone)Ú filesystem)Úos)Ú enhancementsú cert_512.pemz csr_512.derzrsa256_key.pemzrsa512_key.pemzrsa2048_key.pemz cert_2048.pemc@sleZdZdZe d¡dd„ƒZe d¡e d¡e d¡dd„ƒƒƒZe d¡d d „ƒZe d ¡d d „ƒZ dS)ÚTestHandleCertsz1Test for certbot._internal.main._handle_* methodsúsÿz:TestHandleCerts.test_handle_identical_cert_key_type_changecCs6t ¡}d|_t ¡}ddg|j_t |dg|¡}dS)NTZdummy1Zdummy2)rrÚexpandÚnamesrrZ_handle_subset_cert_request)rr Ú mock_configr!r"r#r#r$Útest_handle_subset_cert_requestMs  z/TestHandleCerts.test_handle_subset_cert_requestz)certbot._internal.main.display_util.yesnocCsæt ¡}t ¡}||_t ¡}d|_d|_t ||¡| ¡d|_d|_t ||¡d|_d|_t ||¡d|_t ||¡d|_dd„|_ t j t j ddt ||¡Wdƒn1sÂ0Yd d„|_ t ||¡dS) NZrsaÚecdsaTFcSs|dkS)NÚcertnamer#©Úvarr#r#r$Ú{ózKTestHandleCerts.test_handle_unexpected_key_type_migration..z.Please provide both --cert-name and --key-type©ÚmatchcSs|dkS)NÚkey_typer#r1r#r#r$r3€r4)rrZ set_by_userr7Úprivate_key_typerZ%_handle_unexpected_key_type_migrationÚassert_not_calledrÚ side_effectÚpytestÚraisesrr)rZ mock_yesnoÚconfigZmock_setÚcertr#r#r$Ú)test_handle_unexpected_key_type_migrationWs.     *  z9TestHandleCerts.test_handle_unexpected_key_type_migrationN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rÚpatchr%r*r.r?r#r#r#r$r3s   rcsveZdZdZ‡fdd„Zdd„Zdd„Zdd „Zd d „Ze   d ¡d d„ƒZ e   d¡dd„ƒZ e   d ¡dd„ƒZ ‡ZS)ÚRunTestz%Tests for certbot._internal.main.run.c sôtƒ ¡d|_t d¡t d¡t d¡t d¡t d¡t d¡t d¡t d ¡t d ¡g }|d  ¡|_|d  ¡|_|d  ¡|_|d ¡|_ |d ¡|_ |d ¡|_ |d ¡|_ |d ¡|_ |d ¡|_|D]}| |j¡qÞdS)Nz example.orgú)certbot._internal.main._get_and_save_certz7certbot._internal.main.display_ops.success_installationz2certbot._internal.main.display_ops.success_renewalú&certbot._internal.main._init_le_clientú7certbot._internal.main._suggest_donation_if_appropriateú'certbot._internal.main._report_new_certú!certbot._internal.main._find_certú)certbot._internal.eff.handle_subscriptionú)certbot._internal.main._report_next_stepsréééééééé)ÚsuperÚsetUpÚdomainrrDÚstartÚ mock_authÚmock_success_installationÚmock_success_renewalÚ mock_initZmock_suggest_donationÚmock_report_certÚmock_find_certÚmock_subscriptionÚmock_report_next_stepsÚ addCleanupÚstop)rÚpatchesrD©Ú __class__r#r$rVˆs. ÷ z RunTest.setUpcCs@d |j¡ ¡}tj ¡}t ||¡}ddlm }|||ƒdS)Nz-a webroot -i null -d {0}r)r') ÚformatrWÚsplitrÚPluginsRegistryÚfind_allr Úprepare_and_parse_argsÚcertbot._internal.mainr')rÚargsÚpluginsr=r'r#r#r$Ú_call£s    z RunTest._callcCsHt ¡|j_d|j_| ¡|j |jg¡|j jtj dtj dddS)N©TNT©Znew_or_renewed_cert) rrrYrr^rnrZÚassert_called_once_withrWr`ÚANY©rr#r#r$Útest_newcert_success«s ÿzRunTest.test_newcert_successcCs8t ¡|j_dt ¡f|j_| ¡|j |jg¡dSr) rrrYrr^rnrZrqrWrsr#r#r$Útest_reinstall_success³s zRunTest.test_reinstall_successcCs8t ¡|j_dt ¡f|j_| ¡|j |jg¡dS©NT) rrrYrr^rnr[rqrWrsr#r#r$Útest_renewal_success¹s zRunTest.test_renewal_successú;certbot._internal.main.plug_sel.choose_configurator_pluginscCsdt |jd¡df|_tj ¡}d|j_t  t j ¡t   |j|¡Wdƒn1sV0YdS©NrT)rÚ Installerr=rrrhriÚ auto_hstsr;r<rÚNotSupportedErrorrr'©rÚ mock_choosermr#r#r$Ú"test_run_enhancement_not_supported¿s  z*RunTest.test_run_enhancement_not_supportedú$certbot._internal.main._install_certcCs|t d¡|_t ¡|j_d|j_t  tj¡|  ¡Wdƒn1sJ0Y|j j tj |jtj dd|j ¡dS)NzFake installation errorroTrp)rZ PluginErrorr:rrrYrr^r;r<rnr`rqrrrZr9)rZmock_install_certr#r#r$Útest_cert_success_install_errorÇs  &ÿz'RunTest.test_cert_success_install_errorcCsdt |jd¡df|_tj ¡}d|j_t  t j ¡t   |j|¡Wdƒn1sV0YdSry)rrzr=rrrhriZ must_stapler;r<rr|rr'r}r#r#r$Ú"test_run_must_staple_not_supportedÕs  z*RunTest.test_run_must_staple_not_supported)r@rArBrCrVrnrtrurwrrDrrr‚Ú __classcell__r#r#rdr$rE…s   rEc@s¨eZdZdZdd„Zdd„Zdd„Ze d¡e d ¡e d ¡d d „ƒƒƒZ d d„Z e d¡e d¡e d¡e d¡e d¡e d ¡dd„ƒƒƒƒƒƒZ e d¡e d¡e d¡e d¡e d ¡dd„ƒƒƒƒƒZ e d¡e d ¡e d¡e d¡dd„ƒƒƒƒZ e d¡e d ¡e d¡e d ¡e d¡dd„ƒƒƒƒƒZe d¡e d ¡e d¡e d ¡e d¡dd „ƒƒƒƒƒZe d¡e d ¡e d¡e d ¡d!d"„ƒƒƒƒZd#S)$Ú CertonlyTestz*Tests for certbot._internal.main.certonly.cCst ¡|_|j ¡|_dS©N)Ú test_utilÚpatch_display_utilÚget_utility_patchrXÚmock_get_utilityrsr#r#r$rVàs zCertonlyTest.setUpcCs|j ¡dSr…©rˆrbrsr#r#r$ÚtearDownäszCertonlyTest.tearDownc Cs¦tj ¡}t ||¡}t d¡p}t d¡Ft d¡t ||¡Wdƒn1sZ0YWdƒn1sx0YWdƒn1s–0Y|ƒS)NrGrHrK) rrhrir rjrrDrÚcertonly)rrlrmr=r\r#r#r$rnçs     fzCertonlyTest._callrJrFrIcCs4| ¡j}|j|_t ¡|_d|_| d ¡¡dS)N)FNz!certonly --webroot -d example.com) r‰Ú notificationÚ_assert_no_pauser:rrrrnrg)rZ unused_reportrYr^Zmock_notificationr#r#r$Útest_no_reinstall_text_pauseòs   z)CertonlyTest.test_no_reinstall_text_pausecOsdSr…r#)rrlÚkwargsr#r#r$rŽüszCertonlyTest._assert_no_pauserLú3certbot._internal.cert_manager.lineage_for_certnameú3certbot._internal.cert_manager.domains_for_certnamez$certbot._internal.renewal.renew_certrcCs’ddg}||_||j_| d ¡¡|jtjdtjdd| d ¡¡d| ¡j_t   t j ¡| d ¡¡Wdƒn1s„0YdS)Nú example.comztest.orgzEcertonly --webroot -d example.com -d test.org --cert-name example.comTrpúEcertonly --webroot -d example.com -d test.com --cert-name example.comF) rr,rnrgrqrrrr‰Úyesnor;r<rÚConfigurationError)rr]Zmock_handle_typeÚmock_renew_certÚ mock_domainsr!r`Údomainsr#r#r$Ú*test_find_lineage_for_domains_and_certnameÿs ÿ z7CertonlyTest.test_find_lineage_for_domains_and_certnameú certbot.display.ops.choose_namescCs4d|_| d ¡¡dg|_d|_| d ¡¡dS)Nr”Zsomenamez*certonly --webroot --cert-name example.com)rrnrg)rr]r!Úmock_choose_namesZmock_domains_for_certnameZunused_mock_report_next_stepsr#r#r$Ú*test_find_lineage_for_domains_new_certname#s z7CertonlyTest.test_find_lineage_for_domains_new_certnamez-certbot._internal.main._csr_get_and_save_certcCsZd|_d|_dt›dfD]:}| d|›d ¡¡|jtjtjtjdd| ¡qdS) zLcertonly --dry-run shouldn't report creation of a certificate in NEXT STEPS.N)z/certz/chainz /fullchainz--csr z-d example.comz certonly z, --webroot --cert-name example.com --dry-runFrp)rÚCSRrnrgrqrrrZ reset_mock)rr!Zmock_csr_get_certZunused_mock_get_certr`Úflagr#r#r$Ú$test_dryrun_next_steps_no_cert_saved8sÿz1CertonlyTest.test_dryrun_next_steps_no_cert_savedú?certbot._internal.plugins.selection.choose_configurator_pluginscCs>t ¡}|df|_t ¡|_d|_| d ¡¡|j ¡dS)Nrozcertonly --nginx -d example.com)rr)rrnrgÚrestartZassert_called_once©rÚmock_selÚ mock_get_certr^Úunused_report_newÚunused_report_nextZmock_installerr#r#r$Útest_installer_runs_restartGs   z(CertonlyTest.test_installer_runs_restartcCs>t ¡}|df|_t ¡|_d|_| d ¡¡|j ¡dS)Nroz)certonly --nginx -d example.com --dry-run)rr)rrnrgr¢r9r£r#r#r$Ú$test_dryrun_installer_doesnt_restartVs   z1CertonlyTest.test_dryrun_installer_doesnt_restartcCs2t ¡|_d|_| dt ¡›dd ¡¡dS)Nrozcertonly --webroot -w ú z-i standalone -d example.com)rr)rrnÚtempfileÚ gettempdirrg)rr¥r^r¦r§r#r#r$Útest_invalid_installeres  ÿz#CertonlyTest.test_invalid_installerN)r@rArBrCrVr‹rnrrDrrŽršrr r¨r©r­r#r#r#r$r„ÝsX    r„c@sFeZdZdZe d¡dd„ƒZe d¡dd„ƒZe d¡dd „ƒZd S) ÚFindDomainsOrCertnameTestz;Tests for certbot._internal.main._find_domains_or_certname.r›cCstjddd}d|_dS)N©r™r0Z domainname©rrr©rrœr-r#r#r$Útest_display_opstsz*FindDomainsOrCertnameTest.test_display_opscCsPtjddd}g|_t tj¡t |d¡Wdƒn1sB0YdS)Nr¯) rrrr;r<rrrZ_find_domains_or_certnamer±r#r#r$Útest_no_results{sz)FindDomainsOrCertnameTest.test_no_resultsr’cCstjddd}ddg|_dS)Nzone.comr¯ztwo.comr°)rr˜r-r#r#r$Útest_grab_domainsƒs z+FindDomainsOrCertnameTest.test_grab_domainsN) r@rArBrCrrDr²r³r´r#r#r#r$r®qs  r®cseZdZdZ‡fdd„Zddd„Ze d¡e d¡d d „ƒƒZe d¡e d ¡e d ¡e d ¡dd„ƒƒƒƒZ e d¡e d ¡e d ¡e d ¡dd„ƒƒƒƒZ e d¡e d ¡e d ¡e d ¡dd„ƒƒƒƒZ e d¡dd„ƒZ dd„Z e d¡e d¡e ¡dd„ƒƒƒZ‡ZS)Ú RevokeTestz(Tests for certbot._internal.main.revoke.c stƒ ¡t t|j¡tj tj  |jd¡¡|_ t   d¡t   d¡t   d¡t   d¡g}|d  ¡j|_|d  ¡|d  ¡|_|d   ¡|_|D]}| |j¡q’dd lm}t  ¡|_|jd tjd d ddddtjdd|_||jt|jƒ|_|jdf|j_dS)Nrz$certbot._internal.client.acme_clientzcertbot._internal.client.Clientú)certbot._internal.main._determine_accountz5certbot._internal.main.display_ops.success_revocationrrMrNrO)ÚAccountztest.certbot.orgißrSrPéé )Ztzinfo)Z creation_hostZ creation_dt) rUrVÚshutilÚcopyÚ CERT_PATHÚtempdirrÚpathÚabspathÚjoinÚ tmp_cert_pathrrDrXÚClientV2Úmock_acme_clientÚmock_determine_accountÚmock_success_revokerarbZcertbot._internal.accountr·r)ÚregrZMetaÚdatetimeÚpytzZUTCÚmetaÚJWKÚaccr)rrcrDr·rdr#r$rVs0 ü   ÿþzRevokeTest.setUpNcCsH|sd}| |j¡ ¡}tj ¡}t ||¡}ddlm }|||ƒdS)Nzrevoke --cert-path={0} r)Úrevoke) rfrÁrgrrhrir rjrkrÌ)rrlrmr=rÌr#r#r$rn­s   zRevokeTest._callú-certbot._internal.main._delete_if_appropriateú)certbot._internal.main.client.acme_clientcCsd|_| ¡j}g}tj ¡D]l\}}d |j|¡ ¡}|  |¡|  t   t j |¡¡d |j| ¡¡ ¡}|  |¡|  t   t j |¡¡qdS)NFz#revoke --cert-path={0} --reason {1})rrÂrÌr ZREVOCATION_REASONSÚitemsrfrÁrgrnÚappendrÚcallrrÚupper)rrÃÚmock_delete_if_appropriateÚ mock_revokeZexpectedÚreasonÚcoderlr#r#r$Útest_revoke_with_reason·s  ÿ z"RevokeTest.test_revoke_with_reasonú'certbot._internal.storage.RenewableCertú3certbot._internal.storage.renewal_file_for_certnamez-certbot._internal.client.acme_from_config_keycCsD|j|_tj|jdd|_d ¡}d|_| |¡|j |j¡dS)Núhttps://acme.example©Ú cert_pathÚserverúrevoke --cert-name=example.comF) rÃrrr)rÁrgrnrÅrq©rZmock_acme_from_configZ%unused_mock_renewal_file_for_certnameZ mock_certrÓrlr#r#r$Útest_revoke_by_certnameÈsÿ z"RevokeTest.test_revoke_by_certnamecCs<tj|jdd|_d ¡}d|_| |¡|j |j¡dS)z9Revoking with --server should use the server from the CLIrÚrÛz=revoke --cert-name=example.com --server https://other.exampleFN©rr)rÁrrgrnrÅrqrßr#r#r$Ú"test_revoke_by_certname_and_serverÙsÿ z-RevokeTest.test_revoke_by_certname_and_servercCs<tj|jdd|_d ¡}d|_| |¡|j |j¡dS)zLRevoking with --cert-name where the lineage server is empty shouldn't crash NrÛrÞFrárßr#r#r$Ú$test_revoke_by_certname_empty_serverês  z/RevokeTest.test_revoke_by_certname_empty_servercCs | ¡d|_|j |j¡dSr)rnrrÅrqrÁ)rrÓr#r#r$Útest_revocation_successúsz"RevokeTest.test_revocation_successcCsZddlm}| ¡|j_t |j¡| ¡Wdƒn1sB0Y|j  ¡dS)Nrr) ÚacmerZ ClientErrorrÃr:r;r<rnrÅr9)rZ acme_errorsr#r#r$Útest_revocation_errors   &z RevokeTest.test_revocation_errorú%certbot._internal.cert_manager.deletecCsd|ƒj_d|_| ¡dSr)r•rrn)rr‰Ú mock_deleterÓr#r#r$Útest_revocation_with_prompts z&RevokeTest.test_revocation_with_prompt)N)r@rArBrCrVrnrrDr×ràrârãrärær†r‡rérƒr#r#rdr$rµŒs8       rµcs¤eZdZdZ‡fdd„Z‡fdd„Zdd„Zdd „Ze  d ¡d d „ƒZ d d„Z dd„Z e  d¡dd„ƒZ dd„Ze  d¡dd„ƒZdd„Ze  d¡dd„ƒZ‡ZS)ÚReconfigureTestz,Tests for certbot._internal.main.reconfigurec sTtƒ ¡t ¡|_|j ¡|_t d¡t d¡t d¡t d¡t d¡t d¡t d¡t d¡d œ|_ d d „|j   ¡Dƒ|_ d g|j d _ t j |jd¡|_t j |jd¡}t j |¡sÄt |¡t j |d¡|_d}t|jdƒ}| |¡Wdƒn1s0Yt|jdƒ"}tj|ddd|_Wdƒn1sF0YdS)Nz7certbot._internal.storage.RenewableCert._check_symlinksz-certbot._internal.storage.RenewableCert.namesz2certbot._internal.plugins.selection.pick_installerz6certbot._internal.plugins.selection.pick_authenticatorz9certbot._internal.plugins.disco.PluginsRegistry.find_initrFrGz"certbot._internal.hooks.list_hooks)Zcheck_symlinksÚ cert_namesÚpick_installerÚ pick_authÚ find_initÚ_get_and_save_certZ_init_le_clientZ list_hookscSsi|]\}}|| ¡“qSr#©rX©Ú.0ÚkÚvr#r#r$Ú #r4z)ReconfigureTest.setUp..r“rër=Úrenewalzexample.com.confa” version = 1.32.0 archive_dir = /etc/letsencrypt/archive/example.com cert = /etc/letsencrypt/live/example.com/cert.pem privkey = /etc/letsencrypt/live/example.com/privkey.pem chain = /etc/letsencrypt/live/example.com/chain.pem fullchain = /etc/letsencrypt/live/example.com/fullchain.pem # Options used in the renewal process [renewalparams] account = ee43634db0aa4e6804f152be39990e6a server = https://acme-v02.api.letsencrypt.org/directory authenticator = nginx installer = nginx key_type = rsa ÚwÚrúutf-8©ÚencodingZdefault_encoding)rUrVr†r‡rˆrXr‰rrDÚpatchersrÏÚmocksrrr¾rÀr½Ú config_dirÚexistsrÚmakedirsÚ renewal_fileÚopenÚwriteÚ configobjÚ ConfigObjÚoriginal_config)rZrenewal_configs_dirrÚfrdr#r$rVs4   ø   *ÿzReconfigureTest.setUpcs0tƒ ¡|j ¡|j ¡D] }| ¡qdSr…)rUr‹rˆrbrüÚvalues©rrDrdr#r$r‹Bs  zReconfigureTest.tearDowncCsz|d|jg}tj ¡}t ||¡}ddlm}|||ƒt|j dƒ }t j |ddd}Wdƒn1sl0Y|S)Nú --config-dirr)Ú reconfigurerørùrú) rþrrhrir rjrkr rrrr)rZ passed_argsZ full_argsrmr=r rZ updated_confr#r#r$rnHs    .zReconfigureTest._callcCs>t tj¡| d ¡¡Wdƒn1s00YdS)Nz!--cert-name cert1 -d one.cert.com)r;r<rr–rnrgrsr#r#r$Útest_domains_setUsz ReconfigureTest.test_domains_setú,certbot._internal.cert_manager.get_certnamescCsLt ¡}d|_||jd_||jd_||jd_dg|_| d ¡¡dS)NÚnginxrìrírîr“ú--nginx©rrÚnamerýrrnrg)rÚmock_cert_managerÚ named_mockr#r#r$Útest_asks_for_certnameYs   z&ReconfigureTest.test_asks_for_certnamecCsDt ¡}d|_||jd_||jd_||jd_| d ¡¡}dS)NÚapacherìrírîú --cert-name example.com --apacher©rrÚ new_configr#r#r$Útest_update_configuratores   z(ReconfigureTest.test_update_configuratorcCstt ¡}d|_||jd_||jd_||jd_| d ¡¡}d|dd<d|dd <|dd =|jd |d <d S) zI Check that we don't accidentally modify anything that we didn't mean to rrìrírîrrÚ renewalparamsÚ authenticatorÚ installerrþÚversionN)rrrrýrrnrgrrr#r#r$Útest_only_intended_changesps      z*ReconfigureTest.test_only_intended_changesz&certbot._internal.hooks.validate_hookscCs| d ¡dg¡dS)z6 Check that we use the staging server for the dry run ú"--cert-name example.com --pre-hookúecho preN©rnrg)rÚunused_validate_hooksr#r#r$Útest_staging_used‚sz!ReconfigureTest.test_staging_usedc Cs6|jdd}|jdd}z| d ¡¡Wn&tjyT}z WYd}~n d}~00t|jdƒ }tj|ddd}Wdƒn1sˆ0Y| d |› ¡¡}z| d  ¡¡Wn&tjyÞ}z WYd}~n d}~00t|jdƒ }tj|ddd}Wdƒn1s0Y| d |› ¡¡}dS) zx Check that we error when attempting to change the account id or server, but not when it's the same rr rÝz.--cert-name example.com --account newaccountidNrørùrúz"--cert-name example.com --account z&--cert-name example.com --server x.comz!--cert-name example.com --server ) rrnrgrr–rrrr)rZorig_account_idZ orig_serverÚerrrrr#r#r$Ú!test_new_account_or_server_errorss".0z1ReconfigureTest.test_new_account_or_server_errorscCs@| d ¡dg¡}| d ¡dg¡}| d ¡dg¡}dS)Nrr z echo pre2z%--cert-name example.com --deploy-hookz echo deployr!)rr"rr#r#r$Útest_update_hooks²sz!ReconfigureTest.test_update_hookscCsvtj|jd_z| d ¡¡Wntjy4Yn0t|jdƒ }tj |ddd}Wdƒn1sh0YdS)Nrïrrørùrú) rrrýr:rnrgrrrr)rrrr#r#r$Útest_dry_run_failsÁs.z"ReconfigureTest.test_dry_run_failsú*certbot._internal.main.display_util.notifycCsºd}t|jdƒ}| |¡Wdƒn1s00Yt|jdƒ"}tj|ddd|_Wdƒn1sn0Yt ¡}d|_||j d_ ||j d_ |  d   ¡¡}|  d ¡dS) Na  version = 2.0.0 archive_dir = /etc/letsencrypt/archive/example.com cert = /etc/letsencrypt/live/example.com/cert.pem privkey = /etc/letsencrypt/live/example.com/privkey.pem chain = /etc/letsencrypt/live/example.com/chain.pem fullchain = /etc/letsencrypt/live/example.com/fullchain.pem # Options used in the renewal process [renewalparams] account = ee43634db0aa4e6804f152be39990e6a server = https://acme-staging-v02.api.letsencrypt.org/directory authenticator = webroot installer = nginx key_type = ecdsa webroot_path = /var/www/html, [[webroot_map]] example.com = /var/www/html r÷rørùrúrrírîz--cert-name example.com --nginxzT Successfully updated configuration. Changes will apply when the certificate renews.)rrrrrrrrrrýrrnrgÚassert_called_with)rÚ mock_notifyrrrrr#r#r$Útest_report_resultsÏs(ÿ&  ÿz#ReconfigureTest.test_report_results)r@rArBrCrVr‹rnr rrDrrrr#r%r&r'r+rƒr#r#rdr$rês" -     % rêc @sReZdZdZdd„Zdd„Ze ¡dd„ƒZe ¡dd „ƒZ e   d ¡e   d ¡e   d ¡e   d ¡e   d¡e   d¡e ¡dd„ƒƒƒƒƒƒƒZ e   d ¡e   d ¡e   d¡e   d ¡e   d¡e ¡dd„ƒƒƒƒƒƒZ e   d ¡e   d ¡e   d¡e   d¡e   d ¡e ¡dd„ƒƒƒƒƒƒZe   d ¡e   d ¡e   d¡e   d¡e   d ¡e ¡dd„ƒƒƒƒƒƒZdS)ÚDeleteIfAppropriateTestz8Tests for certbot._internal.main._delete_if_appropriate cCsddlm}||ƒdS)Nr)Ú_delete_if_appropriate)rkr-)rr-r-r#r#r$rnûs zDeleteIfAppropriateTest._callcCsBt d¡}| |j¡Wdƒn1s,0Y| ¡dS)Nrç)rrDrnr=r9)rrèr#r#r$Ú_test_delete_opt_out_commonÿs *z3DeleteIfAppropriateTest._test_delete_opt_out_commoncCsd|j_| ¡dSr)r=Údelete_after_revoker.)rZunused_mock_get_utilityr#r#r$Útest_delete_flag_opt_outsz0DeleteIfAppropriateTest.test_delete_flag_opt_outcCs|ƒ}d|j_| ¡dSr)r•rr.)rr‰Ú util_mockr#r#r$Útest_delete_prompt_opt_out sz2DeleteIfAppropriateTest.test_delete_prompt_opt_outz%certbot._internal.main.logger.warningrÙrçz7certbot._internal.cert_manager.match_and_check_overlapsz+certbot._internal.storage.full_archive_pathz3certbot._internal.cert_manager.cert_path_to_lineagec Cs8|j}d|_d|_d|_t ¡|_| |¡| ¡dS)Nú/some/reasonable/pathÚr“) r=rÜr0rrZOverlappingMatchFoundr:rnr9) rr‰Úmock_cert_path_to_lineageÚ mock_archiveÚmock_match_and_check_overlapsrèÚmock_renewal_file_for_certnameZ mock_warningr=r#r#r$Útest_overlapping_archive_dirss   z5DeleteIfAppropriateTest.test_overlapping_archive_dirscCs,|j}d|_d|_d|_d|_| |¡dS)Nr3r4r“F)r=rÜr0rrn)rr‰r5rèr6Zmock_overlapping_archive_dirsr8r=r#r#r$Útest_cert_path_only$s  z+DeleteIfAppropriateTest.test_cert_path_onlycCs8|j}d|_d|_d|_d|_d|_d|_| |¡dS©NTr3r4r“)r=Znoninteractive_moderÜr0rrn©rr‰rèr5Zmock_full_archive_dirr7r8r=r#r#r$Útest_noninteractive_deletion6s  z4DeleteIfAppropriateTest.test_noninteractive_deletioncCs8|j}d|_d|_d|_d|_d|_d|_| |¡dSr;)r=r/rÜr0rrnr<r#r#r$Útest_opt_in_deletionJs  z,DeleteIfAppropriateTest.test_opt_in_deletionN)r@rArBrCrnr.r†r‡r0r2rrDr9r:r=r>r#r#r#r$r,øsH   r,cs´eZdZdZ‡fdd„Zdd„Ze d¡e d¡dd „ƒƒZd d „Z d d „Z e d¡dd„ƒZ e d¡dd„ƒZ e d¡e d¡dd„ƒƒZ dd„Zdd„Zdd„Zdd„Z‡ZS)ÚDetermineAccountTestz4Tests for certbot._internal.main._determine_account.cs^tƒ ¡d|j_d|j_d|j_tjddtjddg|_t  ¡|_ t ¡|_ d|j j _ dS)NFÚx)ÚidÚyÚhi)rUrVr=r ÚemailZregister_unsafely_without_emailrr)ÚaccsZAccountMemoryStorageÚaccount_storageÚ mock_clientÚ directoryZ new_authzrsrdr#r$rVbs   zDetermineAccountTest.setUpc Cs‚ddlm}t d¡X}t ¡0|j|_||jƒWdƒWdƒS1sV0YWdƒn1st0YdS)Nr)Ú_determine_accountz1certbot._internal.main.account.AccountFileStorage) rkrIrrDr†r‡rFrr=)rrIÚ mock_storager#r#r$rnns   ÿzDetermineAccountTest._callz!certbot._internal.client.registerz.certbot._internal.client.display_ops.get_emailc CsDd|_||_z | ¡Wn&tjy>}z WYd}~n d}~00dS)Nú foo@bar.baz)rr:rnrr)rÚerr_msgÚ exceptionÚmock_get_emailÚ mock_registerr$r#r#r$Ú_register_error_commonvs  z+DetermineAccountTest._register_error_commoncCs*|j |jd|j¡|jdj|j_dS©NrM)rFÚsaverErGrAr=r rsr#r#r$Útest_args_account_setsz*DetermineAccountTest.test_args_account_setcCs|j |jd|j¡dS)Nr)rFrRrErGrsr#r#r$Útest_single_accountˆsz(DetermineAccountTest.test_single_accountz3certbot._internal.client.display_ops.choose_accountcCs,|jD]}|j ||j¡q|jd|_dSrQ)rErFrRrGr)rÚmock_choose_accountsrËr#r#r$Útest_multiple_accountsŽs  z+DetermineAccountTest.test_multiple_accountsc CsZ|jD]}|j ||j¡qd|_z | ¡Wn&tjyT}z WYd}~n d}~00dSr…)rErFrRrGrrnrr)rrUrËr$r#r#r$Útest_multiple_accounts_canceled˜s  z4DetermineAccountTest.test_multiple_accounts_canceledr(cCsld|_t d¡&}|jdtjjf|j_Wdƒn1s<0Y|jj|j|j tj d| d¡dS)NrKúcertbot._internal.main.clientr)Ztos_cbzAccount registered.) rrrDrEÚsentinelråÚregisterrqr=rFrr)rr*rNÚclientr#r#r$Útest_no_accounts_no_email¢s ÿ ÿz.DetermineAccountTest.test_no_accounts_no_emailcCsTd|j_t d¡.}|jdtjjf|j_|  ¡Wdƒn1sF0YdS)Nz other emailrXrM) r=rDrrDrErYrårZrrn)rr[r#r#r$Útest_no_accounts_email²s  &z+DetermineAccountTest.test_no_accounts_emailcCsd}| |t |¡¡dS)Nz$Some error message raised by Certbot)rPrr)rrLr#r#r$Útest_register_error_certbotºsz0DetermineAccountTest.test_register_error_certbotcCs d}tddd}| ||¡dS)NzAError returned by the ACME server: must agree to terms of servicez$urn:ietf:params:acme:error:malformedzmust agree to terms of service)ÚtypZdetail©Ú acme_errorrP©rrLrMr#r#r$Ú(test_register_error_acme_type_and_detail¾s ÿz=DetermineAccountTest.test_register_error_acme_type_and_detailcCsd}tdd}| ||¡dS)NzKError returned by the ACME server: The server experienced an internal errorz)urn:ietf:params:acme:error:serverInternal)r_r`rbr#r#r$Ú"test_register_error_acme_type_onlyÄs z7DetermineAccountTest.test_register_error_acme_type_only)r@rArBrCrVrnrrDrPrSrTrVrWr\r]r^rcrdrƒr#r#rdr$r?_s&     r?cs eZdZdZ‡fdd„Z‡fdd„Zd¹dd „Zdºd d „Zd d „Zdd„Z dd„Z e   d¡dd„ƒZ e   d¡e   d¡e   d¡e   d¡e   d¡e   d¡dd„ƒƒƒƒƒƒZe   d¡e   d¡dd„ƒƒZe   d ¡e   d¡e   d¡d!d"„ƒƒƒZe   d¡e   d ¡e   d¡e   d¡d#d$„ƒƒƒƒZe   d¡e   d¡d%d&„ƒƒZe   d¡e   d¡e   d'¡e   d ¡d(d)„ƒƒƒƒZe   d¡e   d¡e   d¡e   d*¡d+d,„ƒƒƒƒZe   d¡d-d.„ƒZe   d/¡d0d1„ƒZe   d2¡d3d4„ƒZe   d5¡e   d6¡e   d¡d7d8„ƒƒƒZe   d5¡e   d6¡d9d:„ƒƒZe   d5¡e   d6¡d;d<„ƒƒZe   d5¡e   d6¡d=d>„ƒƒZe   d5¡e   d6¡d?d@„ƒƒZdAdB„ZdCdD„ZdEdF„ZdGdH„Z dIdJ„Z!dKdL„Z"dMdN„Z#d»dOdP„Z$e   d¡dQdR„ƒZ%e   d¡e   dS¡e   d¡e   dT¡dUdV„ƒƒƒƒZ&e   d¡dWdX„ƒZ'dddYdde(j( )¡ddfdZd[„Z*e   d¡e   dS¡e   dT¡d\d]„ƒƒƒZ+e   d^¡e   d_¡e   dT¡d`da„ƒƒƒZ,dbdc„Z-ddde„Z.dfdg„Z/e   dh¡didj„ƒZ0e   dh¡dkdl„ƒZ1e   dm¡dndo„ƒZ2e   dm¡dpdq„ƒZ3e   dr¡dsdt„ƒZ4e   d¡dudv„ƒZ5dwdx„Z6dydz„Z7d{d|„Z8d}d~„Z9dd€„Z:dd‚„Z;d¼dƒd„„Zd‰dŠ„Z?d‹dŒ„Z@ddŽ„ZAe   d¡dd‘„ƒZBd’d“„ZCd”d•„ZDd–d—„ZEd˜d™„ZFdšd›„ZGdœd„ZHeI J¡e   dž¡e   dŸ¡e   d¡d d¡„ƒƒƒƒZKd½d¢d£„ZLe   d¤¡e   dS¡e   d¡d¥d¦„ƒƒƒZMe   d¤¡d§d¨„ƒZNe   d©¡e   dª¡d«d¬„ƒƒZOd­d®„ZPe   d©¡e   d¡d¯d°„ƒƒZQe   d¡d±d²„ƒZRe   d¡e   d³¡d´dµ„ƒƒZSe   d¶¡e   d¡e   dŸ¡e   d¡d·d¸„ƒƒƒƒZT‡ZUS)¾ÚMainTestzTests for different commands.csLtƒ ¡t |jj¡d|jjd|jjd|jjdg|_t   d¡  ¡|_ dS)Nr ú --work-dirú --logs-dirú--textz time.sleep) rUrVrÚmkdirr=Úlogs_dirrþÚwork_dirÚ standard_argsrrDrXÚ mock_sleeprsrdr#r$rVÍs  þzMainTest.setUpcsttƒtƒ ¡dSr…)Ú reload_moduler rUr‹rsrdr#r$r‹×szMainTest.tearDownNFc sì|r tjj‰‡fdd„}t d¡l}||_t d¡<}| ||¡\}}}||||fWdƒWdƒS1sv0YWdƒn1s”0YnHt d¡.}| ||¡\}}}||||fWdƒS1sÞ0YdS)zaRun the cli with output streams, actual client and optionally os.path.isfile() mocked outcs*| d¡s| d¡s| d¡r"dSˆ|ƒS)zMock os.path.isfile()r>ÚchainÚprivkeyT)Úendswith)Úfnrlr©Z orig_openr#r$Ú mock_isfileäs ÿþz#MainTest._call..mock_isfilezcertbot.compat.os.path.isfilerXN)rr¾ÚisfilerrDr:Ú_call_no_clientmock) rrlÚstdoutÚ mockisfilertZmock_ifr[r"Ústderrr#rsr$rnÝs   X zMainTest._callc Cs¸|j|}|r|nt ¡}tjd|dvt d¡L}t d¡"t |dd…¡}Wdƒn1sh0YWdƒn1s†0YWdƒn1s¤0Y|||fS)z-Run the client with output streams mocked outú!certbot._internal.main.sys.stdout©Únewú!certbot._internal.main.sys.stderrúcertbot.util.atexitN)rlÚioÚStringIOrrDr)rrlrwZ toy_stdoutryr"r#r#r$rvös   lzMainTest._call_no_clientmockcCs8t d¡}| g¡Wdƒn1s*0YdS)Nzcertbot._internal.main.run)rrDrn)rÚmock_runr#r#r$Ú test_no_flagss  zMainTest.test_no_flagsc Cs¼t ¡}t ¡}tjd|dŠtjd|d\z8zt dg¡WntyTYn0W| ¡pf| ¡}n| ¡px| ¡}0Wdƒn1s0YWdƒn1s®0YdS)Nrzr{r}z --version)rr€rrDrÚ SystemExitÚgetvalue)rZtoy_outZtoy_errÚoutputr#r#r$Ú test_version_string_program_names ÿz)MainTest.test_version_string_program_namec Cszd}zFt d¡(t |j|dd…¡Wdƒn1s>0YWn*tjyt}z|}WYd}~n d}~00dS)zQEnsure that a particular error raises a missing cli flag error containing messageNr})rrDrrlrZMissingCommandlineFlag)rrlÚmessageÚexcZexc_r#r#r$Ú_cli_missing_flags :zMainTest._cli_missing_flagz*certbot._internal.log.post_arg_parse_setupcCs2ddg}| |d¡| gd¢¡| |d¡dS)Nz-nrŒzspecify a plugin)ú --standaloneú-dzeg.iszregister before running)r‰Úextend)rÚ_rlr#r#r$Útest_noninteractives zMainTest.test_noninteractiverKrIr¶zBcertbot._internal.main.client.Client.obtain_and_enroll_certificaterFcCsúgd¢|j}t ¡df|_t ¡|_t d¡R}|j} | |¡t ¡} | j dd} ddl } |   ¡} d|   ¡vrtWdƒn1sˆ0Yt d¡J}|j} d} |d| g7}| |¡| j tj tj d | tjd Wdƒn1sì0YdS) N)rŠrŒú-mz none@none.comr‹r“z --agree-tosrÎrMÚ user_agentrZlinuxZ bandersnatchz --user-agentT)r Z verify_sslrZalg)rlrr)rrDZ ClientNetworkrvr Zget_os_info_uaÚ call_argsÚplatformÚlowerrqrrÚjoseZRS256)rZgscZ_obtZdetrÚ__Ú___rlZ acme_clientZacme_netZos_verZuar’Zplatr#r#r$Útest_user_agent%s, ÿ       ÿzMainTest.test_user_agentú5certbot._internal.main.plug_sel.record_chosen_pluginsú.certbot._internal.main.plug_sel.pick_installercCs|jgd¢dddS)N) Úinstallz --domainsúfoo.barú --cert-pathr>ú --key-pathrpú --chain-pathroT©rx)rn)rZmock_pick_installerÚ_recr#r#r$Útest_installer_selectionFs ÿz!MainTest.test_installer_selectionr€cCs~tjt d¡t d¡t d¡t d¡d}t d¡6}||_|jgd¢dd|jd d }Wdƒn1sp0YdS) Nr>rorp©rÜÚ chain_pathÚfullchain_pathÚkey_pathr‘)ršú --cert-nameÚwhateverTrŸr)rr)r†Ú temp_joinrDrrnr‘)rÚ_instr Ú mock_installr!Ú mock_getlinÚ call_configr#r#r$Útest_installer_certnameMs ý z MainTest.test_installer_certnamec Cs¾tjt d¡t d¡t d¡t d¡d}t d¡v}||_|jdddd t d ¡gd d |jd d }| ¡|jddddt d¡gd d |jd d }Wdƒn1s°0YdS)Nr>rorpr¢r‘ršr¦r§rZoverriding_privkeyTrŸrrœZoverriding_cert) rr)r†r¨rDrrnr‘Úreset)rr©r rªrr!r«r¬r#r#r$Útest_installer_param_override^s* ý   ÿÿ  ÿÿz&MainTest.test_installer_param_overridecCs>t tj¡| gd¢¡Wdƒn1s00YdS)N)ršr¦ZnotfoundrZinvalid©r;r<rr–rn)rr©r r#r#r$Útest_installer_param_errorzsz#MainTest.test_installer_param_errorr cCsntjt d¡t d¡t d¡t d¡d}t d¡&}||_|jdgddWdƒn1s`0YdS) Nr>rorpr¢r‘ršTrŸ)rr)r†r¨rDrrn)rÚ mock_instZ mock_getcertr©r r!r«r#r#r$Útest_installer_select_certs ý .z#MainTest.test_installer_select_certzcertbot.util.exe_existsc Cs d|_tj ¡}gd¢}dddt d¡dt d¡dd d d d g }d |vrX| |¡\}}}}| dgd¡t  d¡b}t  d¡8} t  ¡| _| gd¢¡|j d\} } } Wdƒn1sº0YWdƒn1sØ0Yt  d¡} | ddg¡Wdƒn1s0YdS)NT)z--apachez--authenticatorrršrrœZblahrz--nginx-server-rootz/nonexistent/thingr‹r“ú--debugrrŠz(With the standalone plugin, you probablyrGrF)rŒz--manualr‹r›rúcertbot._internal.main.certonlyÚauth) rrrhrir†r¨rnr‰rrDr)r‘)rZmock_exe_existsrr•r–Z real_pluginsrlr"r\Zmock_gscZ unused_configr¶Zunused_installerÚ mock_certonlyr#r#r$Útest_configurator_selections(  ý   < z$MainTest.test_configurator_selectioncCsF| dg¡\}}}}| gd¢¡\}}}}|j tjdtjtj¡dS)NÚrollback)r¹z --checkpointsZ123é{)rnr¹rqrrr)rrr[r#r#r$Ú test_rollback¹s ÿzMainTest.test_rollbackz+certbot._internal.cert_manager.certificatescCs| dg¡dS)NZ certificates©rv©rrr#r#r$Útest_certificatesÂs zMainTest.test_certificatesrçcCs| dg¡dS)NÚdeleter¼r½r#r#r$Ú test_deleteÇs zMainTest.test_deletez$certbot._internal.main.plugins_discozFcertbot._internal.main.cli.HelpfulArgumentParser.determine_help_topicscsFgd¢‰tj‡fdd„ttˆƒƒDƒŽD]}| dgt|ƒ¡q(dS)N)ú--initú --preparez--authenticatorsz --installersc3s|]}t ˆ|¡VqdSr…)Ú itertoolsÚ combinations)ròrø©Úflagsr#r$Ú Òsÿz(MainTest.test_plugins..rm)rÃroÚrangeÚlenrnÚlist)rrÚ_detÚ mock_discorlr#rÅr$Ú test_pluginsÌs  ÿÿzMainTest.test_pluginscCs‚g}|j ¡}t ¡}tj|d&| dg|¡\}}}}Wdƒn1sN0Y|j ¡| ¡j  |¡| ¡  ¡}dS)N©rwrm© rhrirr€r†Úpatch_display_util_with_stdoutrnÚvisiblerqÚifaces©rrËrÌrÒrmrwrÚfilteredr#r#r$Útest_plugins_no_argsÖs 4  zMainTest.test_plugins_no_argsc Csºg}|j ¡}dd„}t ¡}t d¡X}tj|d,||_|  dg|¡\}}}}Wdƒn1sh0YWdƒn1s†0Y|j   ¡|  ¡j   |¡|  ¡  ¡} dS)NcSs|||}}}t ¡‚dS)zRaises error.Error.N)rr)rHÚmodeÚstrictrr#r#r$Ú throw_errorësz?MainTest.test_plugins_no_args_unprivileged..throw_errorzcertbot.util.set_up_core_dirrÎrm) rhrirr€rrDr†rÐr:rnrÑrqrÒ) rrËrÌrÒrmrØrwZmock_set_up_core_dirrrÔr#r#r$Ú!test_plugins_no_args_unprivilegedås  R  z*MainTest.test_plugins_no_args_unprivilegedcCs„g}|j ¡}t ¡}tj|d(| ddg|¡\}}}}Wdƒn1sP0Y|j ¡| ¡j  |¡| ¡  ¡}dS)NrÎrmrÁrÏrÓr#r#r$Útest_plugins_initûs 6  zMainTest.test_plugins_initc Cs g}|j ¡}t ¡}tj|d(| gd¢|¡\}}}}Wdƒn1sP0Y|j ¡| ¡j  |¡| ¡  ¡}|j  ¡|j  ¡|  ¡}dS)NrÎ)rmrÁrÂ) rhrirr€r†rÐrnrÑrqrÒÚprepareÚ available) rrËrÌrÒrmrwrrÔrÜr#r#r$Útest_plugins_prepare s 6    zMainTest.test_plugins_preparec Cshd}d}d}d}t d¡,}| dd|ddd dd dg ¡Wdƒn1sL0Y|jd \}}dS) Nr>ÚkeyroÚ fullchainrµrŒrœrržz--fullchain-pathr)rrDrnr‘)rr>rÞrorßr·r=Úunused_pluginsr#r#r$Útest_certonly_abspaths þ$zMainTest.test_certonly_abspathc CsHz| gd¢¡t d¡Wn&tjyB}z WYd}~n d}~00dS)N)ú-aZbad_authrŒz!Exception should have been raised)rnr;ÚfailrÚPluginSelectionError©rÚer#r#r$Útest_certonly_bad_args/s zMainTest.test_certonly_bad_argscCsìt tj¡| ddg¡Wdƒn1s00Yt tj¡| ddg¡Wdƒn1sj0Yt tj¡| ddg¡Wdƒn1s¤0Yt tj¡| ddg¡Wdƒn1sÞ0YdS)Nr‹Z@aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaþaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.z 204.11.231.35z%2001:db8:ac69:3ff:b1cb:c8c6:5a84:a31br°rsr#r#r$Útest_check_config_sanity_domain6s,,,z(MainTest.test_check_config_sanity_domaincCsDt tj¡$| d t¡ ¡¡Wdƒn1s60YdS)Nz*certonly --csr {0} --allow-subset-of-names©r;r<rrrnrfržrgrsr#r#r$Útest_csr_with_besteffortDsz!MainTest.test_csr_with_besteffortc CsJz| dtg¡Wn(tjy:}zWYd}~dSd}~00t d¡dS)Nz--csrz2Expected supplying --csr to fail with default verb)rnržrrr;rãrår#r#r$Útest_run_with_csrHs zMainTest.test_run_with_csrcCsJt tj¡*| d t d¡¡ ¡¡Wdƒn1s<0YdS)Nzcertonly --csr {0}zcsr-nonames_512.pem) r;r<rrrnrfr†Ú vector_pathrgrsr#r#r$Útest_csr_with_no_domainsQsÿz!MainTest.test_csr_with_no_domainscCsDt tj¡$| d t¡ ¡¡Wdƒn1s60YdS)Nz!certonly -d example.org --csr {0}rérsr#r#r$Ú"test_csr_with_inconsistent_domainsVsz+MainTest.test_csr_with_inconsistent_domainsc Cs†t d¡h}d|_t d¡8}||_|dur0g}|d ¡7}| |¡Wdƒn1sZ0YWdƒn1sx0YdS)Nú=certbot._internal.main._find_lineage_for_domains_and_certname)ZnewcertNrGz!-d foo.bar -a standalone certonly)rrDrrgrn)rrGrlÚ mock_renewalr\r#r#r$Ú_certonly_new_request_commonZs   z%MainTest._certonly_new_request_commoncCs"t ¡}d|j_| |dg¡dS©Nú --dry-run)rr)Úobtain_and_enroll_certificaterrñ)rÚ mock_reportrGr#r#r$Ú)test_certonly_dry_run_new_request_successesz2MainTest.test_certonly_dry_run_new_request_successz+certbot._internal.main.util.atexit_registerzcertbot.crypto_util.notAfterc Csrtj tj |jjd¡¡}tj tj |jjd¡¡}d}||ƒj_tj ||||d}t  ¡} || j _|  | ¡dS)Nz live/foo.barz live/baz.quxz 1970-01-01)r>rßr¤r¥) rr¾ÚnormpathrÀr=rþÚdaterrr)rôrñ) rZ mock_notAfterr_rOrõrÜr¥rør!rGr#r#r$Ú!test_certonly_new_request_successns ÿ z*MainTest.test_certonly_new_request_successcCsJt ¡}d|j_t tj¡| |¡Wdƒn1s<0YdSr) rr)rôrr;r<rrrñ)rr_rGr#r#r$Ú!test_certonly_new_request_failure…s (z*MainTest.test_certonly_new_request_failureTc st d¡} tj tj |jjd¡¡} tj | | | | d} || j _ d| j _ dg| j _ d| _d| _| | _t  ¡}tj dd }t  ¡}t ¡‰|d |d f|j_ ‡fd d „}z&zÊt d¡X}| df|_ t d¡ }||_ t d¡î}|sð||ƒj_t d¡´}||j_ t d¡€|sgd¢}|r,||7}z0| |ˆ¡\}‰}}|rZtd|ƒt|ƒ‚Wn"|sztdt ¡ƒ‚Yn0Wdƒn1s–0YWdƒn1s¶0YWdƒn1sÖ0YWdƒn1sö0YWdƒn1s0Y|rp| r\| s\|j tjgtj tj |jjd¡¡¡n|j tjgd¡nWn| ¡‚Yn0W|r t tj |jj!d¡ƒ}Wdƒn1sÀ0Yn@|r t tj |jj!d¡ƒ}Wdƒn1s0Y0| |ˆfS)Nrzlive/foo.bar/fullchain.pem)r>rßrÜr¤Fú isnot.orgr/Z secp256r1Zpem_key)ZpemroÚcsrcsˆ |¡dS)zWrite message to stdout.N)r)r‡rlrrÎr#r$Ú write_msg£sz0MainTest._test_renewal_common..write_msgz5certbot._internal.cert_manager.find_duplicative_certsrGz)certbot._internal.display.obj.get_displayz*certbot._internal.main.renewal.crypto_utilrK)r‹rûrârrŒZReturnedzUnexpected renewal error: zlive/sample-renewal/privkey.pemúletsencrypt.log)"r†rìrr¾r÷rÀr=rþrr)Zshould_autorenewrZhas_pending_deploymentr,r8Zelliptic_curveÚ reuse_keyrr€Zobtain_certificaterDrr:ZnotAfterrnÚprintÚAssertionErrorÚ tracebackÚ format_excrqrrÚ _dump_logrrj)rÚdue_for_renewalÚ extra_argsÚlog_outrlÚ should_renewÚerror_expectedÚ quiet_modeÚ expiry_daterÿÚnew_keyrÜr£r!Z mock_certrZmock_keyrGrýZmock_fdcr\Z mock_displayZmock_crypto_utilr"rÚlfr#rÎr$Ú_test_renewal_commonsŠ ÿÿ  ÿ       ÿÿª   ÿÿ "þ"zMainTest._test_renewal_commoncCs&| dg¡\}}}|j | ¡¡dSrv)rZupdate_all_links_torqZlatest_common_version)rrrOrõZlineager#r#r$Útest_certonly_renewalØs ÿzMainTest.test_certonly_renewalr(zEcertbot._internal.log.logging.handlers.RotatingFileHandler.doRollovercCsV|jdddgdd\}}}| d¡|jdgd¢dd|jdgd ¢dd \}}}dS) NFróú--keepzsimulating renewal)rúThe dry run was successful.)z--renew-by-defaultú-tvvr´zAuto-renewal forced)rr´r)r)rÚassert_any_call)rrr•r*Zmock_displayerr#r#r$Útest_certonly_renewal_triggersäs ÿ   ÿ ÿ z'MainTest.test_certonly_renewal_triggerscCs^tdƒtj |jjd¡}tj |¡rZt|ƒ}t| ¡ƒWdƒn1sP0YdS)NzLogs:rþ) rrr¾rÀr=rjrÿrÚread)rZlog_pathr r#r#r$rôs   zMainTest._dump_logcCs.t |jjd¡gd¢}|jdg|dddS)Núsample-renewal.conf©ÚrenewrórT©rlr©r†Ú make_lineager=rþr©rrlr#r#r$Útest_renew_verbûszMainTest.test_renew_verbcCs4tj|jjdddgd¢}|jdg|ddddS)NrF©Zec)rróú --reuse-keyT©rlrrÿrrr#r#r$Útest_reuse_keyszMainTest.test_reuse_keyz6certbot._internal.storage.RenewableCert.save_successorcCs4tj|jjdddddg}|jdg|ddddS)NrFrrrTr r©rZunused_save_successorrlr#r#r$Útest_reuse_key_no_dry_runsz"MainTest.test_reuse_key_no_dry_runcCs2t |jjd¡gd¢}|jdg|dddddS)Nr)rrz --new-keyT)rlrrÿr rr"r#r#r$Ú test_new_key s ÿzMainTest.test_new_keyz sys.stdincCsFd|j_t |jjd¡gd¢}|jdg|dd|jjdd}dS)NFrrTrr) Úisattyrr†rr=rþrrmr‘)rÚstdinrlZsleep_call_argr#r#r$Ú!test_noninteractive_renewal_delays z*MainTest.test_noninteractive_renewal_delaycCs6d|j_t |jjd¡gd¢}|jdg|dddS)NTrrr)r%rr†rr=rþr)rr&rlr#r#r$Ú!test_interactive_no_renewal_delays z*MainTest.test_interactive_no_renewal_delayr&cCsLd|_t |jjd¡tj ¡tjdd}|jddddg|d\}}}dS)NFréZ)Zdaysr)rrrlr ) rr†rr=rþrÇÚnowZ timedeltar)rrZexpiryrrwr#r#r$Útest_renew_skips_recent_certs&s ÿ z&MainTest.test_renew_skips_recent_certscCsft |jjd¡ddg}|jdg|dd\}}}| ¡}gd¢}|jdg|ddd\}}}| ¡}dS)NrrróTr)rróz-q)rlrr )r†rr=rþrr„)rrrlrwÚoutr#r#r$Útest_quiet_renew0s ÿ zMainTest.test_quiet_renewcCs0t |jjd¡gd¢}|jdg|ddddS)Nr)rróú--post-hook=no-such-commandTF©rlrr rrr#r#r$Útest_renew_hook_validation>s  ÿz#MainTest.test_renew_hook_validationcCsZt |jjd¡gd¢}t d¡$|jdg|dddWdƒn1sL0YdS)Nr)rrór.z--disable-hook-validationz!certbot._internal.hooks.post_hookTFr/)r†rr=rþrrDrrr#r#r$Útest_renew_no_hook_validationDs   ÿz&MainTest.test_renew_no_hook_validationcCs|tj |jjd¡}tj |¡s(t |¡ttj |d¡dƒWdƒn1sR0Ygd¢}|j dg|ddddS)Nröz empty.confr÷rFTr/) rr¾rÀr=rþrÿrrrr)rZrdrlr#r#r$Útest_renew_verb_empty_configLs  z%MainTest.test_renew_verb_empty_configcCs*t |jjd¡|jdgdgd¢ddS)NrT©rrór¦zsample-renewal)rrlrrsr#r#r$Útest_renew_with_certnameUs ÿz!MainTest.test_renew_with_certnamecCs|jdgdgd¢dddS)NTFr3)rrlr )rrsr#r#r$Útest_renew_with_bad_certnameZs þz%MainTest.test_renew_with_bad_certnamecCs^tj |jjd¡}t |¡ttj |d¡dƒ}| d¡Wdƒn1sP0YdS)Nröz test.confr÷zMy contents don't matter) rr¾rÀr=rþrrrr)rZrenewer_configs_dirrr#r#r$Ú_make_dummy_renewal_config_s z#MainTest._make_dummy_renewal_configc KsÆ| ¡t d¡ }t ¡}d|_|dur4d|i|_|durD||j_||_t d¡2}| ddg¡|j d dd i|¤ŽWdƒn1sŒ0Y|dur¤|r¤nWdƒn1s¸0YdS) NrØzsomepath/fullchain.pemrú!certbot._internal.main.renew_certrlrTrF)TN) r6rrDr)rßÚ configurationr,rÚ setdefaultr)rrr,Úassert_oc_calledrÚmock_rcr!r—r#r#r$Ú_test_renew_commones    2zMainTest._test_renew_commoncCs|jddddS)NFT©r:r ©r<rsr#r#r$Útest_renew_no_renewalparamszsz$MainTest.test_renew_no_renewalparamscCs|jiddddS)NFT)rr:r r>rsr#r#r$Útest_renew_no_authenticator}sÿz$MainTest.test_renew_no_authenticatorcCsdddœ}|j|ddddS)NÚwebrootz over 9000)rZ rsa_key_sizeTF)rr r:r>©rrr#r#r$Útest_renew_with_bad_ints ÿÿz MainTest.test_renew_with_bad_intcCsdddœ}|j|dddS)NrAÚNone)rZ http01_portT©rr:r>rBr#r#r$Útest_renew_with_nonetype_http01‡s ÿÿz(MainTest.test_renew_with_nonetype_http01cCs$ddi}dg}|j|d|dddS)NrrAu uniçodé.comTF)rr r,r:r>)rrr,r#r#r$Útest_renew_with_bad_domains ÿz#MainTest.test_renew_with_bad_domainr¡cCs2t ¡t ¡f|_ddi}|j|dd ¡ddS)NrrATzrenew --configurator apache©rr:rl)rr)rr<rg)rr¤rr#r#r$Útest_renew_with_configurator“s þz%MainTest.test_renew_with_configuratorcCsddddœ}|j|dddS)NrArDZ42)rZ webroot_pathZwebroot_imaginary_flagTrEr>rBr#r#r$Ú$test_renew_plugin_config_restoration›sþÿz-MainTest.test_renew_plugin_config_restorationc Cs0ddi}|j|dddt dt ¡i¡gddS)NrrATrz --webroot-mapr“rH)r<ÚjsonÚdumpsr«r¬rBr#r#r$Útest_renew_with_webroot_map¢s þz$MainTest.test_renew_with_webroot_mapcCsBt d¡$}t|_|jdddWdƒn1s40YdS)Nz+certbot._internal.main.renewal.reconstituteFTr=)rrDÚ Exceptionr:r<)rZmock_reconstituter#r#r$Útest_renew_reconstitute_error¨s z&MainTest.test_renew_reconstitute_errorc Csž| ¡t d¡x}t ¡}d|_||_dddii|_t d¡,}t|_|j ddddgd d Wdƒn1sr0YWdƒn1s0YdS) NrØzsomewhere/fullchain.pemrrrAr7TrF)r rlr) r6rrDr)rßrr8rNr:r)rr;r!r—r#r#r$Útest_renew_obtain_cert_error®s ÿ  ÿz%MainTest.test_renew_obtain_cert_errorcCs:|jddd ¡ddd|jddd t¡ ¡ddddS)NTzrenew -d example.comFr/zrenew --csr {0})rrgrfržrsr#r#r$Útest_renew_with_bad_cli_args»s ÿÿz%MainTest.test_renew_with_bad_cli_argsc Cs*|jdddddd tj¡gd\}}}dS)NFrz --post-hookz{0} -c "print('hello world');")rrrrl)rrfÚsysÚ executable)rrrwr#r#r$Útest_no_renewal_with_hooksÁsÿÿþ z#MainTest.test_no_renewal_with_hooksrïrGcCs6dt ¡f|_t ¡|_}| gd¢¡| ¡dS)Nr()r‹r›rârrŒ)rr)rrnr9)rZmock_report_new_certr\rðr‰rGr#r#r$Útest_certonly_reinstallÉsz MainTest.test_certonly_reinstallc Cs d}d}t ¡}||f|j_tj tj |jj d¡¡}tj tj |jj d¡¡}|d|f|j _t  d¡„}||_tj tj |jj d¡¡}d  t |||¡ ¡} |rª| |7} t  d¡| | ¡Wdƒn1sÔ0YWdƒn1sò0Yd | vrn|j  |||||¡dS) NÚcertrrozlive/example.com/cert_512.pemzlive/example.com/fullchain.pemrGzlive/example.com/chain.pemzV-a standalone certonly --csr {0} --cert-path {1} --chain-path {2} --fullchain-path {3}z"certbot._internal.main.crypto_utilró)rr)Zobtain_certificate_from_csrrrr¾r÷rÀr=rþZsave_certificaterDrfržrgrnrq) rrrVrorGrÜÚ full_pathr\r£rlr#r#r$Ú_test_certonly_csr_commonØs>  þ þ  þþ F  ÿz"MainTest._test_certonly_csr_commonz+certbot._internal.main._csr_report_new_certcCs | ¡dSr…©rX)rr_rOÚmock_csr_reportr#r#r$Útest_certonly_csr÷szMainTest.test_certonly_csrcCs| dg¡dSròrY)rrZr#r#r$Útest_certonly_csr_dry_runs z"MainTest.test_certonly_csr_dry_runrÍrÎc Csªd|_d}| dtdtd|dg¡ttdƒ}Wdƒn1sB0Yttdƒ@}t | ¡¡d}| ¡j }|  t   |¡t j¡Wdƒn1sœ0YdS) NFr›rœrú--serverrÌÚrbr)rrvÚ SS_CERT_PATHÚRSA2048_KEY_PATHrrÚpyopenssl_load_certificaterrÂrÌrqr”ÚComparableX509rrr)rrÃrÓrÝrr>rÔr#r#r$Útest_revoke_with_key s ÿ   þzMainTest.test_revoke_with_keyc CsLd}t tj¡(| dtdtd|dg¡Wdƒn1s>0YdS)Nr›rœrr]rÌ)r;r<rrrvÚCERTÚKEY)rrÝr#r#r$Útest_revoke_with_key_mismatchs  ÿz&MainTest.test_revoke_with_key_mismatchcCsˆd|_t ¡df|_| dtdg¡\}}}}ttƒ@}t | ¡¡d}|  ¡j }|  t   |¡tj¡Wdƒn1sz0YdS)NFrœrÌr)rrr)rnrdrrrarZacme_from_config_keyrÌrqr”rbrr)rrÄrÓrr[rr>rÔr#r#r$Útest_revoke_without_key"s  þz MainTest.test_revoke_without_keyc Cs¨t d¡Š}t ¡}d|_|df|j_| gd¢¡t d¡8}t ¡}||j_dg|j_| gd¢¡}Wdƒn1s|0YWdƒn1sš0YdS)NrXZimaginary_accountZworked)rZz--emailzuser@example.orgúcertbot._internal.main.accountú an account) rrDr)rArZrrvÚAccountFileStorageri)rrZ mocked_clientrËZmocked_accountÚmocked_storager@r#r#r$Ú test_register0s    zMainTest.test_registerz'certbot._internal.updater._run_updaterscCs^tj|_t tj¡t ddd¡Wdƒn1s80Yd|j_t   |jdd¡dSr) rrär:r;r<rÚ renew_certr=Údry_runrZrun_generic_updaters)rrr~r#r#r$Útest_plugin_selection_errorAs ,z$MainTest.test_plugin_selection_errorz3certbot._internal.main.updater.run_renewal_deployercCsDd|j_t ¡}|t ¡f|_t |jdd¡|j ¡| ¡dS)z8A dry-run renewal shouldn't try to restart the installerTN) r=rnrr)rrrmr¢r9)rr¥r\r~Zmock_run_renewal_deployerrr#r#r$Ú#test_renew_doesnt_restart_on_dryrunNs  z,MainTest.test_renew_doesnt_restart_on_dryrun)NF)N)N)NNN)N)Vr@rArBrCrVr‹rnrvr‚r†r‰rrDrŽr—r¡r­r¯r±r³r¸r»r¾rÀrÍrÕrÙrÚrÝrárçrèrêrërírîrñrörùrúrÇr*rrrrrr!r#r$r'r(r+r-r0r1r2r4r5r6r<r?r@rCrFrGrIrJrMrOrPrQrTr†r‡rUrXr[r\rcrfrgrlrorprƒr#r#rdr$reÊs@         %            ý K         ÿ          rec@s>eZdZdd„Zdd„Zdd„Ze d¡dd „ƒZd d „Z d S) ÚUnregisterTestcCs@t d¡t d¡t d¡t ¡dœ|_dd„|j ¡Dƒ|_dS)Nr¶rhrX)rIr r[Ú get_utilitycSsi|]\}}|| ¡“qSr#rðrñr#r#r$rõhr4z(UnregisterTest.setUp..)rrDr†r‡rürÏrýrsr#r#r$rVbs üzUnregisterTest.setUpcCs|j ¡D] }| ¡q dSr…)rürrbr r#r#r$r‹jszUnregisterTest.tearDowncCsFt ¡|jdj_|jdƒ}d|j_t ¡}t ¡}t ||¡}dS)Nr rrF)rrrýrjrr•rÚ unregister)rr1r=ràÚresr#r#r$Útest_abort_unregisterns  z$UnregisterTest.test_abort_unregisterr(cCstt ¡}dg|j_||jdj_t ¡df|jd_t ¡}||jdj_t ¡}t ¡}t ||¡}|  d¡dS)Nrir ZfoorIr[zAccount deactivated.) rr)rirrýrjÚClientrrsrq)rr*rkÚ cb_clientr=ràrtr#r#r$Útest_unregisterzs  zUnregisterTest.test_unregistercCs^t ¡}g|j_||jdj_t ¡}||jdj_t ¡}d|_t ¡}t  ||¡}d}dS)Nr r[z"https://acme.example.com/directoryzNCould not find existing account for server https://acme.example.com/directory.) rr)rirrýrjrvrÝrrs)rrkrwr=ràrtÚmr#r#r$Útest_unregister_no_accounts z)UnregisterTest.test_unregister_no_accountN) r@rArBrVr‹rurrDrxrzr#r#r#r$rqas   rqc@s"eZdZdZe d¡dd„ƒZdS)ÚMakeOrVerifyNeededDirszt tj¡| gd¢¡Wdƒn1s00YdS)N)r‚râr)r;r<rZMisconfigurationErrorrnrsr#r#r$Útest_no_enhancements_definedsz(EnhanceTest.test_no_enhancements_definedrxcCs*dg|_d|_t ¡|_| ddg¡}dS)Nr“r…r‚r)rrrär:rn)rr r~r‰rGr#r#r$ros  z'EnhanceTest.test_plugin_selection_errorr™cCs2|j|_ddg|_tjdd|_| ddg¡dS)Nr“ú another.tldrƒr„r‚ú --auto-hsts)rrrr)rn©rrr r²r~r!r#r#r$Útest_enhancement_enables  z#EnhanceTest.test_enhancement_enablecCsft |jd¡|_ddg|_tjdd|_t tj ¡|  ddg¡Wdƒn1sX0YdS)Nrr“r’rƒr„r‚r“) rrzr=rrr)r;r<rr|rnr”r#r#r$Ú%test_enhancement_enable_not_supported,s  z1EnhanceTest.test_enhancement_enable_not_supportedcCs>t tj¡| gd¢¡Wdƒn1s00YdS)N)r‚r“r)r;r<rrrnrsr#r#r$Ú test_enhancement_enable_conflict8sz,EnhanceTest.test_enhancement_enable_conflict)r@rArBrCrVr‹rnrrDrŠr‹rŽrrr‘ror†r‡r•r–r—rƒr#r#rdr$r}´sV       r}csXeZdZdZ‡fdd„Ze d¡e d¡dd„ƒƒZe d¡e d¡dd „ƒƒZ‡Z S) Ú InstallTestz)Tests for certbot._internal.main.install.cstƒ ¡tjtjd|_dSr~)rUrVrr)rr€rrsrdr#r$rV@s zInstallTest.setUpr˜r™cCsht |jd¡|_tj ¡}d|j_d|j_t   t j ¡t  |j|¡Wdƒn1sZ0YdS)NrTZ nonexistent)rrzr=rrrhrir{r0r;r<rr|rrš©rr²r rmr#r#r$Ú&test_install_enhancement_not_supportedDs  z2InstallTest.test_install_enhancement_not_supportedcCsp|j|_tj ¡}d|j_d|j_d|j_d|j_ t   t j ¡t |j|¡Wdƒn1sb0YdS)NTrƒ)rrrrhrir=r{r0r¥rÜr;r<rr–rršr™r#r#r$Ú$test_install_enhancement_no_certnameNs z0InstallTest.test_install_enhancement_no_certname) r@rArBrCrVrrDršr›rƒr#r#rdr$r˜=s  r˜c@sxeZdZdZdd„Zdd„Zedd„ƒZedd „ƒZd d „Z d d „Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„ZdS)ÚReportNewCertTestznTests for certbot._internal.main._report_new_cert and certbot._internal.main._csr_report_new_cert. cCsJt d¡|_|j ¡|_t d¡|_|j ¡|_t ddddd¡|j_dS)Nr(z+certbot._internal.main.crypto_util.notAfteri²rMr) rrDÚ notify_patchrXr*Únotafter_patchZ mock_notafterrÇrrsr#r#r$rV`s     zReportNewCertTest.setUpcCs|j ¡|j ¡dSr…)rrbržrsr#r#r$r‹hs zReportNewCertTest.tearDowncOsddlm}||i|¤ŽS)Nr)Ú_report_new_cert)rkrŸ)ÚclsrlrrŸr#r#r$rnls zReportNewCertTest._callcOsddlm}||i|¤ŽS)Nr)Ú_csr_report_new_cert)rkr¡)r rlrr¡r#r#r$Ú _call_csrqs zReportNewCertTest._call_csrcCs(| tjddddd¡|j d¡dS©NT©rnr©rnrrr*r)rsr#r#r$Útest_report_dry_runvsz%ReportNewCertTest.test_report_dry_runcCs(| tjddddd¡|j d¡dSr£©r¢rrr*r)rsr#r#r$Útest_csr_report_dry_runzsz)ReportNewCertTest.test_csr_report_dry_runcCsˆt t¡(| tjddddd¡Wdƒn1s80Yt t¡(| tjddddd¡Wdƒn1sz0YdS)NFr¤)r;r<rrnrrr¢rsr#r#r$Útest_report_no_paths~s 6 z&ReportNewCertTest.test_report_no_pathscCs(| tjddddd¡|j d¡dS)NFr¤ú/path/to/cert.pemú/path/to/fullchain.pemú/path/to/privkey.pemaA Successfully received certificate. Certificate is saved at: /path/to/fullchain.pem Key is saved at: /path/to/privkey.pem This certificate expires on 1970-01-01. These files will be updated when the certificate renews. Certbot has set up a scheduled task to automatically renew this certificate in the background.r¥rsr#r#r$Ú test_report…sþÿzReportNewCertTest.test_reportcCs(| tjddddd¡|j d¡dS)NFr¤rªr«a Successfully received certificate. Certificate is saved at: /path/to/fullchain.pem This certificate expires on 1970-01-01. These files will be updated when the certificate renews. Certbot has set up a scheduled task to automatically renew this certificate in the background.r¥rsr#r#r$Útest_report_no_key”sþÿz$ReportNewCertTest.test_report_no_keycCs*| tjdddddd¡|j d¡dS)NF)rnÚpreconfigured_renewalrªr«r¬úâ Successfully received certificate. Certificate is saved at: /path/to/fullchain.pem Key is saved at: /path/to/privkey.pem This certificate expires on 1970-01-01. These files will be updated when the certificate renews.r¥rsr#r#r$Ú$test_report_no_preconfigured_renewal¢sþÿz6ReportNewCertTest.test_report_no_preconfigured_renewalcCs(| tjddddd¡|j d¡dS)NFr¤rªz/path/to/chain.pemr«zó Successfully received certificate. Certificate is saved at: /path/to/cert.pem Intermediate CA chain is saved at: /path/to/chain.pem Full certificate chain is saved at: /path/to/fullchain.pem This certificate expires on 1970-01-01.r§rsr#r#r$Útest_csr_report¯s ÿÿz!ReportNewCertTest.test_csr_reportcCs,| tjddddddd¡|j d¡dS) zBShouldn't get a message about autorenewal if no --manual-auth-hookFrN)rnrÚmanual_auth_hookrªr«r¬r°r¥rsr#r#r$Útest_manual_no_hooks_report»sþÿz-ReportNewCertTest.test_manual_no_hooks_reportN)r@rArBrCrVr‹Ú classmethodrnr¢r¦r¨r©r­r®r±r²r´r#r#r#r$rœ[s    rœc@sZeZdZdZdd„Zdd„Zedd„ƒZedœd d „Z d d „Z d d„Z dd„Z dd„Z dS)ÚReportNextStepsTestz3Tests for certbot._internal.main._report_next_stepscCsLtjdddddd|_t d¡}| ¡|_| |j¡tj |_ t   ¡t_ dS)Nr“Tr)Z cert_namer¯rürr³r() rr)r=rDrXr*rarbrRrwÚ old_stdoutrr€)rrr#r#r$rVÍsþ   zReportNextStepsTest.setUpcCs |jt_dSr…)r·rRrwrsr#r#r$r‹×szReportNextStepsTest.tearDowncOsddlm}||i|¤ŽdS)Nr)Ú_report_next_steps)rkr¸)r rlrr¸r#r#r$rnÚs zReportNextStepsTest._call)ÚreturncCs|jjdddS)NrMr)r*Úcall_args_listrsr#r#r$Ú_outputßszReportNextStepsTest._outputcCs.d|j_d|j_| |jdd¡|j ¡dS)zNo steps for a normal renewalrz /bin/trueN)r=rr³rnr*r9rsr#r#r$r­äszReportNextStepsTest.test_reportcCsd|j_| |jdd¡dS)z--csr requires manual renewalzfoo.csrN)r=rürnrsr#r#r$r²ësz#ReportNextStepsTest.test_csr_reportcCsd|j_| |jdd¡dS)z/--manual without a hook requires manual renewalrN)r=rrnrsr#r#r$Útest_manual_no_hook_renewalñsz/ReportNextStepsTest.test_manual_no_hook_renewalcCsd|j_| |jdd¡dS)z2No --preconfigured-renewal needs manual cron setupFN)r=r¯rnrsr#r#r$Útest_no_preconfigured_renewal÷sz1ReportNextStepsTest.test_no_preconfigured_renewalN)r@rArBrCrVr‹rµrnÚstrr»r­r²r¼r½r#r#r#r$r¶Ês  r¶csjeZdZdZ‡fdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z e   d¡dd„ƒZ dd„Z‡ZS)ÚUpdateAccountTestz/Tests for certbot._internal.main.update_accountcstt d¡t d¡t d¡t d¡t d¡t d¡t ¡dœ‰‡fdd „ˆDƒ|_ˆ ¡D]}| |j¡qXtƒ  ¡S) Nrhr~rXr¶r(z*certbot._internal.eff.prepare_subscription)r Úatexitr[Údetermine_accountÚnotifyÚ prepare_subr csi|]}|ˆ| ¡“qSr#rð©ròró©rcr#r$rõ r4z+UpdateAccountTest.setUp..© rrDr†r‡rýrrarbrUrVr rdrÅr$rV sù  zUpdateAccountTest.setUpc Csšt d¡|t d¡Rd|jjd|jjd|jjdg|}t |dd…¡WdƒWdƒS1sn0YWdƒn1sŒ0YdS©Nrzr}r rfrgrh©rrDr=rþrkrjrrr#r#r$rn s ÿ þþzUpdateAccountTest._callcCsXt ¡}t ¡}t ¡}|g|j_||jdj_|j|j_|t ¡f|jd_|||fS)Nr rÁ)rr)rirrýrjÚbodyrÆ©rrJZ mock_accountÚ mock_regrr#r#r$Ú_prepare_mock_account s  z'UpdateAccountTest._prepare_mock_accountcCsJ| ¡\}}}| |¡}|jjjdd|jd d¡|jd ¡dS)z9Utility to assert that email removal is handled correctlyr#©ÚcontactrÂzFAny contact information associated with this account has been removed.rÃN)rÌrnrÉÚupdater)rýr9)rrlrrJrËÚresultr#r#r$Ú_test_update_no_contact# s  ÿz)UpdateAccountTest._test_update_no_contactcCs"t ¡}g|j_||jdj_dS©z2Test that no existing account is handled correctlyr N©rr)rirrýrj©rrJr#r#r$Útest_no_existing_accounts5 sz+UpdateAccountTest.test_no_existing_accountscCs| ddg¡dS)zBTest that --register-unsafely-without-email is handled as no emailÚupdate_accountz!--register-unsafely-without-emailN©rÑrsr#r#r$Ú test_update_account_remove_email> sz2UpdateAccountTest.test_update_account_remove_emailcCs| gd¢¡dS)z9Test that providing an empty email is handled as no email)rÖrr4Nr×rsr#r#r$Útest_update_account_empty_emailB sz1UpdateAccountTest.test_update_account_empty_emailz,certbot._internal.main.display_ops.get_emailcCsJd|_| ¡\}}}t ¡}||jdj_| dg¡}|jd d¡dS)z=Test that updating with a singular email is handled correctlyzuser@example.comr[rÖrÂz4Your e-mail address was updated to user@example.com.N)rrÌrr)rýrvrnr))rZ mock_emailrrJrGrÐr#r#r$Útest_update_account_with_emailF s ÿz0UpdateAccountTest.test_update_account_with_emailcCs6| ¡\}}}|jjjddgd|jd d¡dS)z8Test that multiple email addresses are handled correctlyzmailto:user@example.comzmailto:user@example.orgrÍrÂzEYour e-mail address was updated to user@example.com,user@example.org.N)rÌrÉrÏr)rý)rrrJrËr#r#r$Ú(test_update_account_with_multiple_emails[ sÿ ÿz:UpdateAccountTest.test_update_account_with_multiple_emails)r@rArBrCrVrnrÌrÑrÕrØrÙrrDrÚrÛrƒr#r#rdr$r¿þs    r¿cs`eZdZdZ‡fdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z ‡Z S)ÚShowAccountTestz-Tests for certbot._internal.main.show_accountcslt d¡t d¡t d¡t d¡t d¡t ¡dœ‰‡fdd„ˆDƒ|_ˆ ¡D]}| |j¡qPtƒ  ¡S) Nrhr~rXr¶r()r rÀr[rÁrÂr csi|]}|ˆ| ¡“qSr#rðrÄrÅr#r$rõs r4z)ShowAccountTest.setUp..rÆr rdrÅr$rVj sú zShowAccountTest.setUpc Csšt d¡|t d¡Rd|jjd|jjd|jjdg|}t |dd…¡WdƒWdƒS1sn0YWdƒn1sŒ0YdSrÇrÈrr#r#r$rny s ÿ þþzShowAccountTest._callcCs\t ¡}t ¡}t ¡}|g|j_||jdj_|j|j_d|jj _|t ¡f|jd_dS)Nr s foobarbazrÁ) rr)rirrýrjrÉrÆrÞZ thumbprintrÊr#r#r$rÌ s   z%ShowAccountTest._prepare_mock_accountcCsR| ¡t ¡}t ¡}||j_d|_||jj_||j dj _dg}|  |¡dS)Nz+https://www.letsencrypt-demo.org/acme/reg/1r[Ú show_account) rÌrr)rÉrÎZuriråZquery_registrationrrýrvrn)rrÎrGrËrlr#r#r$Ú_test_show_account‹ s  z"ShowAccountTest._test_show_accountcCs"t ¡}g|j_||jdj_dSrÒrÓrÔr#r#r$rÕš sz)ShowAccountTest.test_no_existing_accountsc Cs`| ¡t ¡}d|_||jdj_z| dg¡Wn&tj yZ}z WYd}~n d}~00dS)z;Test that issues with the ACME client are handled correctlyNr[rÝ) rÌrr)rårýrvrrnrr)rrGrær#r#r$Útest_no_existing_client£ sz'ShowAccountTest.test_no_existing_clientcCs&| d¡|jd t d¡g¡dS)Nr#rÂz¾Account details for server https://acme-v02.api.letsencrypt.org/directory: Account URL: https://www.letsencrypt-demo.org/acme/reg/1 Account Thumbprint: Zm9vYmFyYmF6 Email contact: none©rÞrýZassert_has_callsrrÑrsr#r#r$Útest_no_contacts® s  ÿz ShowAccountTest.test_no_contactscCs*d}| |¡|jd t d¡g¡dS)N)úmailto:foo@example.comrÂzÉAccount details for server https://acme-v02.api.letsencrypt.org/directory: Account URL: https://www.letsencrypt-demo.org/acme/reg/1 Account Thumbprint: Zm9vYmFyYmF6 Email contact: foo@example.comrà©rrÎr#r#r$Útest_single_email¸ s   ÿz!ShowAccountTest.test_single_emailcCs*d}| |¡|jd t d¡g¡dS)N)râzmailto:bar@example.comrÂzÛAccount details for server https://acme-v02.api.letsencrypt.org/directory: Account URL: https://www.letsencrypt-demo.org/acme/reg/1 Account Thumbprint: Zm9vYmFyYmF6 Email contacts: foo@example.com, bar@example.comràrãr#r#r$Útest_double_emailà s   ÿz!ShowAccountTest.test_double_email)r@rArBrCrVrnrÌrÞrÕrßrárärårƒr#r#rdr$rÜg s      rÜc@s`eZdZdZejZdZe›dZe j dd„ƒZ e j dd„ƒZe j d ¡d d d „ƒZd d „ZdS)Ú TestLockOrderzFTests that Certbot's directory locks were acquired in the right order.zExpected TestLockOrder errorz|1 renew failureccs4t d¡}|VWdƒn1s&0YdS)Nzcertbot._internal.lock.lock_dir)rrD)rÚ mock_lock_dirr#r#r$rç× s zTestLockOrder.mock_lock_dirc #s‡‡‡fdd„}‡‡‡‡fdd„}tj tjd|¡Htj tjd|¡dVWdƒn1sd0YWdƒn1s‚0YdS)zJPatches plugin prepare to call mock_lock_dir and raise the expected error.csˆˆƒˆ ˆj¡‚dSr…©ÚEXPECTED_ERROR_TYPEÚEXPECTED_ERROR_STR©Z unused_self)Úauthenticator_dirrçrr#r$Úauthenticator_lockß sz=TestLockOrder.mock_plugin_prepare..authenticator_lockcs ˆˆƒˆdkrˆ ˆj¡‚dS)Nršrèrë)Ú installer_dirrçrÚ subcommandr#r$Úinstaller_lockã sz9TestLockOrder.mock_plugin_prepare..installer_lockrÛN)rrDÚobjectrZ Authenticatorrrz)rrìrîrçrïrírðr#)rìrîrçrrïr$Úmock_plugin_prepareÜ s  z!TestLockOrder.mock_plugin_preparezcertonly install renew run)Úparamsc csÎt|dƒ}t|dƒ}t|dƒ}t|dƒ}t|dƒ}|j} | dddd d d |d |d |g } t |d¡| |||| ¡@||||g} | dkrœ| | fVn| | |gfVWdƒn1sÀ0YdS)aRSets up Certbot with args and mocks to error after acquiring the last lock. This fixture yields the CLI arguments that should be given to Certbot and the expected order of directories to be locked. An error is raised after acquiring the last lock just as a means of stopping Certbot's execution. rr=rZlogsZworkrârz-irz--no-random-sleep-on-renewr rgrfrršN)r¾Zparamr†rrò) rrçZrequestZtmp_pathrìrþrîrjrkrïrlÚ lock_orderr#r#r$Úargs_and_lock_orderð s       þ   z!TestLockOrder.args_and_lock_ordercCs^|\}}tj|j|jdt |¡Wdƒn1s:0Yt|j|ƒD]\}}qPdS)Nr5)r;r<réÚEXPECTED_ERROR_STR_REGEXrÚziprº)rrõrçrlrôrÑZ locked_dirr#r#r$Útest_lock_order s (zTestLockOrder.test_lock_orderN)r@rArBrCrrrérêrör;ZfixturerçÚ contextlibÚcontextmanagerròrgrõrør#r#r#r$ræÏ s    ræÚ__main__rM)UrCrùrÇÚ importlibrrnrrÃrKrºrRr«rÚtypingrZunittestrrZjosepyr”r;rÈZ acme.messagesrraZcertbotrrr r Zcertbot._internalr r r rrZcertbot._internal.pluginsrrrrZcertbot.compatrrZcertbot.pluginsrZcertbot.tests.utilZtestsr†rìr¼rdržreZJWKRSAÚloadZ load_vectorrÊr`r_ZTestCaserZConfigTestCaserEr„r®ZTempDirTestCaserµrêr,r?rerqr{r}r˜rœr¶r¿rÜrær@ÚexitÚargvÚ__file__r#r#r#r$Ús’                          RXggk> o4ihK