def test_generate_treeinfo_repositories_fedora(self):
        """Test the generate_treeinfo_repositories function with Fedora repos."""
        root_url = self._load_treeinfo(TREE_INFO_FEDORA)

        original = RepoConfigurationData()
        original.name = "anaconda"
        original.url = root_url
        original.proxy = "http://proxy"
        original.cost = 50
        original.excluded_packages = ["p1", "p2"]
        original.included_packages = ["p2", "p3"]
        original.ssl_verification_enabled = False
        original.ssl_configuration.ca_cert_path = "file.cert"
        original.ssl_configuration.client_key_path = "client.key"
        original.ssl_configuration.client_cert_path = "client.cert"
        original.installation_enabled = True

        generated = generate_treeinfo_repositories(original, self.metadata)

        everything = RepoConfigurationData()
        everything.origin = REPO_ORIGIN_TREEINFO
        everything.name = "Everything"
        everything.enabled = True
        everything.url = root_url
        everything.proxy = "http://proxy"
        everything.cost = 50
        everything.excluded_packages = ["p1", "p2"]
        everything.included_packages = ["p2", "p3"]
        everything.ssl_verification_enabled = False
        everything.ssl_configuration.ca_cert_path = "file.cert"
        everything.ssl_configuration.client_key_path = "client.key"
        everything.ssl_configuration.client_cert_path = "client.cert"
        everything.installation_enabled = False

        self._assert_repo_list_equal(generated, [everything])
Beispiel #2
0
    def url_get_repo_configurations_test(self, publisher):
        """Test DNF GetRepoConfigurations for URL source."""
        source = self.shared_tests.prepare_source(SourceType.URL)

        data = RepoConfigurationData()
        data.name = "Bernard Black"
        data.url = "http://library.uk"
        data.ssl_verification_enabled = False
        data.proxy = "http://MannyBianco/"

        source.set_repo_configuration(data)

        self.shared_tests.set_sources([source])

        expected = [{
            "name": get_variant(Str, "Bernard Black"),
            "url": get_variant(Str, "http://library.uk"),
            "type": get_variant(Str, URL_TYPE_BASEURL),
            "ssl-verification-enabled": get_variant(Bool, False),
            "ssl-configuration": get_variant(Structure, {
                "ca-cert-path": get_variant(Str, ""),
                "client-cert-path": get_variant(Str, ""),
                "client-key-path": get_variant(Str, "")
            }),
            "proxy": get_variant(Str, "http://MannyBianco/"),
            "cost": get_variant(Int, 1000),
            "excluded-packages": get_variant(List[Str], []),
            "included-packages": get_variant(List[Str], [])
        }]

        self.assertEqual(self.interface.GetRepoConfigurations(), expected)
Beispiel #3
0
    def test_disable_ssl_verification_properties(self):
        data = RepoConfigurationData()
        data.ssl_verification_enabled = False

        self._check_dbus_property(
            "RepoConfiguration",
            RepoConfigurationData.to_structure(data)
        )
    def test_add_repository_no_ssl_configuration(self):
        """Test the add_repository method without the ssl configuration."""
        data = RepoConfigurationData()
        data.name = "r1"
        data.ssl_verification_enabled = False

        self.dnf_manager.add_repository(data)
        self._check_repo("r1", [
            "sslverify = 0",
        ])
    def test_add_repository_ssl_configuration(self):
        """Test the add_repository method with the ssl configuration."""
        data = RepoConfigurationData()
        data.name = "r1"
        data.ssl_verification_enabled = True
        data.ssl_configuration.ca_cert_path = "file:///ca-cert"
        data.ssl_configuration.client_cert_path = "file:///client-cert"
        data.ssl_configuration.client_key_path = "file:///client-key"

        self.dnf_manager.add_repository(data)
        self._check_repo("r1", [
            "sslverify = 1",
            "sslcacert = file:///ca-cert",
            "sslclientcert = file:///client-cert",
            "sslclientkey = file:///client-key",
        ])
Beispiel #6
0
def convert_ks_repo_to_repo_data(ks_data):
    """Convert the kickstart command into a repo configuration.

    :param RepoData ks_data: a kickstart data
    :return RepoConfigurationData: a repo configuration
    """
    if not isinstance(ks_data, RepoData):
        raise ValueError("Unexpected kickstart data: {}".format(type(ks_data)))

    repo_data = RepoConfigurationData()
    repo_data.name = ks_data.name
    repo_data.enabled = ks_data.enabled

    if ks_data.baseurl:
        repo_data.url = ks_data.baseurl
        repo_data.type = URL_TYPE_BASEURL
    elif ks_data.mirrorlist:
        repo_data.url = ks_data.mirrorlist
        repo_data.type = URL_TYPE_MIRRORLIST
    elif ks_data.metalink:
        repo_data.url = ks_data.metalink
        repo_data.type = URL_TYPE_METALINK
    else:
        # Handle the `repo --name=updates` use case.
        repo_data.url = ""
        repo_data.type = "NONE"

    if ks_data.treeinfo_origin:
        repo_data.origin = REPO_ORIGIN_TREEINFO
    elif not repo_data.url:
        repo_data.origin = REPO_ORIGIN_SYSTEM
    else:
        repo_data.origin = REPO_ORIGIN_USER

    repo_data.proxy = ks_data.proxy or ""
    repo_data.cost = ks_data.cost or DNF_DEFAULT_REPO_COST
    repo_data.included_packages = ks_data.includepkgs
    repo_data.excluded_packages = ks_data.excludepkgs
    repo_data.installation_enabled = ks_data.install

    repo_data.ssl_verification_enabled = not ks_data.noverifyssl
    repo_data.ssl_configuration.ca_cert_path = ks_data.sslcacert or ""
    repo_data.ssl_configuration.client_cert_path = ks_data.sslclientcert or ""
    repo_data.ssl_configuration.client_key_path = ks_data.sslclientkey or ""

    return repo_data
    def test_generate_repo_file_mirrorlist(self):
        """Test the generate_repo_file method with mirrorlist."""
        data = RepoConfigurationData()
        data.name = "r1"
        data.type = URL_TYPE_MIRRORLIST
        data.url = "http://mirror"
        data.ssl_verification_enabled = False
        data.proxy = "http://*****:*****@example.com:1234"

        self._check_content(
            data, """
            [r1]
            name = r1
            enabled = 1
            mirrorlist = http://mirror
            sslverify = 0
            proxy = http://example.com:1234
            proxy_username = user
            proxy_password = pass
            """)
    def test_load_data_ssl(self, session_getter):
        """Test the load_data method with SSL configuration."""
        session_getter.return_value.__enter__.return_value = \
            Mock(status_code=200, text=TREE_INFO_FEDORA)

        data = RepoConfigurationData()
        data.url = "http://path"
        data.ssl_verification_enabled = True
        data.ssl_configuration.ca_cert_path = "file.cert"
        data.ssl_configuration.client_key_path = "client.key"
        data.ssl_configuration.client_cert_path = "client.cert"

        self.metadata.load_data(data)

        session_getter.assert_called_once_with(
            "http://path/.treeinfo",
            headers={"user-agent": "anaconda (anaconda)/bluesky"},
            proxies={},
            verify="file.cert",
            cert=("client.cert", "client.key"),
            timeout=NETWORK_CONNECTION_TIMEOUT)
Beispiel #9
0
    def test_url_get_repo_configurations(self, publisher):
        """Test DNF GetRepoConfigurations for URL source."""
        source = self.shared_tests.prepare_source(SourceType.URL)

        data = RepoConfigurationData()
        data.name = "Bernard Black"
        data.url = "http://library.uk"
        data.ssl_verification_enabled = False
        data.proxy = "http://MannyBianco/"

        source.set_repo_configuration(data)
        self.shared_tests.set_sources([source])

        expected = self._generate_expected_repo_configuration_dict()
        expected.update({
            "name": get_variant(Str, "Bernard Black"),
            "url": get_variant(Str, "http://library.uk"),
            "proxy": get_variant(Str, "http://MannyBianco/"),
            "ssl-verification-enabled": get_variant(Bool, False),
        })

        assert self.interface.GetRepoConfigurations() == [expected]
Beispiel #10
0
    def process_kickstart(self, data):
        """Process the kickstart data."""
        repo_data = RepoConfigurationData()
        repo_data.name = self._url_source_name

        if data.url.url:
            repo_data.url = data.url.url
            repo_data.type = URL_TYPE_BASEURL
        elif data.url.mirrorlist:
            repo_data.url = data.url.mirrorlist
            repo_data.type = URL_TYPE_MIRRORLIST
        elif data.url.metalink:
            repo_data.url = data.url.metalink
            repo_data.type = URL_TYPE_METALINK

        repo_data.proxy = data.url.proxy
        repo_data.ssl_verification_enabled = not data.url.noverifyssl
        repo_data.ssl_configuration.ca_cert_path = data.url.sslcacert or ""
        repo_data.ssl_configuration.client_cert_path = data.url.sslclientcert or ""
        repo_data.ssl_configuration.client_key_path = data.url.sslclientkey or ""

        self.set_repo_configuration(repo_data)