commit 6738c8897697d5559eebd4d147ba9fc8ff367696
parent 0d1d11b94be1fd98aaa2ccc23ab9fca85f5bb1a2
Author: lash <dev@holbrook.no>
Date: Fri, 2 Dec 2022 12:03:23 +0000
Rehabilitate crypto test
Diffstat:
5 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/piknik/crypto.py b/piknik/crypto.py
@@ -70,7 +70,7 @@ class PGPSigner(Wrapper):
return self.envelope
- def process_message(self, envelope, msg, message_id, message_date):
+ def process_message(self, msg, message_id, message_date):
if msg.get('From') != None:
self.envelope.sender = msg.get('From')
diff --git a/piknik/render/base.py b/piknik/render/base.py
@@ -89,7 +89,7 @@ class Renderer:
logg.warning('no wrapper defined. no message parts will be output {}'.format(message))
return (envelope, message,)
- (envelope, message) = self.w.process_message(envelope, message, message_id, message_date)
+ (envelope, message) = self.w.process_message(message, message_id, message_date)
initial = True
while True:
diff --git a/piknik/wrap.py b/piknik/wrap.py
@@ -25,10 +25,10 @@ class Wrapper:
self.envelope_state = 0
- def process_message(self, envelope, msg, message_id, message_date):
+ def process_message(self, msg, message_id, message_date):
if msg.get('X-Piknik-Msg-Id') == None:
- self.add(envelope, message_id, msg)
- return (envelope, msg,)
+ self.add(self.envelope, message_id, msg)
+ return (self.envelope, msg,)
#raise NotImplementedError()
diff --git a/tests/test_crypto.py b/tests/test_crypto.py
@@ -10,6 +10,7 @@ from email.message import Message
from piknik import Basket
from piknik import Issue
from piknik.msg import IssueMessage
+from piknik.msg import MessageEnvelope
# test imports
from tests.common import TestStates
@@ -51,7 +52,9 @@ class TestMsg(unittest.TestCase):
o = Issue('foo')
m = self.crypto.sign(m, passphrase='foo')
- r = IssueMessage.parse(o, str(m), envelope_callback=self.crypto.envelope_callback, message_callback=self.crypto.message_callback)
+ self.crypto.envelope = MessageEnvelope(m)
+ self.crypto.envelope_state = 0
+ r = IssueMessage.parse(o, str(m), envelope_callback=self.crypto.process_envelope, message_callback=self.crypto.process_message)
def test_wrap_double_sig(self):
@@ -95,9 +98,9 @@ class TestMsg(unittest.TestCase):
m = self.crypto.sign(m, passphrase='foo')
mp.attach(m)
- self.crypto.envelope_callback(mp, 'pgp')
- r = self.crypto.message_callback(mp, m, 'foo')
- r = self.crypto.message_callback(mp, m, 'bar')
+ self.crypto.process_envelope(mp, 'pgp')
+ r = self.crypto.process_message(mp, m, 'foo')
+ r = self.crypto.process_message(mp, m, 'bar')
# TODO: assert
diff --git a/tests/test_render.py b/tests/test_render.py
@@ -58,7 +58,6 @@ class TestRenderer(Renderer):
return r
-# def apply_message(self, state, issue, tags, envelope, message, message_id, message_date, accumulator=None):
def apply_message_part(self, state, issue, tags, envelope, message, message_date, message_content, accumulator=None):
r = self.p
self.p += 1