# This file is meant to allow easy testing of the various pieces of the # puzzle as we go. It's not meant to be a fully functioning test suite, # but rather a quick and dirty way of checking that we are in a working # state. import os, sys import string from distutils.util import get_platform # Get the root path for the source as this contains the BaDCA package testPath = os.path.dirname(sys.argv[0]) rootPath = os.path.abspath(testPath + '/..') sys.path.append(rootPath) # These lines from distutils to ensure we have the correct dir names plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3]) try: debug_ext = sys.pydebug and '_d' or '' except AttributeError: debug_ext = '' build_platlib = os.path.join(rootPath, 'openssl/build/lib' + debug_ext + plat_specifier) sys.path.append(build_platlib) # after all that, now we can do some simple tests to make sure we're # working. from BaDCA import Keys from BaDCA import CSRs from BaDCA import Certificates myKey = Keys.RSAKey() myKey.create(1024) s = myKey.getPublicKeyAsString() print "public key = \n" + s + "\n" myKey.writeToDirectory(testPath) k2 = Keys.RSAKey() k2.readPrivateKey('tests/keys/3dca6bb1d753cad120cd2ed448c425b16cce492f.key') k2.printToStdout() exit(0) print "CSR test...\n\n" myCsr = CSRs.CSR() r = myCsr.readFromFile('tests/csr/test1.csr') print "readFromFile = " + str(r) + "\n" myCsr.printToStdout() c2 = CSRs.CSR() c2.setSubject('CN', 'david reid') c2.setSubject('emailAddress', 'dreid@apache.org') c2.setSubject('O', 'The Apache Software Foundation') c2.printToStdout() c2.setPrivateKey(myKey) c2.createCSR() c2.writeToDirectory('tests/csr') print c2.asString() myCert = Certificates.Certificate(filename = 'tests/certs/test1.pem') myCert.getPublicKey()