diff options
| author | J08nY | 2017-06-21 18:40:47 +0200 |
|---|---|---|
| committer | J08nY | 2017-06-21 18:40:47 +0200 |
| commit | 735695ca7d8cca1e687e209b359064350087f1a7 (patch) | |
| tree | 756c4a4ad53e50f34705c1bd940e542948dca319 /src/mailman_pgp/pgp/tests | |
| parent | 16ef2af65c160872d7cc1243199ed2dc4646ccba (diff) | |
| download | mailman-pgp-735695ca7d8cca1e687e209b359064350087f1a7.tar.gz mailman-pgp-735695ca7d8cca1e687e209b359064350087f1a7.tar.zst mailman-pgp-735695ca7d8cca1e687e209b359064350087f1a7.zip | |
Diffstat (limited to 'src/mailman_pgp/pgp/tests')
| -rw-r--r-- | src/mailman_pgp/pgp/tests/data/clear.eml | 11 | ||||
| -rw-r--r-- | src/mailman_pgp/pgp/tests/data/inline_encrypted.eml | 19 | ||||
| -rw-r--r-- | src/mailman_pgp/pgp/tests/test_inline.py | 35 | ||||
| -rw-r--r-- | src/mailman_pgp/pgp/tests/test_mime.py | 4 |
4 files changed, 63 insertions, 6 deletions
diff --git a/src/mailman_pgp/pgp/tests/data/clear.eml b/src/mailman_pgp/pgp/tests/data/clear.eml new file mode 100644 index 0000000..55e35b3 --- /dev/null +++ b/src/mailman_pgp/pgp/tests/data/clear.eml @@ -0,0 +1,11 @@ +To: nobody@example.org +From: RSA 1024b example <RSA-1024b@example.org> +Subject: Some subject. +Message-ID: <76a591ed-bfc4-d08b-73d3-fc2489148fd7@example.org> +Date: Wed, 21 Jun 2017 13:50:59 +0200 +User-Agent: Mutt/1.7.2 (2016-11-26) +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit + +Some cleartext. diff --git a/src/mailman_pgp/pgp/tests/data/inline_encrypted.eml b/src/mailman_pgp/pgp/tests/data/inline_encrypted.eml new file mode 100644 index 0000000..1c75042 --- /dev/null +++ b/src/mailman_pgp/pgp/tests/data/inline_encrypted.eml @@ -0,0 +1,19 @@ +To: nobody@example.org +From: RSA 1024b example <RSA-1024b@example.org> +Subject: Some subject. +Message-ID: <76a591ed-bfc4-d08b-73d3-fc2489148fd7@example.org> +Date: Wed, 21 Jun 2017 13:50:59 +0200 +User-Agent: Mutt/1.7.2 (2016-11-26) +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Transfer-Encoding: 8bit + +-----BEGIN PGP MESSAGE----- + +hIwD9aW4UkhFqMoBA/9MpeKT7jjrQGIDTH+3Hj5pzIwOsoYLeCETXkgWcACfozUh +bK5IP7W76jO2MPG/PQsa1cP0x25nH4kdYmsa4dzY+gWNfedspT2qGZvAM+zZ12nm +mTr+DmnAMgKIg95CPkAth8bIQUm4i0HGj3j0TjY/I9CSdxJu7twsf3E38yqpJtJR +AW2qZQM7waSpGjoSGhxS4mtFCjNRz7N6hXiG8DfuDdEUodXeGYTHuEU516W+Vv9f +LpjD8AZOm+L6QDpZ0pf7grIh3kQXx7OvyaLliy+OMxXq +=prUG +-----END PGP MESSAGE----- diff --git a/src/mailman_pgp/pgp/tests/test_inline.py b/src/mailman_pgp/pgp/tests/test_inline.py index c6d1d89..1c51fce 100644 --- a/src/mailman_pgp/pgp/tests/test_inline.py +++ b/src/mailman_pgp/pgp/tests/test_inline.py @@ -32,7 +32,11 @@ class TestSigning(PGPTestCase, unittest.TestCase): (load_message('data/inline_signed.eml'), True), (load_message('data/inline_signed_invalid.eml'), - True) + True), + (load_message('data/clear.eml'), + False), + (load_message('data/inline_encrypted.eml'), + False) ]) def test_is_signed(self, message, signed): wrapped = self.wrapper(message) @@ -55,11 +59,32 @@ class TestSigning(PGPTestCase, unittest.TestCase): class TestEncryption(PGPTestCase, unittest.TestCase): - def test_is_encrypted(self): - pass + def setUp(self): + self.wrapper = InlineWrapper + + @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): + wrapped = self.wrapper(message) + self.assertEqual(wrapped.is_encrypted(), encrypted) def test_encrypt(self): pass - def test_decrypt(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): + wrapped = self.wrapper(message) + self.assertEqual(wrapped.decrypt(key).message, + bytearray(clear, 'latin-1')) diff --git a/src/mailman_pgp/pgp/tests/test_mime.py b/src/mailman_pgp/pgp/tests/test_mime.py index 6b30344..48b59ff 100644 --- a/src/mailman_pgp/pgp/tests/test_mime.py +++ b/src/mailman_pgp/pgp/tests/test_mime.py @@ -32,7 +32,9 @@ class TestSigning(PGPTestCase, unittest.TestCase): (load_message('data/mime_signed.eml'), True), (load_message('data/mime_signed_invalid.eml'), - True) + True), + (load_message('data/clear.eml'), + False) ]) def test_is_signed(self, message, signed): wrapped = self.wrapper(message) |
