Просмотр исходного кода

add APT::Update::Auth-Failure script

Michael Vogt лет назад: 18
Родитель
Сommit
5d149bfc7f
2 измененных файлов с 14 добавлено и 5 удалено
  1. 1 0
      apt-pkg/acquire-item.cc
  2. 13 5
      test/pre-upload-check.py

+ 1 - 0
apt-pkg/acquire-item.cc

@@ -1179,6 +1179,7 @@ void pkgAcqMetaIndex::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
 			   "GPG error: %s: %s\n"),
 			   "GPG error: %s: %s\n"),
 			 Desc.Description.c_str(),
 			 Desc.Description.c_str(),
 			 LookupTag(Message,"Message").c_str());
 			 LookupTag(Message,"Message").c_str());
+	 RunScripts("APT::Update::Auth-Failure");
 	 return;
 	 return;
       } else {
       } else {
 	 _error->Warning(_("GPG error: %s: %s"),
 	 _error->Warning(_("GPG error: %s: %s"),

+ 13 - 5
test/pre-upload-check.py

@@ -25,7 +25,8 @@ class testAptAuthenticationReliability(unittest.TestCase):
     apt = "apt-get"
     apt = "apt-get"
 
 
     def setUp(self):
     def setUp(self):
-        pass
+        if os.path.exists("/tmp/autFailure"):
+            os.unlink("/tmp/authFailure");
     def testRepositorySigFailure(self):
     def testRepositorySigFailure(self):
         """
         """
         test if a repository that used to be authenticated and fails on
         test if a repository that used to be authenticated and fails on
@@ -39,26 +40,33 @@ class testAptAuthenticationReliability(unittest.TestCase):
             os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (0,0))
             os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (0,0))
         res = call([self.apt,
         res = call([self.apt,
                     "update",
                     "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,
                    ] + apt_args,
                    stdout=stdout, stderr=stderr)
                    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"),
         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")
                      "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"),
         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")
                      "The Packages file disappeared, this should not happen")
+        self.assert_(os.path.exists("/tmp/authFailure"),
+                     "The APT::Update::Auth-Failure script did not run")
+        os.unlink("/tmp/authFailure");
         # the same with i-m-s hit this time
         # the same with i-m-s hit this time
         for f in glob.glob("./authReliability/lists/*"):
         for f in glob.glob("./authReliability/lists/*"):
             shutil.copy(f,"/var/lib/apt/lists")
             shutil.copy(f,"/var/lib/apt/lists")
             os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (time.time(),time.time()))
             os.utime("/var/lib/apt/lists/%s" % os.path.basename(f), (time.time(),time.time()))
         res = call([self.apt,
         res = call([self.apt,
                     "update",
                     "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,
                    ] + apt_args,
                    stdout=stdout, stderr=stderr)
                    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"),
         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")
                      "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"),
         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")
                      "The Packages file disappeared, this should not happen")
+        self.assert_(os.path.exists("/tmp/authFailure"),
+                     "The APT::Update::Auth-Failure script did not run")
     def testRepositorySigGood(self):
     def testRepositorySigGood(self):
         """
         """
         test that a regular repository with good data stays good
         test that a regular repository with good data stays good
@@ -239,5 +247,5 @@ if __name__ == "__main__":
         stderr = sys.stderr
         stderr = sys.stderr
     
     
     # run only one for now
     # run only one for now
-    #unittest.main(defaultTest="testAptAuthenticationReliability")
-    unittest.main()
+    unittest.main(defaultTest="testAptAuthenticationReliability")
+    #unittest.main()