示例#1
0
def test_encrypt_decrypt(gpg, msg):
    orig_body = msg.get_payload()

    msg = gpg.encrypt_email(msg, recipients="*****@*****.**")
    assert gpgmime.is_encrypted(msg)

    msg, decrypted = gpg.decrypt_email(msg)
    assert decrypted

    # We really ought to check as much of the headers as we can, but it's a bit
    # tricky to make sure they're textually *identical*. Let's at least check
    # that the body comes out right:
    assert msg.get_payload() == orig_body
示例#2
0
    def test_sign_then_encrypt(self, gpg, msg):
        msg_text = msg.as_string()

        signed = gpg.sign_email(msg, keyid="*****@*****.**", passphrase="secret")
        assert gpgmime.is_signed(signed)

        assert msg.as_string() == msg_text
        signed_text = signed.as_string()

        encrypted = gpg.encrypt_email(signed, recipients="*****@*****.**")
        assert gpgmime.is_encrypted(encrypted)
        assert not gpgmime.is_signed(encrypted)

        assert signed.as_string() == signed_text

        logger.debug("two-step output: %r", encrypted.as_string())