From 1c947e2d5900a3b199128918e7ec0404d8feed8c Mon Sep 17 00:00:00 2001 From: Barabas <31799121+Barabazs@users.noreply.github.com> Date: Tue, 24 May 2022 13:42:07 +0200 Subject: [PATCH] Merge latest changes (#18) * Refactor exception printing * Refactor tests * Include entry in assertion message * Replace redundant assertions * Rename functions with inconsistent prefix * Update testing_data.py * Annotate entries * Add missing encodings * Refactor is_ipfs.py * Add missing ipfs path_pattern check * Correct wrong assumption about native url validation * Bump version --- is_ipfs/is_ipfs.py | 64 ++++++----- setup.py | 2 +- tests/integration/test_is_ipfs.py | 40 +++---- tests/testing_data.py | 184 +++++++++++++++++++----------- tests/unit/test_is_cid.py | 14 +-- tests/unit/test_native_url.py | 8 +- tests/unit/test_path.py | 8 +- tests/unit/test_subdomain.py | 8 +- tests/unit/test_url.py | 8 +- 9 files changed, 192 insertions(+), 144 deletions(-) diff --git a/is_ipfs/is_ipfs.py b/is_ipfs/is_ipfs.py index 73751c9..f492b79 100644 --- a/is_ipfs/is_ipfs.py +++ b/is_ipfs/is_ipfs.py @@ -48,15 +48,15 @@ def _is_cid(self) -> bool: elif type(self.input) == bytes: try: return cid.is_cid(decode(self.input)) - except Exception as error: - print(f"Unexpected {type(error)}, {error}") + except ValueError as error: + print(f"Unexpected ValueError, {error}") return False else: try: if isinstance(self.input, (cid.CIDv0, cid.CIDv1)): return cid.is_cid(str(self.input)) - except Exception as error: - print(f"Unexpected {type(error)}, {error}") + except ValueError as error: + print(f"Unexpected ValueError, {error}") return False return False @@ -80,18 +80,19 @@ def _is_integral_ipfs_url( _hash = match["hash"] - if ( - pattern == self.subdomain_gateway_pattern - or pattern == self.native_url_pattern - ): + if pattern == self.subdomain_gateway_pattern: _hash = _hash.lower() try: - if get_codec(_hash).encoding not in ["base32", "base36"]: + if get_codec(_hash).encoding not in ["base32", "base32hex", "base36"]: return False - except Exception as error: - print(f"Unexpected {type(error)}, {error}") + except ValueError as error: + print(f"Unexpected ValueError, {error}") return False - elif pattern == self.path_gateway_pattern: + elif ( + (pattern == self.path_gateway_pattern) + or (pattern == self.native_url_pattern) + or (pattern == self.path_pattern) + ): if not str(_hash).startswith("Qm"): try: if get_codec(_hash).encoding not in [ @@ -106,13 +107,13 @@ def _is_integral_ipfs_url( "base64url", ]: return False - except Exception as error: - print(f"Unexpected {type(error)}, {error}") + except ValueError as error: + print(f"Unexpected ValueError, {error}") return False return Validator(_hash)._is_cid() - def _ipfs_subdomain_url(self) -> bool: + def _is_ipfs_subdomain_url(self) -> bool: """ Returns True if the provided url string includes a valid IPFS subdomain (case-insensitive CIDv1) or False otherwise. """ @@ -120,7 +121,7 @@ def _ipfs_subdomain_url(self) -> bool: self.subdomain_gateway_pattern, ) - def _ipfs_path_url(self) -> bool: + def _is_ipfs_path_url(self) -> bool: """ Returns True if the provided url string is a valid IPFS URL or False otherwise. """ @@ -132,7 +133,7 @@ def _is_ipfs_url(self) -> bool: """ Returns True if the provided string is a valid IPFS url or False otherwise. """ - return self._ipfs_path_url() or self._ipfs_subdomain_url() + return self._is_ipfs_path_url() or self._is_ipfs_subdomain_url() def _is_ipfs_path(self) -> bool: """ @@ -160,18 +161,15 @@ def _is_integral_ipns_url( ipns_id = match["hash"] - if (ipns_id) and ( - pattern == self.subdomain_gateway_pattern - or pattern == self.native_url_pattern - ): + if pattern == self.subdomain_gateway_pattern: ipns_id = ipns_id.lower() if Validator(ipns_id)._is_cid(): try: if get_codec(ipns_id).encoding == "base36": return True - except Exception as error: - print(f"Unexpected {type(error)}, {error}") + except ValueError as error: + print(f"Unexpected ValueError, {error}") return False try: if ("." not in ipns_id and "-" in ipns_id) and ( @@ -182,11 +180,15 @@ def _is_integral_ipns_url( ) return self._id_is_explicit_tld(ipns_id) - except Exception as error: - print(f"Unexpected {type(error)}, {error}") + except ValueError as error: + print(f"Unexpected ValueError, {error}") return False - elif pattern == self.path_gateway_pattern or pattern == self.path_pattern: + elif ( + (pattern == self.path_gateway_pattern) + or (pattern == self.path_pattern) + or (pattern == self.native_url_pattern) + ): if not str(ipns_id).startswith("Qm"): if self._id_is_explicit_tld(ipns_id): return True @@ -204,13 +206,13 @@ def _is_integral_ipns_url( "base64url", ]: return False - except Exception as error: - print(f"Unexpected {type(error)}, {error}") + except ValueError as error: + print(f"Unexpected ValueError, {error}") return False return Validator(ipns_id)._is_cid() - def _ipns_subdomain_url(self) -> bool: + def _is_ipns_subdomain_url(self) -> bool: """ Returns True if the provided url string includes a valid IPFS subdomain (case-insensitive CIDv1) or False otherwise. """ @@ -218,7 +220,7 @@ def _ipns_subdomain_url(self) -> bool: self.subdomain_gateway_pattern, ) - def _ipns_path_url(self) -> bool: + def _is_ipns_path_url(self) -> bool: """ Returns True if the provided url string is a valid IPFS URL or False otherwise. """ @@ -230,7 +232,7 @@ def _is_ipns_url(self) -> bool: """ Returns True if the provided string is a valid IPFS url or False otherwise. """ - return self._ipns_path_url() or self._ipns_subdomain_url() + return self._is_ipns_path_url() or self._is_ipns_subdomain_url() def _is_ipns_path(self) -> bool: """ diff --git a/setup.py b/setup.py index 89d2776..819d771 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setuptools.setup( name="py-is_ipfs", - version="0.2.0", + version="0.3.0", description="Python library to identify valid IPFS resources", long_description=long_description, long_description_content_type="text/markdown", diff --git a/tests/integration/test_is_ipfs.py b/tests/integration/test_is_ipfs.py index f8e6670..0f4258d 100644 --- a/tests/integration/test_is_ipfs.py +++ b/tests/integration/test_is_ipfs.py @@ -8,78 +8,78 @@ class TestCase(unittest.TestCase): def test_all(self): with self.subTest("Test valid CID entries from fixtures"): - for key, value in testing_data.valid_entries["cid"].items(): + for value in testing_data.valid_entries["cid"].values(): for entry in value: - self.assertTrue(Validator(entry).is_ipfs()) + self.assertTrue(Validator(entry).is_ipfs(), entry) with self.subTest("Test invalid CID entries from fixtures"): - for key, value in testing_data.invalid_entries["cid"].items(): + for value in testing_data.invalid_entries["cid"].values(): for entry in value: - self.assertFalse(Validator(entry).is_ipfs()) + self.assertFalse(Validator(entry).is_ipfs(), entry) with self.subTest("Test valid IPFS URL entries from fixtures"): for entry in testing_data.valid_entries["url"]["ipfs"]: - self.assertTrue(Validator(entry).is_ipfs()) + self.assertTrue(Validator(entry).is_ipfs(), entry) with self.subTest("Test invalid IPFS URL entries from fixtures"): for entry in testing_data.invalid_entries["url"]["ipfs"]: - self.assertFalse(Validator(entry).is_ipfs()) + self.assertFalse(Validator(entry).is_ipfs(), entry) with self.subTest("Test valid IPFS subdomain entries from fixtures"): for entry in testing_data.valid_entries["subdomain"]["ipfs"]: - self.assertTrue(Validator(entry).is_ipfs()) + self.assertTrue(Validator(entry).is_ipfs(), entry) with self.subTest("Test invalid IPFS subdomain entries from fixtures"): for entry in testing_data.invalid_entries["subdomain"]["ipfs"]: - self.assertFalse(Validator(entry).is_ipfs()) + self.assertFalse(Validator(entry).is_ipfs(), entry) with self.subTest("Test valid IPFS path entries from fixtures"): for entry in testing_data.valid_entries["path"]["ipfs"]: - self.assertTrue(Validator(entry).is_ipfs()) + self.assertTrue(Validator(entry).is_ipfs(), entry) with self.subTest("Test invalid IPFS path entries from fixtures"): for entry in testing_data.invalid_entries["path"]["ipfs"]: - self.assertFalse(Validator(entry).is_ipfs()) + self.assertFalse(Validator(entry).is_ipfs(), entry) with self.subTest("Test valid IPNS URL entries from fixtures"): for entry in testing_data.valid_entries["url"]["ipns"]: - self.assertTrue(Validator(entry).is_ipfs()) + self.assertTrue(Validator(entry).is_ipfs(), entry) with self.subTest("Test invalid IPNS URL entries from fixtures"): for entry in testing_data.invalid_entries["url"]["ipns"]: - self.assertFalse(Validator(entry).is_ipfs()) + self.assertFalse(Validator(entry).is_ipfs(), entry) with self.subTest("Test valid IPNS subdomain entries from fixtures"): for entry in testing_data.valid_entries["subdomain"]["ipns"]: - self.assertTrue(Validator(entry).is_ipfs()) + self.assertTrue(Validator(entry).is_ipfs(), entry) with self.subTest("Test invalid IPNS subdomain entries from fixtures"): for entry in testing_data.invalid_entries["subdomain"]["ipns"]: - self.assertFalse(Validator(entry).is_ipfs()) + self.assertFalse(Validator(entry).is_ipfs(), entry) with self.subTest("Test valid IPNS path entries from fixtures"): for entry in testing_data.valid_entries["path"]["ipns"]: - self.assertTrue(Validator(entry).is_ipfs()) + self.assertTrue(Validator(entry).is_ipfs(), entry) with self.subTest("Test invalid IPNS path entries from fixtures"): for entry in testing_data.invalid_entries["path"]["ipns"]: - self.assertFalse(Validator(entry).is_ipfs()) + self.assertFalse(Validator(entry).is_ipfs(), entry) with self.subTest("Test valid IPFS native URL entries from fixtures"): for entry in testing_data.valid_entries["native_url"]["ipfs"]: - self.assertTrue(Validator(entry).is_ipfs()) + self.assertTrue(Validator(entry).is_ipfs(), entry) with self.subTest("Test invalid IPFS native URL entries from fixtures"): for entry in testing_data.invalid_entries["native_url"]["ipfs"]: - self.assertFalse(Validator(entry).is_ipfs()) + self.assertFalse(Validator(entry).is_ipfs(), entry) with self.subTest("Test valid IPNS native URL entries from fixtures"): for entry in testing_data.valid_entries["native_url"]["ipns"]: - self.assertTrue(Validator(entry).is_ipfs()) + self.assertTrue(Validator(entry).is_ipfs(), entry) with self.subTest("Test invalid IPNS native URL from fixtures"): for entry in testing_data.invalid_entries["native_url"]["ipns"]: - self.assertFalse(Validator(entry).is_ipfs()) + self.assertFalse(Validator(entry).is_ipfs(), entry) if __name__ == "__main__": # pragma: no cover diff --git a/tests/testing_data.py b/tests/testing_data.py index 2a5e630..fecf177 100644 --- a/tests/testing_data.py +++ b/tests/testing_data.py @@ -10,6 +10,7 @@ "v1": [ "0000000010111000000010010001000001100001111000100011100110011111011001000101011111111110100000110110011111001111010011111111101010000111111111100011010111100110100101110110010000101101001100001011100000000000001001011101101110000100101100110100111000011000111011110100101000011100100011010", # base2 "72700221014170434637310537764066371723775207774327464566205514134000113556045464703073645034432", # base8 + "92793123896416649578508430956173875066425468388805468715479907750778834469731416946970", # base10 "f01701220c3c4733ec8affd06cf9e9ff50ffc6bcd2ec85a6170004bb709669c31de94391a", # base16 "bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va", # base32 "bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi", # base32 @@ -18,9 +19,9 @@ "K2JMTXW8RJH1Z69C6NOT3WTDXB0U3URBZHYLL1T9JG6OX26DHI5SFI1M", # base36upper "ZCJ7vHB6jBiaEvZ1B9N4m6KQ9kWC5bEAXKuzEMRNJzzgHrfXm", # base58flickr "zdj7Wic6KcJAfWz1c9o4M6kq9Lwd5BfbxkVafnrojaaGiSFxM", # base58btc + "zdj7WWeQ43G6JJvLWQWZpyHuAMq6uYWRjkBXFad11vE2LHhQ7", # base58btc "mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka", # base64 "uAXASIMPEcz7Ir_0Gz56f9Q_8a80uyFphcABLtwlmnDHelDka", # base64url - "zdj7WWeQ43G6JJvLWQWZpyHuAMq6uYWRjkBXFad11vE2LHhQ7", # base58btc ], "encoded": [ cid.from_string("QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR"), @@ -46,40 +47,46 @@ }, "url": { "ipfs": [ + "https://ipfs.io/ipfs/0000000010111000000010010001000001100001111000100011100110011111011001000101011111111110100000110110011111001111010011111111101010000111111111100011010111100110100101110110010000101101001100001011100000000000001001011101101110000100101100110100111000011000111011110100101000011100100011010", # base2 + "https://ipfs.io/ipfs/f01701220c3c4733ec8affd06cf9e9ff50ffc6bcd2ec85a6170004bb709669c31de94391a", # base16 + "https://gateway.pinata.cloud/ipfs/bafybeif5dwlk2sdx5yge4azff2ovsnar63cu37ncw4n24vnqixwamwhxui/", # base32 + "https://ipfs.io/ipfs/bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi/", # base32 + "https://ipfs.io/ipfs/v05o14863ohpjti5fvk3cv7kvuk7voqud5r45kobg015re2b6jgott51p38", # base32hex + "https://ipfs.io/ipfs/k2jmtxw8rjh1z69c6not3wtdxb0u3urbzhyll1t9jg6ox26dhi5sfi1m", # base36 + "https://ipfs.io/ipfs/K2JMTXW8RJH1Z69C6NOT3WTDXB0U3URBZHYLL1T9JG6OX26DHI5SFI1M", # base36upper + "https://ipfs.io/ipfs/ZCJ7vHB6jBiaEvZ1B9N4m6KQ9kWC5bEAXKuzEMRNJzzgHrfXm", # base58flickr "http://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=val#hash", # base58btc "http://ipfs.alexandria.media/ipfs/QmeWz9YZEeNFXQhHg4PnR5ZiNr5isttgi5n1tc1eD5EfGU/content/index.html?arg=val#hash", # base58btc "http://ipfs.io/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR", # base58btc "https://gateway.pinata.cloud/ipfs/Qmb4sw3sqA7AZsaRZ7vtMwxCduk1ExJL5gVDPcpnP8kxFK/", # base58btc - "https://gateway.pinata.cloud/ipfs/bafybeif5dwlk2sdx5yge4azff2ovsnar63cu37ncw4n24vnqixwamwhxui/", # base32 - "https://bafybeif5dwlk2sdx5yge4azff2ovsnar63cu37ncw4n24vnqixwamwhxui.ipfs.dweb.link/", # base32 - "https://ipfs.io/ipfs/bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi/", # base32 - "https://ipfs.io/ipfs/f01701220c3c4733ec8affd06cf9e9ff50ffc6bcd2ec85a6170004bb709669c31de94391a", # base16 - "https://ipfs.io/ipfs/0000000010111000000010010001000001100001111000100011100110011111011001000101011111111110100000110110011111001111010011111111101010000111111111100011010111100110100101110110010000101101001100001011100000000000001001011101101110000100101100110100111000011000111011110100101000011100100011010", # base2 - "https://ipfs.io/ipfs/ZCJ7vHB6jBiaEvZ1B9N4m6KQ9kWC5bEAXKuzEMRNJzzgHrfXm", # base58flickr "https://ipfs.io/ipfs/zdj7Wic6KcJAfWz1c9o4M6kq9Lwd5BfbxkVafnrojaaGiSFxM", # base58btc "https://ipfs.io/ipfs/QmR7GSQM93Cx5eAg6a6yRzNde1FQv7uL6X1o4k7zrJa3LX/ipfs.draft3.pdf", # base58btc + "https://ipfs.io/ipfs/uAXASIMPEcz7Ir_0Gz56f9Q_8a80uyFphcABLtwlmnDHelDka", # base64url ], "ipns": [ - "http://ipfs.io/ipns/github.com/", + "http://ipfs.io/ipns/foo.bar/", # theoretically valid, but is missing a dnslink record "https://ipfs.io/ipns/en.wikipedia-on-ipfs.org/wiki/", - "https://ipfs.io/ipns/01011100100000000000100100000010000000000100010010001000000111101000001011100011011101011001111000010001000000111011111010001000000101010010011110000100110011111101001001001011011000100011111110100100011111001101111010011000100110011101010111101110011011111101001100101010000010101010000010001010001000100110100001", # base2 - "https://ipfs.io/ipns/f01720024080112207a0b8dd678440efa20549e133f492d88fe91f37a626757b9bf4ca82a822889a1", # base16 - "https://ipfs.io/ipns/bafzaajaiaejca6qlrxlhqrao7iqfjhqth5es3ch6shzxuythk6436tfifkbcrcnb", # base32 - "https://ipfs.io/ipns/v05p0090804920ugbhnb7gh0ev8g597gj7t4ir27ui7pnkoj7ausruj585a12h2d1", # base32hex - "https://ipfs.io/ipns/k51qzi5uqu5dj83g1ajm0a9z06fny53f7cb5co9k6pvo8b0yr871vinhrohbq9", # base36 - "https://ipfs.io/ipns/K51QZI5UQU5DJ83G1AJM0A9Z06FNY53F7CB5CO9K6PVO8B0YR871VINHROHBQ9", # base36upper - "https://ipfs.io/ipns/Z5azMnuicXMo3NdactTr8XzcdoRMPQUyAPfy3Pt83kU8iZprfMNCMTx", # base58flickr CIDv1 - "https://ipfs.io/ipns/z5AanNVJCxnP3oDACUtS8xaCDPrnpquZbpFZ3pU83Lu8JzQSFnodntY", # base58btc CIDv1 - "https://ipfs.io/ipns/uAXIAJAgBEiB6C43WeEQO-iBUnhM_SS2I_pHzemJnV7m_TKgqgiiJoQ", # base64url + "https://ipfs.io/ipns/01011100100000000000100100000010000000000100010010001000000001101100000000001011010111001111011100001111011011011110000110010010011110000111100011011100010111111100111101110101100110111011011101000001100110101011111110001011000001111110000110000111010100101100011010011000111000101000010101010110100001001100110011", # base2 + "https://ipfs.io/ipns/f01720024080112201b002d73dc3db78649e1e3717f3dd66edd066afe2c1f861d4b1a638a155a1333", # base16 + "https://ipfs.io/ipns/bafzaajaiaejcagyafvz5ypnxqze6dy3rp465m3w5azvp4la7qyouwgtdrikvuezt", # base32 + "https://ipfs.io/ipns/v05p00908049206o05lptofdngp4u3orhfsutcrmt0plfsb0vgoekm6j3h8alk4pj", # base32hex + "https://ipfs.io/ipns/k51qzi5uqu5dgutdk6i1ynyzgkqngpha5xpgia3a5qqp4jsh0u4csozksxel2r", # base36 + "https://ipfs.io/ipns/K51QZI5UQU5DGUTDK6I1YNYZGKQNGPHA5XPGIA3A5QQP4JSH0U4CSOZKSXEL2R", # base36upper + "https://ipfs.io/ipns/Z5azMnuicXMgDMqbtbwJiQHydfF5kzhqYommSLcxq57AXAbA8SFnxoB", # base58flickr CIDv1 + "https://ipfs.io/ipns/z5AanNVJCxnGenRBUBXjJqiZDFg5LaHRyPMMsmCYR57bxbBb8sgNYPc", # base58btc CIDv1 + "https://ipfs.io/ipns/uAXIAJAgBEiAbAC1z3D23hknh43F_PdZu3QZq_iwfhh1LGmOKFVoTMw", # base64url ], }, "subdomain": { "ipfs": [ + "https://bafybeif5dwlk2sdx5yge4azff2ovsnar63cu37ncw4n24vnqixwamwhxui.ipfs.dweb.link/", # base32 "http://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.ipfs.dweb.link", # base32 "http://bafybeidvtwx54qr44kidymvhfzefzxhgkieigwth6oswk75zhlzjdmunoy.ipfs.dweb.link/linkify-demo.html", # base32 "http://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.ipfs.localhost:8080", # base32 "https://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi.ipfs.dweb.link/", # base32 + "https://v05o14863ohpjti5fvk3cv7kvuk7voqud5r45kobg015re2b6jgott51p38.ipfs.dweb.link/", # base32hex "https://k2jmtxw8rjh1z69c6not3wtdxb0u3urbzhyll1t9jg6ox26dhi5sfi1m.ipfs.dweb.link/", # base36 + "https://K2JMTXW8RJH1Z69C6NOT3WTDXB0U3URBZHYLL1T9JG6OX26DHI5SFI1M.ipfs.dweb.link/", # base36upper ], "ipns": [ "http://docs.ipfs.io.ipns.localhost:8080/some/path", @@ -87,8 +94,8 @@ "http://docs.ipfs.io.ipns.locahost:8080", "https://en-wikipedia--on--ipfs-org.ipns.dweb.link", "https://ipfs-io.ipns.dweb.link/", - "https://k51qzi5uqu5dj83g1ajm0a9z06fny53f7cb5co9k6pvo8b0yr871vinhrohbq9.ipns.dweb.link/", # base36 - "https://K51QZI5UQU5DJ83G1AJM0A9Z06FNY53F7CB5CO9K6PVO8B0YR871VINHROHBQ9.ipns.dweb.link", # base36upper + "https://k51qzi5uqu5dgutdk6i1ynyzgkqngpha5xpgia3a5qqp4jsh0u4csozksxel2r.ipns.dweb.link/", # base36 + "https://K51QZI5UQU5DGUTDK6I1YNYZGKQNGPHA5XPGIA3A5QQP4JSH0U4CSOZKSXEL2R.ipns.dweb.link", # base36upper ], }, "path": { @@ -100,48 +107,77 @@ "/ipfs/v05o14863ohpjti5fvk3cv7kvuk7voqud5r45kobg015re2b6jgott51p38", # base32hex "/ipfs/k51qzi5uqu5dkkciu33khkzbcmxtyhn376i1e83tya8kuy7z9euedzyr5nhoew", # base36 "/ipfs/K2JMTXW8RJH1Z69C6NOT3WTDXB0U3URBZHYLL1T9JG6OX26DHI5SFI1M", # base36upper - "/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=val#hash", # base58btc + "/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=val#hash", # base58btc CIDv0 "/ipfs/QmeWz9YZEeNFXQhHg4PnR5ZiNr5isttgi5n1tc1eD5EfGU/content/index.html?arg=val#hash", # base58btc CIDv0 "/ipfs/ZCJ7vHB6jBiaEvZ1B9N4m6KQ9kWC5bEAXKuzEMRNJzzgHrfXm", # base58flickr" "/ipfs/zdj7Wic6KcJAfWz1c9o4M6kq9Lwd5BfbxkVafnrojaaGiSFxM", # base58btc CIDv1 - "/ipfs/QmR7GSQM93Cx5eAg6a6yRzNde1FQv7uL6X1o4k7zrJa3LX/ipfs.draft3.pdf", # base58btc - "/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki/Aardvark.html", # base58btc + "/ipfs/QmR7GSQM93Cx5eAg6a6yRzNde1FQv7uL6X1o4k7zrJa3LX/ipfs.draft3.pdf", # base58btc CIDv0 + "/ipfs/QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki/Aardvark.html", # base58btc CIDv0 "/ipfs/uAXASIMPEcz7Ir_0Gz56f9Q_8a80uyFphcABLtwlmnDHelDka", # base64url ], "ipns": [ - "/ipns/github.com/", + "/ipns/en-wikipedia--on--ipfs-org.ipns.dweb.link", # theoretically valid, but is missing a dnslink record + "/ipns/ipfs-io.ipns.ipfs.io", # theoretically valid, but is missing a dnslink record + "/ipns/github.com/", # theoretically valid, but is missing a dnslink record + "/ipns/cid.ipfs.io", + "/ipns/ipfs.io", "/ipns/libp2p.io", "/ipns/docs.ipfs.io/introduction/", "/ipns/en.wikipedia-on-ipfs.org/", - "/ipns/foo.bar", - "/ipns/01011100100000000000100100000010000000000100010010001000000111101000001011100011011101011001111000010001000000111011111010001000000101010010011110000100110011111101001001001011011000100011111110100100011111001101111010011000100110011101010111101110011011111101001100101010000010101010000010001010001000100110100001", # base2 - "/ipns/f01720024080112207a0b8dd678440efa20549e133f492d88fe91f37a626757b9bf4ca82a822889a1", # base16 - "/ipns/bafzaajaiaejca6qlrxlhqrao7iqfjhqth5es3ch6shzxuythk6436tfifkbcrcnb", # base32 - "/ipns/v05p0090804920ugbhnb7gh0ev8g597gj7t4ir27ui7pnkoj7ausruj585a12h2d1", # base32hex - "/ipns/k51qzi5uqu5dj83g1ajm0a9z06fny53f7cb5co9k6pvo8b0yr871vinhrohbq9", # base36 - "/ipns/K51QZI5UQU5DJ83G1AJM0A9Z06FNY53F7CB5CO9K6PVO8B0YR871VINHROHBQ9", # base36upper - "/ipns/Z5azMnuicXMo3NdactTr8XzcdoRMPQUyAPfy3Pt83kU8iZprfMNCMTx", # base58flickr CIDv1 - "/ipns/z5AanNVJCxnP3oDACUtS8xaCDPrnpquZbpFZ3pU83Lu8JzQSFnodntY", # base58btc CIDv1 - "/ipns/uAXIAJAgBEiB6C43WeEQO-iBUnhM_SS2I_pHzemJnV7m_TKgqgiiJoQ", # base64url + "/ipns/foo.bar", # theoretically valid, but is missing a dnslink record + "/ipns/01011100100000000000100100000010000000000100010010001000000001101100000000001011010111001111011100001111011011011110000110010010011110000111100011011100010111111100111101110101100110111011011101000001100110101011111110001011000001111110000110000111010100101100011010011000111000101000010101010110100001001100110011", # base2 + "/ipns/f01720024080112201b002d73dc3db78649e1e3717f3dd66edd066afe2c1f861d4b1a638a155a1333", # base16 + "/ipns/bafzaajaiaejcagyafvz5ypnxqze6dy3rp465m3w5azvp4la7qyouwgtdrikvuezt", # base32 + "/ipns/v05p00908049206o05lptofdngp4u3orhfsutcrmt0plfsb0vgoekm6j3h8alk4pj", # base32hex + "/ipns/k51qzi5uqu5dgutdk6i1ynyzgkqngpha5xpgia3a5qqp4jsh0u4csozksxel2r", # base36 + "/ipns/K51QZI5UQU5DGUTDK6I1YNYZGKQNGPHA5XPGIA3A5QQP4JSH0U4CSOZKSXEL2R", # base36upper + "/ipns/Z5azMnuicXMgDMqbtbwJiQHydfF5kzhqYommSLcxq57AXAbA8SFnxoB", # base58flickr CIDv1 + "/ipns/z5AanNVJCxnGenRBUBXjJqiZDFg5LaHRyPMMsmCYR57bxbBb8sgNYPc", # base58btc CIDv1 + "/ipns/uAXIAJAgBEiAbAC1z3D23hknh43F_PdZu3QZq_iwfhh1LGmOKFVoTMw", # base64url ], }, "native_url": { "ipfs": [ - "ipfs://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va", # base32 + "ipfs://QmeWz9YZEeNFXQhHg4PnR5ZiNr5isttgi5n1tc1eD5EfGU", # CIDv0 base58btc "ipfs://bafybeidvtwx54qr44kidymvhfzefzxhgkieigwth6oswk75zhlzjdmunoy/linkify-demo.html", # base32 - "ipfs://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va", # base32 "ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi/", # base32 "ipfs://k2jmtxw8rjh1z69c6not3wtdxb0u3urbzhyll1t9jg6ox26dhi5sfi1m/", # base36 + "ipfs://0000000010111000000010010001000001100001111000100011100110011111011001000101011111111110100000110110011111001111010011111111101010000111111111100011010111100110100101110110010000101101001100001011100000000000001001011101101110000100101100110100111000011000111011110100101000011100100011010", # base2 + "ipfs://f01701220c3c4733ec8affd06cf9e9ff50ffc6bcd2ec85a6170004bb709669c31de94391a", # base16 + "ipfs://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va", # base32 + "ipfs://bafzaajaiaejcbl6sqhrt4bii7kvqtk3ye3jmqllbxxeurgms6iuh52vad7vcc4gy", # base32 + "ipfs://v05o14863ohpjti5fvk3cv7kvuk7voqud5r45kobg015re2b6jgott51p38", # base32hex + "ipfs://k51qzi5uqu5dkkciu33khkzbcmxtyhn376i1e83tya8kuy7z9euedzyr5nhoew", # base36 + "ipfs://K2JMTXW8RJH1Z69C6NOT3WTDXB0U3URBZHYLL1T9JG6OX26DHI5SFI1M", # base36upper + "ipfs://QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR?arg=val#hash", # base58btc + "ipfs://QmeWz9YZEeNFXQhHg4PnR5ZiNr5isttgi5n1tc1eD5EfGU/content/index.html?arg=val#hash", # base58btc CIDv0 + "ipfs://ZCJ7vHB6jBiaEvZ1B9N4m6KQ9kWC5bEAXKuzEMRNJzzgHrfXm", # base58flickr" + "ipfs://zdj7Wic6KcJAfWz1c9o4M6kq9Lwd5BfbxkVafnrojaaGiSFxM", # base58btc CIDv1 + "ipfs://QmR7GSQM93Cx5eAg6a6yRzNde1FQv7uL6X1o4k7zrJa3LX/ipfs.draft3.pdf", # base58btc + "ipfs://QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco/wiki/Aardvark.html", # base58btc + "ipfs://uAXASIMPEcz7Ir_0Gz56f9Q_8a80uyFphcABLtwlmnDHelDka", # base64url ], "ipns": [ - "ipns://docs.ipfs.io.ipns.localhost:8080/some/path", - "ipns://docs.ipfs.io.ipns.foo.bar.buzz.dweb.link", - "ipns://docs.ipfs.io.ipns.locahost:8080", - "ipns://en-wikipedia--on--ipfs-org.ipns.dweb.link", + "ipns://en-wikipedia--on--ipfs-org.ipns.dweb.link", # theoretically valid, but is missing a dnslink record "ipns://cid.ipfs.io", - "ipns://ipfs-io.ipns.dweb.link/", - "ipns://k51qzi5uqu5dj83g1ajm0a9z06fny53f7cb5co9k6pvo8b0yr871vinhrohbq9", # base36 - "ipns://K51QZI5UQU5DJ83G1AJM0A9Z06FNY53F7CB5CO9K6PVO8B0YR871VINHROHBQ9/path#title", # base36upper + "ipns://ipfs-io.ipns.ipfs.io", # theoretically valid, but is missing a dnslink record + "ipns://ipfs.io", + "ipns://k51qzi5uqu5dgutdk6i1ynyzgkqngpha5xpgia3a5qqp4jsh0u4csozksxel2r", # base36 + "ipns://K51QZI5UQU5DGUTDK6I1YNYZGKQNGPHA5XPGIA3A5QQP4JSH0U4CSOZKSXEL2R/path#title", # base36upper + "ipns://github.com/", # theoretically valid, but is missing a dnslink record + "ipns://libp2p.io", + "ipns://docs.ipfs.io/introduction/", + "ipns://en.wikipedia-on-ipfs.org/", + "ipns://foo.bar", # theoretically valid, but is missing a dnslink record + "ipns://01011100100000000000100100000010000000000100010010001000000001101100000000001011010111001111011100001111011011011110000110010010011110000111100011011100010111111100111101110101100110111011011101000001100110101011111110001011000001111110000110000111010100101100011010011000111000101000010101010110100001001100110011", # base2 + "ipns://f01720024080112201b002d73dc3db78649e1e3717f3dd66edd066afe2c1f861d4b1a638a155a1333", # base16 + "ipns://bafzaajaiaejcagyafvz5ypnxqze6dy3rp465m3w5azvp4la7qyouwgtdrikvuezt", # base32 + "ipns://v05p00908049206o05lptofdngp4u3orhfsutcrmt0plfsb0vgoekm6j3h8alk4pj", # base32hex + "ipns://k51qzi5uqu5dgutdk6i1ynyzgkqngpha5xpgia3a5qqp4jsh0u4csozksxel2r", # base36 + "ipns://K51QZI5UQU5DGUTDK6I1YNYZGKQNGPHA5XPGIA3A5QQP4JSH0U4CSOZKSXEL2R", # base36upper + "ipns://Z5azMnuicXMgDMqbtbwJiQHydfF5kzhqYommSLcxq57AXAbA8SFnxoB", # base58flickr CIDv1 + "ipns://z5AanNVJCxnGenRBUBXjJqiZDFg5LaHRyPMMsmCYR57bxbBb8sgNYPc", # base58btc CIDv1 + "ipns://uAXIAJAgBEiAbAC1z3D23hknh43F_PdZu3QZq_iwfhh1LGmOKFVoTMw", # base64url ], }, } @@ -167,49 +203,59 @@ }, "url": { "ipfs": [ - "https://Qmb4sw3sqA7AZsaRZ7vtMwxCduk1ExJL5gVDPcpnP8kxFK.ipfs.dweb.link/", + "https://ipfs.io/ipfs/72700221014170434637310537764066371723775207774327464566205514134000113556045464703073645034432", # base8 + "https://ipfs.io/ipfs/92793123896416649578508430956173875066425468388805468715479907750778834469731416946970", # base10 + "https://ipfs.io/ipfs/mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka", # base64 "https://github.com/ipfs/js-ipfs/blob/master/README.md", "https://google.com", - "https://ipfs.com/ipfs/mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka", ], "ipns": [ + "https://ipfs.io/ipns/7134400044020004221001540013271734173336062236074334277475654673350146537613017606072454323070502526411463", # base8 + "https://ipfs.io/ipns/912059270899086145358701227151751949578967872728194642447008830239276889128468550643329311314739", # base10 + "https://ipfs.io/ipns/mAXIAJAgBEiAbAC1z3D23hknh43F/PdZu3QZq/iwfhh1LGmOKFVoTMw", # base64 "https://github.com/ipns/js-ipfs/blob/master/README.md", "https://google.com", ], }, "subdomain": { "ipfs": [ - "http://not-a-cid.ipfs.dweb.link", - "http://QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR.ipfs.dweb.link", # base58btc + "https://010111000000010010001000001100001111000100011100110011111011001000101011111111110100000110110011111001111010011111111101010000111111111100011010111100110100101110110010000101101001100001011100000000000001001011101101110000100101100110100111000011000111011110100101000011100100011010.ipfs.dweb.link", # base2 + "https://7002700221014170434637310537764066371723775207774327464566205514134000113556045464703073645034432.ipfs.dweb.link", # base8 + "https://92793123896416649578508430956173875066425468388805468715479907750778834469731416946970.ipfs.dweb.link/", # base10 + "https://f01701220c3c4733ec8affd06cf9e9ff50ffc6bcd2ec85a6170004bb709669c31de94391a.ipfs.dweb.link/", # base16 + "https://Qmb4sw3sqA7AZsaRZ7vtMwxCduk1ExJL5gVDPcpnP8kxFK.ipfs.dweb.link/", # base58btc CIDv0 + "http://QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR.ipfs.dweb.link", # base58btc CIDv0 "http://bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.dweb.link", - "http://QmcNioXSC1bfJj1dcFErhUfyjFzoX2HodkRccsFFVJJvg8.ipns.dweb.link", # base58btc - "http://bafybeiabc2xofh6tdi6vutusorpumwcikw3hf3st4ecjugo6j52f6xwc6q.dweb.link", + "http://QmcNioXSC1bfJj1dcFErhUfyjFzoX2HodkRccsFFVJJvg8.ipns.dweb.link", # base58btc CIDv0 + "http://bafybeiabc2xofh6tdi6vutusorpumwcikw3hf3st4ecjugo6j52f6xwc6q.dweb.link", # base32 with missing protocol + "https://zdj7Wic6KcJAfWz1c9o4M6kq9Lwd5BfbxkVafnrojaaGiSFxM.ipfs.dweb.link", # base58btc CIDv1 + "https://mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka.ipfs.dweb.link", # base64 + "http://not-a-cid.ipfs.dweb.link", "http://invalid-hostname-.ipns.dweb.link", "http://www.bafybeie5gq4jxvzmsym6hjlwxej4rwdoxt7wadqvmmwbqi7r27fclha2va.ipfs.dweb.link", "http://not-a-cid-or-valid-hostname-.ipns.dweb.link", - "https://zdj7Wic6KcJAfWz1c9o4M6kq9Lwd5BfbxkVafnrojaaGiSFxM.ipfs.dweb.link", # base58btc - "https://f01701220c3c4733ec8affd06cf9e9ff50ffc6bcd2ec85a6170004bb709669c31de94391a.ipfs.dweb.link/", # base16 - "https://7002700221014170434637310537764066371723775207774327464566205514134000113556045464703073645034432.ipfs.dweb.link", # base8 - "https://92793123896416649578508430956173875066425468388805468715479907750778834469731416946970.ipfs.dweb.link/", # base10 ], "ipns": [ "http://invalid-hostname-.ipns.dweb.link", - "https://01011100100000000000100100000010000000000100010010001000000111101000001011100011011101011001111000010001000000111011111010001000000101010010011110000100110011111101001001001011011000100011111110100100011111001101111010011000100110011101010111101110011011111101001100101010000010101010000010001010001000100110100001.ipns.dweb.link", # base2 - "https://7134400044020004221007501343353170210073721005223604637511133043764437157230463527563375145202520212104641.ipns.dweb.link", # base8 - "https://912059270899086145401691048311030210264811084458175133533758497185539793968955433089799685704097.ipns.dweb.link", # base10 - "https://f01720024080112207a0b8dd678440efa20549e133f492d88fe91f37a626757b9bf4ca82a822889a1.ipns.dweb.link", # base16 - "https://bafzaajaiaejca6qlrxlhqrao7iqfjhqth5es3ch6shzxuythk6436tfifkbcrcnb.ipns.dweb.link", # base32 - "https://v05p0090804920ugbhnb7gh0ev8g597gj7t4ir27ui7pnkoj7ausruj585a12h2d1.ipns.dweb.link", # base32hex - "https://Z5azMnuicXMo3NdactTr8XzcdoRMPQUyAPfy3Pt83kU8iZprfMNCMTx.ipns.dweb.link", # base58flickr + "https://01011100100000000000100100000010000000000100010010001000000001101100000000001011010111001111011100001111011011011110000110010010011110000111100011011100010111111100111101110101100110111011011101000001100110101011111110001011000001111110000110000111010100101100011010011000111000101000010101010110100001001100110011.ipns.dweb.link", # base2 + "https://7134400044020004221001540013271734173336062236074334277475654673350146537613017606072454323070502526411463.ipns.dweb.link", # base8 + "https://7134400044020004221001540013271734173336062236074334277475654673350146537613017606072454323070502526411463.ipns.dweb.link", # base10 + "https://f01720024080112201b002d73dc3db78649e1e3717f3dd66edd066afe2c1f861d4b1a638a155a1333.ipns.dweb.link", # base16 + "https://bafzaajaiaejcagyafvz5ypnxqze6dy3rp465m3w5azvp4la7qyouwgtdrikvuezt.ipns.dweb.link", # base32 + "http://bafybeiabc2xofh6tdi6vutusorpumwcikw3hf3st4ecjugo6j52f6xwc6q.ipns.dweb.link", # base32 + "https://v05p00908049206o05lptofdngp4u3orhfsutcrmt0plfsb0vgoekm6j3h8alk4pj.ipns.dweb.link", # base32hex + "https://Z5azMnuicXMgDMqbtbwJiQHydfF5kzhqYommSLcxq57AXAbA8SFnxoB.ipns.dweb.link", # base58flickr "https://z5AanNVJCxnP3oDACUtS8xaCDPrnpquZbpFZ3pU83Lu8JzQSFnodntY.ipns.dweb.link" # base58btc CIDv1 "http://QmcNioXSC1bfJj1dcFErhUfyjFzoX2HodkRccsFFVJJvg8.ipns.dweb.link", # base58btc CIDv0 "https://mAXIAJAgBEiB6C43WeEQO+iBUnhM/SS2I/pHzemJnV7m/TKgqgiiJoQ.ipns.dweb.link", # base64 - "https://uAXIAJAgBEiB6C43WeEQO-iBUnhM_SS2I_pHzemJnV7m_TKgqgiiJoQ.ipns.dweb.link", # base64url - "http://bafybeiabc2xofh6tdi6vutusorpumwcikw3hf3st4ecjugo6j52f6xwc6q.ipns.dweb.link", # base32 + "https://uAXIAJAgBEiAbAC1z3D23hknh43F_PdZu3QZq_iwfhh1LGmOKFVoTMw.ipns.dweb.link", # base64url ], }, "path": { "ipfs": [ + "/ipfs/72700221014170434637310537764066371723775207774327464566205514134000113556045464703073645034432", # base8 + "/ipfs/92793123896416649578508430956173875066425468388805468715479907750778834469731416946970", # base10 + "/ipfs/mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka", # base64 "/ipfs/js-ipfs/blob/master/README.md", "/ipfs/QmcNioXSC1bfJj1dcFErhUfyjFzoX2HodkRccsFFVJJvg8.ipns.dweb.link", "ipfs/QmeWz9YZEeNFXQhHg4PnR5ZiNr5isttgi5n1tc1eD5EfGU" @@ -219,32 +265,38 @@ "/ipfs/1234", ], "ipns": [ + "/ipns/7134400044020004221001540013271734173336062236074334277475654673350146537613017606072454323070502526411463", # base8 + "/ipns/912059270899086145358701227151751949578967872728194642447008830239276889128468550643329311314739", # base10 + "/ipns/mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka", # base64 "/ipns/qmbwqxbekC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR", "/ipfs/js-ipfs/blob/master/README.md", "/ipns/en-wikipedia--on--ipfs-org/", "/foo.bar", "/ipns/1234", - "/ipns/mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka", + "/ipns/", ], }, "native_url": { "ipfs": [ + "ipfs://72700221014170434637310537764066371723775207774327464566205514134000113556045464703073645034432", # base8 + "ipfs://92793123896416649578508430956173875066425468388805468715479907750778834469731416946970", # base10 + "ipfs://mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka", # base64 "ipfs://js-ipfs/blob/master/README.md", "ipfs://QmcNioXSC1bfJj1dcFErhUfyjFzoX2HodkRccsFFVJJvg8.ipns.dweb.link", - "ipfs://QmeWz9YZEeNFXQhHg4PnR5ZiNr5isttgi5n1tc1eD5EfGU" "ipfs://foo/QmeWz9YZEeNFXQhHg4PnR5ZiNr5isttgi5n1tc1eD5EfGU", "foo://bar", "ipfs:/mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka", "ipfs://1234", ], "ipns": [ - "ipns://bafzaajaiaejca6qlrxlhqrao7iqfjhqth5es3ch6shzxuythk6436tfifkbcrcnb", + "ipns://7134400044020004221001540013271734173336062236074334277475654673350146537613017606072454323070502526411463", # base8 + "ipns://912059270899086145358701227151751949578967872728194642447008830239276889128468550643329311314739", # base10 + "ipns://mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka", # base64 "ipns://qmbwqxbekC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR", "ipfs://js-ipfs/blob/master/README.md", "ipns://en-wikipedia--on--ipfs-org/", "foo://bar", - "ipns:///1234", - "ipns:///mAXASIMPEcz7Ir/0Gz56f9Q/8a80uyFphcABLtwlmnDHelDka", + "ipns://1234", ], }, } diff --git a/tests/unit/test_is_cid.py b/tests/unit/test_is_cid.py index 4f23b68..f7d250e 100644 --- a/tests/unit/test_is_cid.py +++ b/tests/unit/test_is_cid.py @@ -7,20 +7,14 @@ class TestCase(unittest.TestCase): def test_is_cid(self): with self.subTest("Test valid CID entries from testing data"): - for key, value in testing_data.valid_entries["cid"].items(): + for value in testing_data.valid_entries["cid"].values(): for entry in value: - result = Validator(entry)._is_cid() - self.assertIsInstance(result, bool) - self.assertTrue(result) + self.assertTrue(Validator(entry)._is_cid(), entry) with self.subTest("Test invalid CID entries from testing data"): - for key, value in testing_data.invalid_entries["cid"].items(): + for value in testing_data.invalid_entries["cid"].values(): for entry in value: - result = Validator(entry)._is_cid() - if result is None: - print(entry) - self.assertIsInstance(result, bool) - self.assertFalse(result) + self.assertFalse(Validator(entry)._is_cid(), entry) if __name__ == "__main__": # pragma: no cover diff --git a/tests/unit/test_native_url.py b/tests/unit/test_native_url.py index e3c6149..ff4a15b 100644 --- a/tests/unit/test_native_url.py +++ b/tests/unit/test_native_url.py @@ -8,19 +8,19 @@ class TestCase(unittest.TestCase): def test_native_url(self): with self.subTest("Test valid IPFS native URL entries from fixtures"): for entry in testing_data.valid_entries["native_url"]["ipfs"]: - self.assertTrue(Validator(entry)._is_native_ipfs_url()) + self.assertTrue(Validator(entry)._is_native_ipfs_url(), entry) with self.subTest("Test invalid IPFS native URL entries from fixtures"): for entry in testing_data.invalid_entries["native_url"]["ipfs"]: - self.assertFalse(Validator(entry)._is_native_ipfs_url()) + self.assertFalse(Validator(entry)._is_native_ipfs_url(), entry) with self.subTest("Test valid IPNS native URL entries from fixtures"): for entry in testing_data.valid_entries["native_url"]["ipns"]: - self.assertTrue(Validator(entry)._is_native_ipns_url()) + self.assertTrue(Validator(entry)._is_native_ipns_url(), entry) with self.subTest("Test invalid IPNS native URL from fixtures"): for entry in testing_data.invalid_entries["native_url"]["ipns"]: - self.assertFalse(Validator(entry)._is_native_ipns_url()) + self.assertFalse(Validator(entry)._is_native_ipns_url(), entry) if __name__ == "__main__": # pragma: no cover diff --git a/tests/unit/test_path.py b/tests/unit/test_path.py index b90f234..027aa09 100644 --- a/tests/unit/test_path.py +++ b/tests/unit/test_path.py @@ -8,19 +8,19 @@ class TestCase(unittest.TestCase): def tests_is_ipfs_path(self): with self.subTest("Test valid IPFS path entries from fixtures"): for entry in testing_data.valid_entries["path"]["ipfs"]: - self.assertTrue(Validator(entry)._is_ipfs_path()) + self.assertTrue(Validator(entry)._is_ipfs_path(), entry) with self.subTest("Test invalid IPFS path entries from fixtures"): for entry in testing_data.invalid_entries["path"]["ipfs"]: - self.assertFalse(Validator(entry)._is_ipfs_path()) + self.assertFalse(Validator(entry)._is_ipfs_path(), entry) with self.subTest("Test valid IPNS path entries from fixtures"): for entry in testing_data.valid_entries["path"]["ipns"]: - self.assertTrue(Validator(entry)._is_ipns_path()) + self.assertTrue(Validator(entry)._is_ipns_path(), entry) with self.subTest("Test invalid IPNS path entries from fixtures"): for entry in testing_data.invalid_entries["path"]["ipns"]: - self.assertFalse(Validator(entry)._is_ipns_path()) + self.assertFalse(Validator(entry)._is_ipns_path(), entry) if __name__ == "__main__": # pragma: no cover diff --git a/tests/unit/test_subdomain.py b/tests/unit/test_subdomain.py index 3b52a30..86889cf 100644 --- a/tests/unit/test_subdomain.py +++ b/tests/unit/test_subdomain.py @@ -8,19 +8,19 @@ class TestCase(unittest.TestCase): def test_ipfs_subdomain(self): with self.subTest("Test valid IPFS subdomain entries from fixtures"): for entry in testing_data.valid_entries["subdomain"]["ipfs"]: - self.assertTrue(Validator(entry)._ipfs_subdomain_url()) + self.assertTrue(Validator(entry)._is_ipfs_subdomain_url(), entry) with self.subTest("Test invalid IPFS subdomain entries from fixtures"): for entry in testing_data.invalid_entries["subdomain"]["ipfs"]: - self.assertFalse(Validator(entry)._ipfs_subdomain_url()) + self.assertFalse(Validator(entry)._is_ipfs_subdomain_url(), entry) with self.subTest("Test valid IPNS subdomain entries from fixtures"): for entry in testing_data.valid_entries["subdomain"]["ipns"]: - self.assertTrue(Validator(entry)._ipns_subdomain_url()) + self.assertTrue(Validator(entry)._is_ipns_subdomain_url(), entry) with self.subTest("Test invalid IPNS URL subdomain from fixtures"): for entry in testing_data.invalid_entries["subdomain"]["ipns"]: - self.assertFalse(Validator(entry)._ipns_subdomain_url()) + self.assertFalse(Validator(entry)._is_ipns_subdomain_url(), entry) if __name__ == "__main__": # pragma: no cover diff --git a/tests/unit/test_url.py b/tests/unit/test_url.py index 8a161cf..a4bafc0 100644 --- a/tests/unit/test_url.py +++ b/tests/unit/test_url.py @@ -8,19 +8,19 @@ class TestCase(unittest.TestCase): def test_ipfs_url(self): with self.subTest("Test valid IPFS URL entries from fixtures"): for entry in testing_data.valid_entries["url"]["ipfs"]: - self.assertTrue(Validator(entry)._is_ipfs_url()) + self.assertTrue(Validator(entry)._is_ipfs_url(), entry) with self.subTest("Test invalid IPFS URL entries from fixtures"): for entry in testing_data.invalid_entries["url"]["ipfs"]: - self.assertFalse(Validator(entry)._is_ipfs_url()) + self.assertFalse(Validator(entry)._is_ipfs_url(), entry) with self.subTest("Test valid IPNS URL entries from fixtures"): for entry in testing_data.valid_entries["url"]["ipns"]: - self.assertTrue(Validator(entry)._is_ipns_url()) + self.assertTrue(Validator(entry)._is_ipns_url(), entry) with self.subTest("Test invalid IPNS URL entries from fixtures"): for entry in testing_data.invalid_entries["url"]["ipns"]: - self.assertFalse(Validator(entry)._is_ipns_url()) + self.assertFalse(Validator(entry)._is_ipns_url(), entry) if __name__ == "__main__": # pragma: no cover