diff options
| author | J08nY | 2017-06-22 20:23:37 +0200 |
|---|---|---|
| committer | J08nY | 2017-06-22 20:23:37 +0200 |
| commit | 35f73955ab03c65936aad59511d92d87f645e3ea (patch) | |
| tree | 22fe38f1444750d9149bdf09057cde4d4534625a /src/mailman_pgp/pgp/tests/test_wrapper.py | |
| parent | 263577d4826630e6871b35c73fe3dd114ee70e22 (diff) | |
| download | mailman-pgp-35f73955ab03c65936aad59511d92d87f645e3ea.tar.gz mailman-pgp-35f73955ab03c65936aad59511d92d87f645e3ea.tar.zst mailman-pgp-35f73955ab03c65936aad59511d92d87f645e3ea.zip | |
Diffstat (limited to 'src/mailman_pgp/pgp/tests/test_wrapper.py')
| -rw-r--r-- | src/mailman_pgp/pgp/tests/test_wrapper.py | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/src/mailman_pgp/pgp/tests/test_wrapper.py b/src/mailman_pgp/pgp/tests/test_wrapper.py new file mode 100644 index 0000000..256d7d1 --- /dev/null +++ b/src/mailman_pgp/pgp/tests/test_wrapper.py @@ -0,0 +1,125 @@ +# Copyright (C) 2017 Jan Jancar +# +# This file is a part of the Mailman PGP plugin. +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# this program. If not, see <http://www.gnu.org/licenses/>. + +"""Tests for the combined wrapper.""" +from parameterized import parameterized + +from mailman_pgp.pgp.tests.base import WrapperTestCase, load_message, load_key +from mailman_pgp.pgp.wrapper import PGPWrapper + + +class PGPWrapperTestCase(WrapperTestCase): + wrapper = PGPWrapper + + +class TestSigning(PGPWrapperTestCase): + @parameterized.expand([ + (load_message('data/inline_signed.eml'), + True), + (load_message('data/inline_signed_invalid.eml'), + True), + (load_message('data/inline_encrypted.eml'), + False), + (load_message('data/mime_signed.eml'), + True), + (load_message('data/mime_signed_invalid.eml'), + True), + (load_message('data/clear.eml'), + False) + ]) + def test_is_signed(self, message, signed): + super().is_signed(message, signed) + + def test_sign(self): + pass + + @parameterized.expand([ + (load_message('data/inline_signed.eml'), + load_key('data/rsa_1024.pub.asc'), + True), + (load_message('data/inline_signed_invalid.eml'), + load_key('data/rsa_1024.pub.asc'), + False), + (load_message('data/mime_signed.eml'), + load_key('data/rsa_1024.pub.asc'), + True), + (load_message('data/mime_signed_invalid.eml'), + load_key('data/rsa_1024.pub.asc'), + False) + ]) + def test_verify(self, message, key, valid): + super().verify(message, key, valid) + + +class TestEncryption(PGPWrapperTestCase): + @parameterized.expand([ + (load_message('data/inline_encrypted.eml'), + True), + (load_message('data/inline_signed.eml'), + False), + (load_message('data/inline_signed_invalid.eml'), + False), + (load_message('data/clear.eml'), + False) + ]) + def test_is_encrypted(self, message, encrypted): + super().is_encrypted(message, encrypted) + + def test_encrypt(self): + pass + + @parameterized.expand([ + (load_message('data/inline_encrypted.eml'), + load_key('data/rsa_1024.priv.asc'), + 'Some encrypted text.\n\n') + ]) + def test_decrypt(self, message, key, clear): + super().decrypt(message, key, clear) + + +class TestKeys(PGPWrapperTestCase): + @parameterized.expand([ + (load_message('data/inline_privkey.eml'), + True), + (load_message('data/inline_pubkey.eml'), + True), + (load_message('data/inline_signed.eml'), + False), + (load_message('data/mime_privkey.eml'), + True), + (load_message('data/mime_pubkey.eml'), + True), + (load_message('data/mime_signed.eml'), + False), + (load_message('data/clear.eml'), + False) + ]) + def test_has_keys(self, message, has_keys): + super().has_keys(message, has_keys) + + @parameterized.expand([ + (load_message('data/inline_privkey.eml'), + [load_key('data/rsa_1024.priv.asc')]), + (load_message('data/inline_pubkey.eml'), + [load_key('data/rsa_1024.pub.asc')]), + (load_message('data/mime_privkey.eml'), + [load_key('data/rsa_1024.priv.asc')]), + (load_message('data/mime_pubkey.eml'), + [load_key('data/rsa_1024.pub.asc')]) + ]) + def test_keys(self, message, keys): + super().keys(message, keys) |
