def test_fetch_with_component(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "./",
                              "components": "component"})
     self.check_channel(channel)
Beispiel #2
0
 def test_fetch_with_component(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "./",
                              "components": "component"})
     self.check_channel(channel)
 def test_fetch_with_good_signature_without_fingerprint_and_component(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "component-less",
                              "keyring": "%s/aptdeb/trusted.gpg" %
                                         TESTDATADIR})
     self.check_channel(channel)
Beispiel #4
0
 def test_fetch_with_good_signature_without_fingerprint_and_component(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "component-less",
                              "keyring": "%s/aptdeb/trusted.gpg" %
                                         TESTDATADIR})
     self.check_channel(channel)
Beispiel #5
0
 def test_fetch_without_component_and_release_file(self):
     channel = createChannel(
         "alias", {
             "type": "apt-deb",
             "baseurl": "file://%s/deb" % TESTDATADIR,
             "distribution": "./"
         })
     self.check_channel(channel)
Beispiel #6
0
 def test_fetch_with_good_signature(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "./",
                              "fingerprint": FINGERPRINT,
                              "keyring": "%s/aptdeb/trusted.gpg" %
                                         TESTDATADIR,
                              "components": "component"})
     self.check_channel(channel)
 def test_fetch_with_good_signature(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "./",
                              "fingerprint": FINGERPRINT,
                              "keyring": "%s/aptdeb/trusted.gpg" %
                                         TESTDATADIR,
                              "components": "component"})
     self.check_channel(channel)
 def test_fetch_with_broken_metalink(self):
     channel = createChannel("alias",
                             {"type": "rpm-md",
                              "baseurl": "file://%s/yumrpm" % TESTDATADIR,
                              "mirrorlist": "file://%s/yumrpm/metalink-broken.xml" % TESTDATADIR})
     try:
          self.check_channel(channel)
     except AttributeError, error:
          # AttributeError: 'ExpatError' object has no attribute 'split'
          self.fail(error)
 def test_fetch_with_unknown_signature_without_fingerprint_and_compon(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "component-less",
                              "keyring": "%s/aptdeb/nonexistent.gpg" %
                                         TESTDATADIR})
     try:
         self.check_channel(channel)
     except Error, error:
         self.assertEquals(str(error),
                           "Channel 'alias' signed with unknown key")
Beispiel #10
0
 def test_fetch_with_missing_keyring_without_component(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "component-less",
                              "fingerprint": "NON-EXISTENT-FINGERPRINT",
                              "keyring": "/dev/null"})
     try:
         self.check_channel(channel)
     except Error, error:
         self.assertEquals(str(error),
                           "Channel 'alias' signed with unknown key")
Beispiel #11
0
 def test_fetch_without_component_and_release_file_with_keyring(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/deb" % TESTDATADIR,
                              "distribution": "./",
                              "keyring": "/dev/null"})
     try:
         self.check_channel(channel)
     except Error, error:
         self.assertEquals(str(error),
                           "Download of Release failed for channel 'alias': "
                           "File not found for validation")
 def test_fetch_without_component_and_release_file_with_keyring(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/deb" % TESTDATADIR,
                              "distribution": "./",
                              "keyring": "/dev/null"})
     try:
         self.check_channel(channel)
     except Error, error:
         self.assertEquals(str(error),
                           "Download of Release failed for channel 'alias': "
                           "File not found for validation")
 def test_fetch_with_missing_keyring_without_component(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "component-less",
                              "fingerprint": "NON-EXISTENT-FINGERPRINT",
                              "keyring": "/dev/null"})
     try:
         self.check_channel(channel)
     except Error, error:
         self.assertEquals(str(error),
                           "Channel 'alias' signed with unknown key")
Beispiel #14
0
 def test_fetch_with_unknown_signature_without_fingerprint_and_compon(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "component-less",
                              "keyring": "%s/aptdeb/nonexistent.gpg" %
                                         TESTDATADIR})
     try:
         self.check_channel(channel)
     except Error, error:
         self.assertEquals(str(error),
                           "Channel 'alias' signed with unknown key")
Beispiel #15
0
    def test_fetch_with_component_missing_in_release_file(self):
        iface_mock = self.mocker.patch(iface.object)
        iface_mock.warning("Component 'non-existent' is not in Release file "
                           "for channel 'alias'")
        self.mocker.replay()

        channel = createChannel("alias",
                                {"type": "apt-deb",
                                 "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                                 "distribution": "./",
                                 "components": "non-existent"})

        self.assertEquals(channel.fetch(self.fetcher, self.progress), True)
Beispiel #16
0
 def test_fetch_with_broken_metalink(self):
     channel = createChannel(
         "alias", {
             "type": "rpm-md",
             "baseurl": "file://%s/yumrpm" % TESTDATADIR,
             "mirrorlist":
             "file://%s/yumrpm/metalink-broken.xml" % TESTDATADIR
         })
     try:
         self.check_channel(channel)
     except AttributeError, error:
         # AttributeError: 'ExpatError' object has no attribute 'split'
         self.fail(error)
    def test_fetch_with_component_missing_in_release_file(self):
        iface_mock = self.mocker.patch(iface.object)
        iface_mock.warning("Component 'non-existent' is not in Release file "
                           "for channel 'alias'")
        self.mocker.replay()

        channel = createChannel("alias",
                                {"type": "apt-deb",
                                 "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                                 "distribution": "./",
                                 "components": "non-existent"})

        self.assertEquals(channel.fetch(self.fetcher, self.progress), True)
 def test_fetch_with_unknown_signature(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "./",
                              "fingerprint": "NON-EXISTENT-FINGERPRINT",
                              "keyring": "%s/aptdeb/trusted.gpg" %
                                         TESTDATADIR,
                              "components": "component"})
     try:
         self.check_channel(channel)
     except Error, error:
         self.assertEquals(str(error),
                           "Channel 'alias' signed with unknown key")
Beispiel #19
0
 def test_fetch_with_unknown_signature(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "./",
                              "fingerprint": "NON-EXISTENT-FINGERPRINT",
                              "keyring": "%s/aptdeb/trusted.gpg" %
                                         TESTDATADIR,
                              "components": "component"})
     try:
         self.check_channel(channel)
     except Error, error:
         self.assertEquals(str(error),
                           "Channel 'alias' signed with unknown key")
Beispiel #20
0
 def test_fetch_with_good_signature_but_no_home(self):
     os.putenv("GNUPGHOME", "/no/such/dir")
     channel = createChannel(
         "alias", {
             "type": "apt-deb",
             "baseurl": "file://%s/aptdeb" % TESTDATADIR,
             "distribution": "./",
             "fingerprint": FINGERPRINT,
             "keyring": "%s/aptdeb/trusted.gpg" % TESTDATADIR,
             "trustdb": "%s/aptdeb/trustdb.gpg" % TESTDATADIR,
             "components": "component"
         })
     try:
         self.check_channel(channel)
     finally:
         os.unsetenv("GNUPGHOME")
Beispiel #21
0
 def test_fetch_without_component_with_corrupted_packages_file_size(self):
     repo_dir = self.makeDir()
     shutil.copytree(TESTDATADIR + "/aptdeb", repo_dir + "/aptdeb")
     path = os.path.join(repo_dir, "aptdeb/component-less/Packages.gz")
     file = open(path, "a")
     file.write(" ")
     file.close()
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % repo_dir,
                              "distribution": "component-less"})
     try:
         self.check_channel(channel)
     except Error, error:
         error_message = "Unexpected size (expected 571, got 572)"
         self.assertTrue(str(error).endswith(error_message), str(error))
 def test_fetch_without_component_with_corrupted_packages_file_size(self):
     repo_dir = self.makeDir()
     shutil.copytree(TESTDATADIR + "/aptdeb", repo_dir + "/aptdeb")
     path = os.path.join(repo_dir, "aptdeb/component-less/Packages.gz")
     file = open(path, "a")
     file.write(" ")
     file.close()
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % repo_dir,
                              "distribution": "component-less"})
     try:
         self.check_channel(channel)
     except Error, error:
         error_message = "Unexpected size (expected 571, got 572)"
         self.assertTrue(str(error).endswith(error_message), str(error))
 def test_fetch_with_good_signature_but_no_home(self):
     os.putenv("GNUPGHOME", "/no/such/dir")
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % TESTDATADIR,
                              "distribution": "./",
                              "fingerprint": FINGERPRINT,
                              "keyring": "%s/aptdeb/trusted.gpg" %
                                         TESTDATADIR,
                              "trustdb": "%s/aptdeb/trustdb.gpg" %
                                         TESTDATADIR,
                              "components": "component"})
     try:
          self.check_channel(channel)
     finally:
          os.unsetenv("GNUPGHOME")
 def test_fetch_with_broken_mirrorlist(self):
     def fail_open(filename, mode='r', bufsize=-1):
          raise IOError("emulating a broken mirrorlist...")
     old_open = __builtin__.open
     __builtin__.open = fail_open
     channel = createChannel("alias",
                             {"type": "rpm-md",
                              "baseurl": "file://%s/yumrpm" % TESTDATADIR,
                              "mirrorlist": "file://%s/yumrpm/mirrorlist-broken.txt" % TESTDATADIR})
     try:
         try:
             self.check_channel(channel)
         except AttributeError, error:
             # AttributeError: 'exceptions.IOError' object has no attribute 'split'
             self.fail(error)
         except IOError:
             pass
Beispiel #25
0
    def setUp(self):
        self.channel = createChannel(
            "alias", {
                "type": "apt-deb",
                "baseurl": "file://%s/deb" % TESTDATADIR,
                "distribution": "./"
            })

        class TestInterface(Interface):
            output = []

            def message(self, level, msg):
                self.output.append((level, msg))

            def showOutput(self, data):
                self.output.append(data)

        self.iface = TestInterface(ctrl)

        self.progress = Progress()
        self.fetcher = Fetcher()
        self.cache = Cache()

        self.channel.fetch(self.fetcher, self.progress)
        self.loader = self.channel.getLoaders()[0]
        self.cache.addLoader(self.loader)

        self.old_iface = iface.object
        self.old_sysconf = pickle.dumps(sysconf.object)

        iface.object = self.iface

        self.cache.load()

        self.pm = DebPackageManager()

        # skip test if dpkg is unavailable
        dpkg = sysconf.get("dpkg", "dpkg")
        output = tempfile.TemporaryFile()
        status = self.pm.dpkg([dpkg, "--version"], output)
        if not os.WIFEXITED(status) or os.WEXITSTATUS(status) != 0:
            if not hasattr(self, 'skipTest'):  # Python < 2.7
                self.skipTest = self.fail  # error
            self.skipTest("%s not found" % dpkg)
 def test_fetch_without_component_with_corrupted_packages_file_md5(self):
     repo_dir = self.makeDir()
     shutil.copytree(TESTDATADIR + "/aptdeb", repo_dir + "/aptdeb")
     path = os.path.join(repo_dir, "aptdeb/component-less/Packages.gz")
     file = open(path, "r+")
     file.seek(0)
     file.write(" ")
     file.close()
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % repo_dir,
                              "distribution": "component-less"})
     try:
         self.check_channel(channel)
     except Error, error:
         error_message =  ("Invalid MD5 "
                           "(expected 384ccb05e3f6da02312b6e383b211777,"
                           " got 6a2857275a35bf2b79e480e653431f83)")
         self.assertTrue(str(error).endswith(error_message), str(error))
Beispiel #27
0
 def test_fetch_without_component_with_corrupted_packages_file_md5(self):
     repo_dir = self.makeDir()
     shutil.copytree(TESTDATADIR + "/aptdeb", repo_dir + "/aptdeb")
     path = os.path.join(repo_dir, "aptdeb/component-less/Packages.gz")
     file = open(path, "r+")
     file.seek(0)
     file.write(" ")
     file.close()
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/aptdeb" % repo_dir,
                              "distribution": "component-less"})
     try:
         self.check_channel(channel)
     except Error, error:
         error_message =  ("Invalid MD5 "
                           "(expected 384ccb05e3f6da02312b6e383b211777,"
                           " got 6a2857275a35bf2b79e480e653431f83)")
         self.assertTrue(str(error).endswith(error_message), str(error))
Beispiel #28
0
    def test_fetch_with_broken_mirrorlist(self):
        def fail_open(filename, mode='r', bufsize=-1):
            raise IOError("emulating a broken mirrorlist...")

        old_open = __builtin__.open
        __builtin__.open = fail_open
        channel = createChannel(
            "alias", {
                "type":
                "rpm-md",
                "baseurl":
                "file://%s/yumrpm" % TESTDATADIR,
                "mirrorlist":
                "file://%s/yumrpm/mirrorlist-broken.txt" % TESTDATADIR
            })
        try:
            try:
                self.check_channel(channel)
            except AttributeError, error:
                # AttributeError: 'exceptions.IOError' object has no attribute 'split'
                self.fail(error)
            except IOError:
                pass
Beispiel #29
0
 def test_fetch(self):
     channel = createChannel("alias", {
         "type": "rpm-md",
         "baseurl": "file://%s/yumrpm" % TESTDATADIR
     })
     self.check_channel(channel)
 def test_fetch_without_component_and_release_file(self):
     channel = createChannel("alias",
                             {"type": "apt-deb",
                              "baseurl": "file://%s/deb" % TESTDATADIR,
                              "distribution": "./"})
     self.check_channel(channel)
 def test_fetch(self):
     channel = createChannel("alias",
                             {"type": "rpm-md",
                              "baseurl": "file://%s/yumrpm" % TESTDATADIR})
     self.check_channel(channel)