Exemple #1
0
def test_main_loop(shutdown, background, revoke, certonly, account, tmp_path):
    directory_path = tmp_path / "letsencrypt"
    os.mkdir(directory_path)

    config_path = tmp_path / "config.yml"
    with open(str(config_path), "w") as f:
        f.write("""\
draft: false
acme:
  email_account: [email protected]
profiles:
- name: dummy
  provider: dummy
  provider_options:
    auth_token: TOKEN
certificates:
- domains:
  - test1.example.net
  - test2.example.net
  profile: dummy
""")

    shutdown.side_effect = [False, True]
    main.main(["-c", str(config_path), "-d", str(directory_path)])

    assert shutdown.called
    assert account.called
    assert certonly.called
    assert not revoke.called
    assert background.worker.called
def test_it(tmp_path):
    with _start_pebble(tmp_path):
        directory_path = tmp_path / "letsencrypt"
        os.mkdir(directory_path)

        config_path = tmp_path / "config.yml"
        with open(str(config_path), "w") as f:
            f.write("""\
draft: false
acme:
  email_account: [email protected]
  directory_url: https://127.0.0.1:14000/dir
profiles:
- name: dummy
  provider: dummy
  provider_options:
    auth_token: TOKEN
certificates:
- domains:
  - test1.example.net
  - test2.example.net
  profile: dummy
  follow_cnames: true
  reuse_key: true
  key_type: ecdsa
""")

        with patch.object(main._Daemon, "do_shutdown") as shutdown:
            shutdown.side_effect = [False, True]
            with patch("dnsrobocert.core.certbot._DEFAULT_FLAGS",
                       ["-n", "--no-verify-ssl"]):
                main.main(["-c", str(config_path), "-d", str(directory_path)])

        assert os.path.exists(
            str(directory_path / "live" / "test1.example.net" / "cert.pem"))