def test_marshalls_untrusted_signatures(self): gref = Gref(self.repo, "testchannel", "test_untrusted_signature") adaptor = RSAAdaptor({"valid": crypto_fixture.passphrase_pubkey}) private_adaptor = RSAPrivateAdaptor(crypto_fixture.valid_key) root = root_object("test", "test_channel", "test") root_oid = self.repo.create_blob(root.as_object()) update = update_object("test object", [root_oid]) update_oid = self.repo.create_blob(update.as_object()) gref.write_tip(update_oid, private_adaptor.sign(update_oid)) marshalled = gref.marshall(crypto_adaptor=adaptor) self.assertFalse(marshalled["signatures"][update_oid])
def get_crypto_adaptor(self): return RSAAdaptor(self.store.get_public_keys())
def test_returns_false_for_unverified_data(self): adaptor = RSAAdaptor({"key1": crypto_fixture.passphrase_pubkey}) self.assertFalse(adaptor.verify( crypto_fixture.sample_data, crypto_fixture.signatures["sample_data"]["valid_key"] ))
def test_verifies_data(self): adaptor = RSAAdaptor({"key1": crypto_fixture.valid_pubkey}) self.assertEqual("key1", adaptor.verify( crypto_fixture.sample_data, crypto_fixture.signatures["sample_data"]["valid_key"] ))