[pyOpenSSL] Unit tests

Morgan Reed morgan.s.reed at gmail.com
Sat Oct 18 10:45:06 CEST 2008


On Sat, Oct 18, 2008 at 12:33 AM, Jean-Paul Calderone
<exarkun at divmod.com> wrote:
> The code you included looks right.  I would certainly expect two tests
> to be run, test_construction and test_generate_key, if I ran a command
> like "trial OpenSSL.test.test_crypto.RSATests", after doing the needed
> song and dance to get the code and tests into a state where they could
> be imported.

Still no joy, I've written a couple of further tests and none of them
are running (except test_construction as previously).

========================
.....
testPlaintext = "testing"
.....
class RSATests(TestCase, _Python23TestCaseHelper):
    .....

    def test_public_encrypt(self):
        """
        L{public_encrypt} generates a new key and encrypts a static value with
        the public key, then decrypts it with the private and compare the
        result
        """
        bits = 1024
        rsaobj = RSA()
        rsaobj.generate_key(bits)
        crypt = rsaobj.public_encrypt(testPlaintext)
        decrypt = rsaobj.private_decrypt(crypt)
        self.assertEqual(decrypt, testPlaintext)

    def test_private_encrypt(self):
        """
        L{private_encrypt} generates a new key and encrypts a static value with
        the private key, then decrypts it with the public and compares
the
        result
        """
        bits = 1024
        rsaobj = RSA()
        rsaobj.generate_key(bits)
        crypt = rsaobj.private_encrypt(testPlaintext)
        decrypt = rsaobj.public_decrypt(crypt)
        self.assertEqual(decrypt, testPlaintext)

========================

This is the script I'm using to execute the tests
========================
#!/bin/sh
python setup.py install --prefix=/tmp/pyOpenSSL-test
PYTHONPATH=/tmp/pyOpenSSL-test/lib/python2.5/site-packages/:$PYTHONPATH
python -c 'import OpenSSL; print OpenSSL'
PYTHONPATH=/tmp/pyOpenSSL-test/lib/python2.5/site-packages/:$PYTHONPATH
trial OpenSSL
========================

And the output
========================
  .....
    test_rsaGeneration ...                                                 [OK]
  RSATests
    test_construction ...                                                  [OK]
  X509NameTests
  .....
========================

Any suggestions would be greatly appreciated, I've pushed the latest
revision if anybody wants to look at the code in situ

Thanks,

Morgan




More information about the pyopenssl-users mailing list