diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-03-17 16:12:55 +0100 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2016-03-17 16:12:55 +0100 |
commit | ff7f0c7ae75e8aa56a1ad338185004077a854e17 (patch) | |
tree | 200c62058600387f34be7271a382d295df623e0d /tests | |
parent | bb27408398923b746c81282fb738b70b1015f912 (diff) | |
download | rsa-git-ff7f0c7ae75e8aa56a1ad338185004077a854e17.tar.gz |
Added unit test for rsa.util.private_to_public()
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cli.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_cli.py b/tests/test_cli.py index 511d25d..aad734a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -14,6 +14,7 @@ from io import StringIO, BytesIO import rsa import rsa.cli +import rsa.util from rsa._compat import b if sys.version_info[0] < 3: @@ -278,3 +279,21 @@ class SignVerifyTest(AbstractCliTest): with cli_args('-i', 'cleartext.txt', self.pub_fname, 'signature.txt'): with captured_output() as (out, err): self.assertExits('Verification failed.', rsa.cli.verify) + + +class PrivatePublicTest(AbstractCliTest): + """Test CLI command to convert a private to a public key.""" + + @cleanup_files('test_private_to_public.pem') + def test_private_to_public(self): + + with cli_args('-i', self.priv_fname, '-o', 'test_private_to_public.pem'): + with captured_output(): + rsa.util.private_to_public() + + # Check that the key is indeed valid. + with open('test_private_to_public.pem', 'rb') as pemfile: + key = rsa.PublicKey.load_pkcs1(pemfile.read()) + + self.assertEqual(self.priv_key.n, key.n) + self.assertEqual(self.priv_key.e, key.e) |