def test_blacklist(self):
     # mock pkg (yeah, complicated)
     pkg = self._get_mock_package()
     # mock cache
     cache = MockCache()
     cache._depcache = MockDepCache()
     cache._depcache.broken_count = 0
     cache.append(pkg)
     # origins and blacklist
     allowed_origins = ["o=Ubuntu"]
     blacklist = ["linux-.*"]
     # with blacklist pkg
     self.assertFalse(check_changes_for_sanity(cache, allowed_origins, blacklist))
     # with "normal" pkg
     pkg.name = "apt"
     self.assertTrue(check_changes_for_sanity(cache, allowed_origins, blacklist))   
 def test_blacklist(self):
     # get the mocks
     pkg = self._get_mock_package("linux-image")
     cache = self._get_mock_cache()
     cache[pkg.name] = pkg
     # origins and blacklist
     allowed_origins = ["o=Ubuntu"]
     blacklist = ["linux-.*"]
     # with blacklist pkg
     self.assertFalse(
         check_changes_for_sanity(
             cache, allowed_origins, blacklist, [".*"]))
     # with "normal" pkg
     pkg.name = "apt"
     self.assertTrue(
         check_changes_for_sanity(
             cache, allowed_origins, blacklist, [".*"]))
Exemple #3
0
 def test_blacklist(self):
     # mock pkg (yeah, complicated)
     pkg = self._get_mock_package()
     # mock cache
     cache = MockCache()
     cache._depcache = MockDepCache()
     cache._depcache.broken_count = 0
     cache.append(pkg)
     # origins and blacklist
     allowed_origins = ["o=Ubuntu"]
     blacklist = ["linux-.*"]
     # with blacklist pkg
     self.assertFalse(
         check_changes_for_sanity(cache, allowed_origins, blacklist))
     # with "normal" pkg
     pkg.name = "apt"
     self.assertTrue(
         check_changes_for_sanity(cache, allowed_origins, blacklist))
 def test_whitelist_with_strict_whitelisting(self):
     cache = self._get_mock_cache()
     for pkgname in ["not-whitelisted", "whitelisted"]:
         pkg = self._get_mock_package(name=pkgname)
         cache[pkg.name] = pkg
     # origins and blacklist
     allowed_origins = ["o=Ubuntu"]
     whitelist = ["whitelisted"]
     # test with strict whitelist
     apt_pkg.config.set(
         "Unattended-Upgrade::Package-Whitelist-Strict", "true")
     # ensure that a not-whitelisted pkg will fail
     self.assertTrue(cache["not-whitelisted"].marked_upgrade)
     self.assertFalse(
         check_changes_for_sanity(cache, allowed_origins, [], whitelist))