## build up the cas structure
opts.ca = {}
-# opts.ca[''] = {}
## Add the default items when just using a single ca
-# main_items = confparser.items('main')
-# for (key,value) in main_items:
-# if key in ['autosign','cadir','cert_dir','certroot','csrroot']:
-# print "main ca: key: %s, value: %s" % (key,value)
-# opts.ca[''][key] = value
opts.ca[''] = BaseConfigDerived()
opts.ca[''].populate(confparser,'main')
for a_section in sections:
if a_section.startswith('ca:'):
ca_name = a_section[3:]
-# items = confparser.items(a_section)
-# opts.ca[ca_name] = {}
-# for (key,value) in items:
-# opts.ca[ca_name][key] = value
opts.ca[ca_name] = BaseConfigDerived()
opts.ca[ca_name].populate(confparser,a_section)
opts.ca[ca_name].cakey = None
import distutils.sysconfig
import optparse
+import sys
from certmaster import requester
(opts, args) = parser.parse_args()
- requester.request_cert(hostname=opts.hostname, ca_name=opts.ca)
+ try:
+ requester.request_cert(hostname=opts.hostname, ca_name=opts.ca)
+ except Exception as e:
+ print >> sys.stderr, "error: %s" % str(e)
}
+test_CertmasterRequest_UnknownCA()
+{
+ actual=$(certmaster-request --hostname unknown.pwan.co --ca unknown 2>&1)
+ expected=$(cat <<EOF
+error: Unknown cert authority: unknown
+EOF
+)
+
+ assertEquals "certmaster-request --ca unknown" "$actual" "$expected"
+}
+
test_CertmasterCAHelp()
{
actual=`certmaster-ca --help`
assertTrue "version includes a release" $?
}
+test_CertmasterCA_UnknownCA()
+{
+ actual=$(certmaster-ca --list --ca unknown 2>&1)
+
+ expected=$(cat <<EOF
+Unknown ca unknown: check /etc/certmaster.cfg
+EOF
+)
+
+ assertEquals "certmaster-ca --ca unknown" "$actual" "$expected"
+}
+
test_TestCA_Autosigning()
{
certmaster-request --hostname testcert.pwan.co --ca test