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])
    def test_generate_treeinfo_repositories_custom(self, mock_conf):
        """Test the generate_treeinfo_repositories function with custom repos."""
        mock_conf.payload.enabled_repositories_from_treeinfo = ["variant"]
        root_url = self._load_treeinfo(TREE_INFO_CUSTOM)

        original = RepoConfigurationData()
        original.name = "anaconda"
        original.url = root_url

        generated = generate_treeinfo_repositories(original, self.metadata)

        optional = RepoConfigurationData()
        optional.origin = REPO_ORIGIN_TREEINFO
        optional.name = "MyOptional"
        optional.enabled = False
        optional.url = root_url + "/optional"

        variant = RepoConfigurationData()
        variant.origin = REPO_ORIGIN_TREEINFO
        variant.name = "MyVariant"
        variant.enabled = True
        variant.url = root_url + "/variant"

        # Anaconda ignores addons and child variants.
        self._assert_repo_list_equal(generated, [optional, variant])
Beispiel #3
0
    def test_write_multiple_repositories(self):
        """Write multiple repositories."""
        r1 = RepoConfigurationData()
        r1.name = "r1"
        r1.url = "http://repo/1"
        r1.installation_enabled = True

        r2 = RepoConfigurationData()
        r2.name = "r2"
        r2.url = "https://repo/2"
        r2.installation_enabled = True

        r3 = RepoConfigurationData()
        r3.name = "r3"
        r3.url = "ftp://repo/3"
        r3.installation_enabled = True

        r4 = RepoConfigurationData()
        r4.name = "r4"
        r4.url = "nfs://repo/4"
        r4.installation_enabled = True

        with tempfile.TemporaryDirectory() as sysroot:
            self._run_task(sysroot, [r1, r2, r3])
            self._check_files(sysroot, [
                "r1.repo",
                "r2.repo",
                "r3.repo",
            ])
            self._check_content(
                sysroot,
                "r1.repo",
                "[r1]\n"
                "name = r1\n"
                "enabled = 1\n"
                "baseurl = http://repo/1\n"
            )
            self._check_content(
                sysroot,
                "r2.repo",
                "[r2]\n"
                "name = r2\n"
                "enabled = 1\n"
                "baseurl = https://repo/2\n"
            )
            self._check_content(
                sysroot,
                "r3.repo",
                "[r3]\n"
                "name = r3\n"
                "enabled = 1\n"
                "baseurl = ftp://repo/3\n"
            )
    def set_url_mirrorlist_properties_test(self):
        data = RepoConfigurationData()
        data.url = "http://forthehorde.com/mirrorlist?url"
        data.type = URL_TYPE_MIRRORLIST

        self._check_dbus_property("RepoConfiguration",
                                  RepoConfigurationData.to_structure(data))
    def set_url_base_source_properties_test(self):
        data = RepoConfigurationData()
        data.url = "http://example.com/repo"
        data.type = URL_TYPE_BASEURL

        self._check_dbus_property("RepoConfiguration",
                                  RepoConfigurationData.to_structure(data))
 def description_test(self):
     """Test URL source description."""
     rc = RepoConfigurationData()
     rc.url = "http://example.com/"
     self.url_source_interface.SetRepoConfiguration(rc.to_structure(rc))
     self.assertEqual("http://example.com/",
                      self.url_source_module.description)
 def repr_test(self):
     config = RepoConfigurationData()
     config.url = "http://some.example.com/repository"
     self.module.set_repo_configuration(config)
     self.assertEqual(
         repr(self.module),
         "Source(type='URL', url='http://some.example.com/repository')")
    def set_url_metalink_properties_test(self):
        data = RepoConfigurationData()
        data.url = "https://alianceFTW/metalink?nopesir"
        data.type = URL_TYPE_METALINK

        self._check_dbus_property("RepoConfiguration",
                                  RepoConfigurationData.to_structure(data))
Beispiel #9
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 #10
0
    def test_set_proxy_properties(self):
        data = RepoConfigurationData()
        data.proxy = "http://*****:*****@super-cool-server.com"

        self._check_dbus_property(
            "RepoConfiguration",
            RepoConfigurationData.to_structure(data)
        )
Beispiel #11
0
    def test_set_name_properties(self):
        data = RepoConfigurationData()
        data.name = "Saitama"

        self._check_dbus_property(
            "RepoConfiguration",
            RepoConfigurationData.to_structure(data)
        )
    def test_add_repository_cost(self):
        """Test the add_repository method with a cost."""
        data = RepoConfigurationData()
        data.name = "r1"
        data.cost = 256

        self.dnf_manager.add_repository(data)
        self._check_repo("r1", ["cost = 256"])
Beispiel #13
0
    def test_set_included_packages_properties(self):
        data = RepoConfigurationData()
        data.include_packages = ["python*", "perl", "rattlesnake", "<- what does not belong there"]

        self._check_dbus_property(
            "RepoConfiguration",
            RepoConfigurationData.to_structure(data)
        )
Beispiel #14
0
    def test_set_excluded_packages_properties(self):
        data = RepoConfigurationData()
        data.exclude_packages = ["foo", "bar", "foobar", "<-yep it's merge of the two!"]

        self._check_dbus_property(
            "RepoConfiguration",
            RepoConfigurationData.to_structure(data)
        )
Beispiel #15
0
    def test_set_cost_properties(self):
        data = RepoConfigurationData()
        data.cost = 2000

        self._check_dbus_property(
            "RepoConfiguration",
            RepoConfigurationData.to_structure(data)
        )
Beispiel #16
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 set_ssl_configuration_properties_test(self):
        data = RepoConfigurationData()
        ssl_conf = data.ssl_configuration
        ssl_conf.ca_cert_path = "file:///my/cool/cert"
        ssl_conf.client_cert_path = "file:///my/cool/client/cert"
        ssl_conf.client_key_path = "file:///my/cool/client/key/"

        self._check_dbus_property("RepoConfiguration",
                                  RepoConfigurationData.to_structure(data))
Beispiel #18
0
    def test_load_data_missing_url(self):
        """Test the load_data method with a missing URL."""
        data = RepoConfigurationData()
        data.url = ""

        with self.assertRaises(NoTreeInfoError) as cm:
            self.metadata.load_data(data)

        self.assertEqual(str(cm.exception), "No URL specified.")
    def test_load_data_unsupported_url(self):
        """Test the load_data method with an unsupported URL."""
        data = RepoConfigurationData()
        data.type = URL_TYPE_METALINK

        with pytest.raises(NoTreeInfoError) as cm:
            self.metadata.load_data(data)

        assert str(cm.value) == "Unsupported type of URL (METALINK)."
    def test_load_data_missing_url(self):
        """Test the load_data method with a missing URL."""
        data = RepoConfigurationData()
        data.url = ""

        with pytest.raises(NoTreeInfoError) as cm:
            self.metadata.load_data(data)

        assert str(cm.value) == "No URL specified."
Beispiel #21
0
    def test_load_data_unsupported_url(self):
        """Test the load_data method with an unsupported URL."""
        data = RepoConfigurationData()
        data.type = URL_TYPE_METALINK

        with self.assertRaises(NoTreeInfoError) as cm:
            self.metadata.load_data(data)

        self.assertEqual(str(cm.exception), "Unsupported type of URL (METALINK).")
    def test_load_data_no_metadata(self):
        """Test the load_data method with no metadata."""
        with tempfile.TemporaryDirectory() as path:
            data = RepoConfigurationData()
            data.url = "file://" + path

            with pytest.raises(NoTreeInfoError) as cm:
                self.metadata.load_data(data)

            assert str(cm.value) == "No treeinfo metadata found (404)."
    def test_load_data_failed_download(self):
        """Test the load_data method with no metadata."""
        with tempfile.TemporaryDirectory() as path:
            data = RepoConfigurationData()
            data.url = "invalid://" + path

            with pytest.raises(NoTreeInfoError) as cm:
                self.metadata.load_data(data)

            assert str(cm.value) == "Couldn't download treeinfo metadata."
    def test_add_repository_no_auth_proxy(self):
        """Test the add_repository method the no auth proxy configuration."""
        data = RepoConfigurationData()
        data.name = "r1"
        data.proxy = "http://example.com:1234"

        self.dnf_manager.add_repository(data)
        self._check_repo("r1", [
            "proxy = http://example.com:1234",
        ])
    def test_add_repository_invalid_proxy(self):
        """Test the add_repository method the invalid proxy configuration."""
        data = RepoConfigurationData()
        data.name = "r1"
        data.proxy = "@:/invalid"

        self.dnf_manager.add_repository(data)
        self._check_repo("r1", [
            "proxy = ",
        ])
    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_load_data(self):
        """Test the load_data method."""
        # Load the .treeinfo file.
        with tempfile.TemporaryDirectory() as path:
            self._create_file(path, ".treeinfo", TREE_INFO_FEDORA)

            data = RepoConfigurationData()
            data.url = "file://" + path

            self.metadata.load_data(data)

        # Load the treeinfo file.
        with tempfile.TemporaryDirectory() as path:
            self._create_file(path, "treeinfo", TREE_INFO_FEDORA)

            data = RepoConfigurationData()
            data.url = "file://" + path

            self.metadata.load_data(data)
    def test_add_repository_metalink(self):
        """Test the add_repository method with metalink."""
        data = RepoConfigurationData()
        data.name = "r1"
        data.type = URL_TYPE_METALINK
        data.url = "http://metalink"

        self.dnf_manager.add_repository(data)
        self._check_repo("r1", [
            "metalink = http://metalink",
        ])
    def test_add_repository_mirrorlist(self):
        """Test the add_repository method with mirrorlist."""
        data = RepoConfigurationData()
        data.name = "r1"
        data.type = URL_TYPE_MIRRORLIST
        data.url = "http://mirror"

        self.dnf_manager.add_repository(data)
        self._check_repo("r1", [
            "mirrorlist = http://mirror",
        ])
    def test_add_repository_disabled(self):
        """Test the add_repository method with disabled repo."""
        data = RepoConfigurationData()
        data.name = "r1"
        data.enabled = False

        self.dnf_manager.add_repository(data)

        self._check_repo("r1", [
            "enabled = 0",
        ])