コード例 #1
0
ファイル: conftest.py プロジェクト: jdelic/salt
def ssl_webserver(integration_files_dir, scope="module"):
    """
    spins up an https webserver.
    """
    context = ssl.SSLContext()
    root_dir = os.path.join(integration_files_dir, "https")
    context.load_cert_chain(os.path.join(root_dir, "cert.pem"),
                            os.path.join(root_dir, "key.pem"))

    webserver = Webserver(root=integration_files_dir, ssl_opts=context)
    webserver.start()
    yield webserver
    webserver.stop()
コード例 #2
0
ファイル: conftest.py プロジェクト: zfouts/salt
def ssl_webserver(integration_files_dir, scope="module"):
    """
    spins up an https webserver.
    """
    context = ssl.SSLContext()
    context.load_cert_chain(
        str(integration_files_dir / "https" / "cert.pem"),
        str(integration_files_dir / "https" / "key.pem"),
    )

    webserver = Webserver(root=str(integration_files_dir), ssl_opts=context)
    webserver.start()
    yield webserver
    webserver.stop()
コード例 #3
0
def ssl_webserver(integration_files_dir, scope="module"):
    """
    spins up an https webserver.
    """
    if sys.version_info < (3, 5, 3):
        pytest.skip("Python versions older than 3.5.3 do not define `ssl.PROTOCOL_TLS`")
    context = ssl.SSLContext(ssl.PROTOCOL_TLS)
    context.load_cert_chain(
        str(integration_files_dir / "https" / "cert.pem"),
        str(integration_files_dir / "https" / "key.pem"),
    )

    webserver = Webserver(root=str(integration_files_dir), ssl_opts=context)
    webserver.start()
    yield webserver
    webserver.stop()
コード例 #4
0
class SPMInstallTest(SPMCase):
    """
    Validate the spm install command
    """
    def setUp(self):
        self.config = self._spm_config()
        self._spm_build_files(self.config)
        self.spm_build_dir = self.config["spm_build_dir"]
        if "http" in self.id():
            # only start the webserver when testing http
            self.webserver = Webserver()
            self.webserver.root = self.spm_build_dir
            self.webserver.start()
            self.repo_dir = self.config["spm_repos_config"] + ".d"
            self.repo = os.path.join(self.repo_dir, "spm.repo")
            url = {"my_repo": {"url": self.webserver.url("")[:-1]}}

            if not os.path.exists(self.repo_dir):
                os.makedirs(self.repo_dir)

            with salt.utils.files.fopen(self.repo, "w") as fp:
                salt.utils.yaml.safe_dump(url, fp)

    def test_spm_install_http(self):
        """
        test spm install using http repo
        """
        build_spm = self.run_spm("build", self.config, self.formula_dir)
        spm_file = os.path.join(self.spm_build_dir, "apache-201506-2.spm")

        create_repo = self.run_spm("create_repo", self.config,
                                   self.spm_build_dir)

        for root, dirs, files in salt.utils.path.os_walk(self.spm_build_dir):
            for fp in files:
                self.webserver.url(fp)

        install = self.run_spm("install", self.config, "apache")

        sls = os.path.join(self.config["formula_path"], "apache", "apache.sls")

        self.assertTrue(os.path.exists(sls))

    @slowTest
    def test_spm_install_local_dir(self):
        """
        test spm install from local directory
        """
        build_spm = self.run_spm("build", self.config, self.formula_dir)
        spm_file = os.path.join(self.config["spm_build_dir"],
                                "apache-201506-2.spm")

        install = self.run_spm("install", self.config, spm_file)

        sls = os.path.join(self.config["formula_path"], "apache", "apache.sls")

        self.assertTrue(os.path.exists(sls))

    @slowTest
    def test_spm_install_from_repo(self):
        """
        test spm install from repo
        """
        self._spm_create_update_repo(self.config)
        install = self.run_spm("install", self.config, "apache")

        sls = os.path.join(self.config["formula_path"], "apache", "apache.sls")

        self.assertTrue(os.path.exists(sls))

    def tearDown(self):
        if "http" in self.id():
            self.webserver.stop()
        shutil.rmtree(self._tmp_spm)