Adding digicert documentation. (#480)

This commit is contained in:
kevgliss
2016-11-08 14:56:05 -08:00
committed by GitHub
parent 67a5993926
commit 25a6c722b6
4 changed files with 68 additions and 16 deletions

View File

@ -130,6 +130,23 @@ def handle_response(response):
return response.json()
def verify_configuration():
if not current_app.config.get('DIGICERT_API_KEY'):
raise Exception("No Digicert API key found. Ensure that 'DIGICERT_API_KEY' is set in the Lemur conf.")
if not current_app.config.get('DIGICERT_URL'):
raise Exception("No Digicert URL found. Ensure that 'DIGICERT_URL' is set in the Lemur conf.")
if not current_app.config.get('DIGICERT_ORG_ID'):
raise Exception("No Digicert organization ID found. Ensure that 'DIGICERT_ORG_ID' is set in Lemur conf.")
if not current_app.config.get('DIGICERT_ROOT'):
raise Exception("No Digicert root found. Ensure that 'DIGICERT_ROOT' is set in the Lemur conf.")
if not current_app.config.get('DIGICERT_INTERMEDIATE'):
raise Exception("No Digicert intermediate found. Ensure that 'DIGICERT_INTERMEDIATE is set in Lemur conf.")
class DigiCertSourcePlugin(SourcePlugin):
"""Wrap the Digicert Certifcate API."""
title = 'DigiCert'
@ -142,8 +159,7 @@ class DigiCertSourcePlugin(SourcePlugin):
def __init__(self, *args, **kwargs):
"""Initialize source with appropriate details."""
if not current_app.config.get('DIGICERT_API_KEY'):
raise Exception("No Digicert API key found. Ensure that 'DIGICERT_API_KEY' is set in the Lemur conf.")
verify_configuration()
self.session = requests.Session()
self.session.headers.update(
@ -173,8 +189,7 @@ class DigiCertIssuerPlugin(IssuerPlugin):
def __init__(self, *args, **kwargs):
"""Initialize the issuer with the appropriate details."""
if not current_app.config.get('DIGICERT_API_KEY'):
raise Exception("No Digicert API key found. Ensure that 'DIGICERT_API_KEY' is set in the Lemur conf.")
verify_configuration()
self.session = requests.Session()
self.session.headers.update(

View File

@ -27,13 +27,13 @@ def test_process_options(app):
assert data == {
'certificate': {
'csr': CSR_STR,
'csr': CSR_STR.decode('utf-8'),
'common_name': 'example.com',
'dns_names': names,
'signature_hash': 'sha256'
},
'organization': {'id': 'org-id'},
'validity_years': '1',
'organization': {'id': 0},
'validity_years': 1,
'custom_expiration_date': arrow.get(2017, 5, 7).format('YYYY-MM-DD')
}
@ -49,7 +49,7 @@ def test_issuance():
end_date, period = get_issuance(options)
assert period == '2'
assert period == 2
options = {
'validity_end': arrow.get(2017, 5, 7),
@ -58,7 +58,7 @@ def test_issuance():
end_date, period = get_issuance(options)
assert period == '1'
assert period == 1
options = {
'validity_end': arrow.get(2020, 5, 7),