def test_graceful_renew_it_is_not_time(context): """Test graceful renew is not done when it is not due time.""" certname = context.get_domain('renew') context.certbot(['-d', certname]) assert_cert_count_for_lineage(context.config_dir, certname, 1) context.certbot( ['renew', '--deploy-hook', misc.echo('deploy', context.hook_probe)], force_renew=False) assert_cert_count_for_lineage(context.config_dir, certname, 1) with pytest.raises(AssertionError): assert_hook_execution(context.hook_probe, 'deploy')
def test_http_01(context): """Test the HTTP-01 challenge using standalone plugin.""" # We start a server listening on the port for the # TLS-SNI challenge to prevent regressions in #3601. with misc.create_http_server(context.tls_alpn_01_port): certname = context.get_domain('le2') context.certbot([ '--domains', certname, '--preferred-challenges', 'http-01', 'run', '--cert-name', certname, '--pre-hook', misc.echo('wtf_pre', context.hook_probe), '--post-hook', misc.echo('wtf_post', context.hook_probe), '--deploy-hook', misc.echo('deploy', context.hook_probe), ]) assert_hook_execution(context.hook_probe, 'deploy') assert_saved_renew_hook(context.config_dir, certname)
def test_renew_hook_override(context: IntegrationTestsContext) -> None: """Test correct hook override on renew.""" certname = context.get_domain('override') context.certbot([ 'certonly', '-d', certname, '--preferred-challenges', 'http-01', '--pre-hook', misc.echo('pre', context.hook_probe), '--post-hook', misc.echo('post', context.hook_probe), '--deploy-hook', misc.echo('deploy', context.hook_probe), ]) assert_hook_execution(context.hook_probe, 'pre') assert_hook_execution(context.hook_probe, 'post') assert_hook_execution(context.hook_probe, 'deploy') # Now we override all previous hooks during next renew. with open(context.hook_probe, 'w'): pass context.certbot([ 'renew', '--cert-name', certname, '--pre-hook', misc.echo('pre_override', context.hook_probe), '--post-hook', misc.echo('post_override', context.hook_probe), '--deploy-hook', misc.echo('deploy_override', context.hook_probe), ]) assert_hook_execution(context.hook_probe, 'pre_override') assert_hook_execution(context.hook_probe, 'post_override') assert_hook_execution(context.hook_probe, 'deploy_override') with pytest.raises(AssertionError): assert_hook_execution(context.hook_probe, 'pre') with pytest.raises(AssertionError): assert_hook_execution(context.hook_probe, 'post') with pytest.raises(AssertionError): assert_hook_execution(context.hook_probe, 'deploy') # Expect that this renew will reuse new hooks registered in the previous renew. with open(context.hook_probe, 'w'): pass context.certbot(['renew', '--cert-name', certname]) assert_hook_execution(context.hook_probe, 'pre_override') assert_hook_execution(context.hook_probe, 'post_override') assert_hook_execution(context.hook_probe, 'deploy_override')
def test_graceful_renew_it_is_time(context: IntegrationTestsContext) -> None: """Test graceful renew is done when it is due time.""" certname = context.get_domain('renew') context.certbot(['-d', certname]) assert_cert_count_for_lineage(context.config_dir, certname, 1) with open(join(context.config_dir, 'renewal', '{0}.conf'.format(certname)), 'r') as file: lines = file.readlines() lines.insert(4, 'renew_before_expiry = 100 years{0}'.format(os.linesep)) with open(join(context.config_dir, 'renewal', '{0}.conf'.format(certname)), 'w') as file: file.writelines(lines) context.certbot(['renew', '--deploy-hook', misc.echo('deploy', context.hook_probe)], force_renew=False) assert_cert_count_for_lineage(context.config_dir, certname, 2) assert_hook_execution(context.hook_probe, 'deploy')