def testHashFragment(self): self.assertEqual(ARCP + "#frag", generate.arcp_hash(BYTES, fragment="frag"))
def testHashPathQueryFragment(self): self.assertEqual( ARCP + "bin/evil?a=b&c=d#frag", generate.arcp_hash(BYTES, "/bin/evil", "a=b&c=d", "frag"))
def testHashPath(self): self.assertEqual(ARCP + "bin/evil", generate.arcp_hash(BYTES, "/bin/evil"))
def testHashQuery(self): self.assertEqual(ARCP + "?q=a", generate.arcp_hash(BYTES, query="q=a"))
def testHash(self): # Using "Hello World!" example # instead of a real archive file self.assertEqual(ARCP, generate.arcp_hash(BYTES))
def testHashWrongHash(self): h = md5(BYTES) with self.assertRaises(Exception): generate.arcp_hash(hash=h)
def testHashPathPremadeHash(self): h = sha256(BYTES) self.assertEqual(ARCP + "bin/evil", generate.arcp_hash(path="bin/evil", hash=h))
def testHashPathEmptyHash(self): h = sha256() self.assertEqual(ARCP + "bin/evil", generate.arcp_hash(BYTES, "bin/evil", hash=h))
def testHashHash(self): h = sha256(BYTES) self.assertEqual(ARCP, generate.arcp_hash(hash=h))