MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / testVerifyUnsafePattern

Method testVerifyUnsafePattern

src/Test/TestContent.py:237–248  ·  view source on GitHub ↗
(self, site, crypt_bitcoin_lib)

Source from the content-addressed store, hash-verified

235
236
237 def testVerifyUnsafePattern(self, site, crypt_bitcoin_lib):
238 site.content_manager.contents["content.json"]["includes"]["data/test_include/content.json"]["files_allowed"] = "([a-zA-Z]+)*"
239 with pytest.raises(UnsafePatternError) as err:
240 with site.storage.open("data/test_include/content.json") as data:
241 site.content_manager.verifyFile("data/test_include/content.json", data, ignore_same=False)
242 assert "Potentially unsafe" in str(err.value)
243
244 site.content_manager.contents["data/users/content.json"]["user_contents"]["permission_rules"]["([a-zA-Z]+)*"] = {"max_size": 0}
245 with pytest.raises(UnsafePatternError) as err:
246 with site.storage.open("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json") as data:
247 site.content_manager.verifyFile("data/users/1C5sgvWaSgfaTpV5kjBCnCiKtENNMYo69q/content.json", data, ignore_same=False)
248 assert "Potentially unsafe" in str(err.value)

Callers

nothing calls this directly

Calls 2

openMethod · 0.80
verifyFileMethod · 0.45

Tested by

no test coverage detected