Ejemplo n.º 1
0
 def _cli_missing_flag(self, args, message):
     "Ensure that a particular error raises a missing cli flag error containing message"
     exc = None
     try:
         with mock.patch('certbot.main.sys.stderr'):
             main.main(self.standard_args + args[:])  # NOTE: parser can alter its args!
     except errors.MissingCommandlineFlag as exc:
         self.assertTrue(message in str(exc))
     self.assertTrue(exc is not None)
Ejemplo n.º 2
0
    def _call_no_clientmock(self, args, stdout=None):
        "Run the client with output streams mocked out"
        args = self.standard_args + args

        toy_stdout = stdout if stdout else six.StringIO()
        with mock.patch('certbot.main.sys.stdout', new=toy_stdout):
            with mock.patch('certbot.main.sys.stderr') as stderr:
                ret = main.main(args[:])  # NOTE: parser can alter its args!
        return ret, toy_stdout, stderr
Ejemplo n.º 3
0
    def _call_no_clientmock(self, args, stdout=None):
        "Run the client with output streams mocked out"
        args = self.standard_args + args

        toy_stdout = stdout if stdout else six.StringIO()
        with mock.patch('certbot.main.sys.stdout', new=toy_stdout):
            with mock.patch('certbot.main.sys.stderr') as stderr:
                ret = main.main(args[:])  # NOTE: parser can alter its args!
        return ret, toy_stdout, stderr
Ejemplo n.º 4
0
def handler(event, context):
    domain = ','.join(os.getenv('DOMAIN').split())
    email = os.getenv('EMAIL')
    distribution_id = os.getenv('DISTRIBUTION_ID')
    workdir = os.getenv('WORKDIR') or '/tmp/letsencrypt'
    test_flag = os.getenv('TEST_MODE')

    args = [
        '-i', 'certbot-s3front:installer', '--dns-route53', '-d', domain, '-d',
        ('*.' + domain), '--agree-tos', '--text', '--email', email, '-n',
        '--config-dir', workdir, '--logs-dir', workdir, '--work-dir', workdir,
        '--certbot-s3front:installer-cf-distribution-id', distribution_id,
        '--keep'
    ]
    if test_flag:
        args.append('--staging')

    app.main(args)
Ejemplo n.º 5
0
    utils.execute([
        sys.executable,
        "-m",
        "dnsrobocert.core.certbot",
        "revoke",
        "-n",
        "--config-dir",
        directory_path,
        "--work-dir",
        os.path.join(directory_path, "workdir"),
        "--logs-dir",
        os.path.join(directory_path, "logs"),
        "--server",
        url,
        "--cert-path",
        os.path.join(directory_path, "live", lineage, "cert.pem"),
    ])


def _hook_cmd(hook_type: str, config_path: str, lineage: str = None) -> str:
    command = '{0} -m dnsrobocert.core.hooks -t {1} -c "{2}"'.format(
        sys.executable, hook_type, config_path)
    if lineage:
        command = '{0} -l "{1}"'.format(command, lineage)
    return command


if __name__ == "__main__":
    sys.exit(main.main())
Ejemplo n.º 6
0
def run_certbot(args):
    logger.info(f"running certbot {' '.join(args)}")
    # certbot doesnt provide a public API so just call `main()` to avoid shell
    # https://certbot.eff.org/docs/api/certbot.main.html
    cb.main(args)
    logger.info(f"finished certbot!")