def test_doesnt_break_on_unexisting_file(self):
     os.unlink(self.client_conf_path)
     sysconf.set("use-landscape-proxies", True)
     landscape.run()
     self.assertEquals(sysconf.get("http-proxy"), None)
     self.assertEquals(sysconf.get("https-proxy"), None)
     self.assertEquals(sysconf.get("ftp-proxy"), None)
Exemple #2
0
 def test_detect_all_explicitly_enabled_with_true(self):
     self.make_rpm()
     self.make_deb()
     self.make_slack()
     self.make_arch()
     sysconf.set("detect-sys-channels", True)
     self.rerun_plugin()
     self.assertEquals(
         sysconf.get("channels"), {
             "rpm-sys": {
                 "type": "rpm-sys",
                 "name": "RPM System"
             },
             "deb-sys": {
                 "type": "deb-sys",
                 "name": "DEB System"
             },
             "slack-sys": {
                 "type": "slack-sys",
                 "name": "Slackware System"
             },
             "arch-sys": {
                 "type": "arch-sys",
                 "name": "Archlinux System"
             }
         })
Exemple #3
0
    def test_deb_non_interactive_false(self):
        pkg = self.cache.getPackages()[0]
        info = self.loader.getInfo(pkg)

        file_url = info.getURLs()[0]
        self.assertEquals(file_url[:7], "file://")
        file_path = file_url[7:]

        check_results = []

        def check(argv, output):
            check_results.append(os.environ.get("DEBIAN_FRONTEND"))
            check_results.append(os.environ.get("APT_LISTCHANGES_FRONTEND"))
            check_results.append("--force-confold" in argv)
            return 0

        self.pm.dpkg = check

        sysconf.set("pm-iface-output", False, soft=True)
        sysconf.set("deb-non-interactive", False, soft=True)

        self.pm.commit({pkg: INSTALL}, {pkg: [file_path]})

        # One time for --unpack, one time for --configure.
        self.assertEquals(check_results,
                          [None, None, False, None, None, False])
Exemple #4
0
 def test_doesnt_break_on_unexisting_file(self):
     os.unlink(self.client_conf_path)
     sysconf.set("use-landscape-proxies", True)
     landscape.run()
     self.assertEquals(sysconf.get("http-proxy"), None)
     self.assertEquals(sysconf.get("https-proxy"), None)
     self.assertEquals(sysconf.get("ftp-proxy"), None)
 def test_synchronize_config_mirrorlist(self):
     product_id = self.makeFile(PRODUCT_ID, dirname=self.config_dir, basename="product.id")
     sysconf.set("product-id", product_id, soft=True)
     filename = self.makeFile(URPMI_CONFIG_MIRRORLIST, dirname=self.urpmi_dir, basename="urpmi.cfg")
     syncURPMIChannels(filename, self.media_dir)
     self.assertEquals(sysconf.get("channels")["urpmisync-MirrorList"]["mirrorurl"],
                       "http://api.mandriva.com/mirrors/base.2010.1.x86_64.list")
 def test_synchronize_config_variables(self):
     release = self.makeFile(RELEASE, dirname=self.config_dir, basename="release")
     sysconf.set("release", release, soft=True)
     filename = self.makeFile(URPMI_CONFIG_VARIABLES, dirname=self.urpmi_dir, basename="urpmi.cfg")
     syncURPMIChannels(filename, self.media_dir)
     self.assertEquals(sysconf.get("channels")["urpmisync-Variables"]["mirrorurl"],
                       "2010.1/x86_64")
 def test_rpm_database_detected_with_individual_setting(self):
     self.make_rpm()
     self.make_deb()
     sysconf.set("detect-sys-channels", "rpm")
     self.rerun_plugin()
     self.assertEquals(sysconf.get("channels"),
                       {"rpm-sys":
                        {"type": "rpm-sys", "name": "RPM System"}})
 def setUp(self):
     self.apt_dir = self.makeDir()
     self.sources_dir = os.path.join(self.apt_dir, "sources.list.d")
     self.keyring_file = os.path.join(self.apt_dir, "trusted.gpg")
     self.trustdb_file = os.path.join(self.apt_dir, "trustdb.gpg")
     os.mkdir(self.sources_dir)
     sysconf.set("sync-apt-keyring", self.keyring_file)
     sysconf.set("sync-apt-trustdb", self.trustdb_file)
 def test_detect_none_when_disabled_with_false(self):
     self.make_rpm()
     self.make_deb()
     self.make_slack()
     self.make_arch()
     sysconf.set("detect-sys-channels", False)
     self.rerun_plugin()
     self.assertEquals(sysconf.get("channels"), None)
 def setUp(self):
     self.apt_dir = self.makeDir()
     self.sources_dir = os.path.join(self.apt_dir, "sources.list.d")
     self.keyring_file = os.path.join(self.apt_dir, "trusted.gpg")
     self.trustdb_file = os.path.join(self.apt_dir, "trustdb.gpg")
     os.mkdir(self.sources_dir)
     sysconf.set("sync-apt-keyring", self.keyring_file)
     sysconf.set("sync-apt-trustdb", self.trustdb_file)
 def test_arch_database_detected_with_individual_setting(self):
     self.make_rpm()
     self.make_arch()
     sysconf.set("detect-sys-channels", "arch")
     self.rerun_plugin()
     self.assertEquals(sysconf.get("channels"),
                       {"arch-sys":
                        {"type": "arch-sys", "name": "Archlinux System"}})
 def test_slack_database_detected_with_individual_setting(self):
     self.make_rpm()
     self.make_slack()
     sysconf.set("detect-sys-channels", "slack")
     self.rerun_plugin()
     self.assertEquals(sysconf.get("channels"),
                       {"slack-sys":
                        {"type": "slack-sys", "name": "Slackware System"}})
Exemple #13
0
 def test_detect_none_when_disabled_with_false(self):
     self.make_rpm()
     self.make_deb()
     self.make_slack()
     self.make_arch()
     sysconf.set("detect-sys-channels", False)
     self.rerun_plugin()
     self.assertEquals(sysconf.get("channels"), None)
Exemple #14
0
def run():
    if (sysconf.get("use-landscape-proxies", False) and
        os.path.isfile(CLIENT_CONF_PATH)):
        parser = ConfigParser()
        parser.read(CLIENT_CONF_PATH)
        for type in "http", "https", "ftp":
            option = "%s_proxy" % type
            if parser.has_option("client", option) and option not in os.environ:
                setting = parser.get("client", option)
                sysconf.set(option.replace("_", "-"), setting, weak=True)
 def test_use_proxies_set_in_landscape(self):
     """
     If enabled, the landscape smart plugin will read the proxies
     set in Landscape.
     """
     sysconf.set("use-landscape-proxies", True)
     landscape.run()
     self.assertEquals(sysconf.get("http-proxy"), "http://proxy.url")
     self.assertEquals(sysconf.get("https-proxy"), "https://proxy.url")
     self.assertEquals(sysconf.get("ftp-proxy"), "ftp://proxy.url")
Exemple #16
0
def run():
    if (sysconf.get("use-landscape-proxies", False) and
        os.path.isfile(CLIENT_CONF_PATH)):
        parser = ConfigParser()
        parser.read(CLIENT_CONF_PATH)
        for type in "http", "https", "ftp", "no":
            option = "%s_proxy" % type
            if parser.has_option("client", option) and option not in os.environ:
                setting = parser.get("client", option)
                sysconf.set(option.replace("_", "-"), setting, weak=True)
Exemple #17
0
 def test_use_proxies_set_in_landscape(self):
     """
     If enabled, the landscape smart plugin will read the proxies
     set in Landscape.
     """
     sysconf.set("use-landscape-proxies", True)
     landscape.run()
     self.assertEquals(sysconf.get("http-proxy"), "http://proxy.url")
     self.assertEquals(sysconf.get("https-proxy"), "https://proxy.url")
     self.assertEquals(sysconf.get("ftp-proxy"), "ftp://proxy.url")
Exemple #18
0
 def test_rpm_database_detected_with_individual_setting(self):
     self.make_rpm()
     self.make_deb()
     sysconf.set("detect-sys-channels", "rpm")
     self.rerun_plugin()
     self.assertEquals(
         sysconf.get("channels"),
         {"rpm-sys": {
             "type": "rpm-sys",
             "name": "RPM System"
         }})
Exemple #19
0
 def test_arch_database_detected_with_individual_setting(self):
     self.make_rpm()
     self.make_arch()
     sysconf.set("detect-sys-channels", "arch")
     self.rerun_plugin()
     self.assertEquals(
         sysconf.get("channels"),
         {"arch-sys": {
             "type": "arch-sys",
             "name": "Archlinux System"
         }})
 def test_nothing_happens_if_there_are_no_proxy_settings(self):
     """
     The default settings won't be touched if there are no
     proxy options in the client configuration.
     """
     self.write_client_conf(EMPTY_CLIENT_CONF)
     sysconf.set("use-landscape-proxies", True)
     landscape.run()
     self.assertEquals(sysconf.get("http-proxy"), None)
     self.assertEquals(sysconf.get("https-proxy"), None)
     self.assertEquals(sysconf.get("ftp-proxy"), None)
Exemple #21
0
 def test_slack_database_detected_with_individual_setting(self):
     self.make_rpm()
     self.make_slack()
     sysconf.set("detect-sys-channels", "slack")
     self.rerun_plugin()
     self.assertEquals(
         sysconf.get("channels"),
         {"slack-sys": {
             "type": "slack-sys",
             "name": "Slackware System"
         }})
Exemple #22
0
 def test_collapse_libc_requires(self):
     requires1 = (Requires, "libc.so.6(GLIBC_2.3.4)(64bit)", None, None)
     requires2 = (Requires, "libc.so.6(GLIBC_2.2.5)(64bit)", None, None)
     requires3 = (Requires, "libc.so.6()(64bit)", None, None)
     requires = [requires1, requires2, requires3]
     sysconf.set("rpm-collapse-libc-requires", False)
     req = collapse_libc_requires(requires)
     self.assertEquals(req, requires)
     sysconf.set("rpm-collapse-libc-requires", True)
     req = collapse_libc_requires(requires)
     self.assertEquals(req, [requires1])
Exemple #23
0
 def test_nothing_happens_if_there_is_no_section(self):
     """
     The default settings won't be touched if there are no
     proxy options in the client configuration.
     """
     self.write_client_conf("")
     sysconf.set("use-landscape-proxies", True)
     landscape.run()
     self.assertEquals(sysconf.get("http-proxy"), None)
     self.assertEquals(sysconf.get("https-proxy"), None)
     self.assertEquals(sysconf.get("ftp-proxy"), None)
 def test_collapse_libc_requires(self):
     requires1 = (Requires, "libc.so.6(GLIBC_2.3.4)(64bit)", None, None)
     requires2 = (Requires, "libc.so.6(GLIBC_2.2.5)(64bit)", None, None)
     requires3 = (Requires, "libc.so.6()(64bit)", None, None)
     requires = [requires1, requires2, requires3]
     sysconf.set("rpm-collapse-libc-requires", False)
     req = collapse_libc_requires(requires)
     self.assertEquals(req, requires)
     sysconf.set("rpm-collapse-libc-requires", True)
     req = collapse_libc_requires(requires)
     self.assertEquals(req, [requires1])
Exemple #25
0
    def setUp(self):
        self.progress = Progress()
        self.fetcher = Fetcher()
        self.cache = Cache()

        self.download_dir = self.makeDir()
        self.fetcher.setLocalPathPrefix(self.download_dir + "/")

        # Disable caching so that things blow up when not found.
        self.fetcher.setCaching(NEVER)

        sysconf.set("deb-arch", "i386")
 def test_synchronize_config_variables(self):
     release = self.makeFile(RELEASE,
                             dirname=self.config_dir,
                             basename="release")
     sysconf.set("release", release, soft=True)
     filename = self.makeFile(URPMI_CONFIG_VARIABLES,
                              dirname=self.urpmi_dir,
                              basename="urpmi.cfg")
     syncURPMIChannels(filename, self.media_dir)
     self.assertEquals(
         sysconf.get("channels")["urpmisync-Variables"]["mirrorurl"],
         "2010.1/x86_64")
 def test_synchronize_config_mirrorlist(self):
     product_id = self.makeFile(PRODUCT_ID,
                                dirname=self.config_dir,
                                basename="product.id")
     sysconf.set("product-id", product_id, soft=True)
     filename = self.makeFile(URPMI_CONFIG_MIRRORLIST,
                              dirname=self.urpmi_dir,
                              basename="urpmi.cfg")
     syncURPMIChannels(filename, self.media_dir)
     self.assertEquals(
         sysconf.get("channels")["urpmisync-MirrorList"]["mirrorurl"],
         "http://api.mandriva.com/mirrors/base.2010.1.x86_64.list")
Exemple #28
0
    def setUp(self):
        self.progress = Progress()
        self.fetcher = Fetcher()
        self.cache = Cache()

        self.download_dir = self.makeDir()
        self.fetcher.setLocalPathPrefix(self.download_dir + "/")

        # Disable caching so that things blow up when not found.
        self.fetcher.setCaching(NEVER)

        sysconf.set("deb-arch", "i386")
        self.trustdb = open("%s/aptdeb/trustdb.gpg" % TESTDATADIR).read()
    def setUp(self):
        self.progress = Progress()
        self.fetcher = Fetcher()
        self.cache = Cache()

        self.download_dir = self.makeDir()
        self.fetcher.setLocalPathPrefix(self.download_dir + "/")

        # Disable caching so that things blow up when not found.
        self.fetcher.setCaching(NEVER)

        sysconf.set("deb-arch", "i386")
        self.trustdb = open("%s/aptdeb/trustdb.gpg" % TESTDATADIR).read()
Exemple #30
0
    def setUp(self):
        self.progress = Progress()
        self.fetcher = Fetcher()
        self.cache = Cache()

        self.download_dir = self.makeDir()
        self.fetcher.setLocalPathPrefix(self.download_dir + "/")

        # Disable caching so that things blow up when not found.
        self.fetcher.setCaching(NEVER)

        # Make sure to trigger old bugs in debug error reporting.
        sysconf.set("log-level", DEBUG)
    def setUp(self):
        self.progress = Progress()
        self.fetcher = Fetcher()
        self.cache = Cache()

        self.download_dir = self.makeDir()
        self.fetcher.setLocalPathPrefix(self.download_dir + "/")

        # Disable caching so that things blow up when not found.
        self.fetcher.setCaching(NEVER)

        # Make sure to trigger old bugs in debug error reporting.
        sysconf.set("log-level", DEBUG)
 def test_preserves_unrelated_changes(self):
     filename = self.makeFile(SOURCES_LIST_1, dirname=self.apt_dir,
                              basename="sources.list")
     syncAptChannels(filename, self.sources_dir)
     channel_key = "aptsync-1cd42dbb12232a2e2582ad0145fd0516"
     sysconf.set(("channels", channel_key, "disabled"), True)
     syncAptChannels(filename, self.sources_dir)
     self.assertEquals(sysconf.get(("channels", channel_key)),
                       {"distribution": "distro/name1",
                        "type": "apt-deb",
                        "name": "distro/name1 - comp1 comp2",
                        "components": "comp1 comp2",
                        "baseurl": "http://some/url/",
                        "disabled": True})
Exemple #33
0
 def test_preserves_unrelated_changes(self):
     filename = self.makeFile(SOURCES_LIST_1, dirname=self.apt_dir,
                              basename="sources.list")
     syncAptChannels(filename, self.sources_dir)
     channel_key = "aptsync-1cd42dbb12232a2e2582ad0145fd0516"
     sysconf.set(("channels", channel_key, "disabled"), True)
     syncAptChannels(filename, self.sources_dir)
     self.assertEquals(sysconf.get(("channels", channel_key)),
                       {"distribution": "distro/name1",
                        "type": "apt-deb",
                        "name": "distro/name1 - comp1 comp2",
                        "components": "comp1 comp2",
                        "baseurl": "http://some/url/",
                        "disabled": True})
 def test_detect_all_explicitly_enabled_with_true(self):
     self.make_rpm()
     self.make_deb()
     self.make_slack()
     self.make_arch()
     sysconf.set("detect-sys-channels", True)
     self.rerun_plugin()
     self.assertEquals(sysconf.get("channels"),
                       {"rpm-sys":
                        {"type": "rpm-sys", "name": "RPM System"},
                        "deb-sys":
                        {"type": "deb-sys", "name": "DEB System"},
                        "slack-sys":
                        {"type": "slack-sys", "name": "Slackware System"},
                        "arch-sys":
                        {"type": "arch-sys", "name": "Archlinux System"}})
    def test_do_not_override_environment_variable(self):
        """
        If the environment variable is set for some variable, do not
        import the setting from Landscape.
        """
        environ_snapshot = EnvironSnapshot()
        self.addCleanup(environ_snapshot.restore)

        os.environ["http_proxy"] = "http_from_environ"
        os.environ["https_proxy"] = "https_from_environ"
        os.environ["ftp_proxy"] = "ftp_from_environ"

        sysconf.set("use-landscape-proxies", True)
        landscape.run()

        self.assertEquals(sysconf.get("http-proxy"), None)
        self.assertEquals(sysconf.get("https-proxy"), None)
        self.assertEquals(sysconf.get("ftp-proxy"), None)
Exemple #36
0
    def test_do_not_override_environment_variable(self):
        """
        If the environment variable is set for some variable, do not
        import the setting from Landscape.
        """
        environ_snapshot = EnvironSnapshot()
        self.addCleanup(environ_snapshot.restore)
        
        os.environ["http_proxy"] = "http_from_environ"
        os.environ["https_proxy"] = "https_from_environ"
        os.environ["ftp_proxy"] = "ftp_from_environ"

        sysconf.set("use-landscape-proxies", True)
        landscape.run()

        self.assertEquals(sysconf.get("http-proxy"), None)
        self.assertEquals(sysconf.get("https-proxy"), None)
        self.assertEquals(sysconf.get("ftp-proxy"), None)
    def test_ratelimit(self):
        bytes = 30
        rate_limit = 10
        
        sysconf.set("max-download-rate", rate_limit, soft=True)

        def handler(request):
            request.send_header("Content-Length", str(bytes))
            request.wfile.write(" " * bytes)
        
        self.start_server(handler)
        self.fetcher.enqueue(URL)
        start = time.time()
        self.fetcher.run(progress=Progress())
        stop = time.time()
        elapsed_time = stop - start
        
        self.assertTrue(elapsed_time >= bytes / rate_limit)
Exemple #38
0
    def test_ratelimit(self):
        bytes = 30
        rate_limit = 10

        sysconf.set("max-download-rate", rate_limit, soft=True)

        def handler(request):
            request.send_header("Content-Length", str(bytes))
            request.wfile.write(" " * bytes)

        self.start_server(handler)
        self.fetcher.enqueue(URL)
        start = time.time()
        self.fetcher.run(progress=Progress())
        stop = time.time()
        elapsed_time = stop - start

        self.assertTrue(elapsed_time >= bytes / rate_limit)
Exemple #39
0
    def test_commit_outputs_to_iface(self):
        self.assertNotEquals(os.getuid(), 0, "Can't run this test with root.")

        pkg = self.cache.getPackages()[0]
        info = self.loader.getInfo(pkg)

        file_url = info.getURLs()[0]
        self.assertEquals(file_url[:7], "file://")
        file_path = file_url[7:]

        sysconf.set("pm-iface-output", True, soft=True)

        self.pm.commit({pkg: INSTALL}, {pkg: [file_path]})

        self.assertEquals(self.iface.output, [
            "\n[unpack] name1_version1-release1\n"
            "dpkg: requested operation requires superuser privilege\n",
            (1, "Sub-process dpkg returned an error code (2)")
        ])
Exemple #40
0
 def test_keyring_isnt_changed_if_modified(self):
     open(self.keyring_file, "w").close()
     filename = self.makeFile(SOURCES_LIST_2, dirname=self.apt_dir,
                              basename="sources.list")
     syncAptChannels(filename, self.sources_dir)
     sysconf.set(("channels",
                  "aptsync-a3ea5e5aa96019e33241318e7f87a3d1",
                  "keyring"),
                 "/a/different/keyring.gpg")
     syncAptChannels(filename, self.sources_dir)
     self.assertEquals(sysconf.get("channels"),
                       {"aptsync-a3ea5e5aa96019e33241318e7f87a3d1":
                           {"type": "apt-deb",
                            "name": "distro/name3 - comp1 comp2",
                            "distribution": "distro/name3",
                            "components": "comp1 comp2",
                            "baseurl": "http://some/url/",
                            "keyring": "/a/different/keyring.gpg"},
                       })
 def test_wb_rpm_root_path_must_be_absolute(self):
     """
     Somewhat of a weak test.  I haven't managed to make the code
     break when rpm root isn't absolute, so I decided to do a whitebox
     test and verify that at least the fix which is mentioned in
     #307386 is in place.
     """
     current_path = os.getcwd()
     # Using realpath here because if it happens to be a link, the
     # assertion below will fail. (and /tmp is a symlink on Darwin)
     test_path = os.path.realpath(self.makeDir())
     def cleanup():
         os.chdir(current_path)
         sysconf.remove("rpm-root")
     self.addCleanup(cleanup)
     os.chdir(test_path)
     sysconf.set("rpm-root", "relative-rpm-root")
     ts = getTS()
     self.assertEquals(getTS.root, "%s/relative-rpm-root" % test_path)
 def test_keyring_isnt_changed_if_modified(self):
     open(self.keyring_file, "w").close()
     filename = self.makeFile(SOURCES_LIST_2, dirname=self.apt_dir,
                              basename="sources.list")
     syncAptChannels(filename, self.sources_dir)
     sysconf.set(("channels",
                  "aptsync-a3ea5e5aa96019e33241318e7f87a3d1",
                  "keyring"),
                 "/a/different/keyring.gpg")
     syncAptChannels(filename, self.sources_dir)
     self.assertEquals(sysconf.get("channels"),
                       {"aptsync-a3ea5e5aa96019e33241318e7f87a3d1":
                           {"type": "apt-deb",
                            "name": "distro/name3 - comp1 comp2",
                            "distribution": "distro/name3",
                            "components": "comp1 comp2",
                            "baseurl": "http://some/url/",
                            "keyring": "/a/different/keyring.gpg"},
                       })
Exemple #43
0
    def test_wb_rpm_root_path_must_be_absolute(self):
        """
        Somewhat of a weak test.  I haven't managed to make the code
        break when rpm root isn't absolute, so I decided to do a whitebox
        test and verify that at least the fix which is mentioned in
        #307386 is in place.
        """
        current_path = os.getcwd()
        # Using realpath here because if it happens to be a link, the
        # assertion below will fail. (and /tmp is a symlink on Darwin)
        test_path = os.path.realpath(self.makeDir())

        def cleanup():
            os.chdir(current_path)
            sysconf.remove("rpm-root")

        self.addCleanup(cleanup)
        os.chdir(test_path)
        sysconf.set("rpm-root", "relative-rpm-root")
        ts = getTS()
        self.assertEquals(getTS.root, "%s/relative-rpm-root" % test_path)
    def test_when_missing_do_not_override_existing_options(self):
        """
        If there are existing settings, they won't be overriden if
        the Landscape client didn't provide any options.
        """
        sysconf.set("http-proxy", "http-url", weak=True)
        sysconf.set("https-proxy", "https-url", weak=True)
        sysconf.set("ftp-proxy", "ftp-url", weak=True)

        self.write_client_conf(EMPTY_CLIENT_CONF)
        sysconf.set("use-landscape-proxies", True)
        landscape.run()

        self.assertEquals(sysconf.get("http-proxy"), "http-url")
        self.assertEquals(sysconf.get("https-proxy"), "https-url")
        self.assertEquals(sysconf.get("ftp-proxy"), "ftp-url")
Exemple #45
0
    def test_when_missing_do_not_override_existing_options(self):
        """
        If there are existing settings, they won't be overriden if
        the Landscape client didn't provide any options.
        """
        sysconf.set("http-proxy", "http-url", weak=True)
        sysconf.set("https-proxy", "https-url", weak=True)
        sysconf.set("ftp-proxy", "ftp-url", weak=True)

        self.write_client_conf(EMPTY_CLIENT_CONF)
        sysconf.set("use-landscape-proxies", True)
        landscape.run()

        self.assertEquals(sysconf.get("http-proxy"), "http-url")
        self.assertEquals(sysconf.get("https-proxy"), "https-url")
        self.assertEquals(sysconf.get("ftp-proxy"), "ftp-url")
    def test_plguin_sets_proxies_as_weak(self):
        """
        Settings are weak in the sysconf, which means that settings
        performed explicitly will have precedence.
        """
        sysconf.set("http-proxy", "http-url")
        sysconf.set("https-proxy", "https-url")
        sysconf.set("ftp-proxy", "ftp-url")

        sysconf.set("use-landscape-proxies", True)
        landscape.run()

        self.assertEquals(sysconf.get("http-proxy"), "http-url")
        self.assertEquals(sysconf.get("https-proxy"), "https-url")
        self.assertEquals(sysconf.get("ftp-proxy"), "ftp-url")

        self.assertEquals(sysconf.get("http-proxy", weak=True), "http://proxy.url")
        self.assertEquals(sysconf.get("https-proxy", weak=True), "https://proxy.url")
        self.assertEquals(sysconf.get("ftp-proxy", weak=True), "ftp://proxy.url")
Exemple #47
0
    def test_plguin_sets_proxies_as_weak(self):
        """
        Settings are weak in the sysconf, which means that settings
        performed explicitly will have precedence.
        """
        sysconf.set("http-proxy", "http-url")
        sysconf.set("https-proxy", "https-url")
        sysconf.set("ftp-proxy", "ftp-url")

        sysconf.set("use-landscape-proxies", True)
        landscape.run()

        self.assertEquals(sysconf.get("http-proxy"), "http-url")
        self.assertEquals(sysconf.get("https-proxy"), "https-url")
        self.assertEquals(sysconf.get("ftp-proxy"), "ftp-url")

        self.assertEquals(sysconf.get("http-proxy", weak=True),
                          "http://proxy.url")
        self.assertEquals(sysconf.get("https-proxy", weak=True),
                          "https://proxy.url")
        self.assertEquals(sysconf.get("ftp-proxy", weak=True),
                          "ftp://proxy.url")
Exemple #48
0
 def test_also_sets_no_proxy_config(self):
     sysconf.set("use-landscape-proxies", True)
     landscape.run()
     self.assertEquals(sysconf.get("no-proxy"), "localdomain")
 def test_rpm_database_not_detected_with_different_config(self):
     self.make_rpm()
     self.rpm_dbpath = "random/path/rpm"
     sysconf.set("rpm-dbpath", self.rpm_dbpath)
     self.rerun_plugin()
     self.assertEquals(sysconf.get("channels"), None)
Exemple #50
0
    def setUp(self):
        self.rpm_root = self.makeDir()
        self.deb_root = self.makeDir()
        self.slack_root = self.makeDir()
        self.arch_root = self.makeDir()

        self.rpm_dbpath = "var/lib/rpm"
        self.deb_admindir = "var/lib/dpkg"
        self.slack_packages_dir = "var/log/packages"
        self.arch_packages_dir = "var/lib/pacman"

        sysconf.set("rpm-root", self.rpm_root)
        sysconf.set("rpm-dbpath", self.rpm_dbpath)
        sysconf.set("deb-root", self.deb_root)
        sysconf.set("deb-admindir", self.deb_admindir)
        sysconf.set("slack-root", self.slack_root)
        sysconf.set("slack-packages-dir", self.slack_packages_dir)
        sysconf.set("arch-root", self.arch_root)
        sysconf.set("arch-packages-dir", self.arch_packages_dir)

        self.old_sysconf = pickle.dumps(sysconf.object)
 def test_also_sets_no_proxy_config(self):
     sysconf.set("use-landscape-proxies", True)
     landscape.run()
     self.assertEquals(sysconf.get("no-proxy"), "localdomain")
Exemple #52
0
 def test_deb_database_not_detected_with_different_config(self):
     self.make_deb()
     self.deb_admindir = "random/path/dpkg"
     sysconf.set("deb-admindir", self.deb_admindir)
     self.rerun_plugin()
     self.assertEquals(sysconf.get("channels"), None)
    def _initSmart(self, command=None, argv=None):
        iutil.mkdirChain(self.smart_dir)
        iutil.mkdirChain(self.wrapper_dir)

        buf = """#!/bin/bash

export PATH="${PATH}"
export D="%s"
export OFFLINE_ROOT="$D"
export IPKG_OFFLINE_ROOT="$D"
export OPKG_OFFLINE_ROOT="$D"
export INTERCEPT_DIR="/"
export NATIVE_ROOT="/"

exec 1>>/tmp/scriptlet.log 2>&1

echo $2 $1/$3 $4
if [ $2 = "/bin/sh" ]; then
  $2 -x $1/$3 $4
else
  $2 $1/$3 $4
fi
if [ $? -ne 0 ]; then
  if [ $4 -eq 1 ]; then
    mkdir -p $1/etc/rpm-postinsts
    num=100
    while [ -e $1/etc/rpm-postinsts/${num}-* ]; do num=$((num + 1)); done
    name=`head -1 $1/$3 | cut -d' ' -f 2`
    echo "#!$2" > $1/etc/rpm-postinsts/${num}-${name}
    echo "# Arg: $4" >> $1/etc/rpm-postinsts/${num}-${name}
    cat $1/$3 >> $1/etc/rpm-postinsts/${num}-${name}
    chmod +x $1/etc/rpm-postinsts/${num}-${name}
  else
    echo "Error: pre/post remove scriptlet failed"
  fi
fi
""" % (self.sysroot)

        fd = open(self.wrapper_dir + "/scriptlet_wrapper", "w")
        fd.write(buf)
        fd.close()
        os.chmod(self.wrapper_dir + "/scriptlet_wrapper", 0755)

        self.smart_ctrl = init(command,
                               argv=argv,
                               datadir=self.smart_dir,
                               configfile=None,
                               gui=False,
                               shell=False,
                               quiet=True,
                               interface=None,
                               forcelocks=False,
                               loglevel=None)

        # Override the dummy interface with the locally defined one
        iface.object = AnacondaInterface(self.smart_ctrl)

        initDistro(self.smart_ctrl)
        initPlugins()
        initPycurl()
        initPsyco()

        sysconf.set("rpm-root", self.sysroot, soft=True)
        sysconf.set("rpm-extra-macros._tmppath", "/install/tmp", soft=True)
        sysconf.set("rpm-extra-macros._cross_scriptlet_wrapper",
                    self.wrapper_dir + "/scriptlet_wrapper",
                    soft=True)
        sysconf.set("rpm-nolinktos", "1")
        sysconf.set("rpm-noparentdirs", "1")

        sysconf.remove("channels")

        self.repo_manager = SmartRepoManager(self.runSmart)
    def setUp(self):
        self.rpm_root = self.makeDir()
        self.deb_root = self.makeDir()
        self.slack_root = self.makeDir()
        self.arch_root = self.makeDir()

        self.rpm_dbpath = "var/lib/rpm"
        self.deb_admindir = "var/lib/dpkg"
        self.slack_packages_dir = "var/log/packages"
        self.arch_packages_dir = "var/lib/pacman"

        sysconf.set("rpm-root", self.rpm_root)
        sysconf.set("rpm-dbpath", self.rpm_dbpath)
        sysconf.set("deb-root", self.deb_root)
        sysconf.set("deb-admindir", self.deb_admindir)
        sysconf.set("slack-root", self.slack_root)
        sysconf.set("slack-packages-dir", self.slack_packages_dir)
        sysconf.set("arch-root", self.arch_root)
        sysconf.set("arch-packages-dir", self.arch_packages_dir)

        self.old_sysconf = pickle.dumps(sysconf.object)
 def test_deb_database_not_detected_with_different_config(self):
     self.make_deb()
     self.deb_admindir = "random/path/dpkg"
     sysconf.set("deb-admindir", self.deb_admindir)
     self.rerun_plugin()
     self.assertEquals(sysconf.get("channels"), None)
Exemple #56
0
 def test_rpm_database_not_detected_with_different_config(self):
     self.make_rpm()
     self.rpm_dbpath = "random/path/rpm"
     sysconf.set("rpm-dbpath", self.rpm_dbpath)
     self.rerun_plugin()
     self.assertEquals(sysconf.get("channels"), None)