]> git.saurik.com Git - apt.git/blobdiff - test/pre-upload-check.py
* cmdline/apt-cache.cc:
[apt.git] / test / pre-upload-check.py
index 75a726808e6a9c1d647af8f4a9bc9e6213e177a5..97a0ec4c4c274929dc4f603b79642c20ab1bc912 100755 (executable)
@@ -21,10 +21,14 @@ class testAptAuthenticationReliability(unittest.TestCase):
     test if the spec https://wiki.ubuntu.com/AptAuthenticationReliability 
     is properly implemented
     """
-    apt = "../bin/apt-get"
+    #apt = "../bin/apt-get"
+    apt = "apt-get"
 
     def setUp(self):
-        pass
+        if os.path.exists("/tmp/autFailure"):
+            os.unlink("/tmp/authFailure");
+        if os.path.exists("/tmp/autFailure2"):
+            os.unlink("/tmp/authFailure2");
     def testRepositorySigFailure(self):
         """
         test if a repository that used to be authenticated and fails on
@@ -38,26 +42,32 @@ class testAptAuthenticationReliability(unittest.TestCase):
             os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (0,0))
         res = call([self.apt,
                     "update",
-                    "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure"
+                    "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure", 
+                    "-o",'APT::Update::Auth-Failure::=touch /tmp/authFailure',
                    ] + apt_args,
                    stdout=stdout, stderr=stderr)
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"),
                      "The gpg file disappeared, this should not happen")
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"),
                      "The Packages file disappeared, this should not happen")
+        self.assert_(os.path.exists("/tmp/authFailure"),
+                     "The APT::Update::Auth-Failure script did not run (1)")
         # the same with i-m-s hit this time
         for f in glob.glob("./authReliability/lists/*"):
             shutil.copy(f,"/var/lib/apt/lists")
             os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (time.time(),time.time()))
         res = call([self.apt,
                     "update",
-                    "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure"
+                    "-o","Dir::Etc::sourcelist=./authReliability/sources.list.failure",
+                    "-o",'APT::Update::Auth-Failure::=touch /tmp/authFailure2',
                    ] + apt_args,
                    stdout=stdout, stderr=stderr)
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Release.gpg"),
                      "The gpg file disappeared, this should not happen")
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-broken_Packages"),
                      "The Packages file disappeared, this should not happen")
+        self.assert_(os.path.exists("/tmp/authFailure2"),
+                     "The APT::Update::Auth-Failure script did not run (2)")
     def testRepositorySigGood(self):
         """
         test that a regular repository with good data stays good
@@ -68,7 +78,7 @@ class testAptAuthenticationReliability(unittest.TestCase):
                    ] + apt_args,
                    stdout=stdout, stderr=stderr)
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg"),
-                     "The gpg file disappeared, this should not happen")
+                     "The gpg file disappeared after a regular download, this should not happen")
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages"),
                      "The Packages file disappeared, this should not happen")
         # test good is still good after non I-M-S hit and a previous files in lists/
@@ -82,7 +92,7 @@ class testAptAuthenticationReliability(unittest.TestCase):
                    ] + apt_args,
                    stdout=stdout, stderr=stderr)
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Release.gpg"),
-                     "The gpg file disappeared, this should not happen")
+                     "The gpg file disappeared after a I-M-S hit, this should not happen")
         self.assert_(os.path.exists("/var/lib/apt/lists/people.ubuntu.com_%7emvo_apt_auth-test-suit_gpg-package-ok_Packages"),
                      "The Packages file disappeared, this should not happen")
         # test good is still good after I-M-S hit