Rely on the lemur generating the correct name for rotated certificates. (#714)

* Rely on the lemur generating the correct name for rotated certificates.

* Fixing tests.
This commit is contained in:
kevgliss 2017-03-09 13:09:20 -08:00 committed by GitHub
parent 602c5580d3
commit 3c5b2618c0
2 changed files with 9 additions and 5 deletions

View File

@ -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

View File

@ -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