def test_get_allowed_origins_with_substitute(self): """ test if substitute for get_allowed_origins works """ apt_pkg.config.clear("Unattended-Upgrade::Allowed-Origins") apt_pkg.config.set("Unattended-Upgrade::Allowed-Origins::", "${distro_id} ${distro_codename}-security") li = get_allowed_origins() self.assertTrue(("o=MyDistroID,a=nacked-security") in li)
def test_escaped_colon(self): apt_pkg.config.clear("Unattended-Upgrade") apt_pkg.read_config_file(apt_pkg.config, "./data/50unattended-upgrades.colon") allowed_origins = unattended_upgrade.get_allowed_origins() self.assertIn('o=http://foo.bar,a=stable', allowed_origins)
def test_get_allowed_origins_with_substitute(self): """ test if substitute for get_allowed_origins works """ apt_pkg.config.clear("Unattended-Upgrade::Allowed-Origins") apt_pkg.config.set("Unattended-Upgrade::Allowed-Origins::", "${distro_id} ${distro_codename}-security") l = get_allowed_origins() self.assertTrue(("o=MyDistroID,a=nacked-security") in l)
def test_escaped_colon(self): apt_pkg.config.clear("Unattended-Upgrade") apt_pkg.read_config_file( apt_pkg.config, "./data/50unattended-upgrades.colon") allowed_origins = unattended_upgrade.get_allowed_origins() self.assertIn('o=http://foo.bar,a=stable', allowed_origins)
def test_match_whitelist_from_conffile(self): # read some apt_pkg.config.clear("Unattended-Upgrade") apt_pkg.read_config_file(apt_pkg.config, "./data/50unattended-upgrades.Test") allowed_origins = unattended_upgrade.get_allowed_origins() #print allowed_origins self.assertTrue("o=aOrigin,a=aArchive" in allowed_origins) self.assertTrue("s=aSite,l=aLabel" in allowed_origins) self.assertTrue("o=Google\, Inc.,suite=stable" in allowed_origins)
def test_compatiblity(self): apt_pkg.config.clear("Unattended-Upgrade") apt_pkg.read_config_file(apt_pkg.config, "./data/50unattended-upgrades.compat") allowed_origins = unattended_upgrade.get_allowed_origins() #print allowed_origins self.assertTrue("o=Google\, Inc.,a=stable" in allowed_origins) self.assertTrue("o=MoreCorp\, eink,a=stable" in allowed_origins) # test whitelist pkg = self._get_mock_package() self.assertTrue(is_allowed_origin(pkg.candidate, allowed_origins))
def test_remove_valid(self): allowed_origins = unattended_upgrade.get_allowed_origins() cache = unattended_upgrade.UnattendedUpgradesCache( rootdir=self.rootdir, allowed_origins=allowed_origins) auto_removable = unattended_upgrade.get_auto_removable(cache) print(auto_removable) cache["old-unused-dependency"].mark_delete() res = unattended_upgrade.is_autoremove_valid( cache, "test-package-dependency", auto_removable, [], []) self.assertTrue(res, "Simple autoremoval set is not valid") res = unattended_upgrade.is_autoremove_valid( cache, "test-package-dependency", set(), [], []) self.assertFalse(res, "Autoremoving non-autoremovable package") cache["forbidden-dependency"].mark_install() auto_removable.add("forbidden-dependency") res = unattended_upgrade.is_autoremove_valid( cache, "test-package-dependency", auto_removable, [], []) self.assertFalse(res, "Package set to reinstall in cache is reinstalled")