async def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = await checker.check()

        self.assertEqual(len(ext_data), 3)
        for data in ext_data:
            self.assertIsNotNone(data.new_version)
            self.assertIsNotNone(data.new_version.version)
            self.assertGreater(LooseVersion(data.new_version.version),
                               LooseVersion("90.0.4430.212"))

            if isinstance(data, ExternalData):
                self.assertIsInstance(data.new_version, ExternalFile)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsInstance(data.new_version.checksum, MultiDigest)
                if data.filename.startswith("chromium-"):
                    self.assertRegex(
                        data.new_version.url,
                        r"^https://commondatastorage.googleapis.com/chromium-browser-official/chromium-[\d.]+\.tar\.xz$",
                    )
                    self.assertNotEqual(
                        data.new_version.checksum,
                        MultiDigest(
                            sha256=
                            "abe11d0cb1ff21278aad2eec1a1e279d59176b15331804d7df1807446786d59e"
                        ),
                    )
                elif data.filename.startswith("clang-"):
                    self.assertRegex(
                        data.new_version.url,
                        r"^https://commondatastorage.googleapis.com/chromium-browser-clang/Linux_x64/clang-.*\.tgz$",
                    )
                    self.assertNotEqual(
                        data.new_version.checksum,
                        MultiDigest(
                            sha256=
                            "676448e180fb060d3983f24476a2136eac83c6011c600117686035634a2bbe26"
                        ),
                    )
                else:
                    self.fail(
                        f"unexpected extra-data filename {data.filename}")
            elif isinstance(data, ExternalGitRepo):
                self.assertEqual(data.filename, "llvm-project")
                self.assertIsInstance(data.new_version, ExternalGitRef)
                self.assertIsNotNone(data.new_version.commit)
                self.assertNotEqual(data.new_version.commit,
                                    data.current_version.commit)
            else:
                self.fail(repr(type(data)))
    async def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = await checker.check()

        for data in ext_data:
            self.assertIsNotNone(data.new_version)
            self.assertIsNotNone(data.new_version.checksum)
            self.assertIsInstance(data.new_version.checksum, MultiDigest)
            self.assertNotEqual(
                data.new_version.checksum,
                MultiDigest(
                    sha256="0000000000000000000000000000000000000000000000000000000000000000"
                ),
            )
            self.assertIsNotNone(data.new_version.version)
            self.assertIsInstance(data.new_version.version, str)

            if data.filename == "baobab-3.34.0.tar.xz":
                self._test_stable_only(data)
            elif data.filename == "pygobject-3.36.0.tar.xz":
                self._test_include_unstable(data)
                self.assertLess(
                    LooseVersion(data.new_version.version), LooseVersion("3.38.0")
                )
            elif data.filename == "alleyoop-0.9.8.tar.xz":
                self._test_non_standard_version(data)
 async def check(self, external_data):
     external_data.state |= external_data.State.BROKEN
     external_data.new_version = external_data.current_version._replace(
         size=self.SIZE,
         checksum=MultiDigest(sha256=self.CHECKSUM),
         version=self.VERSION,
         timestamp=self.TIMESTAMP,
     )
    async def test_check(self):
        checker = manifest.ManifestChecker(TEST_MANIFEST)
        ext_data = await checker.check()

        self.assertEqual(len(ext_data), NUM_ALL_EXT_DATA)

        ext_data_with_new_version = 0

        for data in ext_data:
            if data.new_version:
                self.assertIsInstance(data.new_version.url, str)
                self.assertIsInstance(data.new_version.checksum, MultiDigest)
                self.assertIsInstance(data.new_version.size, int)
                ext_data_with_new_version += 1

        self.assertEqual(ext_data_with_new_version, NUM_NEW_VERSIONS)

        file_ext_data = checker.get_external_data(ExternalData.Type.FILE)
        self.assertEqual(len(file_ext_data), NUM_FILE_IN_MANIFEST)

        archive_ext_data = checker.get_external_data(ExternalData.Type.ARCHIVE)
        self.assertEqual(len(archive_ext_data), NUM_ARCHIVE_IN_MANIFEST)

        extra_data = checker.get_external_data(ExternalData.Type.EXTRA_DATA)
        self.assertEqual(len(extra_data), NUM_EXTRA_DATA_IN_MANIFEST)

        outdated_ext_data = checker.get_outdated_external_data()
        self.assertEqual(len(outdated_ext_data), NUM_OUTDATED_DATA)

        dropbox = self._find_by_filename(ext_data, "dropbox.tgz")
        self.assertIsNotNone(dropbox)
        self.assertEqual(dropbox.new_version.version, "64")
        self.assertEqual(dropbox.new_version.url,
                         "https://httpbingo.org/base64/4puE")

        relative_redirect = self._find_by_filename(ext_data,
                                                   "relative-redirect.txt")
        self.assertIsNotNone(relative_redirect)
        self.assertEqual(
            relative_redirect.new_version.url,
            "https://httpbingo.org/base64/MzAtNTAgZmVyYWwgaG9ncyEK",
        )
        self.assertEqual(
            relative_redirect.new_version.checksum,
            MultiDigest(
                sha256=
                "e4d67702da4eeeb2f15629b65bf6767c028a511839c14ed44d9f34479eaa2b94"
            ),
        )
        self.assertEqual(relative_redirect.new_version.size, 18)

        # this URL is a redirect, but since it is not a rotating-url the URL
        # should not be updated.
        image = self._find_by_filename(ext_data, "image.jpeg")
        self.assertIsNone(image)
    async def test_complete_digests(self):
        CORRECT = "Correct".encode()
        WRONG = "Wrong".encode()

        checker = DummyChecker(self.http)
        sha256 = hashlib.sha256(CORRECT).hexdigest()
        sha512 = hashlib.sha512(CORRECT).hexdigest()

        checksum = await checker._complete_digests(self._get_url(CORRECT),
                                                   MultiDigest(sha512=sha512))
        self.assertEqual(checksum.sha256, sha256)
        self.assertEqual(checksum.sha512, sha512)

        with self.assertRaises(CheckerFetchError):
            await checker._complete_digests(self._get_url(WRONG),
                                            MultiDigest(sha512=sha512))

        with self.assertRaises(CheckerFetchError):
            await checker._complete_digests(
                "https://httpbin.org/base64/status/404",
                MultiDigest(sha512=sha512))
 def _test_combo_pattern_nosort(self, data):
     self.assertIsNotNone(data)
     self.assertRegex(data.filename, r"qrupdate-[\d\.-]+.tar.gz")
     self.assertIsNotNone(data.new_version)
     self.assertLessEqual(LooseVersion("1.1.0"),
                          LooseVersion(data.new_version.version))
     self.assertRegex(
         data.new_version.url,
         r"^https://sourceforge\.net/projects/qrupdate/.+/qrupdate-\d[\d\.]+\d\.tar\.gz$",  # noqa: E501
     )
     self.assertNotEqual(
         data.new_version.checksum,
         MultiDigest(
             sha256=
             "0000000000000000000000000000000000000000000000000000000000000000"
         ),
     )
 def _test_combo_pattern(self, data):
     self.assertIsNotNone(data)
     self.assertRegex(data.filename, r"libXScrnSaver-[\d\.-]+.tar.bz2")
     self.assertIsNotNone(data.new_version)
     self.assertLessEqual(LooseVersion("1.2.2"),
                          LooseVersion(data.new_version.version))
     self.assertRegex(
         data.new_version.url,
         r"^https?://www.x.org/releases/individual/lib/libXScrnSaver-[\d\.-]+.tar.bz2$",  # noqa: E501
     )
     self.assertNotEqual(
         data.new_version.checksum,
         MultiDigest(
             sha256=
             "0000000000000000000000000000000000000000000000000000000000000000"
         ),
     )
 def _test_check_with_url_template(self, data):
     self.assertIsNotNone(data)
     self.assertEqual(data.filename, "ico-1.0.4.tar.bz2")
     self.assertIsNotNone(data.new_version)
     self.assertEqual(
         data.new_version.url,
         "https://www.x.org/releases/individual/app/ico-1.0.5.tar.bz2",
     )
     self.assertIsInstance(data.new_version.size, int)
     self.assertGreater(data.new_version.size, 0)
     self.assertIsNotNone(data.new_version.checksum)
     self.assertIsInstance(data.new_version.checksum, MultiDigest)
     self.assertEqual(
         data.new_version.checksum,
         MultiDigest(
             sha256=
             "d73b62f29eb98d850f16b76d759395180b860b613fbe1686b18eee99a6e3773f"
         ),
     )
示例#9
0
    async def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = await checker.check()

        data = self._find_by_filename(ext_data, "UnityHubSetup.AppImage")
        self.assertIsNotNone(data)
        self.assertEqual(data.filename, "UnityHubSetup.AppImage")
        self.assertIsNotNone(data.new_version)
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, MultiDigest)
        self.assertNotEqual(
            data.new_version.checksum,
            MultiDigest(
                sha256=
                "0000000000000000000000000000000000000000000000000000000000000000"
            ),
        )
        self.assertIsNotNone(data.new_version.version)
    async def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = await checker.check()

        self.assertEqual(len(ext_data), 1)
        data = ext_data[0]
        self.assertIsNotNone(data.new_version)
        self.assertRegex(
            data.new_version.url,
            r"^https://static.rust-lang.org/dist/[\-\d]+/rust-nightly-x86_64-unknown-linux-gnu.tar.xz$",
        )
        self.assertIsNone(data.new_version.size)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, MultiDigest)
        self.assertNotEqual(
            data.new_version.checksum,
            MultiDigest(
                sha256=
                "24b4681187654778817652273a68a4d55f5090604cd14b1f1c3ff8785ad24b99"
            ),
        )
示例#11
0
    async def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = await checker.check()

        data = self._find_by_filename(ext_data, "nordpass.snap")
        self.assertIsNotNone(data)
        self.assertEqual(data.filename, "nordpass.snap")
        self.assertIsNotNone(data.new_version)
        self.assertRegex(
            data.new_version.url,
            r"^https://api\.snapcraft\.io/api/v1/snaps/download/[A-Za-z0-9]{32}_[0-9]+.snap$",
        )
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, MultiDigest)
        self.assertNotEqual(
            data.new_version.checksum,
            MultiDigest(
                sha256="0000000000000000000000000000000000000000000000000000000000000000"
            ),
        )
示例#12
0
    async def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = await checker.check()

        data = self._find_by_filename(ext_data, "phpstorm.tar.gz")
        self.assertIsNotNone(data)
        self.assertEqual(data.filename, "phpstorm.tar.gz")
        self.assertIsNotNone(data.new_version)
        self.assertRegex(
            data.new_version.url,
            r"^https://download\.jetbrains\.com/webide/PhpStorm-.+\.tar\.gz$",  # noqa: E501
        )
        self.assertIsInstance(data.new_version.size, int)
        self.assertGreater(data.new_version.size, 0)
        self.assertIsNotNone(data.new_version.checksum)
        self.assertIsInstance(data.new_version.checksum, MultiDigest)
        self.assertNotEqual(
            data.new_version.checksum,
            MultiDigest(
                sha256=
                "0000000000000000000000000000000000000000000000000000000000000000"
            ),
        )
    async def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = await checker.check()

        self.assertEqual(len(ext_data), 9)
        for data in ext_data:
            self.assertIsNotNone(data)
            if data.filename == "jq-1.4.tar.gz":
                self.assertIsInstance(data.new_version, ExternalFile)
                self.assertNotEqual(data.current_version.url,
                                    data.new_version.url)
                self.assertRegex(
                    data.new_version.url,
                    r"^https://github.com/stedolan/jq/releases/download/jq-[0-9\.\w]+/jq-[0-9\.\w]+\.tar.gz$",
                )
                self.assertIsInstance(data.new_version.size, int)
                self.assertGreater(data.new_version.size, 0)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsInstance(data.new_version.checksum, MultiDigest)
                self.assertNotEqual(
                    data.new_version.checksum,
                    MultiDigest(
                        sha256=
                        "0000000000000000000000000000000000000000000000000000000000000000"
                    ),
                )
            elif data.filename == "jq-1.4.tarball.tar.gz":
                self.assertEqual(
                    data.new_version.timestamp,
                    datetime.datetime.fromisoformat(
                        "2018-11-02T01:54:23+00:00"),
                )
            elif data.filename == "oniguruma.git":
                self.assertIsInstance(data.new_version, ExternalGitRef)
                self.assertEqual(data.current_version.url,
                                 data.new_version.url)
                self.assertIsNotNone(data.new_version.tag)
                self.assertIsNotNone(data.new_version.commit)
                self.assertNotEqual(data.new_version.tag,
                                    data.current_version.tag)
                self.assertNotEqual(data.new_version.commit,
                                    data.current_version.commit)
                self.assertNotEqual(
                    data.new_version.commit,
                    "e03900b038a274ee2f1341039e9003875c11e47d")
                self.assertIsNotNone(data.new_version.version)
                self.assertIsNotNone(data.new_version.timestamp)
            elif data.filename == "yasm.git":
                self.assertIsInstance(data.new_version, ExternalGitRef)
                self.assertEqual(data.current_version.url,
                                 data.new_version.url)
                self.assertIsNotNone(data.new_version.tag)
                self.assertIsNotNone(data.new_version.commit)
                self.assertNotEqual(data.new_version.tag,
                                    data.current_version.tag)
                self.assertIsNotNone(data.new_version.version)
                self.assertIsNone(data.new_version.timestamp)
            elif data.filename == "openal-soft.git":
                self.assertIsInstance(data.new_version, ExternalGitRef)
                self.assertEqual(data.current_version.url,
                                 data.new_version.url)
                self.assertIsNotNone(data.new_version.tag)
                self.assertIsNotNone(data.new_version.commit)
                self.assertIsNotNone(data.new_version.timestamp)
                self.assertIsInstance(data.new_version.timestamp,
                                      datetime.datetime)
            elif data.filename == "tdesktop.git":
                self.assertIsNotNone(data.new_version)
                self.assertEqual(data.new_version.tag, "v3.7.3")
            elif data.filename == "tg_owt.git":
                self.assertIsNotNone(data.new_version)
                self.assertEqual(data.new_version.commit,
                                 "63a934db1ed212ebf8aaaa20f0010dd7b0d7b396")
            elif data.filename == "lib_webrtc.git":
                self.assertIsNone(data.new_version)
            elif data.filename == "tg_angle.git":
                self.assertIsNone(data.new_version)
            else:
                self.fail(f"Unhandled data {data.filename}")
    async def test_check(self):
        checker = ManifestChecker(TEST_MANIFEST)
        ext_data = await checker.check()

        self.assertEqual(len(ext_data), 5)
        for data in ext_data:
            if data.filename == "ghostscript-9.26.tar.xz":
                self.assertIsNotNone(data.new_version)
                self.assertIsInstance(data.new_version, ExternalFile)
                self.assertRegex(
                    data.new_version.url,
                    r"^https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs[\d]+/ghostscript-[\d.]+.tar.xz$",
                )
                self.assertIsNotNone(data.new_version.version)
                self.assertGreater(LooseVersion(data.new_version.version),
                                   LooseVersion("9.26"))
                self.assertIsInstance(data.new_version.size, int)
                self.assertGreater(data.new_version.size, 0)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsInstance(data.new_version.checksum, MultiDigest)
                self.assertNotEqual(
                    data.new_version.checksum,
                    MultiDigest(
                        sha256=
                        "90ed475f37584f646e9ef829932b2525d5c6fc2e0147e8d611bc50aa0e718598"
                    ),
                )
            elif data.filename == "boost_1_74_0.tar.bz2":
                self.assertIsNotNone(data.new_version)
                self.assertIsInstance(data.new_version, ExternalFile)
                self.assertRegex(
                    data.new_version.url,
                    r"^https://boostorg\.jfrog\.io/artifactory/main/release/[\d.]+/source/boost_[\d]+_[\d]+_[\d]+.tar.bz2$",
                )
                self.assertIsNotNone(data.new_version.version)
                self.assertGreater(LooseVersion(data.new_version.version),
                                   LooseVersion("1.74.0"))
                self.assertIsInstance(data.new_version.size, int)
                self.assertGreater(data.new_version.size, 0)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsInstance(data.new_version.checksum, MultiDigest)
                self.assertNotEqual(
                    data.new_version.checksum,
                    MultiDigest(
                        sha256=
                        "83bfc1507731a0906e387fc28b7ef5417d591429e51e788417fe9ff025e116b1"
                    ),
                )
            elif data.filename == "flatpak-1.8.2.tar.xz":
                self.assertIsNotNone(data.new_version)
                self.assertIsInstance(data.new_version, ExternalFile)
                self.assertRegex(
                    data.new_version.url,
                    r"^https://github.com/flatpak/flatpak/releases/download/[\w\d.]+/flatpak-[\w\d.]+.tar.xz$",
                )
                self.assertIsNotNone(data.new_version.version)
                self.assertEqual(LooseVersion(data.new_version.version),
                                 LooseVersion("1.10.1"))
                self.assertIsInstance(data.new_version.size, int)
                self.assertGreater(data.new_version.size, 0)
                self.assertIsNotNone(data.new_version.checksum)
                self.assertIsInstance(data.new_version.checksum, MultiDigest)
                self.assertNotEqual(
                    data.new_version.checksum,
                    MultiDigest(
                        sha256=
                        "7926625df7c2282a5ee1a8b3c317af53d40a663b1bc6b18a2dc8747e265085b0"
                    ),
                )
            elif data.filename == "ostree.git":
                self.assertIsNotNone(data.new_version)
                self.assertIsInstance(data.new_version, ExternalGitRef)
                self.assertIsNotNone(data.new_version.commit)
                self.assertIsNotNone(data.new_version.tag)
                self.assertNotEqual(data.new_version.commit,
                                    data.current_version.commit)
                self.assertNotEqual(data.new_version.tag,
                                    data.current_version.tag)
                self.assertIsNotNone(data.new_version.version)
                self.assertGreater(LooseVersion(data.new_version.version),
                                   LooseVersion("2020.7"))
                self.assertNotEqual(data.new_version.commit,
                                    data.current_version.commit)
            elif data.filename == "gr-iqbal.git":
                self.assertIsNone(data.new_version)
            else:
                self.fail(f"Unknown data {data.filename}")