labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject svn commit: r604187 - in /labs/badca: BaDCA/baseCA.py build/python.m4 configure.ac openssl/certmodule.c tests/04baseCATestCase.py
Date Fri, 14 Dec 2007 13:22:27 GMT
Author: dreid
Date: Fri Dec 14 05:22:25 2007
New Revision: 604187

URL: http://svn.apache.org/viewvc?rev=604187&view=rev
Log:
Start adding in the baseCA class, which will be the basis for both
the CA and subCA classes.
Small simplification of the python 2.4 fix, suggested by Mads Toftum
Add simple function to allow us to check availability of python
modules (not yet in use, but tested)

make test will run this new test, but it doesn't do much yet!


Added:
    labs/badca/BaDCA/baseCA.py
    labs/badca/tests/04baseCATestCase.py
Modified:
    labs/badca/build/python.m4
    labs/badca/configure.ac
    labs/badca/openssl/certmodule.c

Added: labs/badca/BaDCA/baseCA.py
URL: http://svn.apache.org/viewvc/labs/badca/BaDCA/baseCA.py?rev=604187&view=auto
==============================================================================
--- labs/badca/BaDCA/baseCA.py (added)
+++ labs/badca/BaDCA/baseCA.py Fri Dec 14 05:22:25 2007
@@ -0,0 +1,28 @@
+import os, sys
+
+from BaDCA.Utils import getSHA1
+
+class baseCA:
+    name = None
+    baseDir = None
+    keys = []
+    certs = []
+    crls = []
+
+    def __init__(self, baseDir = None):
+        if baseDir is not None:
+            if os.path.isdir(baseDir):
+                self.baseDir = os.path.abspath(baseDir)
+                self.getConfig()
+
+    def getConfig(self):
+        configFn = os.path.join(self.baseDir, 'conf.py')
+        if not os.path.exists(configFn):
+            return
+        print "configFn = " + configFn
+
+    def isValid(self):
+        if self.name is None:
+            return False
+        return True
+

Modified: labs/badca/build/python.m4
URL: http://svn.apache.org/viewvc/labs/badca/build/python.m4?rev=604187&r1=604186&r2=604187&view=diff
==============================================================================
--- labs/badca/build/python.m4 (original)
+++ labs/badca/build/python.m4 Fri Dec 14 05:22:25 2007
@@ -93,3 +93,21 @@
 exec_prefix=$PYTHON_EXEC_PREFIX
 ])
 
+AC_DEFUN(PY_PYTHON_IMPORT_CHECK,
+  [
+    module=$1
+    scriptCode="$2"
+    AC_MSG_CHECKING(for Python module $module)
+    rv=`$PYTHON -c "import sys; \
+$scriptCode "`
+    if test "$?" != "0"; then
+        AC_MSG_RESULT(no)
+        AC_ERROR([In order to use BaDCA you need the following python module available
+
+$module
+
+Please install this module and then rerun configure.])
+    fi
+    AC_MSG_RESULT(yes)
+  ])
+

Modified: labs/badca/configure.ac
URL: http://svn.apache.org/viewvc/labs/badca/configure.ac?rev=604187&r1=604186&r2=604187&view=diff
==============================================================================
--- labs/badca/configure.ac (original)
+++ labs/badca/configure.ac Fri Dec 14 05:22:25 2007
@@ -12,10 +12,14 @@
 PY_PYTHON_PREFIX()
 PY_PYTHON_EXEC_PREFIX()
 
-dnl if test -z "$PYTHON_VERSION" || test "$PYTHON_VERSION" < "2.4"; then
-dnl   AC_MSG_ERROR([Failed to find Python!])
-dnl fi
-
+dnl We don't yet require this module, so comment this test out
+dnl until we do - soon, but not quite yet!
+dnl PY_PYTHON_IMPORT_CHECK(gpgme, [
+dnl from pyme import core, constants
+dnl 
+dnl plain = core.Data('Testing availability of gpgme.')
+dnl ])
+ 
 AC_CHECK_HEADER(Python.h)
 
 BADCA_CHECK_OPENSSL

Modified: labs/badca/openssl/certmodule.c
URL: http://svn.apache.org/viewvc/labs/badca/openssl/certmodule.c?rev=604187&r1=604186&r2=604187&view=diff
==============================================================================
--- labs/badca/openssl/certmodule.c (original)
+++ labs/badca/openssl/certmodule.c Fri Dec 14 05:22:25 2007
@@ -10,6 +10,10 @@
 
 #define SERIAL_RAND_BITS  128
 
+#ifdef PYTHON24
+#define Py_ssize_t   int
+#endif
+
 static void delcert(void *ptr)
 {
     X509_free((X509 *)ptr);
@@ -200,11 +204,7 @@
 static int 
 removeNameFields(X509_NAME *subj, PyObject *list)
 {
-#ifdef PYTHON25
     Py_ssize_t sz = PyList_Size(list), pos = 0;
-#else
-    int sz = PyList_Size(list), pos = 0;
-#endif
 
     for (pos = 0; pos < sz; pos++) {
         PyObject *pVal = PyList_GetItem(list, pos);
@@ -232,11 +232,7 @@
 mergeSubjects(X509_NAME *to, X509_NAME *from, PyObject *ignore)
 {
     int i, sz = X509_NAME_entry_count(from);
-#ifdef PYTHON25
     Py_ssize_t iSz = 0, iPos = 0;
-#else
-    int iSz = 0, iPos = 0;
-#endif
     int *nids = NULL;
 
     if (ignore) {

Added: labs/badca/tests/04baseCATestCase.py
URL: http://svn.apache.org/viewvc/labs/badca/tests/04baseCATestCase.py?rev=604187&view=auto
==============================================================================
--- labs/badca/tests/04baseCATestCase.py (added)
+++ labs/badca/tests/04baseCATestCase.py Fri Dec 14 05:22:25 2007
@@ -0,0 +1,21 @@
+import unittest
+
+from BaDCA import baseCA
+from BaDCA.Testing import *
+
+class BaDCAbaseCATestCase(unittest.TestCase):
+
+    def test01(self):
+        """ Testing basic creation of an empty baseCA """
+        ca = baseCA.baseCA()
+        assert ca is not None, "Failed to create a baseCA object"
+        assert not ca.isValid(), "baseCA should not be valid!"
+
+    def test02(self):
+        """ Testing basic creation of baseCA with data"""
+        ca = baseCA.baseCA(baseDir='tests/ca/test01')
+        assert ca is not None, "Failed to create a baseCA object"
+        assert not ca.isValid(), "baseCA should not be valid!"
+
+if __name__ == "__main__":
+    unittest.main()



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message