From 2096b7b7b4e1c4013ac16a18efd4dfa0d7d7ca33 Mon Sep 17 00:00:00 2001 From: Jude N Date: Sun, 22 Mar 2015 12:07:45 -0400 Subject: [PATCH] Adding unknown ca tests --- certmaster/config.py | 10 ---------- scripts/certmaster-request | 6 +++++- tests/test-certmaster.sh | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/certmaster/config.py b/certmaster/config.py index 7f7e623..2cec66f 100644 --- a/certmaster/config.py +++ b/certmaster/config.py @@ -478,14 +478,8 @@ def read_config(config_file, BaseConfigDerived): ## 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') @@ -494,10 +488,6 @@ def read_config(config_file, BaseConfigDerived): 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 diff --git a/scripts/certmaster-request b/scripts/certmaster-request index 6b3414f..de4d047 100755 --- a/scripts/certmaster-request +++ b/scripts/certmaster-request @@ -17,6 +17,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. import distutils.sysconfig import optparse +import sys from certmaster import requester @@ -33,4 +34,7 @@ if __name__ == "__main__": (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) diff --git a/tests/test-certmaster.sh b/tests/test-certmaster.sh index eab2d9a..b9c6be1 100755 --- a/tests/test-certmaster.sh +++ b/tests/test-certmaster.sh @@ -88,6 +88,17 @@ EOF } +test_CertmasterRequest_UnknownCA() +{ + actual=$(certmaster-request --hostname unknown.pwan.co --ca unknown 2>&1) + expected=$(cat <&1) + + expected=$(cat <