piknik

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit 4c8ced04e6bacd5f6ae2ac8a8adda9c51544432c
parent 6cdb76451876b1b46fe59aa8e422c2e9ab449d22
Author: lash <dev@holbrook.no>
Date:   Wed,  9 Nov 2022 15:53:23 +0000

Move basket signature outside all parts

Diffstat:
Mpiknik/crypto.py | 5+++++
Mpiknik/msg.py | 4++--
Mtests/test_crypto.py | 20+++++++++++++++-----
Mtests/test_store.py | 4++++
4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/piknik/crypto.py b/piknik/crypto.py @@ -17,6 +17,7 @@ class PGPSigner: m = Message() v = msg.as_string() m.set_type('multipart/relative') + m.add_header('X-Piknik-Envelope', 'pgp') ms = Message() ms.set_type('application/pgp-signature') fn = '{}.asc'.format(msg.get('X-Piknik-Msg-Id')) @@ -29,3 +30,7 @@ class PGPSigner: m.attach(ms) return m + + + def verify(self, msg, sig): # msg = IssueMessage object + pass diff --git a/piknik/msg.py b/piknik/msg.py @@ -83,9 +83,9 @@ class IssueMessage: r = self.from_file(v) elif p == 's:': r = self.from_text(v) - if wrapper: - r = wrapper(r) m.attach(r) + if wrapper: + m = wrapper(m) self.__m.attach(m) diff --git a/tests/test_crypto.py b/tests/test_crypto.py @@ -40,14 +40,25 @@ class TestMsg(unittest.TestCase): def tearDown(self): shutil.rmtree(self.gpg_dir) + def test_wrap_sig(self): m = Message() - m.set_charset('utf-8') - m.set_payload('foo') + m.set_type('multipart/mixed') + m.set_payload(None) + + one = Message() + one.set_charset('utf-8') + one.set_payload('foo') + m.attach(one) + + two = Message() + two.set_charset('utf-8') + two.set_payload('bar') + m.attach(two) + v = m.as_string() m = self.crypto.sign(m, passphrase='foo') - print('msg {}'.format(v)) for p in m.walk(): if p.get_content_type() == 'application/pgp-signature': sig = p.get_payload() @@ -62,6 +73,7 @@ class TestMsg(unittest.TestCase): break + # TODO: assert def test_wrap_basket_sig(self): o = Issue('foo') v = self.b.add(o) @@ -69,7 +81,5 @@ class TestMsg(unittest.TestCase): print(r) - - if __name__ == '__main__': unittest.main() diff --git a/tests/test_store.py b/tests/test_store.py @@ -42,11 +42,13 @@ class TestStore(unittest.TestCase): pass + # TODO: assert def test_basic(self): o = Issue('foo') v = self.b.add(o) + # TODO: assert def test_load(self): o = Issue('foo') va = self.b.add(o) @@ -78,12 +80,14 @@ class TestStore(unittest.TestCase): self.assertIn('PINKY', r) + # TODO: assert def test_msg_putget(self): o = Issue('foo') issue_id = self.b.add(o) m = self.b.msg(issue_id, 's:bar') + # TODO: assert def test_msg_resume(self): o = Issue('foo') v = self.b.add(o)