Ejemplo n.º 1
0
    def get_nginx_configurator(self, config_path, config_dir, work_dir, logs_dir,
            version=(1, 6, 2), openssl_version="1.0.2g"):
        """Create an Nginx Configurator with the specified options."""

        backups = os.path.join(work_dir, "backups")

        self.configuration.nginx_server_root = config_path
        self.configuration.le_vhost_ext = "-le-ssl.conf"
        self.configuration.config_dir = config_dir
        self.configuration.work_dir = work_dir
        self.configuration.logs_dir = logs_dir
        self.configuration.backup_dir = backups
        self.configuration.temp_checkpoint_dir = os.path.join(work_dir, "temp_checkpoints")
        self.configuration.in_progress_dir = os.path.join(backups, "IN_PROGRESS")
        self.configuration.server = "https://acme-server.org:443/new"
        self.configuration.http01_port = 80
        self.configuration.https_port = 5001

        with mock.patch("certbot_nginx._internal.configurator.NginxConfigurator."
                        "config_test"):
            with mock.patch("certbot_nginx._internal.configurator.util."
                            "exe_exists") as mock_exe_exists:
                mock_exe_exists.return_value = True
                config = configurator.NginxConfigurator(
                    self.configuration,
                    name="nginx",
                    version=version,
                    openssl_version=openssl_version)
                config.prepare()

        # Provide general config utility.
        zope.component.provideUtility(self.configuration)

        return config
Ejemplo n.º 2
0
    def _prepare_configurator(self) -> None:
        """Prepares the Nginx plugin for testing"""
        for k in constants.CLI_DEFAULTS:
            setattr(self.le_config, "nginx_" + k, constants.os_constant(k))

        conf = configuration.NamespaceConfig(self.le_config)
        self._configurator = configurator.NginxConfigurator(config=conf,
                                                            name="nginx")
        self._configurator.prepare()