From: W. Trevor King Date: Sat, 1 Sep 2012 00:51:04 +0000 (-0400) Subject: mailpipe: add .authenticated attribute to _get_verified_message results. X-Git-Tag: v0.3~48 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8cc7b76b69885b81f81955d900101dc42121b73e;p=pygrader.git 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. --- 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