diff --git a/lemur/certificates/service.py b/lemur/certificates/service.py index 3f1fe4b5..3bfb9909 100644 --- a/lemur/certificates/service.py +++ b/lemur/certificates/service.py @@ -470,6 +470,11 @@ def get_certificate_primitives(certificate): """ start, end = calculate_reissue_range(certificate.not_before, certificate.not_after) data = CertificateInputSchema().load(CertificateOutputSchema().dump(certificate).data).data + + # we can't quite tell if we are using a custom name, as this is an automated process (typically) + # we will rely on the Lemur generated name + data.pop('name', None) + data['validity_start'] = start data['validity_end'] = end return data @@ -484,8 +489,7 @@ def reissue_certificate(certificate, replace=None, user=None): :return: """ primitives = get_certificate_primitives(certificate) - from pprint import pprint - pprint(primitives) + if not user: primitives['creator'] = certificate.user diff --git a/lemur/tests/test_certificates.py b/lemur/tests/test_certificates.py index c3c4b05e..a7471a9e 100644 --- a/lemur/tests/test_certificates.py +++ b/lemur/tests/test_certificates.py @@ -53,7 +53,7 @@ def test_get_certificate_primitives(certificate): with freeze_time(datetime.date(year=2016, month=10, day=30)): primitives = get_certificate_primitives(certificate) - assert len(primitives) == 21 + assert len(primitives) == 20 def test_certificate_edit_schema(session): @@ -321,7 +321,7 @@ def test_import(user): assert str(cert.not_after) == '2040-01-01T20:30:52+00:00' assert str(cert.not_before) == '2015-06-26T20:30:52+00:00' assert cert.issuer == 'Example' - assert cert.name == 'long.lived.com-Example-20150626-20400101-1' + assert cert.name == 'long.lived.com-Example-20150626-20400101-2' cert = import_certificate(body=INTERNAL_VALID_LONG_STR, chain=INTERNAL_VALID_SAN_STR, private_key=PRIVATE_KEY_STR, owner='joe@example.com', name='ACustomName2', creator=user['user']) assert cert.name == 'ACustomName2' @@ -333,7 +333,7 @@ def test_upload(user): assert str(cert.not_after) == '2040-01-01T20:30:52+00:00' assert str(cert.not_before) == '2015-06-26T20:30:52+00:00' assert cert.issuer == 'Example' - assert cert.name == 'long.lived.com-Example-20150626-20400101-2' + assert cert.name == 'long.lived.com-Example-20150626-20400101-3' cert = upload(body=INTERNAL_VALID_LONG_STR, chain=INTERNAL_VALID_SAN_STR, private_key=PRIVATE_KEY_STR, owner='joe@example.com', name='ACustomName', creator=user['user']) assert 'ACustomName' in cert.name