def test_simple(self, mycmd, gen_mail): mycmd.run_ok(["init"]) mail = gen_mail() out1 = mycmd.run_ok(["process-outgoing"], input=mail.as_string()) m = mime.parse_message_from_string(out1) assert len(m.get_all("Autocrypt")) == 1 found_header = "Autocrypt: " + m["Autocrypt"] gen_header = mycmd.run_ok(["make-header", "*****@*****.**"]) x1 = mime.parse_one_ac_header_from_string(gen_header) x2 = mime.parse_one_ac_header_from_string(found_header) assert x1 == x2
def test_init_and_make_header(mycmd): mycmd.run_fail(["make-header", "xyz"], """ *Account*not initialized* """) adr = "*****@*****.**" mycmd.run_ok(["init"]) out = mycmd.run_ok(["make-header", adr]) d = mime.parse_one_ac_header_from_string(out) assert "prefer-encrypt" not in out assert "type" not in out assert d["to"] == adr out2 = mycmd.run_ok(["make-header", adr]) assert out == out2
def test_account_header_defaults(account_maker): account = account_maker(init=False) addr = "*****@*****.**" with pytest.raises(NotInitialized): account.make_header(addr) account.init() ident = account.add_identity() assert ident.config.gpgmode == "own" h = account.make_header(addr) d = mime.parse_one_ac_header_from_string(h) assert d["addr"] == addr key = ident.bingpg.get_public_keydata(ident.config.own_keyhandle, b64=True) assert d["keydata"] == key assert d["prefer-encrypt"] == "nopreference" assert d["type"] == "1"
def test_account_set_prefer_encrypt_and_header(self, account_maker, pref): account = account_maker() addr = "*****@*****.**" ident = account.get_identity() with pytest.raises(ValueError): ident.modify(prefer_encrypt="random") with pytest.raises(ValueError): account.mod_identity(ident.config.name, prefer_encrypt="random") account.mod_identity(ident.config.name, prefer_encrypt=pref) h = account.make_header(addr) d = mime.parse_one_ac_header_from_string(h) assert d["addr"] == addr key = ident.bingpg.get_public_keydata(ident.config.own_keyhandle, b64=True) assert d["keydata"] == key assert d["prefer-encrypt"] == pref assert d["type"] == "1"