From c1243f054eb32a5fa21e6d44c9503189a0530424 Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 11 Apr 2018 13:29:13 +0200 Subject: [PATCH] use dicts as claim values --- muacryptcc/plugin.py | 9 ++++++--- tests/test_functional.py | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/muacryptcc/plugin.py b/muacryptcc/plugin.py index 04f7f92..c2ec5b4 100644 --- a/muacryptcc/plugin.py +++ b/muacryptcc/plugin.py @@ -55,7 +55,7 @@ def process_incoming_gossip(self, addr2pagh, account_key, dec_msg): if value: # for now we can only read claims about ourselves... # so if we get a value it must be our head imprint. - assert value == bytes2ascii(pagh.keydata) + assert value['key'] == bytes2ascii(pagh.keydata) @hookimpl def process_before_encryption(self, sender_addr, sender_keyhandle, @@ -65,10 +65,13 @@ def process_before_encryption(self, sender_addr, sender_keyhandle, logging.error("no recipients found.\n") for recipient in recipients: - claim = recipient, bytes2ascii(recipient2keydata.get(recipient)) + key = recipient + value = dict( + key=bytes2ascii(recipient2keydata.get(recipient)) + ) for reader in recipients: pk = self.addr2pk.get(reader) - self.add_claim(claim, access_pk=pk) + self.add_claim((key, value), access_pk=pk) self.commit_to_chain() payload_msg["GossipClaims"] = self.head_imprint diff --git a/tests/test_functional.py b/tests/test_functional.py index 7d880ef..743cb31 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -35,7 +35,8 @@ def test_claims_contain_keys(account_maker): cc2, ac2 = get_cc_and_ac(send_encrypted_mail(acc2, acc1)) cc1, ac1 = get_cc_and_ac(send_encrypted_mail(acc1, acc2)) - assert cc1.read_claim(acc2.addr, reader=cc2) == bytes2ascii(ac2.keydata) + data = cc1.read_claim(acc2.addr, reader=cc2) + assert data['key'] == bytes2ascii(ac2.keydata) def test_gossip_claims(account_maker): @@ -47,7 +48,8 @@ def test_gossip_claims(account_maker): cc3, ac3 = get_cc_and_ac(send_encrypted_mail(acc3, acc1)) cc1, ac1 = get_cc_and_ac(send_encrypted_mail(acc1, [acc2, acc3])) - assert cc1.read_claim(acc3.addr, reader=cc2) == bytes2ascii(ac3.keydata) + data = cc1.read_claim(acc3.addr, reader=cc2) + assert data['key'] == bytes2ascii(ac3.keydata) # send a mail from acc1 with autocrypt key to acc2