def test_audit_matching_md5sums(self): with self.run_in_subprocess("click_get_frameworks_dir") as (enter, preloads): enter() data_path = os.path.join(self.temp_dir, "foo") with mkfile(data_path) as data: print("test", file=data) with open(data_path, "rb") as data: data_md5sum = hashlib.md5(data.read()).hexdigest() path = self.make_fake_package( control_fields={"Click-Version": "0.2"}, manifest={ "name": "test-package", "version": "1.0", "framework": "ubuntu-sdk-13.10", }, control_scripts={ "preinst": static_preinst, "md5sums": "%s foo" % data_md5sum, }, data_files={"foo": data_path}) self._setup_frameworks(preloads, frameworks=["ubuntu-sdk-13.10"]) with mock_quiet_subprocess_call(): installer = ClickInstaller(self.db) self.assertEqual(("test-package", "1.0"), installer.audit(path, slow=True))
def test_audit_multiple_frameworks(self): with self.run_in_subprocess("click_get_frameworks_dir") as (enter, preloads): enter() path = self.make_fake_package( control_fields={"Click-Version": "0.4"}, manifest={ "name": "test-package", "version": "1.0", "framework": "ubuntu-sdk-14.04-basic, ubuntu-sdk-14.04-webapps", }, control_scripts={"preinst": static_preinst}) installer = ClickInstaller(self.db) self._setup_frameworks(preloads, frameworks=["dummy"]) self.assertRaisesRegex( ClickInstallerAuditError, 'Frameworks "ubuntu-sdk-14.04-basic", ' '"ubuntu-sdk-14.04-webapps" not present on system.*', installer.audit, path) self._setup_frameworks( preloads, frameworks=["dummy", "ubuntu-sdk-14.04-basic"]) self.assertRaisesRegex( ClickInstallerAuditError, 'Framework "ubuntu-sdk-14.04-webapps" not present on ' 'system.*', installer.audit, path) self._setup_frameworks(preloads, frameworks=[ "dummy", "ubuntu-sdk-14.04-basic", "ubuntu-sdk-14.04-webapps", ]) self.assertEqual(("test-package", "1.0"), installer.audit(path))
def run(argv): parser = OptionParser("%prog verify [options] PACKAGE-FILE") parser.add_option("--force-missing-framework", action="store_true", default=False, help="ignore missing system framework") parser.add_option("--allow-unauthenticated", action="store_true", default=False, help="allow installing packages with no sigantures") options, args = parser.parse_args(argv) if len(args) < 1: parser.error("need package file name") package_path = args[0] installer = ClickInstaller( db=None, force_missing_framework=options.force_missing_framework, allow_unauthenticated=options.allow_unauthenticated) installer.audit(package_path, slow=True) return 0
def test_audit_passes_correct_package(self): with self.run_in_subprocess("click_get_frameworks_dir") as (enter, preloads): enter() path = self.make_fake_package( control_fields={"Click-Version": "0.2"}, manifest={ "name": "test-package", "version": "1.0", "framework": "ubuntu-sdk-13.10", }, control_scripts={"preinst": static_preinst}) self._setup_frameworks(preloads, frameworks=["ubuntu-sdk-13.10"]) installer = ClickInstaller(self.db) self.assertEqual(("test-package", "1.0"), installer.audit(path))