Exemplo n.º 1
0
 def test_check_matching_sign_url(self):
     with tempfile.TemporaryDirectory() as tmpd:
         shutil.copy(os.path.join(TESTKEYDIR, "023A4420C7EC6914.pkey"),
                     tmpd)
         pkg_integrity.download_file(PACKAGE_URL, tmpd)
         result = pkg_integrity.check(PACKAGE_URL, tmpd)
         self.assertTrue(result)
Exemplo n.º 2
0
 def test_from_disk(self):
     with tempfile.TemporaryDirectory() as tmpd:
         shutil.copy(os.path.join(TESTKEYDIR, "023A4420C7EC6914.pkey"),
                     tmpd)
         out_file = os.path.join(tmpd, os.path.basename(PACKAGE_URL))
         out_key = out_file + ".asc"
         pkg_integrity.download_file(PACKAGE_URL, tmpd)
         pkg_integrity.download_file(PACKAGE_URL + ".asc", tmpd)
         result = pkg_integrity.from_disk(PACKAGE_URL, out_file, out_key)
         self.assertTrue(result)
Exemplo n.º 3
0
 def test_check_with_existing_sign(self):
     """ Download signature for local verification """
     with tempfile.TemporaryDirectory() as tmpd:
         shutil.copy(os.path.join(TESTKEYDIR, "6FE57CA8C1A4AEA6.pkey"),
                     tmpd)
         pkg_integrity.download_file(NOSIGN_PKT_URL, tmpd)
         sign_file = os.path.join(tmpd,
                                  os.path.basename(NOSIGN_PKT_URL) + ".asc")
         pkg_integrity.download_file(NOSIGN_SIGN_URL, sign_file)
         result = pkg_integrity.check(NOSIGN_PKT_URL, tmpd)
         self.assertTrue(result)
Exemplo n.º 4
0
 def test_check_quit(self):
     with tempfile.TemporaryDirectory() as tmpd:
         with self.assertRaises(SystemExit) as a:
             shutil.copy(os.path.join(TESTKEYDIR, "6FE57CA8C1A4AEA6.pkey"),
                         tmpd)
             pkg_integrity.download_file(NOSIGN_PKT_URL_BAD, tmpd)
             sign_file = os.path.join(
                 tmpd,
                 os.path.basename(NOSIGN_PKT_URL_BAD) + ".asc")
             pkg_integrity.download_file(NOSIGN_SIGN_URL, sign_file)
             result = pkg_integrity.check(NOSIGN_PKT_URL_BAD, tmpd)
             self.assertEqual(a.exception.code, 1)
Exemplo n.º 5
0
 def run_test_for_domain(self, Verifier, url):
     with tempfile.TemporaryDirectory() as tmpd:
         package_path = pkg_integrity.download_file(url, tmpd)
         verifier = Verifier(**{'package_path': package_path, 'url': url})
         return verifier.verify()
     return None
Exemplo n.º 6
0
 def test_result_on_nosign_package(self):
     with tempfile.TemporaryDirectory() as tmpd:
         pkg_integrity.download_file(NO_SIGN_PKT_URL, tmpd)
         result = pkg_integrity.check(NO_SIGN_PKT_URL, tmpd)
         self.assertIsNone(result)
Exemplo n.º 7
0
 def test_from_url(self):
     with tempfile.TemporaryDirectory() as tmpd:
         pkg_integrity.download_file(GEM_PKT, tmpd)
         result = pkg_integrity.check(GEM_PKT, tmpd)
         self.assertTrue(result)