示例#1
0
 def test_malformed_item(self):
     """
     Does not contain the expected _p4p2p metadata.
     """
     item = {
         'foo': 'bar',
         'baz': [1, 2, 3]
     }
     self.assertFalse(verify_item(item))
示例#2
0
 def test_signed_item_is_verifiable(self):
     """
     Check that the resulting item is able to be verified.
     """
     item = {
         'foo': 'bar',
         'baz': [1, 2, 3]
     }
     signed_item = get_signed_item(item, PUBLIC_KEY, PRIVATE_KEY)
     self.assertTrue(verify_item(signed_item))
示例#3
0
 def test_good_item(self):
     """
     The good case should pass.
     """
     item = {
         'foo': 'bar',
         'baz': [1, 2, 3]
     }
     signed_item = get_signed_item(item, PUBLIC_KEY, PRIVATE_KEY)
     self.assertTrue(verify_item(signed_item))
示例#4
0
 def test_modified_item(self):
     """
     The content of the item does not match the hash / signature.
     """
     item = {
         'foo': 'bar',
         'baz': [1, 2, 3]
     }
     signed_item = get_signed_item(item, PUBLIC_KEY, PRIVATE_KEY)
     signed_item['_p4p2p']['public_key'] = BAD_PUBLIC_KEY
     self.assertFalse(verify_item(item))