Esempio n. 1
0
 def test_check_no_matching_sign_url(self):
     """ Test a package that does not have simple signature pattern """
     with tempfile.TemporaryDirectory() as tmpd:
         out_file = os.path.join(tmpd, os.path.basename(NOSIGN_PKT_URL))
         attempt_to_download(NOSIGN_PKT_URL, out_file)
         result = check(NOSIGN_PKT_URL, tmpd)
         self.assertEqual(result, None)
Esempio n. 2
0
 def test_from_disk(self):
     with tempfile.TemporaryDirectory() as tmpd:
         out_file = os.path.join(tmpd, os.path.basename(ALEMBIC_PKT_URL))
         out_key = out_file + '.asc'
         attempt_to_download(ALEMBIC_PKT_URL, out_file)
         attempt_to_download(ALEMBIC_PKT_URL + '.asc', out_key)
         result = from_disk(out_file, out_key)
         self.assertTrue(result)
Esempio n. 3
0
 def test_check_with_existing_sign(self):
     """ Download signature for local verification """
     with tempfile.TemporaryDirectory() as tmpd:
         out_file = os.path.join(tmpd, os.path.basename(NOSIGN_PKT_URL))
         attempt_to_download(NOSIGN_PKT_URL, out_file)
         key_file = os.path.join(tmpd, os.path.basename(NOSIGN_PKT_URL))
         attempt_to_download(NOSIGN_SIGN_URL, key_file + '.asc')
         result = check(NOSIGN_PKT_URL, tmpd)
         self.assertTrue(result)
Esempio n. 4
0
 def test_from_url(self):
     with tempfile.TemporaryDirectory() as tmpd:
         out_file = os.path.join(tmpd, os.path.basename(ALEMBIC_PKT_URL))
         attempt_to_download(ALEMBIC_PKT_URL, out_file)
         out_file1 = os.path.join(tmpd, os.path.basename(XATTR_PKT_URL))
         attempt_to_download(XATTR_PKT_URL, out_file1)
         result = from_url(ALEMBIC_PKT_URL, tmpd)
         self.assertTrue(result)
         result = from_url(XATTR_PKT_URL, tmpd)
         self.assertTrue(result is None)
Esempio n. 5
0
    def test_attempt_to_download(self):
        fakeURL = "https://download.my.url.com/file.tar.gz"
        realURLnoFile = "http://pypi.debian.net/alembic/alembic-0.8.8.non-existent.tar.gz"
        realURL = "http://pypi.debian.net/alembic/alembic-0.8.8.tar.gz"

        tmpf = tempfile.NamedTemporaryFile()
        fname = tmpf.name
        tmpf.close()

        self.assertEqual(attempt_to_download(fakeURL, fname), None)
        self.assertEqual(attempt_to_download(realURLnoFile, fname), 404)
        self.assertEqual(attempt_to_download(realURL, fname), 200)

        os.unlink(fname)
Esempio n. 6
0
 def test_from_url(self):
     with tempfile.TemporaryDirectory() as tmpd:
         out_file = os.path.join(tmpd, os.path.basename(GEM_PKT))
         attempt_to_download(GEM_PKT, out_file)
         result = from_url(GEM_PKT, tmpd)
         self.assertTrue(result)
Esempio n. 7
0
 def test_check_matching_sign_url(self):
     with tempfile.TemporaryDirectory() as tmpd:
         out_file = os.path.join(tmpd, os.path.basename(ALEMBIC_PKT_URL))
         attempt_to_download(ALEMBIC_PKT_URL, out_file)
         result = check(ALEMBIC_PKT_URL, tmpd)
         self.assertTrue(result)
Esempio n. 8
0
 def test_result_on_nosign_package(self):
     with tempfile.TemporaryDirectory() as tmpd:
         out_file = os.path.join(tmpd, os.path.basename(NO_SIGN_PKT_URL))
         attempt_to_download(NO_SIGN_PKT_URL, out_file)
         result = from_url(NO_SIGN_PKT_URL, tmpd)
         self.assertTrue(result is None)