Exemplo n.º 1
0
    def test_simple_dont_replace(self, mycmd, gen_mail):
        mycmd.run_ok(["init"])
        mail = gen_mail()
        gen_header = mycmd.run_ok(["make-header", "*****@*****.**"])
        mail.add_header("Autocrypt", gen_header)

        out1 = mycmd.run_ok(["process-outgoing"], input=mail.as_string())
        m = mime.parse_message_from_string(out1)
        assert len(m.get_all("Autocrypt")) == 1
        x1 = mime.parse_ac_headervalue(m["Autocrypt"])
        x2 = mime.parse_ac_headervalue(gen_header)
        assert x1 == x2
Exemplo n.º 2
0
def test_make_and_parse_header_errors():
    addr, keydata = "[email protected]", "123"
    h = mime.make_ac_header_value(addr=addr,
                                  keydata=keydata,
                                  prefer_encrypt="nopreference",
                                  keytype="9")
    assert "prefer-encrypt" not in h, h
    d = mime.parse_ac_headervalue(h)
    assert "unknown key type" in mime.verify_ac_dict(d)[0]
    assert d == make_ac_dict(addr=addr, keydata=keydata, type="9")
Exemplo n.º 3
0
    def test_reply_with_autocrypt(self, bcmd, ac_sender, linematch):
        send_adr = ac_sender.adr
        msg = mime.gen_mail_msg(
            From=send_adr, To=[bcmd.bot_adr],
            Autocrypt=ac_sender.ac_headerval,
            Subject="hello", _dto=True)

        out = bcmd.run_ok(["bot-reply"], input=msg.as_string())

        reply_msg = mime.parse_message_from_string(out)
        linematch(decode_body(reply_msg), """
            *processed*identity*default*
        """)
        assert reply_msg["Subject"] == "Re: " + msg["Subject"]
        assert reply_msg["From"] == bcmd.bot_adr
        assert reply_msg["To"] == msg["From"]
        assert reply_msg["Autocrypt"]
        ac_dict = mime.parse_ac_headervalue(reply_msg["Autocrypt"])
        assert ac_dict["to"] == bcmd.bot_adr
        assert ac_dict["key"]
        body = decode_body(reply_msg)
        assert "no Autocrypt header" not in body
        print(body)
Exemplo n.º 4
0
def test_make_and_parse_header_value():
    addr, keydata = "[email protected]", "123"
    h = mime.make_ac_header_value(addr=addr, keydata=keydata)
    d = mime.parse_ac_headervalue(h)
    assert not mime.verify_ac_dict(d)
    assert d == make_ac_dict(addr=addr, keydata=keydata)