From 8cc7b76b69885b81f81955d900101dc42121b73e Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 31 Aug 2012 20:51:04 -0400 Subject: [PATCH] mailpipe: add .authenticated attribute to _get_verified_message results. This will allow message handlers to easily determine if the message they're processing is from an authenticated user. --- pygrader/mailpipe.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pygrader/mailpipe.py b/pygrader/mailpipe.py index 5b18de8..f32c151 100644 --- a/pygrader/mailpipe.py +++ b/pygrader/mailpipe.py @@ -808,6 +808,10 @@ def _get_verified_message(message, pgp_key, use_color=None): We check that the message is signed, and that it is signed by the appropriate key. + >>> signed.authenticated + Traceback (most recent call last): + ... + AttributeError: 'MIMEMultipart' object has no attribute 'authenticated' >>> our_message = _get_verified_message(signed, pgp_key='4332B6E3') >>> print(our_message.as_string()) # doctest: +REPORT_UDIFF Content-Type: text/plain; charset="us-ascii" @@ -819,6 +823,8 @@ def _get_verified_message(message, pgp_key, use_color=None): Received: from smtp.home.net ... 1.23 joules + >>> our_message.authenticated + True If it is signed, but not by the right key, we get ``None``. @@ -869,4 +875,5 @@ def _get_verified_message(message, pgp_key, use_color=None): 'content-disposition', ]: decrypted[k] = v + decrypted.authenticated = True return decrypted -- 2.26.2