Skip to content

Commit

Permalink
use dicts as claim values
Browse files Browse the repository at this point in the history
  • Loading branch information
azul committed Apr 11, 2018
1 parent f46def6 commit c1243f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions muacryptcc/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit c1243f0

Please sign in to comment.