Пример #1
0
    def test_send_reply(self, smtpserver, bcmd, ac_sender, with_ac, linematch):
        host, port = smtpserver.addr[:2]
        Autocrypt = None if not with_ac else ac_sender.ac_headerval
        msg = mime.gen_mail_msg(
            From=ac_sender.adr, To=[bcmd.bot_adr],
            MessageID=mime.make_msgid("5" * 50),  # long MessageID
            Autocrypt=Autocrypt, Subject="hello", _dto=True)

        bcmd.run_ok(["bot-reply", "--smtp={},{}".format(host, port)],
                    input=msg.as_string())

        assert len(smtpserver.outbox) == 1
        msg2 = smtpserver.outbox[0]
        assert msg2["To"] == msg["From"]
        assert msg2["From"] == msg["To"]
        assert msg2["In-Reply-To"] == msg["Message-ID"]
        assert msg["Subject"] in msg2["Subject"]
        body = decode_body(msg2)
        linematch(body, """
            *Got your mail*
            *Message-ID*{}*
        """.format(msg["Message-ID"][:20]))
        if with_ac:
            linematch(body, """
                *processed incoming*
                *{senderadr}*{senderkeyhandle}*
            """.format(
                senderadr=mime.parse_email_addr(ac_sender.adr),
                senderkeyhandle=ac_sender.ownstate.keyhandle,
            ))
Пример #2
0
    def process_incoming_gossip(self, addr2pagh, account_key, dec_msg):
        sender_addr = parse_email_addr(dec_msg["From"])
        root_hash = dec_msg["GossipClaims"]
        store_url = dec_msg["ClaimStore"]
        if not root_hash or not store_url:
            # this peer has no CC support
            return
        self.register_peer(sender_addr, root_hash, store_url)

        peers_chain = self.get_chain(store_url, root_hash)
        recipients = get_target_emailadr(dec_msg)
        for addr in recipients:
            pagh = addr2pagh[addr]
            self.verify_claim(peers_chain, addr, pagh.keydata)
            value = self.read_claim(addr, chain=peers_chain)
            if value and value.get('store_url'):
                self.register_peer(addr, value['root_hash'],
                                   value['store_url'])
Пример #3
0
 def process_incoming_gossip(self, addr2pagh, account_key, dec_msg):
     root_hash = dec_msg["GossipClaims"]
     store = FileStore(dec_msg["ChainStore"])
     peers_chain = Chain(store, root_hash=ascii2bytes(root_hash))
     assert peers_chain
     view = View(peers_chain)
     peers_pk = view.params.dh.pk
     assert peers_pk
     sender = parse_email_addr(dec_msg["From"])
     self.addr2root_hash[sender] = root_hash
     self.addr2pk[sender] = peers_pk
     recipients = get_target_emailadr(dec_msg)
     for recipient in recipients:
         pagh = addr2pagh[recipient]
         value = self.read_claim_from(peers_chain, recipient)
         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)
Пример #4
0
def test_parse_email_addr(input, output):
    addr = mime.parse_email_addr(input)
    assert isinstance(addr, six.text_type)
    assert addr == output